/* ============================================================
   base.css — reset, base typography, layout primitives, and
   the global chrome (loader, grain, cursor, nav, placeholders).
   Visual polish layers on top in main.css (Phase 7).
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; }
/* Lenis manages scroll; keep native smooth off to avoid double-easing */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

::selection { background: var(--color-accent); color: var(--color-bg); }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 2px; }

/* Skip link — first focusable, visible only on focus */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  transform: translateY(-150%);
  background: var(--color-accent); color: var(--color-bg);
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.1em;
  text-transform: uppercase; padding: 10px 16px; border-radius: var(--radius-btn);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); outline-offset: 2px; }

/* ---- Typography base ---- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.02; }
p { max-width: 62ch; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent);
}
.section-label { display: inline-block; margin-bottom: var(--space-lg); }
.h2 {
  font-size: var(--fs-h2);
  letter-spacing: var(--tracking-h2);
  color: var(--color-text-primary);
  max-width: 18ch;
}
/* word-mask reveal primitives (clip the rising word; padding gives descenders room) */
.word-mask { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.word-inner { display: inline-block; will-change: transform; }
.lead { font-size: var(--fs-lead); color: var(--color-text-primary); line-height: 1.45; }
.muted { color: var(--color-text-secondary); }

/* ---- Layout primitives ---- */
.section { padding-block: var(--section-pad); }
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* ---- Placeholder media boxes (every missing asset) ---- */
.ph {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(45deg, var(--color-surface) 0 12px, var(--color-surface-2) 12px 24px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-text-secondary);
  text-align: center;
  overflow: hidden;
  min-height: 200px;
}
.ph::after {
  content: attr(data-ph-label);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  padding: var(--space-md);
  max-width: 36ch;
}
.ph[data-ratio="16/10"] { aspect-ratio: 16/10; }
.ph[data-ratio="16/9"]  { aspect-ratio: 16/9; }
.ph[data-ratio="4/5"]   { aspect-ratio: 4/5; }
.ph[data-ratio="1/1"]   { aspect-ratio: 1/1; }

/* ============================================================
   Global chrome
   ============================================================ */

/* Grain overlay — deferred past the hero intro (busiest frame) then faded in.
   mix-blend over a fixed full viewport is the one steady compositing cost we
   accept; it must NOT run during the intro animation. */
.grain {
  position: fixed; inset: 0; z-index: var(--z-grain);
  pointer-events: none; opacity: 0;
  mix-blend-mode: overlay;
  background-image: var(--grain-img, none);
  background-size: 180px 180px;
  transition: opacity 0.8s ease;
}
.grain.is-on { opacity: var(--grain-opacity); }

/* Loader */
.loader {
  position: fixed; inset: 0; z-index: var(--z-loader);
  background: var(--color-bg);
  display: grid; place-items: center;
}
.loader__inner { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--gutter); text-align: center; }
.loader__mark {
  width: 84px; height: 84px;
  opacity: 1;   /* visible immediately = instant first paint (no wait on JS/GSAP) */
}
.loader__line { color: var(--color-text-secondary); max-width: 30ch; opacity: 1; }
.loader__line em { color: var(--color-accent); font-style: normal; }
.loader.is-done { pointer-events: none; }

/* Custom cursor (desktop/pointer only — toggled via JS) */
.cursor, .cursor__ring {
  position: fixed; top: 0; left: 0; z-index: var(--z-cursor);
  pointer-events: none; border-radius: 50%;
  transform: translate(-50%, -50%);
  will-change: transform;
  opacity: 0;
}
.cursor {
  width: 8px; height: 8px; background: var(--color-accent);
}
.cursor__ring {
  width: 40px; height: 40px;
  border: 1px solid var(--color-accent);
  transition: width var(--dur-fast) var(--ease-out),
              height var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.cursor__ring.is-hover { width: 60px; height: 60px; background: var(--color-accent-faint); }
.cursor__ring.is-view  { width: 84px; height: 84px; background: var(--color-accent-faint); }
.cursor-enabled, .cursor-enabled * { cursor: none; }

/* Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-nav);
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding-inline: var(--gutter);
  /* solid off-white over the dark skin — robust + cheaper than mix-blend over the amber glow */
}
.nav__mark { width: 30px; height: 30px; }
.nav__links { display: flex; gap: var(--space-md); }
.nav__links a {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--color-text-primary);
  position: relative; padding-block: 4px;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 0; height: 1px;
  background: var(--color-accent); transition: width var(--dur-fast) var(--ease-out);
}
.nav__links a:hover::after { width: 100%; }
.nav__toggle { display: none; }

@media (max-width: 720px) {
  .nav__links { display: none; }
  .nav__toggle {
    display: block; font-family: var(--font-mono); font-size: var(--fs-label);
    letter-spacing: var(--tracking-label); text-transform: uppercase;
    color: var(--color-text-primary);
  }
}

/* ---- Reveal stub (motion is wired in animations.js) ---- */
[data-reveal] { opacity: 0; }
.no-js [data-reveal], .reveal-ready [data-reveal].is-in { opacity: 1; }

/* Reduced motion: kill vestibular triggers (transforms, loops) but allow gentle
   opacity fades — JS owns reveal opacity, so do NOT force opacity here. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  [data-reveal] { transform: none !important; }   /* vestibular guard; opacity left to GSAP */
  .cursor, .cursor__ring { display: none !important; }
}
