/* Reset, type, layout primitives, surfaces, focus and the reveal system. */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-optical-sizing: auto;
  --focus-ring: var(--ink);
  /* Clears the fixed nav for anchors and for focus moved by Tab or Shift+Tab. */
  scroll-padding-top: calc(var(--nav-h) + 48px);
}
/* The pill nav now stays at its full 32px offset, so anchors clear it by the same 32px gap. */
@media (min-width: 941px) {
  html { scroll-padding-top: calc(var(--nav-h) + 64px); }
}
body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.4;
  letter-spacing: var(--track-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* clip, never hidden: hidden makes body a scroll container and breaks every sticky element */
  overflow-x: clip;
}
img, svg, video, canvas { display: block; max-width: 100%; }
picture { display: contents; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- type ---------- */
h1, h2, h3, h4 { font-weight: inherit; font-size: inherit; text-wrap: balance; }
p, li, dd, figcaption { text-wrap: pretty; }

.t-display, .t-h2 {
  font-family: var(--font-display);
  font-weight: 452;
  letter-spacing: var(--track-display);
  line-height: 0.97;
}
.t-display { font-size: var(--fs-display); max-width: 13em; }
.t-h2 { font-size: var(--fs-h2); max-width: 16ch; }
@media (max-width: 767px) { .t-h2 { line-height: 1.02; } }

.t-lead, .t-sub {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track-lead);
}
.t-lead { font-size: var(--fs-lead); line-height: 1.25; color: var(--ink-muted); max-width: var(--measure-lead); }
.t-lead .t-lead__key { color: var(--ink); }
.t-sub { font-size: var(--fs-sub); line-height: 1.3; color: var(--ink-muted); }

.t-title, .t-title-row { font-weight: 600; line-height: 1.1; letter-spacing: 0.005em; color: var(--ink-2); }
.t-title { font-size: var(--fs-title); }
.t-title-row { font-size: var(--fs-title-row); }
.t-body { font-size: var(--fs-body); line-height: 1.4; color: var(--ink-body); max-width: var(--measure); }
.t-stat {
  font-size: var(--fs-stat);
  font-weight: 300;
  line-height: 1;
  color: var(--ink-2);
}
.t-stat-label { font-size: var(--fs-body); line-height: 1.2; color: var(--ink-body); }

/* Site-wide heading accent. Upright, never italic. The bright stops fall under 3:1 on white, so light surfaces get the deep set. */
:is(h1, h2, h3, .t-display, .t-h2) em, .accent {
  font-style: normal;
  background-image: var(--accent-grad, var(--gradient-brand-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* A phrase split into word spans shares one gradient: --gs is the word's share of the phrase width. */
  background-size: calc(100% / var(--gs, 1)) 100%;
  background-position: var(--gp, 0%) 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- layout ---------- */
.container {
  width: min(var(--content-max), 100% - var(--pad-l) - var(--pad-r));
  margin-inline: auto;
}
.section { padding-block: var(--section-y); position: relative; }
/* Nav links land on the section head, not the section box, whose top padding (and AI's lip) is up to 300px. */
.section[id] { scroll-margin-top: calc(-1 * var(--anchor-skip, var(--section-y))); }
#ai { --anchor-skip: calc(clamp(560px, 70vw, 1040px) * .3); }
.stats-band + #about { --anchor-skip: calc(var(--section-y) * .5); }

/* ---------- surfaces ---------- */
.surface-light { background: var(--page); color: var(--ink); color-scheme: light; --focus-ring: var(--ink); --accent-grad: var(--gradient-brand-light); }
@media (prefers-color-scheme: dark) { .surface-light { color-scheme: dark; } }
.surface-dark {
  background: var(--night);
  color: var(--on-night);
  color-scheme: dark;
  --focus-ring: #fff;
  --accent-grad: var(--gradient-brand);
}
.surface-dark :is(.t-title, .t-title-row, .t-stat) { color: #fff; }
.surface-dark :is(.t-body, .t-stat-label) { color: var(--on-night-55); }
.surface-dark :is(.t-lead, .t-sub) { color: var(--on-night-60); }
.surface-dark .t-lead .t-lead__key { color: #fff; }

/* ---------- focus and a11y ---------- */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
/* Programmatic focus on a section or heading can still match :focus-visible after a keyboard click. */
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  z-index: 20000;
  top: max(12px, env(safe-area-inset-top));
  left: var(--pad-l);
  padding: 14px 22px;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 500;
  transform: translateY(calc(-100% - 40px));
  --focus-ring: var(--ink);
}
.skip-link:focus-visible { transform: none; box-shadow: 0 8px 24px rgb(17 23 44 / .18); }

/* ---------- reveal ----------
   Every entrance rule stops at .is-settled (motion.js), so the element's own hover, press and magnetic transitions take over. */
html.js [data-reveal]:not(.is-settled) {
  opacity: 0;
  transform: translate3d(0, var(--rise), 0);
  transition:
    opacity var(--dur-reveal) var(--ease-out-expo),
    transform var(--dur-reveal) var(--ease-out-expo);
  transition-delay: min(calc(var(--i, 0) * var(--stagger)), 450ms);
}
/* :focus-within shows a focused control the observer has not reached yet, such as one in the bottom 10%. */
html.js [data-reveal]:is(.is-in, :focus-within):not(.is-settled) { opacity: 1; transform: none; }
html.js [data-reveal="media"]:not(.is-settled) { transform: none; }

/* Word mask: words are wrapped in the HTML (.w > span, --i per word), never split at runtime.
   Padding keeps descenders inside the clip at line-height 0.97. */
[data-words] .w {
  display: inline-block;
  overflow: clip;
  padding-block: 0.16em;
  margin-block: -0.16em;
  vertical-align: top;
}
[data-words] .w > span { display: inline-block; }
html.js [data-words] .w > span { transform: translate3d(0, 105%, 0); opacity: 0; }
html.hero-go [data-words="hero"] .w > span,
html.js [data-words].is-in .w > span {
  transform: none;
  opacity: 1;
  transition:
    transform var(--dur-hero) var(--ease-out-expo),
    opacity 600ms var(--ease-out-quart);
  transition-delay: calc(60ms + var(--i, 0) * var(--stagger-word));
}
/* The last hero word must read fully, and sit within 4px, by 700ms after hero-go (spec 37). */
html.hero-go [data-words="hero"] .w > span {
  transition-duration: 800ms, 300ms;
  transition-delay: min(calc(60ms + var(--i, 0) * var(--stagger-word)), 300ms);
}

/* Per-word gradient with a one-off sheen. Each word sets --g1 and --g2. */
.grad {
  background-image: linear-gradient(100deg, var(--g1) 0%, var(--g2) 50%, #fff 75%, var(--g2) 100%);
  background-size: 200% 100%;
  background-position: 0% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* background-clip: text paints only the box, so descenders need room below the baseline. */
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
html.hero-go [data-words="hero"] .grad,
html.js [data-words].is-in .grad {
  animation: grad-settle 1600ms var(--ease-out-expo) both;
  animation-delay: calc(60ms + var(--i, 0) * var(--stagger-word));
}
@keyframes grad-settle { from { background-position: 100% 0; } to { background-position: 0% 0; } }

/* Hero timeline. --d is the start offset from html.hero-go. */
html.js [data-hero]:not(.is-settled) { opacity: 0; }
/* The aurora never fades: in Safari a glass button over a fading aurora split it at the button's top edge. */
html.js [data-hero="aurora"]:not(.is-settled) { opacity: 1; transition: none; }
html.js [data-hero="rise"]:not(.is-settled) { transform: translate3d(0, var(--rise-sm), 0); }
html.js [data-hero="card"]:not(.is-settled) { transform: translate3d(0, var(--rise-lg), 0) scale(.98); }
html.hero-go [data-hero]:not(.is-settled) {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-reveal) var(--ease-out-expo),
    transform var(--dur-reveal) var(--ease-out-expo);
  transition-delay: var(--d, 0ms);
}
html.hero-go [data-hero="card"]:not(.is-settled) { transition-duration: 900ms; }
html.hero-go [data-hero="fade"]:not(.is-settled) { transition: opacity 800ms var(--ease-in-out) var(--d, 800ms); }

/* Ambient loops stop when their section is offscreen (motion.js toggles .is-paused). */
[data-ambient].is-paused, [data-ambient].is-paused *, [data-ambient].is-paused *::before, [data-ambient].is-paused *::after { animation-play-state: paused !important; }

/* If motion.js never runs, nothing may stay hidden. */
html.js:not(.motion) :is([data-reveal], [data-hero], [data-words] .w > span) {
  animation: show-fallback 1ms 2.5s forwards;
}
@keyframes show-fallback { to { opacity: 1; transform: none; } }

/* Back or forward visit (motion.js): what is on screen shows at once. */
html.instant *, html.instant *::before, html.instant *::after { transition: none !important; }
html.back .grad { animation: none !important; }

/* No cross-document view transition: Safari showed it as a second intro on top of the hero rise. */

/* ---------- reduced motion: fades stay, travel goes ---------- */
@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal]:not(.is-settled),
  html.js [data-reveal="media"]:not(.is-settled) > :first-child,
  html.js [data-words] .w > span,
  html.js [data-hero]:not(.is-settled) { transform: none; }
  html.js [data-reveal]:not(.is-settled) {
    transition: opacity 400ms var(--ease-in-out);
    transition-delay: min(calc(var(--i, 0) * var(--stagger-list)), 200ms);
  }
  html.hero-go [data-words="hero"] .w > span,
  html.js [data-words].is-in .w > span,
  html.hero-go [data-hero]:not(.is-settled),
  html.hero-go [data-hero="card"]:not(.is-settled),
  html.hero-go [data-hero="fade"]:not(.is-settled) {
    transition: opacity 400ms var(--ease-in-out);
    transition-delay: min(calc(var(--i, 0) * var(--stagger-list)), 200ms);
  }
  html.hero-go [data-words="hero"] .grad,
  html.js [data-words].is-in .grad { animation: none; }
}
