/* =============================================================================
   site.css — WildQuant
   -----------------------------------------------------------------------------
   1. fonts            4. home (title, about card, social icons)
   2. design tokens    5. sections (text blocks, buttons, quote, form)
   3. base + board     6. other pages (about, section pages, comments)
                       7. states (page changes, reduced motion)
   HOW TO EDIT: colours and sizes live in the tokens (section 2). Where a
   section's text sits on the screen is set per section in section 5.
   ============================================================================= */

/* ---------------------------------------------------------------- 1. fonts
   Self-hosted subsets (see fonts/LICENSES.txt). Latin Modern is the LaTeX
   font, so headings match the chalk equations; Inter is for small text.     */
@font-face { font-family: "WQ Serif"; src: url("../fonts/lm-roman-regular.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "WQ Serif"; src: url("../fonts/lm-roman-bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "WQ Serif"; src: url("../fonts/lm-roman-italic.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "WQ Serif Caps"; src: url("../fonts/lm-roman-caps.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
/* maths symbols only (ℕ ℚ ℝ ∅ ∈ → ≤ √ ℵ 𝒫 …), for the chapter pages; letters and digits come from WQ Serif */
@font-face { font-family: "WQ Math"; src: url("../fonts/lm-math.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "WQ Sans"; src: url("../fonts/inter-400.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "WQ Sans"; src: url("../fonts/inter-500.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "WQ Sans"; src: url("../fonts/inter-600.woff") format("woff"); font-weight: 600; font-display: swap; }

/* ---------------------------------------------------------------- 2. tokens */
:root {
  --board: #0d0f0f;                       /* the blackboard */
  --ink: 246 244 236;                     /* chalk (r g b) */
  --ink-1: rgb(var(--ink) / 0.95);        /* headings */
  --ink-2: rgb(var(--ink) / 0.76);        /* body text */
  --ink-3: rgb(var(--ink) / 0.52);        /* quiet text */
  --line: rgb(var(--ink) / 0.42);         /* chalk outlines (buttons, cards) */
  --serif: "WQ Serif", "Latin Modern Roman", "CMU Serif", Georgia, "Times New Roman", serif;
  --caps: "WQ Serif Caps", var(--serif);
  --sans: "WQ Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(18px, 5.5vw, 84px);     /* page side margin */
  --radius: 10px;
  --chalk: none;                          /* chalk texture for the title (set by js/site.js) */
  --reveal: 1;                            /* 0..1 progress of the title's chalk writing */
  color-scheme: dark;
}

/* ---------------------------------------------------------------- 3. base */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--board); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--board); color: var(--ink-2);
  font: 400 clamp(15px, 0.35vw + 14px, 17.5px)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
/* the two fixed board canvases (100lvh = full height even when a phone hides its toolbar) */
#board-tex, #board-fx { position: fixed; inset: 0 auto auto 0; width: 100%; height: 100vh; height: 100lvh; display: block; pointer-events: none; }
#board-tex { z-index: 0; }
#board-fx { z-index: 1; }
/* the board starts right after a page's first paint (site.js): its drawings fade in, so nothing pops */
#board-tex, #board-fx { opacity: 0; transition: opacity .35s ease; }
.wq-ready #board-tex, .wq-ready #board-fx { opacity: 1; }
main, .page__main { position: relative; z-index: 2; }
a { color: inherit; }
::selection { background: rgb(var(--ink) / 0.22); }
:focus-visible { outline: 2px solid rgb(var(--ink) / 0.85); outline-offset: 3px; border-radius: 6px; }
.visually-hidden, .hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }

h1, h2 { font-family: var(--serif); font-weight: 700; color: var(--ink-1); letter-spacing: 0.005em; margin: 0; line-height: 1.08; }
h2 { font-size: clamp(30px, 3.4vw + 10px, 56px); text-shadow: 0 0 18px rgb(var(--ink) / 0.12); }
p { margin: 0.7em 0 0; }

/* ---------------------------------------------------------------- 4. home */
.panel { position: relative; min-height: 100vh; min-height: 100svh; padding: var(--gutter); display: flex; flex-direction: column; }

/* contact and profile links, top-right of the first screen (written as names) */
.social { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(10px, calc(var(--gutter) - 12px)); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; z-index: 3; }
.social a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 11px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font: 500 13px/1 var(--sans); letter-spacing: 0.04em; transition: color .2s, background-color .2s; }
.social a:hover { color: var(--ink-1); background: rgb(var(--ink) / 0.08); }
@media (max-width: 420px) { .social { right: 4px; } .social a { padding: 0 7px; font-size: 12px; } }

/* the hero block: WildQuant written in chalk, subtitle, name, about card */
/* sizes follow the screen height too, so on short or very wide screens the
   block stays compact and the chase below it keeps its strip */
.hero { margin-top: clamp(40px, calc(38vh - 150px), 230px); max-width: min(46rem, 52vw); }
.hero__title { font-size: clamp(56px, min(7.6vw + 12px, 15vh + 6px), 148px); line-height: 1; position: relative; display: inline-block; padding: 0.04em 0.02em 0.1em; }
.chalk-text {
  display: inline-block; color: rgb(var(--ink) / 0.96);
  background-image: var(--chalk); background-size: 240px 240px;
  -webkit-background-clip: text; background-clip: text;
  clip-path: inset(-20% calc((1 - var(--reveal)) * 100%) -25% -2%);
  filter: drop-shadow(0 0 10px rgb(var(--ink) / 0.10));
}
.has-chalk .chalk-text { color: transparent; }
.chalk-tip { position: absolute; top: 46%; left: calc(var(--reveal) * 100%); width: 0.09em; height: 0.09em; border-radius: 50%; background: #fffdf4; box-shadow: 0 0 14px 4px rgb(255 253 240 / 0.45); opacity: 0; pointer-events: none; }
.writing .chalk-tip { opacity: 1; }
.hero__subtitle { font-family: var(--serif); font-style: italic; font-size: clamp(19px, min(1.2vw + 13px, 2.2vh + 12px), 30px); color: var(--ink-1); margin-top: 0.35em; line-height: 1.25; }
.hero__by { font-family: var(--caps); font-size: clamp(15px, 0.5vw + 12px, 20px); letter-spacing: 0.08em; color: var(--ink-3); margin-top: 0.55em; }
.about-card {
  display: inline-grid; grid-template-columns: auto auto; column-gap: 18px; align-items: center; margin-top: clamp(14px, 3.4vh, 26px);
  padding: 12px 18px 12px 20px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none;
  background: rgb(13 15 15 / 0.35); transition: background-color .25s, border-color .25s, transform .25s;
}
.about-card:hover { background: rgb(var(--ink) / 0.07); border-color: rgb(var(--ink) / 0.7); transform: translateY(-1px); }
.about-card__title { font: 600 15px/1.2 var(--sans); color: var(--ink-1); letter-spacing: 0.01em; }
.about-card__sub { grid-column: 1; font: 400 13px/1.3 var(--sans); color: var(--ink-3); margin-top: 2px; }
.about-card__arrow { grid-column: 2; grid-row: 1 / span 2; font-size: 20px; color: var(--ink-2); transition: transform .25s; }
.about-card:hover .about-card__arrow { transform: translateX(3px); }

/* the intro: hero pieces appear in turn (js/site.js adds the classes).
   html.intro is set by a tiny script in <head>, so nothing flashes before the intro;
   if the drawing code ever fails, everything still appears after 14 s (wq-failsafe). */
@property --reveal { syntax: "<number>"; inherits: true; initial-value: 1; }
.intro { --reveal: 0; animation: wq-failsafe 0.01s 14s forwards; }
@keyframes wq-failsafe { to { --reveal: 1; } }
.intro .hero__subtitle, .intro .hero__by, .intro .about-card, .intro .scroll-hint { opacity: 0; transform: translateY(8px); transition: opacity .9s ease, transform .9s ease; animation: wq-show 0.01s 14s forwards; }
@keyframes wq-show { to { opacity: 1; transform: none; } }
.intro .title-done .hero__subtitle { opacity: 1; transform: none; transition-delay: .1s; }
.intro .title-done .hero__by { opacity: 1; transform: none; transition-delay: .45s; }
.intro .about-on .about-card { opacity: 1; transform: none; }
.intro .about-on .scroll-hint { opacity: 1; transform: none; transition-delay: 1.2s; }
/* the drawing engine started fine: its intro is in charge, so the failsafe is not needed */
.intro.wq-ready, .intro.wq-ready .hero__subtitle, .intro.wq-ready .hero__by, .intro.wq-ready .about-card, .intro.wq-ready .scroll-hint { animation: none; }
.scroll-hint { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0; display: grid; justify-items: center; gap: 2px; color: var(--ink-3); text-decoration: none; font: 500 11px/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; z-index: 3; }
.scroll-hint svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
.scrolled .scroll-hint { opacity: 0 !important; pointer-events: none; }

/* ---------------------------------------------------------------- 5. sections */
.panel__text { position: relative; max-width: 36rem; margin-top: clamp(64px, 13vh, 150px); }
.panel__text > p { max-width: 33rem; }
.panel__text--center { align-self: center; text-align: center; max-width: 44rem; margin-top: clamp(64px, 16vh, 170px); }
.panel__text--top { align-self: center; text-align: center; margin-top: clamp(40px, 8vh, 96px); }
/* Blogs: the explorer dances on the cliff (left), so the text sits above his blackboard (right) */
.panel--blogs .panel__text--top { align-self: flex-end; margin-right: max(2vw, calc(32vw - 18rem)); }
.panel--lab .panel__text { margin-top: clamp(64px, 16vh, 180px); }
.panel--feedback { align-items: flex-end; }
.feedback { width: min(30rem, 100%); margin-top: clamp(56px, 12vh, 140px); }

.btn {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 22px; padding: 11px 20px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 999px; background: rgb(13 15 15 / 0.35); color: var(--ink-1);
  font: 500 14.5px/1.2 var(--sans); letter-spacing: 0.01em; text-decoration: none; cursor: pointer;
  transition: background-color .25s, border-color .25s, transform .25s;
}
.btn:hover { background: rgb(var(--ink) / 0.08); border-color: rgb(var(--ink) / 0.72); transform: translateY(-1px); }
.btn span { transition: transform .25s; }
.btn:hover span { transform: translateX(3px); }
.btn--solid { background: rgb(var(--ink) / 0.9); color: #111; border-color: transparent; font-weight: 600; }
.btn--solid:hover { background: rgb(var(--ink) / 1); }
.badge { display: inline-block; margin-top: 16px; padding: 5px 12px; border: 1px dashed rgb(var(--ink) / 0.5); border-radius: 999px; font: 500 12px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }

.quote { margin: 22px auto 0; max-width: 40rem; font-family: var(--serif); font-size: clamp(18px, 0.9vw + 13px, 25px); line-height: 1.45; color: var(--ink-2); }
.quote p { margin: 0; }
.quote b { color: var(--ink-1); font-weight: 700; }
.quote footer { margin-top: 12px; font-family: var(--caps); font-size: 0.82em; letter-spacing: 0.06em; color: var(--ink-3); }

.comment-form { margin-top: 20px; }
.comment-form textarea {
  width: 100%; min-height: 128px; resize: vertical; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: rgb(10 12 12 / 0.72); color: var(--ink-1);
  font: 400 16px/1.5 var(--sans); transition: border-color .2s, background-color .2s;
}
.comment-form textarea::placeholder { color: var(--ink-3); }
.comment-form textarea:focus { outline: none; border-color: rgb(var(--ink) / 0.8); background: rgb(10 12 12 / 0.85); }
.comment-form__row { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: center; }
.comment-form__status { min-height: 1.6em; font-size: 14px; color: var(--ink-3); }

.site-footer { margin-top: auto; padding-top: 40px; width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; font-size: 13px; color: var(--ink-3); }
.site-footer__links { display: flex; gap: 18px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink-1); text-decoration: underline; text-underline-offset: 3px; }

/* short desktop windows: a more compact form, so the snow leopard can walk in below it */
@media (max-height: 720px) and (min-width: 761px) {
  .feedback { margin-top: clamp(36px, 6vh, 140px); }
  .comment-form { margin-top: 12px; }
  .comment-form textarea { min-height: 92px; }
  .comment-form .btn { margin-top: 12px; }
}
/* phones and narrow windows: every text block sits at the top, full width */
@media (max-width: 760px) {
  .hero { max-width: 100%; margin-top: clamp(76px, 13vh, 130px); }
  .panel__text, .panel__text--center, .panel__text--top, .feedback { margin-top: clamp(40px, 8vh, 80px); max-width: 100%; }
  .panel__text--center, .panel__text--top { text-align: left; align-self: flex-start; }
  .quote { margin-left: 0; }
  .panel--feedback { align-items: stretch; }
  .site-footer { flex-direction: column; }
}
/* short landscape screens (phones on their side): a compact title block so the chase keeps its strip */
@media (max-height: 520px) and (orientation: landscape) {
  .panel--home { padding-top: 34px; }
  .hero { margin-top: 6px; }
  .hero__title { font-size: clamp(38px, min(6vw, 11vh), 70px); }
  .hero__subtitle { font-size: 17px; margin-top: 0.2em; }
  .hero__by { font-size: 14px; margin-top: 0.3em; }
  .about-card { margin-top: 10px; padding: 7px 14px 7px 16px; }
  .panel__text, .panel__text--center, .panel__text--top { margin-top: 28px; }
}

/* ---------------------------------------------------------------- 6. pages */
.page .page__main { min-height: 100vh; min-height: 100svh; padding: var(--gutter); display: flex; flex-direction: column; }
.page__block { max-width: 46rem; }
.page__title { font-size: clamp(40px, 5vw + 14px, 92px); margin-top: clamp(80px, 22vh, 240px); }
.comments__intro { margin-top: 14px; color: var(--ink-3); }
.comments__intro a { color: var(--ink-1); text-underline-offset: 3px; }
body[data-scene="feedback"] .page__title { margin-top: clamp(72px, 14vh, 160px); }
.back { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(12px, calc(var(--gutter) - 14px)); z-index: 3; display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font: 500 14px/1 var(--sans); background: rgb(13 15 15 / 0.88); box-shadow: 0 0 14px 7px rgb(13 15 15 / 0.7); transition: background-color .2s, color .2s; } /* opaque, with a soft dark halo, so text scrolling under it stays out of the way */
.back:hover { color: var(--ink-1); background: rgb(32 33 33 / 0.95); }
.comments { list-style: none; margin: 32px 0 0; padding: 0; max-width: 42rem; display: grid; gap: 16px; }
.comments li { padding: 16px 18px; border: 1px solid rgb(var(--ink) / 0.22); border-radius: var(--radius); background: rgb(10 12 12 / 0.7); }
.comments .comment__text { margin: 0; color: var(--ink-1); white-space: pre-wrap; overflow-wrap: anywhere; }
.comments .comment__meta { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
.comments__note { margin-top: 28px; max-width: 36rem; color: var(--ink-3); }

/* Elementary Mathematics: title, a small index, then the chapters further down */
.page--chapters .page__title { margin-top: clamp(76px, 15vh, 170px); }
.page__lead { margin-top: 18px; max-width: 38rem; font-family: var(--serif); font-size: clamp(18px, 0.6vw + 14px, 22px); line-height: 1.5; color: var(--ink-2); }
.toc { margin-top: clamp(30px, 6vh, 60px); width: min(30rem, 100%); }
.toc__title { font: 600 12px/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); text-shadow: none; }
.toc__list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid rgb(var(--ink) / 0.2); }
.toc__list a { display: flex; gap: 14px; align-items: baseline; padding: 12px 4px; border-bottom: 1px solid rgb(var(--ink) / 0.2); color: var(--ink-1); text-decoration: none; font-family: var(--serif); font-size: clamp(18px, 0.4vw + 15.5px, 21px); transition: padding-left .2s, background-color .2s; }
.toc__list a:hover { padding-left: 12px; background: rgb(var(--ink) / 0.05); }
.toc__no { min-width: 1.6em; font: 500 13px/1 var(--sans); color: var(--ink-3); }
.chapter { margin-top: clamp(90px, 30vh, 300px); max-width: 40rem; scroll-margin-top: max(110px, 20vh); }
.chapter + .chapter { margin-top: clamp(70px, 18vh, 180px); }
.chapter:last-child { margin-bottom: 22vh; }
.chapter__meta { margin: 0; font: 500 12px/1.4 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.chapter__title { margin-top: 10px; font-size: clamp(30px, 2.6vw + 14px, 52px); }
.chapter__intro { margin-top: 14px; font-family: var(--serif); font-size: clamp(18px, 0.5vw + 14.5px, 21px); line-height: 1.55; color: var(--ink-2); }

/* chapter pages: a long read on the board (maths set in Latin Modern, like LaTeX) */
.article { width: min(42rem, 100%); margin: clamp(70px, 13vh, 150px) auto 0; font-family: var(--serif); font-size: clamp(17.5px, 0.35vw + 15.5px, 20px); line-height: 1.68; color: rgb(var(--ink) / 0.87); }
.article__kicker { margin: 0; font: 500 12px/1.4 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.article .article__title { margin-top: 12px; font-size: clamp(42px, 4.4vw + 16px, 86px); }
.article__by { margin-top: 14px; font-family: var(--caps); letter-spacing: 0.06em; color: var(--ink-3); }
.article__by time { white-space: nowrap; }
.article h2:not(.article__title) { margin: 2.3em 0 0.5em; font-family: var(--caps); font-weight: 400; font-size: 1.12em; letter-spacing: 0.08em; text-shadow: none; color: var(--ink-1); }
.article p { margin: 0.95em 0 0; text-wrap: pretty; }
.article b { color: var(--ink-1); }
.m { font-family: "WQ Math", var(--serif); }
.m i { font-family: var(--serif); }
.m sub, .m sup { font-size: 0.72em; line-height: 0; }
.rt { font-family: "WQ Math", var(--serif); border-top: 0.04em solid; margin-left: -0.03em; padding: 0 0.05em 0 0.03em; } /* the bar of a root: <span class="m">√<span class="rt">2</span></span> */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 0.8em; line-height: 1.12; margin: 0 0.12em; }
.frac > span:first-child { padding: 0 0.18em 0.05em; border-bottom: 1px solid currentColor; }
.frac > span:last-child { padding: 0.05em 0.18em 0; }
.article .math { margin: 1.1em 0 0; text-align: center; overflow-x: auto; overflow-y: hidden; padding: 0.15em 0; }
.math--lines .m { display: block; }
.diag { color: var(--ink-1); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.theorem, .proof { margin: 1.5em 0 0; padding-left: 1.1em; border-left: 2px solid rgb(var(--ink) / 0.4); }
.proof { border-left-style: dotted; }
.theorem p:first-child, .proof p:first-child { margin-top: 0; }
.qed { float: right; margin-left: 1em; }
.fig { margin: 1.8em 0 0; }
.fig__svg { display: block; width: 100%; height: auto; max-width: 34rem; margin: 0 auto; overflow: visible; }
.fig__svg--grid { max-width: 38rem; }
.fig figcaption { margin-top: 0.7em; text-align: center; font-size: 0.86em; font-style: italic; color: var(--ink-3); }
.fig__set { fill: none; stroke: rgb(var(--ink) / 0.75); stroke-width: 1.4; }
.fig__lab { fill: rgb(var(--ink) / 0.9); font: 17px var(--serif); }
.fig__set-lab { fill: rgb(var(--ink) / 0.9); font: 20px var(--serif); }
.fig__cap { fill: rgb(var(--ink) / 0.8); font: 18px var(--serif); }
.fig__arrow { stroke: rgb(var(--ink) / 0.72); stroke-width: 1.3; stroke-linecap: round; }
.fig__ah { stroke: rgb(var(--ink) / 0.85); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.fig__frac { fill: rgb(var(--ink) / 0.5); font: 16px var(--serif); }
.fig__frac--on { fill: rgb(var(--ink) / 0.98); }
.fig__keep { fill: rgb(var(--ink) / 0.1); stroke: rgb(var(--ink) / 0.35); stroke-width: 1; }
.fig__start { fill: none; stroke: rgb(var(--ink) / 0.95); stroke-width: 1.6; stroke-dasharray: 5 3; }
.fig__dots { fill: rgb(var(--ink) / 0.4); font: 18px var(--serif); }
.article__reading ul { margin: 0.6em 0 0; padding-left: 1.2em; }
.article__reading li { margin-top: 0.5em; }
.article__end { margin: 2.6em 0 0 !important; text-align: center; font-size: 1.4em; color: var(--ink-3); }
.article__back { margin: 2em 0 18vh !important; text-align: center; }
@media (max-width: 760px) { .article { margin-top: 64px; } .fig__lab, .fig__frac { font-size: 18px; } }

/* ---------------------------------------------------------------- 6b. simulations */
/* the Simulations page: lead, collection cards, then numbered cards: as many per row as fit (each at least
   about 20rem wide, so the text stays readable), one per row on phones */
.page--sims .page__title { margin-top: clamp(76px, 15vh, 170px); }
.collections { margin-top: clamp(30px, 6vh, 60px); width: min(30rem, 100%); }
.collections__list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.collection-card { display: grid; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: rgb(10 12 12 / 0.6); color: var(--ink-2); text-decoration: none; transition: background-color .2s, border-color .2s, transform .2s; }
.collection-card:hover { background: rgb(var(--ink) / 0.06); border-color: rgb(var(--ink) / 0.72); transform: translateY(-1px); }
.collection-card__title { font-family: var(--serif); font-size: clamp(19px, 0.5vw + 16px, 23px); color: var(--ink-1); }
.collection-card__meta { font: 500 12px/1.4 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.collection { margin-top: clamp(80px, 22vh, 220px); scroll-margin-top: max(70px, 8vh); margin-bottom: 18vh; }
.collection__title { font-size: clamp(28px, 2.4vw + 14px, 48px); }
.collection__intro { margin-top: 10px; max-width: 38rem; color: var(--ink-2); }
.collection__intro a { color: var(--ink-1); text-underline-offset: 3px; }
.project-grid { list-style: none; margin: clamp(22px, 4vh, 36px) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: clamp(14px, 2vw, 24px); }
.project-card { position: relative; height: 100%; min-height: 15rem; display: flex; flex-direction: column; gap: 10px; padding: clamp(18px, 2.4vw, 28px); border: 1px solid var(--line); border-radius: var(--radius); background: rgb(10 12 12 / 0.66); color: var(--ink-2); text-decoration: none; scroll-margin-top: 90px; transition: background-color .2s, border-color .2s, transform .2s; }
a.project-card:hover { background: rgb(var(--ink) / 0.06); border-color: rgb(var(--ink) / 0.72); transform: translateY(-2px); }
.project-card__no { font: 400 clamp(38px, 3vw + 18px, 58px)/1 var(--serif); color: var(--ink-3); }
.project-card__title { font-family: var(--serif); font-weight: 700; font-size: clamp(20px, 0.8vw + 16px, 26px); line-height: 1.2; color: var(--ink-1); }
.project-card__text { font-size: 0.95em; line-height: 1.5; }
.project-card__go, .project-card__badge { margin-top: auto; font: 600 13px/1 var(--sans); letter-spacing: 0.04em; color: var(--ink-1); }
.project-card__badge { align-self: flex-start; padding: 6px 10px; border: 1px dashed rgb(var(--ink) / 0.5); border-radius: 999px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--ink-2); }
.project-card--soon { opacity: 0.5; }

/* a simulation page: compact header, then panels (plot + its terminal box side by side; stacked on narrow screens) */
.sim { width: min(72rem, 100%); margin: 0 auto; }
.page .page__main.sim { padding-bottom: 14vh; }
.sim-head { margin-top: clamp(64px, 10vh, 110px); }
.page__title.sim__title { margin-top: 8px; font-size: clamp(34px, 3.2vw + 16px, 64px); }
.sim-eq { margin-top: 16px; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 10px 32px; align-items: start; }
.sim-eq__formula { margin: 0; font-size: clamp(22px, 1.2vw + 16px, 32px); color: var(--ink-1); white-space: nowrap; padding-top: 2px; }
.sim-notation { margin: 0; display: grid; gap: 4px; font-size: 0.93em; }
.sim-notation > div { display: grid; grid-template-columns: 5.6em minmax(0, 1fr); gap: 10px; }
.sim-notation dt { color: var(--ink-1); font-size: 1.08em; }
.sim-notation dd { margin: 0; color: var(--ink-2); }
@media (max-width: 860px) { .sim-eq { grid-template-columns: minmax(0, 1fr); } }
.sim-sec { margin-top: clamp(48px, 9vh, 90px); scroll-margin-top: 70px; }
.sim-sec__title { font-size: clamp(24px, 1.6vw + 15px, 36px); }
.sim-sec__lead { max-width: 46rem; color: var(--ink-2); }
.sim-controls { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.sim-ctl { display: flex; align-items: center; gap: 10px; flex: 1 1 15rem; max-width: 24rem; }
.sim-ctl__name { min-width: 2.6em; color: var(--ink-1); font-size: 1.02em; }
.sim-ctl output { min-width: 3.4em; text-align: right; font: 500 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; color: var(--ink-1); }
.sim-ctl input[type="range"] { flex: 1; min-width: 0; }
/* range sliders in chalk */
.sim input[type="range"] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; accent-color: #f6f4ec; cursor: pointer; }
.sim input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: rgb(var(--ink) / 0.35); border-radius: 2px; }
.sim input[type="range"]::-moz-range-track { height: 2px; background: rgb(var(--ink) / 0.35); border-radius: 2px; }
.sim input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--ink-1); box-shadow: 0 0 8px rgb(var(--ink) / 0.35); }
.sim input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--ink-1); box-shadow: 0 0 8px rgb(var(--ink) / 0.35); }
.sim input[type="range"]:focus-visible { outline: 2px solid rgb(var(--ink) / 0.85); outline-offset: 2px; }
.sim-errs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 0; padding: 0; border: 0; min-width: 0; }
.sim-errs legend { float: left; margin-right: 6px; color: var(--ink-1); }
.sim-err { display: inline-flex; align-items: center; gap: 7px; font: 500 14px/1.3 var(--sans); color: var(--ink-2); }
.sim-err input[type="checkbox"] { accent-color: #f6f4ec; width: 15px; height: 15px; }
.swatch { width: 16px; height: 3px; border-radius: 2px; background: var(--c); }
.sim-num { width: 8.5em; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgb(10 12 12 / 0.8); color: var(--ink-1); font: 500 14px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.sim-hint { font-size: 13px; color: #f0b27a; }
.sim-panel { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .sim-panel { grid-template-columns: minmax(0, 1fr); } }
.sim-plot { position: relative; margin: 0; padding: 8px 6px 6px; border: 1px solid rgb(var(--ink) / 0.18); border-radius: var(--radius); background: rgb(10 12 12 / 0.62); }
.sim-plot canvas { display: block; width: 100%; height: clamp(220px, 34vw, 400px); touch-action: pan-y; }
.sim-plot--tall canvas { height: clamp(260px, 40vw, 460px); cursor: crosshair; }
.sim-plot canvas.is-zooming { touch-action: none; outline: 1px dashed rgb(var(--ink) / 0.5); outline-offset: -1px; }
.sim-cap { margin: 4px 6px 2px; font-size: 13px; color: var(--ink-3); }
.sim-note { margin: 4px 6px 2px; font-size: 13px; color: #f0b27a; }
.sim-toggle { margin: 0 0 6px 6px; display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.sim-toggle button, .sim-btn { padding: 5px 12px; border: 0; background: rgb(10 12 12 / 0.85); color: var(--ink-2); font: 500 12.5px/1 var(--sans); cursor: pointer; }
.sim-toggle button[aria-pressed="true"] { background: rgb(var(--ink) / 0.88); color: #111; }
.sim-btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; }
.sim-btn:hover, .sim-toggle button:hover { color: var(--ink-1); }
.sim-btn[aria-pressed="true"] { background: rgb(var(--ink) / 0.88); color: #111; }
.sim-btn[hidden] { display: none; }
.sim-btn--zoom, .sim-hint--coarse { display: none; }
@media (pointer: coarse) { .sim-btn--zoom { display: inline-block; } .sim-hint--coarse { display: inline; } .sim-hint--fine { display: none; } }
.sim-theory ul { margin: 14px 0 0; padding-left: 1.2em; max-width: 46rem; font-family: var(--serif); font-size: clamp(17px, 0.3vw + 15.5px, 19px); line-height: 1.6; color: rgb(var(--ink) / 0.86); }
.sim-theory li { margin-top: 0.55em; }
.sim-theory b { color: var(--ink-1); }
.sim-more { margin-top: clamp(40px, 7vh, 70px); display: flex; flex-wrap: wrap; gap: 14px; }

/* the "terminal" boxes beside the plots: neon green chalk on a dark panel */
.term { margin: 0; padding: 14px 16px; min-height: 6em; border: 1px solid rgb(125 255 138 / 0.28); border-radius: var(--radius); background: rgb(4 10 5 / 0.82); color: #7dff8a; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; text-shadow: 0 0 6px rgb(125 255 138 / 0.35); white-space: pre-wrap; overflow-wrap: anywhere; }
.term sub { font-size: 0.78em; line-height: 0; }
.term__hi { color: #c9ffcf; text-shadow: 0 0 9px rgb(125 255 138 / 0.75); font-weight: 600; }
.term__dim { opacity: 0.6; }
.term__cursor { display: inline-block; width: 0.6em; height: 1.05em; margin-left: 2px; vertical-align: -0.18em; background: #7dff8a; box-shadow: 0 0 6px rgb(125 255 138 / 0.6); animation: term-blink 1.1s steps(1) infinite; }
@keyframes term-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .term__cursor { animation: none; } }
@media (max-width: 520px) { .term { font-size: 12px; padding: 12px; } }

/* shared pieces for the population-dynamics pages (cards 2–6): mode switches, presets, slider groups,
   phase planes, and two more terminal colours */
.sim [hidden] { display: none !important; } /* .sim-ctl, .sim-panel … set display, which would beat the hidden attribute */
.sim-seg { display: inline-flex; flex-wrap: wrap; width: fit-content; max-width: 100%; align-self: flex-start; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.sim-seg button { padding: 7px 12px; border: 0; background: rgb(10 12 12 / 0.85); color: var(--ink-2); font: 500 13px/1.2 var(--sans); cursor: pointer; }
.sim-seg button + button { border-left: 1px solid rgb(var(--ink) / 0.2); }
.sim-seg button:hover { color: var(--ink-1); }
.sim-seg button[aria-pressed="true"] { background: rgb(var(--ink) / 0.88); color: #111; }
.sim-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.sim-presets__label { font: 500 12px/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-right: 4px; }
.sim-presets button { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgb(10 12 12 / 0.85); color: var(--ink-2); font: 500 12.5px/1.2 var(--sans); cursor: pointer; }
.sim-presets button:hover { color: var(--ink-1); border-color: rgb(var(--ink) / 0.72); }
.sim-group { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 8px; }
.sim-group legend { padding: 0; margin-bottom: 4px; font: 600 12px/1.2 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.sim-controls--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 10px 28px; }
.sim-controls--grid .sim-ctl { max-width: none; }
.sim-plot--phase canvas { height: clamp(300px, 46vw, 560px); cursor: crosshair; }
.sim-btn--play { min-width: 5.5em; }
.sim-sec > .sim-seg { margin-top: 14px; }
.sim-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-panel--wideterm { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } /* boxes with long table rows */
@media (max-width: 900px) { .sim-panel--wideterm { grid-template-columns: minmax(0, 1fr); } }
.sim-eq__formula--small { font-size: clamp(16px, 0.8vw + 12px, 24px); white-space: normal; } /* three long equations */
.sim-controls--grid > .sim-group { align-self: start; }
@media (max-width: 600px) { .sim-eq__formula--wrap { white-space: normal; font-size: 19px; } } /* long equations on a phone */
.sim-stack { display: grid; gap: 14px; min-width: 0; }
.term__warn { color: #f0b27a; text-shadow: 0 0 6px rgb(240 178 122 / 0.35); }
.term__why { color: #b4f7bb; opacity: 0.92; }

/* ---------------------------------------------------------------- 7. states */
/* leaving for another page: the text fades fast while the drawings are pulled into the link */
.wq-collapsing main, .wq-collapsing .page__main, .wq-collapsing .back { opacity: 0; transition: opacity .2s ease; }
/* arriving from another page of the site: a quick flash of chalk light from the spot where the
   link was clicked, over the page, which is shown at once. html.wq-arrive and --fx / --fy are set
   by a tiny script in <head>, so the flash starts with the first paint. */
.wq-arrive body::after {
  content: ""; position: fixed; z-index: 30; left: var(--fx, 50%); top: var(--fy, 50%); pointer-events: none;
  width: 240vmax; height: 240vmax; margin: -120vmax 0 0 -120vmax; border-radius: 50%; opacity: 0;
  background: radial-gradient(closest-side, rgb(255 253 246 / 0.95), rgb(255 253 246 / 0.55) 7%, rgb(246 244 236 / 0.16) 24%, rgb(246 244 236 / 0) 55%);
  animation: wq-flash .55s cubic-bezier(.2, .75, .3, 1) both;
}
@keyframes wq-flash { from { transform: scale(.06); opacity: 1; } 30% { opacity: .9; } to { transform: scale(1); opacity: 0; } }
/* reduced motion: everything is shown at once, nothing moves */
.wq-still .hero__subtitle, .wq-still .hero__by, .wq-still .about-card, .wq-still .scroll-hint { opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wq-arrive body::after { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
