/* ============================================================
   ATOMATE — BASE
   Reset, fonts, global typography, layout primitives, focus.
   ============================================================ */

/* ---- Fonts (self-hosted variable, OFL licence) ------------- */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans-latin-wght.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  color-scheme: light;
  hanging-punctuation: first last;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, picture, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---- Type --------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-head);
  letter-spacing: var(--track-head);
  text-wrap: balance;
  overflow-wrap: break-word;
}
h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-3); }
h4 { font-size: var(--step-2); line-height: var(--leading-sub); }

.display {
  font-size: var(--step-7);
  line-height: var(--leading-tight);
  letter-spacing: var(--track-display);
  font-weight: 800;
}
.display-2 {
  font-size: var(--step-6);
  line-height: var(--leading-tight);
  letter-spacing: var(--track-display);
  font-weight: 800;
}

p, li, dd { text-wrap: pretty; max-width: var(--measure); }
.lede {
  font-size: var(--step-1);
  line-height: var(--leading-sub);
  color: var(--text-2);
  font-weight: 400;
}
.small { font-size: var(--step--1); line-height: var(--leading-cap); }
.muted { color: var(--text-2); }
.meta  { color: var(--text-3); }

/* Instrumentation labels — telemetry voice, used sparingly. */
.label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-3);
}

strong { font-weight: 600; }
::selection { background: var(--sage-200); color: var(--ink-900); }
.on-ink ::selection { background: var(--sage-500); color: var(--ink-900); }

/* ---- Links -------------------------------------------------- */
a { color: inherit; }

/* Prose links: underline draws its weight on hover, never fades. */
.link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--sage-600);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness var(--dur-1) var(--ease-out),
              background-color var(--dur-1) var(--ease-out);
}
.link:hover  { text-decoration-thickness: 3px; background: var(--sage-100); }
.link:active { background: var(--sage-200); }

/* ---- Focus — a real ring, on every ground ------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}
.btn:focus-visible, .chip:focus-visible {
  outline-offset: 3px;
}

/* ---- Skip link ---------------------------------------------- */
.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-5);
  background: var(--ink-800);
  color: var(--surface);
  font-weight: 600;
  border-radius: var(--radius-m);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus-visible {
  transform: none;
  outline-color: var(--focus-on-ink);
}

/* ---- Layout primitives -------------------------------------- */
.container {
  inline-size: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}
.container-wide {
  inline-size: min(100% - 2 * var(--gutter), var(--container-wide));
  margin-inline: auto;
}

.section    { padding-block: var(--section-pad); }
.section-s  { padding-block: var(--section-pad-s); }
.section-wash { background: var(--surface-down); }
.section-ink  { background: var(--ink-800); }
.section-ink-9{ background: var(--ink-900); }

.stack-2 > * + * { margin-block-start: var(--space-2); }
.stack-3 > * + * { margin-block-start: var(--space-3); }
.stack-4 > * + * { margin-block-start: var(--space-4); }
.stack-5 > * + * { margin-block-start: var(--space-5); }
.stack-6 > * + * { margin-block-start: var(--space-6); }

.grid { display: grid; gap: var(--space-6); }

/* ---- Scroll-reveal defaults (JS adds .is-in) ----------------- */
.rise {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out);
}
.rise.is-in { opacity: 1; transform: none; }

/* ---- Chalk strokes (SVG draw-ins) ---------------------------- */
.chalk-svg path, .chalk-svg ellipse {
  fill: none;
  stroke: var(--chalk);
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-draw] path, [data-draw] ellipse {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
[data-draw].is-drawn path, [data-draw].is-drawn ellipse {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms var(--ease-out);
}
[data-draw].is-drawn path:nth-child(2),
[data-draw].is-drawn ellipse:nth-child(2) { transition-delay: 250ms; }
[data-draw].is-drawn path:nth-child(3),
[data-draw].is-drawn ellipse:nth-child(3) { transition-delay: 480ms; }

/* Highlighter sweep behind a single key word (hero treatment). */
.hl {
  position: relative;
}
.hl > .hl-ink { position: relative; z-index: 1; }
.hl > svg {
  position: absolute;
  inset: -0.12em -0.22em -0.28em;
  width: calc(100% + 0.44em);
  height: calc(100% + 0.4em);
  z-index: 0;
}
.hl > svg path {
  stroke: var(--chalk-blue);
  fill: none;
  stroke-linecap: round;
  opacity: 0.92;
}

/* ---- Reduced motion — global guarantee ----------------------- */
@media (prefers-reduced-motion: reduce), (update: slow) {
  .rise { opacity: 1; transform: none; transition: none; }
  [data-draw] path, [data-draw] ellipse {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    transition: none;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
html.reduced-motion .rise { opacity: 1; transform: none; transition: none; }
html.reduced-motion [data-draw] path,
html.reduced-motion [data-draw] ellipse {
  stroke-dasharray: none; stroke-dashoffset: 0; transition: none;
}

/* ---- No-JS: everything readable, nothing hidden ---------------- */
html.no-js .rise { opacity: 1; transform: none; transition: none; }
html.no-js [data-draw] path,
html.no-js [data-draw] ellipse { stroke-dasharray: none; stroke-dashoffset: 0; }
html.no-js .rotator-item { position: static; opacity: 1; transform: none; margin-block-start: var(--space-5); }
html.no-js .rotator-item[hidden] { display: block; }
html.no-js .rotator-controls { display: none; }
html.no-js .ticker-track { animation: none; flex-wrap: wrap; width: auto; }

/* ---- Utilities ----------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.nowrap { white-space: nowrap; }
