/* tokens.css — Spaceframe base. Copy verbatim; apply tokens, never ad-hoc values.
   Load before page CSS. Theme via <html data-theme="dark|light">. */

:root,
:root[data-theme="dark"] {
  --bg: #010101;
  --bg-raised: #0c0c0c;
  --fg: #ffffff;
  --fg-muted: #b0b0a9;
  --fg-faint: #565654;
  --accent: #DFF140;
  --accent-dim: #eff8a0;
  --accent-ink: #010101;
  --alert: #FF3535;
  --border: rgba(255, 255, 255, 0.14);
  --overlay: rgba(1, 1, 1, 0.55);
  --glass: rgba(1, 1, 1, 0.6);
  --wash: radial-gradient(120% 70% at 70% 15%, #1a1a14, transparent);
  --grid: repeating-linear-gradient(to right, rgba(255,255,255,.10) 0 1px, transparent 1px 96px),
          repeating-linear-gradient(to bottom, rgba(255,255,255,.10) 0 1px, transparent 1px 96px);
  --sheen: linear-gradient(180deg, #ffffff, #a8a8a4);
  --field-mask: linear-gradient(to top, transparent, rgba(255,255,255,.35) 70%, #ffffff 100%);
}

:root[data-theme="light"] {
  --bg: #f1f0ea;
  --bg-raised: #ffffff;
  --fg: #010101;
  --fg-muted: #6c6e6b;
  --fg-faint: #b0b0a9;
  --accent: #010101;
  --accent-dim: #010101;
  --accent-ink: #f1f0ea;
  --alert: #FF3535;
  --border: rgba(1, 1, 1, 0.14);
  --overlay: rgba(241, 240, 234, 0.55);
  --glass: rgba(241, 240, 234, 0.6);
  --wash: none;
  --grid: repeating-linear-gradient(to right, rgba(1,1,1,.12) 0 1px, transparent 1px 96px),
          repeating-linear-gradient(to bottom, rgba(1,1,1,.12) 0 1px, transparent 1px 96px);
  --sheen: linear-gradient(180deg, #010101, #6c6e6b);
  --field-mask: linear-gradient(to top, transparent, rgba(1,1,1,.3) 70%, #010101 100%);
}

:root {
  /* type */
  --font-sans: "Helvetica Now Display", "Neue Haas Grotesk", Inter, Helvetica, Arial, sans-serif;
  --font-mono: "Berkeley Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --type-display: clamp(3rem, 8vw, 14rem);
  --type-h1: clamp(2rem, 4vw, 4rem);
  --type-h2: clamp(1.25rem, 2vw, 2rem);
  --type-lead: 1.125rem;
  --type-body: 0.9375rem;
  --type-data: 0.9375rem;
  --type-label: 0.75rem;

  /* spacing */
  --space-1: 4px;  --space-2: 8px;  --space-3: 16px; --space-4: 24px;
  --space-5: 32px; --space-6: 48px; --space-7: 64px; --space-8: 96px; --space-9: 128px;

  --gutter: clamp(24px, 6vw, 96px);
  --max-w: 1440px;
  --measure: 68ch;
  --space-section: clamp(96px, 14vw, 192px);
  --gap-grid: var(--space-5);
  --radius: 2px;

  /* motion */
  --ease: cubic-bezier(0.215, 0.62, 0.34, 1);      /* swift-out */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94); /* delayed-out, entrances */
  --dur-fast: 200ms;
  --dur: 450ms;
  --dur-slow: 900ms;
  --ent-r: 16px;

  /* smooth scroll — JS scroller should override these at runtime */
  --scroll-lerp: 0.1;
  --scroll-wheel: 1;
}

/* ---- base ---- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;   /* baseline; replace with Lenis-class scroller when JS runs */
  overscroll-behavior-y: none;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--type-body);
  line-height: 1.55;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 300; }
h1 { font-size: var(--type-h1); letter-spacing: -0.03em; line-height: 1.02; }
h2 { font-size: var(--type-h2); letter-spacing: -0.02em; line-height: 1.15; font-weight: 400; }
p  { margin: 0; max-width: var(--measure); }
p + p { margin-top: var(--space-3); }

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; height: auto; }

/* roles */
.display { font-size: var(--type-display); letter-spacing: -0.04em; line-height: 0.95; font-weight: 300; }
.display--sheen {
  background: var(--sheen);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;          /* Apple-style metal type — max one per page, tokens.md §1 */
}
.lead    { font-size: var(--type-lead);  letter-spacing: -0.015em; line-height: 1.5; color: var(--fg); }
.muted   { color: var(--fg-muted); }
.label {
  font-size: var(--type-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--fg-muted);
}
.data { font-family: var(--font-mono); font-size: var(--type-data); line-height: 1.4; }
.accent { color: var(--accent); }

/* links — hairline underline, accent only on hover */
.link { position: relative; }
.link::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%; height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-fast) var(--ease);
}
.link:hover::after, .link:focus-visible::after { transform: scaleX(1); }

/* buttons — square, hairline, quiet */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--type-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.btn:hover, .btn:focus-visible { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.btn--accent { border-color: var(--accent); color: var(--accent); }
.btn--accent:hover, .btn--accent:focus-visible { background: var(--accent); color: var(--accent-ink); }

/* glass — translucent chrome; deliberately WITHOUT backdrop blur (no liquid-glass sheen) */
.glass {
  background: var(--glass);
  border-bottom: 1px solid var(--border);
}

/* layout */
.container {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
section { padding-block: var(--space-section); }
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gap-grid);
}
.hair { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* instrument field — hero substrate (P1): wash bg + masked hairline grid on ::before */
.field {
  position: relative;
  background:
    var(--wash),
    var(--bg);
}
.field::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grid);
  -webkit-mask-image: var(--field-mask);
  mask-image: var(--field-mask);
  pointer-events: none;
}
.field > * { position: relative; }   /* content above the grid layer */

/* entrance: fade + rise, once */
.ent { opacity: 0; transform: translateY(var(--ent-r)); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
.ent.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .ent { opacity: 1; transform: none; transition: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* focus — single token ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
