/* base.css: reset, layout primitives, and the CSS half of the motion patterns.
   The site's look comes from tokens.css and site.css. */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 1rem); }
@media (prefers-reduced-motion: no-preference) { html:not([data-lenis]) { scroll-behavior: smooth; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-underline-offset: 0.2em; }
p, li { max-width: 65ch; text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; text-wrap: balance; font-weight: 600; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 0; }
::selection { background: var(--accent); color: var(--accent-contrast); }

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: var(--z-overlay); padding: .6rem 1rem; background: var(--text); color: var(--bg); border-radius: 0; }
.skip-link:focus { top: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.container { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.section { padding-block: var(--section-y); position: relative; }
.stack > * + * { margin-top: var(--stack-gap, 1.25rem); }
.display { font-size: var(--fs-display); letter-spacing: var(--tracking-display); line-height: var(--leading-display); padding-bottom: .08em; }
.h2 { font-size: var(--fs-h2); letter-spacing: -0.025em; }
.h3 { font-size: var(--fs-h3); letter-spacing: -0.01em; }
.lead { font-size: clamp(1.05rem, 1rem + .4vw, 1.25rem); color: var(--text-muted); max-width: 52ch; }
.muted { color: var(--text-muted); }
.eyebrow { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); } /* max 1 per 3 sections */
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: 48px; padding: .8rem 1.4rem; border-radius: var(--radius-button);
  font-weight: 600; font-size: .98rem; line-height: 1; text-decoration: none; white-space: nowrap;
  transition: transform .2s var(--ease-out), background-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: color-mix(in oklab, var(--accent) 88%, var(--text)); }
.btn--ghost { border: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 70%, transparent); }
.btn--ghost:hover { border-color: color-mix(in oklab, var(--text) 35%, transparent); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn i, .btn svg { font-size: 1.1em; transition: transform .3s var(--ease-out); }
.btn:hover i, .btn:hover svg { transform: translateX(3px); }

/* ---------- Media ---------- */
.frame { position: relative; overflow: hidden; border-radius: var(--radius-card); background: var(--bg-muted); }
.frame > img, .frame > video { width: 100%; height: 100%; object-fit: cover; }
.frame--parallax > img { height: 115%; margin-top: -7.5%; } /* room for data-parallax on the img */

/* ---------- WebGL / Three hosts ---------- */
[data-shader], [data-three] { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
[data-three].scene { position: relative; inset: auto; aspect-ratio: 1; pointer-events: none; }
.shader-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s var(--ease-out); }
.is-live > .shader-canvas { opacity: 1; }
.shader-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 1.2s var(--ease-out); }
.is-live > .shader-fallback { opacity: 0; }
.scrim { position: absolute; inset: 0; background: var(--scrim); pointer-events: none; } /* keeps copy readable over WebGL */

/* ---------- Scroll patterns (CSS half) ---------- */
[data-stack] > * { position: sticky; top: calc(var(--nav-h) + 1rem); transform-origin: 50% 0; will-change: transform; }
[data-stack] > * + * { margin-top: 12vh; }

/* Horizontal pan: native scroll-snap row by default (mobile, reduced motion); GSAP pins it on desktop. */
[data-hpan] { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
[data-hpan]::-webkit-scrollbar { display: none; }
[data-hpan-track] { display: flex; gap: var(--gutter); width: max-content; padding-inline: var(--gutter); }
[data-hpan-track] > * { scroll-snap-align: start; flex: 0 0 auto; }
[data-hpan].is-pinned { overflow: hidden; height: 100svh; display: flex; align-items: center; }

/* Story: steps stack in normal flow; GSAP pins and crossfades on desktop. */
[data-story].is-pinned { min-height: 100svh; }
[data-story].is-pinned [data-story-stage] { display: grid; }
[data-story].is-pinned [data-story-stage] > [data-story-step] { grid-area: 1 / 1; }

[data-marquee] { overflow: hidden; }
[data-marquee] > * { display: flex; width: max-content; gap: 3rem; }

[data-progress] { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; z-index: calc(var(--z-nav) + 1); }

/* ---------- Motion gating ----------
   html.js is set inline in <head>. Elements start hidden only when JS is on; motion.js reveals them.
   If motion.js never boots (blocked CDN), the head failsafe adds .motion-off after 2.5s. */
html.js:not(.motion-off) [data-reveal],
html.js:not(.motion-off) [data-split],
html.js:not(.motion-off) [data-hero-item] { visibility: hidden; }
html.motion-off [data-reveal], html.motion-off [data-split], html.motion-off [data-hero-item] { visibility: visible !important; opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  [data-stack] > * { position: static; }
}
