/* ------------------------------------------------------------------ fonts */
/* One face per family: no bold, no italic. font-synthesis: none keeps the browser from faking either. */
@font-face {
  font-family: 'Academic Mono';
  src: url('/fonts/AcademicMono-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Academic Serif';
  src: url('/fonts/AcademicSerif-Light.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}

/* ------------------------------------------------------------------ tokens */
:root {
  --paper: #F4F1E8;
  --paper-2: #FFFAEC;
  --ink: #1D2126;
  --ink-2: #33373D;
  --muted: #6E7278;
  --rule: #D9D4C6;
  --sand: #CDC9BA;
  --unobs: #D6D1C3;
  --green: #46C535;
  --green-ink: #237A17;
  --teal: #1F756A;
  --red: #9E2B38;
  --serif: 'Academic Serif', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --mono: 'Academic Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  /* The whole type scale: one mono size, two serif sizes, all growing with the window. */
  --text: clamp(1rem, .8rem + .36vw, 1.375rem);        /* 16px phone · 18px at 1440 · 22px at 2560 */
  --statement: clamp(1.9rem, 2.9vw + .6rem, 4rem);      /* 30px phone · 51px at 1440 · 64px from 1880 */
  --display: clamp(2.5rem, 4.9vw + .5rem, 6.5rem);      /* 40px phone · 79px at 1440 · 104px from 1960 */
  --gutter: clamp(20px, 5.5vw, 96px);
  --vh: 100vh;
}
@supports (height: 100svh) { :root { --vh: 100svh; } }

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text)/1.6 var(--mono);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, p, ul, ol { margin: 0; }
canvas { display: block; }
:focus-visible { outline: 2px solid var(--green-ink); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; left: var(--gutter); top: -4rem; z-index: 20;
  padding: .6rem .9rem; background: var(--ink); color: var(--paper);
  text-decoration: none;
  transition: top .2s;
}
.skip:focus { top: 1rem; }

/* ------------------------------------------------------------------ type */
h1, .statement-xl, .figure { font: 300 var(--display) / 1.05 var(--serif); letter-spacing: -.015em; }
.statement { font: 300 var(--statement) / 1.1 var(--serif); letter-spacing: -.015em; }
h1 { text-wrap: balance; margin-bottom: 1.4rem; }
.statement { margin-bottom: 1rem; text-wrap: balance; }
.statement--h2 { margin-bottom: 1.2rem; }
.statement-xl { max-width: 24ch; margin-bottom: 3rem; text-wrap: balance; }
.lede { color: var(--ink-2); max-width: 46ch; margin-bottom: 2.2rem; }
.note, .readout, .legend {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.note { max-width: 48ch; }

.actions { display: flex; flex-wrap: wrap; gap: 1.2rem 2rem; align-items: center; }
.button {
  display: inline-block; padding: .8em 1.2em; border: 1px solid var(--ink);
  text-decoration: none;
  transition: background .2s, color .2s;
}
.button:hover { background: var(--ink); color: var(--paper); }
.link {
  text-decoration: none;
  border-bottom: 1px solid var(--sand); padding-bottom: 3px;
  transition: color .2s, border-color .2s;
}
.link:hover { color: var(--green-ink); border-color: var(--green-ink); }

/* ------------------------------------------------------------------ nav */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 18px var(--gutter);
  transition: background .3s, border-color .3s;
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled { background: rgba(244, 241, 232, .86); }
.nav.is-scrolled { background: color-mix(in srgb, var(--paper) 86%, transparent); border-color: var(--rule); backdrop-filter: blur(6px); }
.nav a { text-decoration: none; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.mark { flex: none; height: 1em; width: auto; }

/* ------------------------------------------------------------------ story (scenes 01–03) */
.story { position: relative; height: calc(var(--vh) * 4.8); }
.story__stage { position: sticky; top: 0; height: var(--vh); overflow: hidden; }
.field { position: absolute; inset: 0; width: 100%; height: 100%; }
.wash {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(244,241,232,.9) 0%, rgba(244,241,232,.72) 26%, rgba(244,241,232,0) 56%);
}

.step {
  position: absolute; left: var(--gutter); top: 50%;
  transform: translateY(-50%);
  max-width: min(calc(var(--display) * 8.4), 46vw);
  opacity: 0; visibility: hidden;
  transition: opacity .55s ease, visibility 0s .55s;
}
.step.is-on { opacity: 1; visibility: visible; transition: opacity .55s ease .08s, visibility 0s; }
.step[data-step="1"], .step[data-step="2"], .step[data-step="3"] { max-width: min(calc(var(--statement) * 9.4), 40vw); }

.story__foot {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 26px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem 2rem;
}
.legend { display: flex; gap: 1.6rem; list-style: none; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: .55rem; }
.sw { display: inline-block; width: 9px; height: 9px; background: var(--unobs); box-shadow: inset 0 0 0 1px var(--sand); }
.sw--meas { background: linear-gradient(90deg, var(--red) 50%, var(--teal) 50%); box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--ink); }
.sw--inf { background: var(--green); }

/* ------------------------------------------------------------------ evidence (scene 04) */
/* One screen tall, like the pinned scenes around it: the top padding clears the fixed header,
   and the vertical spacing shrinks with the window's height so short laptop screens fit too. */
.evidence {
  min-height: var(--vh);
  display: flex; flex-direction: column; justify-content: center;
  padding: 5rem var(--gutter) 2rem; border-top: 1px solid var(--rule);
}
.figures {
  display: grid; grid-template-columns: repeat(4, 1fr);
  list-style: none; padding: 0; border-top: 1px solid var(--rule);
}
.figures li { padding: clamp(1.2rem, calc(var(--vh) * .042), 2.6rem) 1.6rem; padding-left: 0; border-right: 1px solid var(--rule); }
.figures li + li { padding-left: 1.6rem; }
.figures li:last-child { border-right: 0; padding-right: 0; }
.figure { display: block; margin-bottom: 1.1rem; font-variant-numeric: lining-nums; }
.cap { display: block; color: var(--ink-2); max-width: 28ch; text-wrap: pretty; }
.paper {
  display: grid; justify-items: start; gap: clamp(1.1rem, calc(var(--vh) * .03), 2rem);
  padding-top: clamp(1.6rem, calc(var(--vh) * .05), 3.5rem); border-top: 1px solid var(--rule);
}
.credits { line-height: 1.9; color: var(--muted); }
/* Names never split across lines; a wrapped line ends on its separator. */
.authors { display: flex; flex-wrap: wrap; list-style: none; padding: 0; }
.authors li { white-space: nowrap; }
.authors li:not(:last-child)::after { content: '·'; margin: 0 1ch; }
.logos { display: flex; flex-wrap: wrap; align-items: center; gap: 1.6rem 3.5rem; list-style: none; padding: 0; margin-top: .6rem; }
.logos img { display: block; height: 2.8em; width: auto; }

/* ------------------------------------------------------------------ domains (scene 05) */
.domains { position: relative; height: calc(var(--vh) * 4.6); border-top: 1px solid var(--rule); }
.domains__stage {
  position: sticky; top: 0; height: var(--vh);
  display: grid; grid-template-columns: minmax(17rem, 1fr) minmax(0, 1.45fr);
  gap: clamp(2rem, 5vw, 5rem); align-items: center;
  padding: 0 var(--gutter);
}
.plate {
  position: relative; margin: 0; width: 100%;
  height: min(calc(var(--vh) * .72), 58vw);
  border: 1px solid var(--rule); background: var(--paper);
}
.readout--plate { position: absolute; left: 0; right: 0; top: calc(100% + .8em); }
.domains__list { list-style: none; padding: 0; margin-top: .4rem; display: grid; gap: .55rem; }
.domains__list li {
  display: grid; grid-template-columns: 8px 11ch 1fr; gap: 1rem; align-items: baseline;
  color: var(--muted); transition: color .4s;
}
.domains__list li::before { content: ''; width: 8px; height: 8px; background: var(--unobs); transition: background .4s; align-self: center; }
.domains__list li.is-on { color: var(--ink); }
.domains__list li.is-on::before { background: var(--green); }
.domains__list .how { color: var(--muted); }

/* ------------------------------------------------------------------ contact + footer (scene 06) */
/* One screen tall: the closing line and actions centred in the space above the end row. */
.contact {
  min-height: var(--vh);
  display: flex; flex-direction: column;
  padding: 5rem var(--gutter) 2rem; border-top: 1px solid var(--rule);
}
.contact .statement-xl { margin-top: auto; }
.contact__end {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1.4rem 3rem;
  margin-top: auto; padding-top: 3rem; color: var(--muted);
}

/* ------------------------------------------------------------------ text reconstruction */
.rc-vis .rc-w { white-space: nowrap; }
.rc-ready .rc { position: relative; color: transparent; }
.rc-ready .rc::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: .34em; height: .34em; margin: -.2em 0 0 -.17em;
  background: var(--unobs);
}
.rc-on .rc { animation: rc-glyph .01s linear both; animation-delay: calc(var(--d) * 1000ms + 250ms); }
.rc-on .rc::before { animation: rc-cell .01s linear both; animation-delay: calc(var(--d) * 1000ms + 250ms); }
.rc-on .rc--held { animation-name: rc-glyph-held; animation-duration: 750ms; animation-delay: calc(var(--d) * 1000ms + 500ms); }
.rc-on .rc--held::before { animation-name: rc-cell-held; animation-duration: 750ms; animation-delay: calc(var(--d) * 1000ms + 500ms); }
@keyframes rc-glyph { to { color: currentcolor; } }
@keyframes rc-cell { to { opacity: 0; } }
@keyframes rc-glyph-held {
  0%, 30% { color: transparent; }
  31%, 80% { color: var(--green-ink); }
  100% { color: currentcolor; }
}
@keyframes rc-cell-held {
  0%, 30% { background: var(--green); opacity: 1; }
  31%, 100% { opacity: 0; }
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1199px) {
  /* Text above the plate. The plate takes the height the text leaves, with room below for its readout. */
  .domains__stage {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch; gap: 1.4rem;
    padding-top: 11vh; padding-top: 11svh; padding-bottom: 4.2em;
  }
  .plate { height: auto; }
}

@media (min-width: 720px) and (max-width: 1199px) and (orientation: portrait) {
  /* Portrait tablets: four columns would wrap each caption over five or six lines. */
  .figures { grid-template-columns: 1fr 1fr; }
  .figures li:nth-child(2n) { border-right: 0; padding-right: 0; }
  .figures li:nth-child(3) { padding-left: 0; }
  .figures li:nth-child(n + 3) { border-top: 1px solid var(--rule); }
}

@media (max-width: 719px) {
  .nav { padding: 14px var(--gutter); }
  .step { top: 12.5vh; top: 12.5svh; transform: none; right: var(--gutter); max-width: none; }
  .step[data-step="1"], .step[data-step="2"], .step[data-step="3"] { max-width: none; }
  h1 { margin-bottom: 1rem; }
  .lede { margin-bottom: 1.6rem; }
  .legend { display: none; }
  .wash { background: linear-gradient(180deg, rgba(244,241,232,.92) 0%, rgba(244,241,232,.8) 42%, rgba(244,241,232,0) 66%); }
  .story__foot { bottom: 18px; }
  /* Figures become rows, number beside caption, so the section still fits one screen. */
  .figures { grid-template-columns: 1fr; }
  .figures li, .figures li + li {
    display: grid; grid-template-columns: calc(var(--statement) * 2.6) minmax(0, 1fr); gap: 1rem; align-items: baseline;
    padding: clamp(.5rem, calc(var(--vh) * .018), 1.1rem) 0; border-right: 0;
  }
  .figures li + li { border-top: 1px solid var(--rule); }
  .figure { font-size: var(--statement); margin-bottom: 0; }
  .cap { line-height: 1.45; }
  .evidence { padding: 4.1rem var(--gutter) .8rem; }
  .domains__list { margin-top: .2rem; gap: .35rem; }
  .paper { padding-top: clamp(1rem, calc(var(--vh) * .035), 2rem); gap: clamp(.9rem, calc(var(--vh) * .025), 1.5rem); }
  .button { padding: .65em 1.1em; }
  .credits { line-height: 1.6; }
  .authors { display: block; }                         /* one name per line */
  .authors li:not(:last-child)::after { content: none; }
  .venue { display: none; }                            /* the paper link carries it; phones need the room */
  .logos { gap: 1rem 1.6rem; margin-top: 0; }
  .logos img { height: 2em; }
  .contact { padding: 4.1rem var(--gutter) 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .step { transition: none; }
  .rc-ready .rc { color: inherit; }
  .rc-ready .rc::before { display: none; }
}
