/* ---------- tokens ---------- */
:root {
  --cream: #f3ecdf;
  --cream-dim: rgba(243, 236, 223, .68);
  --paper: #f4eee2;
  --ink: #17140f;
  --space: #05060d;
  --night: #0b1a33;
  --ochre: #e7a640;
  --rust: #c8552f;
  --glow: #7ff5dc;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --marker: "Permanent Marker", "Marker Felt", "Comic Sans MS", cursive;
  --gutter: clamp(16px, 4vw, 56px);
  --wrap: min(1160px, calc(100% - 2 * var(--gutter)));
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--space);
  color: var(--cream);
  font-family: var(--serif);
  font-size: clamp(1.02rem, .95rem + .3vw, 1.22rem);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
canvas, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--ochre); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--paper); color: var(--ink); padding: 8px 14px; border-radius: 4px;
  font: 500 .8rem var(--mono); text-decoration: none;
}
.skip:focus { top: 16px; }

/* ---------- type ---------- */
h1, h2, h3 { font-weight: 400; margin: 0; }
h2 {
  font-size: clamp(2.6rem, 1.5rem + 4.8vw, 5.8rem);
  line-height: .98; letter-spacing: -.025em;
  margin-bottom: .45em; text-wrap: balance;
}
h1 em, h2 em { font-weight: 300; }
p { margin: 0 0 1em; max-width: 34em; text-wrap: pretty; }
.lede { font-size: 1.12em; }
.fig {
  display: flex; align-items: center; gap: .9em; max-width: none;
  margin: 0 0 1.6rem; opacity: .8;
  font: 400 .7rem/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase;
}
.fig::before { content: ""; flex: 0 0 32px; height: 1px; background: currentColor; }
.note { font: .8rem/1.65 var(--mono); opacity: .78; max-width: 40em; }
figure { margin: 0; }
figcaption { font: .72rem/1.65 var(--mono); opacity: .78; margin-top: 14px; max-width: 46em; }

/* ---------- layout ---------- */
.sec {
  position: relative; isolation: isolate; overflow: clip;
  min-height: 100vh; min-height: 100svh;
  padding: clamp(110px, 16vh, 180px) 0 clamp(80px, 12vh, 140px);
}
.wrap { width: var(--wrap); margin-inline: auto; position: relative; }
.two {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
}
@media (max-width: 860px) { .two { grid-template-columns: minmax(0, 1fr); } }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px var(--gutter);
  color: #fff; mix-blend-mode: difference; pointer-events: none;
}
.topbar a { pointer-events: auto; text-decoration: none; }
.monogram { font: italic 400 1.6rem/1 var(--serif); letter-spacing: -.04em; }
.topbar nav { display: flex; gap: clamp(14px, 2.2vw, 30px); font: 400 .7rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.topbar nav a { opacity: .62; transition: opacity .2s; padding: 4px 0; }
.topbar nav a:hover, .topbar nav a[aria-current] { opacity: 1; }
.topbar nav a[aria-current] { text-decoration: underline; text-underline-offset: 6px; }
@media (max-width: 680px) { .topbar nav { display: none; } }

/* ---------- altimeter ---------- */
.gauge {
  position: fixed; z-index: 40; right: var(--gutter); top: 50%;
  height: min(52vh, 480px); width: 1px; transform: translateY(-50%);
  color: #fff; mix-blend-mode: difference; pointer-events: none;
  font-family: var(--mono);
}
.gauge::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: .3; }
.tick { position: absolute; right: 0; width: 7px; height: 1px; background: currentColor; opacity: .7; }
.tick b {
  position: absolute; right: 14px; top: -.62em; white-space: nowrap; opacity: .5;
  font-weight: 400; font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  display: none;
}
.gauge-marker {
  position: absolute; right: -6px; top: calc(var(--p, 0) * 100%);
  width: 13px; height: 2px; margin-top: -1px; background: currentColor;
}
.readout {
  position: fixed; z-index: 40; right: var(--gutter); bottom: 20px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  color: #fff; mix-blend-mode: difference; pointer-events: none;
  font-family: var(--mono); text-align: right;
}
.readout b { font-weight: 500; font-size: .95rem; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.readout span { font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; opacity: .65; }
@media (min-width: 1440px) { .tick b { display: block; } }
@media (max-width: 900px) { .gauge { display: none; } }

/* ---------- footnotes (Pratchett would want them) ---------- */
.fn { position: relative; display: inline; }
.fn > button {
  appearance: none; background: none; border: 0; padding: 0 .1em; margin: 0;
  color: var(--ochre); font-size: .9em; line-height: 1; cursor: help; vertical-align: super;
}
.fn-note {
  position: absolute; z-index: 20; left: 50%; bottom: calc(100% + 10px);
  width: min(300px, 80vw); transform: translate(-50%, 6px);
  padding: 12px 14px; border-radius: 3px;
  background: var(--paper); color: var(--ink);
  font: italic 400 .85rem/1.45 var(--serif);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.fn:hover .fn-note, .fn:focus-within .fn-note, .fn.open .fn-note { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
@media (max-width: 680px) {
  .fn-note { position: fixed; left: 16px; right: 16px; bottom: 16px; width: auto; transform: translateY(8px); }
  .fn:hover .fn-note, .fn:focus-within .fn-note, .fn.open .fn-note { transform: none; }
}

/* ---------- small parts ---------- */
.chip {
  appearance: none; cursor: pointer; background: transparent;
  border: 1px solid currentColor; border-radius: 999px; padding: 6px 14px;
  font: 500 .7rem/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  opacity: .78; transition: background .2s, color .2s, opacity .2s, border-color .2s;
}
.chip:hover { opacity: 1; }
.chip[aria-pressed="true"] { background: var(--cream); border-color: var(--cream); color: var(--ink); opacity: 1; }

/* ---------- reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 1s ease, transform 1.1s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
