/* base.css: reset, layout primitives, and the CSS half of the motion/WebGL patterns.
   Components here are intentionally plain; the site's look comes from tokens.css and
   the section compositions you write per business. */

*, *::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);
  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: 6px; }
::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: 8px; }
.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; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  height: var(--nav-h);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.nav__links { display: flex; gap: clamp(1rem, 2vw, 2rem); list-style: none; padding: 0; font-size: .95rem; white-space: nowrap; }
.nav__links a { text-decoration: none; color: var(--text-muted); transition: color var(--dur) var(--ease-out); }
.nav__links a:hover, .nav__links a[aria-current="page"] { color: var(--text); }
.nav__toggle { display: none; width: 44px; height: 44px; place-items: center; }
@media (max-width: 900px) {
  .nav__toggle { display: grid; }
  .nav__menu {
    position: fixed; inset: var(--nav-h) 0 auto 0; background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 1.5rem var(--gutter) 2rem; display: none;
  }
  .nav__menu[data-open="true"] { display: block; }
  .nav__links { flex-direction: column; gap: 1rem; font-size: 1.25rem; }
}
@supports not (backdrop-filter: blur(1px)) { .nav { background: var(--bg); } }
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--bg); backdrop-filter: none; } }

/* ---------- 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); }

/* ---------- Forms (label above, error below, never placeholder-as-label) ---------- */
.field { display: grid; gap: .45rem; }
.field label { font-weight: 600; font-size: .92rem; }
.field__hint { font-size: .85rem; color: var(--text-muted); }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; padding: .75rem .9rem; border-radius: var(--radius-input);
  border: 1px solid color-mix(in oklab, var(--text) 22%, transparent); background: var(--bg-elevated);
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: color-mix(in oklab, var(--text-muted) 85%, transparent); }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--radius-input); }
.field [aria-invalid] { border-color: #c2413a; }
.field__error { color: #b3261e; font-size: .88rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .field__error { color: #ff8a80; } }
:root[data-theme="dark"] .field__error { color: #ff8a80; }
.form-status { min-height: 1.5em; font-weight: 600; }
form[data-state="success"] .form-status { color: color-mix(in oklab, #1f8a4c 80%, var(--text)); }
form[data-state="error"] .form-status { color: #b3261e; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; } /* honeypot */

/* ---------- 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; }
}

/* ---------- Grain (optional): fixed, never on scrolling elements ---------- */
.grain::after {
  content: ""; position: fixed; inset: 0; z-index: var(--z-grain); pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 3.5rem 2.5rem; font-size: .95rem; color: var(--text-muted); }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); }
