@font-face {
  font-family: "Inter Tight Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/lab/_shared/fonts/inter-tight-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("./fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
}

:root {
  --paper: #F3F2EE;   /* porcelain */
  --ink: #0B0B0C;
  --ink-2: #3B3B38;   /* body copy */
  --grey: #6E6D68;    /* mono labels, 4.6:1 on paper */
  --line: #D6D5CF;
  --cobalt: #2F4BFF;  /* fast particles, progress line, CTA only */

  --g: 32px;
  --copy-top: 68%;
  --body-size: 21px;
  --sb: env(safe-area-inset-bottom, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
}
@media (max-width: 767px) {
  :root { --g: 16px; --copy-top: 66.5%; --body-size: 20px; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  background: var(--paper);
  color: var(--ink-2);
  scroll-snap-type: y proximity;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  background: var(--paper);
  font-family: "Inter Tight Variable", "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 480;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.mono {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 400;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}
.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* scroll track: 3 sections, each a full large viewport */
.sec {
  position: relative;
  height: 100vh;
  height: 100lvh;
  scroll-snap-align: start;
}

#gl {
  position: fixed; left: 0; top: 0; z-index: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: pan-y;
  background: var(--paper);
}
.no-gl #gl { display: none; }

/* shockwave ring, driven by the same wavefront as the physics */
#waves { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.wave { fill: none; stroke: var(--ink); stroke-width: 1; opacity: 0; vector-effect: non-scaling-stroke; }

/* HUD: one centred stack at the top, one centred stack at the bottom */
.hud {
  position: fixed; z-index: 4; pointer-events: none;
  left: 0; right: 0;
  top: max(var(--g), calc(var(--st) + 10px));
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; white-space: nowrap;
}
.hud .v { color: var(--ink); }
.hud .l { color: var(--grey); }
.hud-brand .v { letter-spacing: 0.22em; }
.hud-meta { display: inline-flex; align-items: center; gap: 6px; }
.hud-meta .sep { display: inline-block; width: 1px; height: 10px; background: var(--line); margin: 0 8px; }
.swap { animation: swap 180ms linear; }
@keyframes swap { from { opacity: 0; } to { opacity: 1; } }

.credit {
  position: fixed; z-index: 4; pointer-events: none;
  left: 0; right: 0; text-align: center;
  bottom: max(var(--g), calc(var(--sb) + 10px));
  font-size: 10px;
  white-space: nowrap;
}
.rail {
  position: fixed; z-index: 4; pointer-events: none;
  left: 0; right: 0;
  bottom: calc(max(var(--g), calc(var(--sb) + 10px)) + 26px);
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.rail .v { color: var(--ink); }
.rail .track { position: relative; display: block; width: 96px; height: 1px; background: var(--line); }
.rail .track i {
  position: absolute; inset: 0 0 -0.5px 0; height: 2px; top: -0.5px;
  background: var(--cobalt);
  transform: scaleX(0); transform-origin: left;
}

/* chapters */
.chapter { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.copy {
  position: absolute;
  top: var(--copy-top);
  left: 0; right: 0;
  margin: 0 auto;
  width: min(calc(100% - 2 * var(--g)), 460px);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.lab { margin-bottom: 12px; }
.body {
  font-size: var(--body-size);
  line-height: 1.25;
  letter-spacing: -0.012em;
  font-weight: 500;
  color: var(--ink-2);
  text-wrap: balance;
}

.hint {
  position: absolute; left: 0; right: 0;
  bottom: calc(max(var(--g), calc(var(--sb) + 10px)) + 52px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}
.h-coarse { display: none; }
@media (pointer: coarse) { .h-fine { display: none; } .h-coarse { display: inline; } }
.scroll { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.pulse {
  display: block; width: 1px; height: 18px; background: var(--grey);
  transform-origin: top; transform: scaleY(0.3);
  animation: pulse 1600ms ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.scroll > span { display: none; }

/* enter / exit: only transform and opacity animate */
.copy > *, .hint > * { opacity: 0; transform: translateY(14px); }
.chapter.is-on .copy > *, .chapter.is-on .hint > * {
  opacity: 1; transform: none;
  transition: opacity 560ms var(--ease-out) calc(var(--i, 0) * 70ms), transform 560ms var(--ease-out) calc(var(--i, 0) * 70ms);
}
.chapter.is-out .copy > *, .chapter.is-out .hint > * {
  opacity: 0; transform: translateY(-8px);
  transition: opacity 220ms var(--ease-in), transform 220ms var(--ease-in);
}
.chapter:focus-within .copy > * { opacity: 1; transform: none; }

/* CTA: cobalt, the one filled shape on the page */
.cta {
  pointer-events: none;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 22px;
  min-height: 48px; padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--cobalt);
  color: #F6F5F2;
  font: 560 16px/1 "Inter Tight Variable", "Inter Tight", system-ui, sans-serif;
  letter-spacing: -0.005em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms linear;
}
.copy > .cta { transition: none; }
.chapter.is-on .copy > .cta {
  pointer-events: auto;
  transition: opacity 560ms var(--ease-out) calc(var(--i, 0) * 70ms), transform 560ms var(--ease-out) calc(var(--i, 0) * 70ms), background-color 160ms linear;
}
.chapter.is-on .copy > .cta:active, .chapter.is-on .copy > .cta.pressed { transform: scale(0.97); transition: transform 120ms var(--ease-out), background-color 160ms linear; }
.chapter:focus-within .copy > .cta { pointer-events: auto; }
.cta:hover { background: #2640E6; }
.cta.done { background: var(--ink); }
.cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.skip {
  position: fixed; z-index: 10; left: 16px; top: 12px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--ink); color: var(--paper); border: 0;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; outline: 2px solid var(--cobalt); outline-offset: 3px; }

/* DOM headline fallback (no WebGL): nothing to drag or tap */
.no-gl .hint .h1 { display: none; }

.hl { display: none; }
.no-gl .hl {
  display: block;
  position: absolute; left: 0; right: 0; top: 42%;
  transform: translateY(-50%);
  text-align: center;
  font-family: "Inter Tight Variable", "Inter Tight", system-ui, sans-serif;
  font-weight: 720; letter-spacing: -0.035em; line-height: 0.92;
  color: var(--ink);
  font-size: min(19vw, 290px);
  opacity: 0; transition: opacity 220ms var(--ease-in);
}
.no-gl .hl-core { font-size: min(11.5vw, 190px); }
.no-gl .chapter.is-on .hl { opacity: 1; transition: opacity 560ms var(--ease-out); }
.hl .ln { display: inline; }
@media (max-width: 767px) {
  .no-gl .hl { top: 38%; font-size: 36vw; }
  .no-gl .hl .ln { display: block; }
  .no-gl .hl-core { font-size: 22vw; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-snap-type: none; }
  .pulse { animation: none; transform: scaleY(0.6); }
  .hint .h1 { display: none; }
  .swap { animation: none; }
  .copy > *, .hint > * { transform: none !important; }
  .chapter.is-on .copy > *, .chapter.is-on .hint > * { transition: opacity 200ms linear 0ms; }
  .chapter.is-out .copy > *, .chapter.is-out .hint > * { transition: opacity 200ms linear 0ms; }
  .chapter.is-on .copy > .cta { transition: opacity 200ms linear 0ms, background-color 160ms linear; }
  .no-gl .chapter.is-on .hl, .no-gl .hl { transition: opacity 200ms linear; }
  .chapter.is-on .copy > .cta:active { transform: none; }
}
