/* ============================================================
   abyss — the page around a real-time scene.
   The canvas is the design. Type stays out of the lamp's way and
   never sits on the frame unprotected.
   ============================================================ */

:root {
  --step--2: clamp(0.69rem, 0.67rem + 0.09vw, 0.75rem);
  --step--1: clamp(0.81rem, 0.78rem + 0.14vw, 0.91rem);
  --step-0:  clamp(0.96rem, 0.93rem + 0.19vw, 1.09rem);
  --step-1:  clamp(1.16rem, 1.09rem + 0.32vw, 1.39rem);
  --step-2:  clamp(1.44rem, 1.30rem + 0.60vw, 1.87rem);
  --step-3:  clamp(1.82rem, 1.54rem + 1.20vw, 2.72rem);
  --display: clamp(2.4rem, 1.0rem + 6.0vw, 5.6rem);

  --space-3xs: .25rem; --space-2xs: .5rem; --space-xs: .75rem;
  --space-s: 1rem;  --space-m: 1.5rem; --space-l: 2.5rem;
  --space-xl: 4rem; --space-2xl: 6rem;
  --space-3xl: clamp(5rem, 11vh, 9rem);

  --gutter: clamp(1.15rem, .6rem + 2.1vw, 3rem);
  --page: min(100% - var(--gutter) * 2, 1240px);

  --void:   oklch(9% 0.014 250);
  --void-2: oklch(14% 0.018 248);
  --ink:    oklch(95% 0.006 240);
  --ink-2:  oklch(76% 0.012 240);
  --ink-3:  oklch(62% 0.016 242);
  --rule:   oklch(28% 0.020 248);
  --rule-2: oklch(20% 0.016 250);
  /* the lamp's own colour, used only for the lamp's own readouts */
  --lamp:   oklch(86% 0.10 78);
  --focus:  oklch(82% 0.13 220);

  --dur-fast: .18s; --dur-base: .4s;
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body, h1, h2, p, dl, dd, figure { margin: 0; padding: 0; }
a { color: inherit; }

body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--lamp); color: var(--void); }

.skip {
  position: absolute; left: var(--space-s); top: -4rem; z-index: 60;
  background: var(--ink); color: var(--void);
  padding: .7rem 1.1rem; font-family: var(--mono); font-size: var(--step--1);
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-out);
}
.skip:focus-visible { top: var(--space-s); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---- the scene sits behind everything ---- */
#stage {
  position: fixed; inset: 0; z-index: 0;
  display: block; width: 100%; height: 100%;
  background: var(--void);
}
header, main, footer, .hud { position: relative; z-index: 2; }

.head {
  width: var(--page); margin-inline: auto;
  padding-block: var(--space-m);
  display: flex; flex-wrap: wrap; gap: var(--space-s);
  align-items: baseline; justify-content: space-between;
  font-family: var(--mono); font-size: var(--step--1);
}
.head__back { text-decoration: none; }
.head__back:hover { color: var(--lamp); }
.dim { color: var(--ink-3); }
.head__meta {
  font-size: var(--step--2); color: var(--ink-3);
  letter-spacing: .10em; text-transform: uppercase;
}

/* ---- the readout ---- */
.hud {
  position: fixed; right: var(--gutter); bottom: var(--space-l); z-index: 3;
  font-family: var(--mono); text-align: right;
  opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
}
.hud.is-live { opacity: 1; }
.hud::before {
  content: ""; position: absolute; inset: -1.2rem -1.6rem -1.6rem -3rem; z-index: -1;
  background: radial-gradient(120% 100% at 80% 50%,
    oklch(9% 0.014 250 / .88) 0%, oklch(9% 0.014 250 / .5) 55%, transparent 78%);
  pointer-events: none;
}
.hud__row { display: flex; align-items: baseline; justify-content: flex-end; gap: var(--space-2xs); }
.hud__k {
  font-size: var(--step--2); letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
}
.hud__v {
  font-size: clamp(1.6rem, 3.6vw, 2.6rem); line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--lamp);
}
.hud__v--sm { font-size: var(--step--1); color: var(--ink-2); }
.hud__u { font-size: var(--step--1); color: var(--ink-3); }
@media (max-width: 56rem) {
  .hud { bottom: auto; top: 4.4rem; }
  .hud__v { font-size: var(--step-1); }
}

/* ---- the descent: one long scene, type pinned in stages ---- */
.scene { position: relative; }
.scene__type {
  min-height: 100svh;
  /* full-bleed so the scrim can be exactly viewport-wide with no 100vw and no
     scrollbar overflow; the copy is constrained by padding instead */
  width: 100%;
  padding-block: var(--space-2xl);
  padding-inline: max(var(--gutter), calc(50% - var(--page) / 2));
  display: flex; flex-direction: column; justify-content: center;
  position: relative;
}
/* the copy sits left, the lamp usually finds the right — and the copy carries
   its own dark so it never depends on where the light happens to be */
.scene__type > * { position: relative; z-index: 1; max-width: 34rem; }
.scene__type::before {
  /* the gutters back, never a viewport width: -50vw put a horizontal scrollbar
     on the page, same mistake as demo 02 */
  content: ""; position: absolute; inset: 0;
  z-index: 0; pointer-events: none;
  background: linear-gradient(to right,
    oklch(9% 0.014 250 / .86) 0%, oklch(9% 0.014 250 / .70) 30%, transparent 56%);
}
@media (max-width: 56rem) {
  .scene__type::before { background: oklch(9% 0.014 250 / .84); }
}

.eyebrow, .beat__mark {
  font-family: var(--mono); font-size: var(--step--2);
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
}
.beat__mark { color: var(--lamp); }
.title {
  font-size: var(--display); line-height: .96;
  letter-spacing: -.035em; font-weight: 700;
  margin-block: var(--space-s) var(--space-m);
  text-wrap: balance;
}
.beat__title {
  font-size: var(--step-3); line-height: 1.1; letter-spacing: -.02em;
  font-weight: 620; margin-block: var(--space-2xs) var(--space-s);
  max-width: 18ch; text-wrap: balance;
}
.lede { font-size: var(--step-1); max-width: 42ch; color: var(--ink-2); line-height: 1.45; }
.beat__body { max-width: 44ch; color: var(--ink-2); }
.beat__body i { color: var(--ink); font-style: italic; }
.cue {
  margin-top: var(--space-xl);
  font-family: var(--mono); font-size: var(--step--2);
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
  transition: opacity var(--dur-base) var(--ease-out);
}
.cue.is-done { opacity: 0; }

/* ---- reading sections ---- */
.section {
  width: var(--page); margin-inline: auto;
  padding-block: var(--space-3xl);
  border-top: 1px solid var(--rule-2);
  background: oklch(9% 0.014 250 / .92);
}
.section__head { margin-bottom: var(--space-l); }
.section__title {
  font-size: var(--step-3); line-height: 1.08; letter-spacing: -.025em;
  font-weight: 620; margin-block: var(--space-2xs) var(--space-s);
  max-width: 20ch; text-wrap: balance;
}
.section__sub { max-width: 52ch; color: var(--ink-2); }

.cols { display: grid; gap: var(--space-l); }
.col p { max-width: 46ch; color: var(--ink-2); }
.col p + p { margin-top: var(--space-s); }
@media (min-width: 54rem) { .cols { grid-template-columns: 1fr 1fr; column-gap: var(--space-2xl); } }

/* ---- the live counters ---- */
.counts {
  display: grid; gap: 1px;
  background: var(--rule-2);
  border: 1px solid var(--rule-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 46rem) { .counts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.counts > div {
  background: var(--void); padding: var(--space-m);
  display: grid; gap: var(--space-3xs);
}
.counts dt {
  font-family: var(--mono); font-size: var(--step--2);
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}
.counts dd {
  font-family: var(--mono); font-size: var(--step-2);
  font-variant-numeric: tabular-nums; color: var(--lamp);
}
.note {
  margin-top: var(--space-m); max-width: 60ch;
  font-size: var(--step--1); color: var(--ink-2); line-height: 1.6;
  padding-left: var(--space-s); border-left: 2px solid var(--rule);
}
code {
  font-family: var(--mono); font-size: .92em;
  background: var(--void-2); padding: .1em .35em; border-radius: 2px;
}

/* ---- colophon ---- */
.colophon__grid { display: grid; gap: var(--space-l); }
.creds > div {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: var(--space-s); padding-block: var(--space-2xs);
  border-bottom: 1px solid var(--rule-2);
}
.creds dt {
  font-family: var(--mono); font-size: var(--step--2);
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}
.creds dd { font-size: var(--step--1); color: var(--ink-2); }
.creds b { color: var(--ink); }
.colophon__note p { max-width: 48ch; color: var(--ink-2); font-size: var(--step--1); line-height: 1.6; }
.cta {
  display: inline-block; margin-top: var(--space-m);
  font-family: var(--mono); font-size: var(--step--1);
  text-decoration: none; border-bottom: 2px solid var(--lamp); padding-bottom: 2px;
}
.cta:hover { color: var(--lamp); }
@media (min-width: 56rem) {
  .colophon__grid { grid-template-columns: 1fr 1fr; column-gap: var(--space-2xl); }
}

.foot {
  width: var(--page); margin-inline: auto;
  padding-block: var(--space-l) var(--space-2xl);
  border-top: 1px solid var(--rule-2);
  background: oklch(9% 0.014 250 / .92);
  display: flex; flex-wrap: wrap; gap: var(--space-s); justify-content: space-between;
  font-family: var(--mono); font-size: var(--step--2); color: var(--ink-3);
}

/* ---- reduced motion: the scene holds one composed frame ---- */
@media (prefers-reduced-motion: reduce) {
  .cue { display: none; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
