/* ==========================================================================
   Design system
   --------------------------------------------------------------------------
   Every value in the stylesheet comes from these tokens. Change the tokens,
   not the components. See DESIGN.md for the rules behind them.
   ========================================================================== */
/* Fonts, self-hosted (Inter and Newsreader, SIL Open Font License) */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 500; font-display: swap; src: url(fonts/inter-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 500; font-display: swap; src: url(fonts/inter-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 500; font-display: swap; src: url(fonts/newsreader-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 500; font-display: swap; src: url(fonts/newsreader-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Colour: warm neutrals on white, one accent */
  --c-bg:        #ffffff;
  --c-surface:   #f8f7f4;
  --c-ink:       #141413;   /* primary text */
  --c-ink-2:     #5e5d59;   /* secondary text */
  --c-ink-3:     #75736c;   /* tertiary text, metadata (4.7:1 on white) */
  --c-line:      #ecebe6;   /* hairlines */
  --c-accent:    #c9822b;   /* the "seed": marks, active states */
  --c-accent-ink:#9a5f17;   /* accent used as text on white */

  /* Network (hero) colours as RGB triplets, read by site.js */
  --net-node: 20 20 19;
  --net-seed: 201 130 43;

  /* Type */
  --f-sans:  "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --t-xs:  12px;
  --t-sm:  13px;
  --t-base:15px;
  --t-md:  17px;
  --t-lg:  22px;
  --t-xl:  clamp(26px, 3vw, 32px);

  --lh-tight: 1.2;
  --lh-base:  1.6;

  /* Space: 4px base */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Shape and motion */
  --radius: 6px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur:  240ms;

  /* Layout */
  --sidebar: 232px;
  --content: 680px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg:        #141413;
    --c-surface:   #1c1c1a;
    --c-ink:       #f0efea;
    --c-ink-2:     #b5b3ab;
    --c-ink-3:     #85837c;
    --c-line:      #2a2a27;
    --c-accent-ink:#e0a65a;
    --net-node: 240 239 234;
  }
}
:root[data-theme="dark"] {
  --c-bg:        #141413;
  --c-surface:   #1c1c1a;
  --c-ink:       #f0efea;
  --c-ink-2:     #b5b3ab;
  --c-ink-3:     #85837c;
  --c-line:      #2a2a27;
  --c-accent-ink:#e0a65a;
  --net-node: 240 239 234;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: var(--s-6); }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font: 400 var(--t-base)/var(--lh-base) var(--f-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--c-accent) 30%, transparent); }
a { color: inherit; text-decoration: none; transition: color var(--dur) var(--ease); }
a:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--c-accent) 60%, transparent);
  outline-offset: 2px; border-radius: var(--radius);
}
p, ul, ol, dl, dd, h1, h2, h3 { margin: 0; padding: 0; }
ul, ol { list-style: none; }

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

/* ==========================================================================
   Brand mark
   ========================================================================== */
.mark { width: 20px; height: 20px; flex: none; }
/* A tiny Schelling board: two sorted patches and one restless square, which settles on hover. */
.mark rect { fill: var(--tc); transition: fill var(--dur) var(--ease); }
.mark .restless { fill: transparent; stroke: var(--tc); stroke-width: 1.6; }
.brand:hover .mark .restless { fill: var(--tc); }

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s-7);
  padding: var(--s-6) var(--s-5) var(--s-6) var(--s-6);
}
.brand { display: flex; align-items: center; gap: var(--s-3); }
.brand-name { font-size: var(--t-base); font-weight: 500; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: var(--s-1); }
.nav a {
  position: relative;
  padding: var(--s-1) 0;
  font-size: var(--t-sm);
  color: var(--c-ink-3);
}
.nav a:hover, .nav a.active { color: var(--c-ink); }
.nav a::before {
  content: ""; position: absolute; left: calc(-1 * var(--s-4)); top: 50%;
  width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
  background: var(--c-accent);
  transform: scale(0); transition: transform var(--dur) var(--ease);
}
.nav a.active::before { transform: scale(1); }

.side-links { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); }
.ilink { display: inline-flex; align-items: center; gap: var(--s-2); width: fit-content; font-size: var(--t-sm); color: var(--c-ink-3); }
.ilink:hover { color: var(--c-ink); }
.ilink svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   Hero: the network sits directly on the page, no frame
   ========================================================================== */
.main { min-width: 0; padding: 0 var(--s-7); }
.main > .block, .main > .foot { margin-left: auto; margin-right: auto; }
.hero {
  position: relative;
  height: min(340px, 55vh);
  display: flex; align-items: flex-end;
  padding-bottom: var(--s-7);
}
.society {
  position: absolute; inset: 0 calc(-1 * var(--s-7)) 0 0;
  width: calc(100% + var(--s-7)); height: 100%;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 70% 45%, #000 35%, transparent 80%);
          mask-image: radial-gradient(ellipse 60% 85% at 50% 45%, #000 30%, transparent 78%);
}
.hero-text { position: relative; width: 100%; max-width: var(--content); margin: 0 auto; }
h1 {
  font-family: var(--f-serif);
  font-weight: 400;
  font-size: var(--t-xl);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin-bottom: var(--s-3);
}
.affil { font-size: var(--t-sm); color: var(--c-ink-2); }
.affil.muted { color: var(--c-ink-3); }
.js .hero-text { animation: rise 900ms var(--ease) both 150ms; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   Sections
   ========================================================================== */
.block {
  max-width: var(--content);
  padding: var(--s-7) 0;
  border-top: 1px solid var(--c-line);
}
.block h2 {
  font-family: var(--f-serif);
  font-weight: 400;
  font-size: var(--t-lg);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin-bottom: var(--s-5);
}
.block h3 { font-size: var(--t-sm); font-weight: 500; color: var(--c-ink-3); margin-bottom: var(--s-3); }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-5); }
.block-head h2 { margin: 0; margin-right: auto; }

/* Published-in line under About */
.venue-line { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--c-line); font-size: var(--t-sm); color: var(--c-ink-2); line-height: 1.8; }
.venue-line span { color: var(--c-ink-3); margin-right: var(--s-2); }
.venue-line i { font-style: normal; color: var(--c-ink-3); margin: 0 4px; }

/* About */
.about { display: grid; grid-template-columns: 1fr 148px; gap: var(--s-6); align-items: start; }
.prose { font-size: var(--t-md); line-height: 1.65; color: var(--c-ink); }
.prose p + p { margin-top: var(--s-4); }
.portrait { width: 148px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); display: block; background: var(--c-surface); }
.portrait.placeholder { display: grid; place-items: center; color: var(--c-ink-3); font-family: var(--f-serif); font-size: var(--t-lg); }

.rows { margin-top: var(--s-6); }
.rows > div { display: grid; grid-template-columns: 180px 1fr; gap: var(--s-4); padding: var(--s-3) 0; border-top: 1px solid var(--c-line); font-size: var(--t-sm); }
.rows > div:last-child { border-bottom: 1px solid var(--c-line); }
.rows dt { color: var(--c-ink-3); }
.rows a:hover { color: var(--c-accent-ink); }

/* Research */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); }
.plain li { font-size: var(--t-base); padding: 3px 0; }
.venues li { font-family: var(--f-serif); font-size: var(--t-md); }

/* Filter */
.filter { display: inline-flex; align-items: center; gap: var(--s-2); padding: 5px var(--s-3); border-radius: var(--radius); background: var(--c-surface); color: var(--c-ink-3); }
.filter svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.filter input { border: 0; outline: 0; background: transparent; color: var(--c-ink); font: var(--t-sm) var(--f-sans); width: 120px; }
.filter input::placeholder { color: var(--c-ink-3); }
.filter:focus-within { box-shadow: 0 0 0 1px var(--c-line) inset; }

/* Papers */
.papers { display: flex; flex-direction: column; }
.paper { display: grid; grid-template-columns: 56px 1fr; gap: var(--s-4); padding: var(--s-3) 0; position: relative; z-index: 0; }
/* The whole row is a target: a very faint wash on hover, and a small arrow after the title */
.paper:has(.ptitle a)::before {
  content: ""; position: absolute; z-index: -1; inset: 2px calc(-1 * var(--s-3));
  border-radius: var(--radius); background: var(--c-surface);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.filtering .paper.year-start:not(.first-visible)::before { top: calc(var(--s-3) + 2px); }
.paper:has(.ptitle a):hover { cursor: pointer; }
.paper:has(.ptitle a):hover::before { opacity: 1; }
.ptitle .arrow { display: inline-block; width: 0; white-space: nowrap; padding-left: 4px; font-size: 0.85em; color: var(--c-ink-3); opacity: 0; transform: translate(-2px, 1px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.paper:hover .ptitle .arrow { opacity: 1; transform: translate(0, 0); }
.paper[hidden] { display: none; }
.pyear { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); color: var(--c-ink-3); font-variant-numeric: tabular-nums; padding-top: 1px; }
/* With JS, each year shows once and starts a new group */
.filtering .paper:not(.year-start) .y { visibility: hidden; }
.filtering .paper.year-start:not(.first-visible) { margin-top: var(--s-3); padding-top: var(--s-5); border-top: 1px solid var(--c-line); }

/* Research-area marks: the network's squares, one per area */
.marks { display: flex; gap: 3px; }
.sq { width: 6px; height: 6px; border-radius: 1px; background: var(--tc); display: block; }
.ptitle { font-size: var(--t-base); font-weight: 500; line-height: 1.45; letter-spacing: -0.005em; }
.ptitle a { transition: color var(--dur) var(--ease); }
.ptitle a:hover { color: var(--c-accent-ink); }
.pauthors, .pmeta { font-size: var(--t-sm); color: var(--c-ink-2); margin-top: 2px; }
.pmeta { color: var(--c-ink-3); }
.pmeta em, .venue-line em { font-style: italic; }
.venue-line em { white-space: nowrap; }
.self { color: var(--c-ink); }
.slinks a { color: var(--c-ink-2); }
.slinks a:hover { color: var(--c-accent-ink); }
/* Resource pills under each paper: PDF, Replication, Code, Data, Preprint */
.plinks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-2); }
.lpill {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px 0 7px;
  border-radius: 999px; box-shadow: inset 0 0 0 1px var(--c-line);
  background: var(--c-bg);
  font-size: var(--t-xs); font-weight: 500; color: var(--c-ink-2);
  transition: color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.lpill svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.lpill:hover { color: var(--c-accent-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-accent) 45%, transparent); background: color-mix(in srgb, var(--c-accent) 6%, var(--c-bg)); }
.empty { font-size: var(--t-sm); color: var(--c-ink-3); padding: var(--s-3) 0; }

/* Topic pills
   Each research area has one colour (content/topics.json → --tc). Pills are
   tinted, never solid, so the colours stay quiet next to body text. */
.pill {
  --tc: var(--c-ink-3);
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border: 0; border-radius: 999px;
  font: 500 var(--t-xs)/1 var(--f-sans);
  letter-spacing: 0.005em;
  color: color-mix(in srgb, var(--tc) 88%, var(--c-ink));
  background: color-mix(in srgb, var(--tc) 9%, transparent);
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pill i { width: 6px; height: 6px; border-radius: 1px; background: var(--tc); flex: none; }
button.pill { cursor: pointer; }
button.pill:hover { background: color-mix(in srgb, var(--tc) 15%, transparent); }

.topic-bar { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: calc(-1 * var(--s-2)) 0 var(--s-5); }
.topic-bar .pill { height: 28px; padding: 0 10px; color: var(--c-ink-2); background: transparent; box-shadow: inset 0 0 0 1px var(--c-line); }
.topic-bar .pill:hover { color: var(--c-ink); background: var(--c-surface); }
.topic-bar .pill[aria-pressed="true"] {
  color: color-mix(in srgb, var(--tc) 88%, var(--c-ink));
  background: color-mix(in srgb, var(--tc) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 35%, transparent);
}
/* Selected / All sit first, set slightly apart from the areas. */
.topic-bar [data-view="all"] { margin-right: var(--s-2); }
.topic-bar .pill.all[aria-pressed="true"] { color: var(--c-bg); background: var(--c-ink); box-shadow: none; }
.pill .n { font-weight: 400; color: var(--c-ink-3); font-variant-numeric: tabular-nums; margin-left: 2px; }
.pill[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.pill .nw { opacity: 0.6; }
.pill .n { position: relative; }
.sr { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.count-key { margin-left: auto; align-self: center; font-size: var(--t-xs); color: var(--c-ink-3); white-space: nowrap; }
.count-key span { opacity: 0.6; }
.count-key i { font-style: normal; opacity: 0.6; }

.ptopics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-2); }
.ptopics .pill { height: 20px; padding: 0 8px; font-size: 11px; gap: 5px; cursor: pointer; }
.ptopics .pill i { width: 5px; height: 5px; }
.ptopics .pill:hover { background: color-mix(in srgb, var(--tc) 16%, transparent); }

.topic-links { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }

.paper.enter { animation: enter 320ms var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(3px); } }

/* Talks: same 56px date column as the paper list */
.talks { list-style: none; margin: 0; padding: 0; }
.talk { display: grid; grid-template-columns: 56px 1fr; gap: var(--s-4); padding: var(--s-3) 0; }
.talk.year-start:not(:first-child) { margin-top: var(--s-3); padding-top: var(--s-5); border-top: 1px solid var(--c-line); }
.tdate { display: grid; align-content: start; gap: 2px; font-size: var(--t-xs); color: var(--c-ink-3); padding-top: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tdate .y { font-size: var(--t-sm); }
.tdate .y:empty { display: none; }
.ttitle { font-weight: 500; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-2); }
.ttitle a { color: inherit; text-decoration: none; }
.ttitle a:hover { text-decoration: underline; text-decoration-color: var(--c-line); text-underline-offset: 3px; }
.tsoon, .trole { font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 7px; border-radius: 999px; }
.tsoon { color: var(--c-accent-ink); background: color-mix(in srgb, var(--c-accent) 14%, transparent); }
.trole { color: var(--c-ink-3); box-shadow: inset 0 0 0 1px var(--c-line); font-weight: 400; }
.tmeta { font-size: var(--t-sm); color: var(--c-ink-2); }
.more-talks { border-top: 1px solid var(--c-line); margin-top: var(--s-3); }
.more-talks summary { cursor: pointer; padding: var(--s-3) 0; font-size: var(--t-sm); color: var(--c-ink-2); }
@media (max-width: 600px) {
  .talk { grid-template-columns: 1fr; gap: 2px; }
  .tdate { display: flex; gap: var(--s-2); padding-top: 0; }
}

/* Software */
.software { display: flex; flex-direction: column; }
.sw { display: grid; gap: 2px; padding: var(--s-3) 0; }
.sname { font-weight: 500; display: flex; align-items: baseline; gap: var(--s-2); }
.slang { font-size: var(--t-xs); color: var(--c-ink-3); font-weight: 400; }
.sdesc { font-size: var(--t-sm); color: var(--c-ink-2); }
.slinks { font-size: var(--t-sm); }

.foot {
  max-width: var(--content);
  display: flex; justify-content: space-between;
  padding: var(--s-5) 0 var(--s-7);
  border-top: 1px solid var(--c-line);
  font-size: var(--t-xs); color: var(--c-ink-3);
}
.foot-brand { display: inline-flex; align-items: center; gap: var(--s-2); }

/* Easter egg: the Schelling game below the footer */
.overscroll {
  position: fixed; left: 50%; bottom: var(--s-5); z-index: 20;
  display: grid; grid-template-columns: repeat(3, 6px); gap: 3px;
  transform: translateX(-50%); opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.overscroll i { width: 6px; height: 6px; border-radius: 1px; box-shadow: inset 0 0 0 1px var(--c-ink-3); transition: background-color 160ms var(--ease), box-shadow 160ms var(--ease); }
.overscroll i.on { background: var(--c-accent); box-shadow: none; }
/* The game: a full-screen overlay over the blurred page */
html.game-open { overflow: hidden; }
html.game-open body > :not(#play) { filter: blur(10px) saturate(0.8); pointer-events: none; user-select: none; }
body > :not(#play) { transition: filter 360ms var(--ease); }
.secret {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto; overscroll-behavior: contain;
  max-width: none; margin: 0; padding: var(--s-7) var(--s-5) var(--s-8); border-top: 0; overflow-x: hidden;
  background: color-mix(in srgb, var(--c-bg) 55%, transparent);
}
.secret[hidden] { display: none; }
.secret-inner { position: relative; max-width: 940px; margin: 0 auto; }
.secret h2 { padding-right: 120px; }
.secret-close { position: absolute; top: 0; right: 0; z-index: 1; display: inline-flex; gap: 8px; align-items: center;
  --arc-panel: #1d1d1a; --arc-ink: #f0efea; --arc-line: #2d2d29; --arc-accent: #e0a65a; --f-pixel: "Silkscreen", ui-monospace, monospace; }
.secret-close span { font-size: 14px; line-height: 1; }
.secret.enter { animation: pop-in 420ms var(--ease) both; }
.secret.enter .secret-inner { animation: enter 520ms var(--ease) both; }
@keyframes pop-in { from { background-color: transparent; } }
.secret.settling { overflow-y: hidden; }
/* Wide screens: board on the left, everything else in a column beside it,
   so the board, readouts and controls all fit on screen at once. */
@media (min-width: 1100px) {
  .secret-inner { max-width: 1320px; }
  .secret .arcade {
    display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: var(--s-5); align-content: start;
    grid-template-areas: "top top" "screen levels" "screen note" "screen hud" "screen chart" "screen legend" "screen panel" "screen .";
    grid-template-rows: auto auto auto auto auto auto auto 1fr;
  }
  .secret .arc-top { grid-area: top; }
  .secret .arc-levels { grid-area: levels; }
  .secret .game-note { grid-area: note; min-height: 0; }
  .secret .arc-hud { grid-area: hud; grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s-4); }
  .secret .arc-screen { grid-area: screen; align-self: start; }
  .secret .game-chart { grid-area: chart; margin-top: 0; height: 72px; }
  .secret .game-legend { grid-area: legend; }
  .secret .arc-panel { grid-area: panel; }
  .secret .gslider { max-width: none; flex: 1 1 120px; }
  .secret .arc-panel { column-gap: var(--s-4); }
  .secret .game-acts { margin-left: 0; flex-wrap: wrap; }
  .secret .secret-lede { max-width: 100ch; font-size: var(--t-sm); margin-bottom: var(--s-4); }
  .secret h2 { margin-bottom: var(--s-2); }
  .secret { padding-top: var(--s-5); }
  .secret .arc-hud { padding: var(--s-2) var(--s-3); }
}
@media (max-width: 600px) {
  .secret { padding: var(--s-5) var(--s-3) var(--s-7); }
  .secret h2 { padding-right: 96px; }
}
@media (prefers-reduced-motion: reduce) { body > :not(#play) { transition: none; } .secret.enter, .secret.enter .secret-inner { animation: none; } }
.secret-lede { color: var(--c-ink-2); max-width: 60ch; margin-bottom: var(--s-5); }
/* The cabinet: a dark screen in both themes, the site's colours and squares,
   a pixel face (Silkscreen) for everything that reads as the machine. */
@font-face { font-family: "Silkscreen"; font-weight: 400; font-display: swap; src: url(fonts/silkscreen-400.woff2) format("woff2"); }
@font-face { font-family: "Silkscreen"; font-weight: 700; font-display: swap; src: url(fonts/silkscreen-700.woff2) format("woff2"); }
.arcade {
  --arc-bg: #151513; --arc-panel: #1d1d1a; --arc-line: #2d2d29; --arc-ink: #f0efea; --arc-ink-2: #9a988f;
  --arc-accent: #e0a65a; --f-pixel: "Silkscreen", ui-monospace, monospace;
  position: relative; color: var(--arc-ink); background: var(--arc-bg);
  border-radius: 14px; padding: var(--s-4) var(--s-4) var(--s-5);
  box-shadow: 0 0 0 1px var(--arc-line), 0 24px 48px -24px rgb(0 0 0 / 0.45);
  font-family: var(--f-pixel); -webkit-font-smoothing: none;
}
.arc-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.arc-title { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--arc-ink); }
.arc-mark { width: 20px; height: 20px; }
.arc-hi { font-size: 10px; color: var(--arc-ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.arc-hi b { color: var(--arc-accent); font-weight: 400; }

/* Buttons: chunky keys with a little depth */
.abtn {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; cursor: pointer;
  font: 400 10px/1 var(--f-pixel); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--arc-ink); background: var(--arc-panel); border: 0; border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--arc-line), 0 3px 0 #0b0b0a;
  transition: transform 80ms ease, box-shadow 80ms ease, color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.abtn i { font-style: normal; color: var(--arc-ink-2); }
.abtn:hover { background: #262622; }
.abtn:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px var(--arc-line), 0 1px 0 #0b0b0a; }
.abtn[aria-pressed="true"] { color: var(--arc-accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--arc-accent) 60%, transparent), 0 3px 0 #0b0b0a; }
.abtn[aria-pressed="true"] i { color: var(--arc-accent); }
.abtn.big { height: 38px; padding: 0 22px; font-size: 12px; font-weight: 700; color: #1a1206; background: var(--arc-accent); box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.18), 0 4px 0 #7a4c12; }
.abtn.big:hover { background: #ebb36a; }
.abtn.big:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.18), 0 1px 0 #7a4c12; }
.abtn.big[aria-pressed="true"] { color: var(--arc-accent); background: var(--arc-panel); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--arc-accent) 60%, transparent), 0 4px 0 #0b0b0a; }
.abtn:focus-visible, .gslider input:focus-visible, .game-board:focus-visible { outline: 2px solid var(--arc-accent); outline-offset: 3px; }

.arc-levels { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--s-3); }
.arcade .game-note { font: 400 var(--t-xs)/1.5 var(--f-sans); -webkit-font-smoothing: antialiased; color: var(--arc-ink-2); min-height: 3em; margin: 0 0 var(--s-3); max-width: 64ch; }

/* HUD: the numbers that matter, big and pixel */
.arc-hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-3); padding: var(--s-3) var(--s-4); background: var(--arc-panel); border-radius: 8px; box-shadow: inset 0 0 0 1px var(--arc-line); }
.arc-hud div { display: grid; gap: 4px; min-width: 0; }
.arc-hud dt { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--arc-ink-2); }
.arc-hud dd { margin: 0; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--arc-ink); white-space: nowrap; }
.arc-hud div:nth-child(3) dd > span { color: var(--arc-accent); text-shadow: 0 0 12px color-mix(in srgb, var(--arc-accent) 55%, transparent); }
.arc-hud .game-groups { display: block; margin-top: 4px; font-size: 9px; color: var(--arc-ink-2); }

/* The screen: board, faint scanlines and a vignette */
.arc-screen { position: relative; border-radius: 8px; background: #0e0e0d; padding: var(--s-3); box-shadow: inset 0 0 0 1px var(--arc-line), inset 0 0 60px rgb(0 0 0 / 0.6); overflow: hidden; }
.arc-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 60%, rgb(0 0 0 / 0.35)); }
.game-board { display: block; margin: 0 auto; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.arc-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none;
  display: grid; justify-items: center; gap: 8px; padding: 14px 22px 12px; text-align: center;
  background: rgb(14 14 13 / 0.95); border-radius: 8px; max-width: calc(100% - 32px); box-shadow: 0 0 0 1px var(--arc-line), 0 0 40px rgb(0 0 0 / 0.6); }
.arc-banner[hidden] { display: none; }
.arc-banner b { white-space: nowrap; font-size: 22px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--arc-accent); text-shadow: 0 0 14px color-mix(in srgb, var(--arc-accent) 60%, transparent); }
.arc-banner span { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--arc-ink-2); }
.arc-banner.pop { animation: arc-pop 260ms steps(4) both; }
@keyframes arc-pop { from { transform: translate(-50%, -50%) scale(0.85); opacity: 0; } }
.arcade:not(.running) .arc-banner b { animation: arc-blink 1.1s steps(1) infinite; }
@keyframes arc-blink { 50% { opacity: 0.55; } }

/* Chart and legend */
.game-chart { display: block; width: 100%; height: 96px; margin-top: var(--s-3); }
.game-legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--arc-ink-2); margin: var(--s-2) 0 var(--s-4); }
.game-legend span::before { content: ""; display: inline-block; width: 14px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid var(--arc-accent); }
.game-legend .lg-content::before { border-top: 1.25px solid var(--arc-ink-2); }
.game-legend .lg-want::before { border-top: 1px dashed rgb(240 239 234 / 0.45); }
.game-legend .lg-base::before { border-top: 1px dotted rgb(240 239 234 / 0.55); }

/* Control panel */
.arc-panel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-4) var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--arc-line); }
.gslider { display: grid; gap: 8px; font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--arc-ink-2); flex: 1 1 160px; max-width: 210px; }
.gslider b { font-weight: 400; color: var(--arc-accent); font-variant-numeric: tabular-nums; }
.gslider input { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer; }
.gslider input::-webkit-slider-runnable-track { height: 6px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--arc-line) 0 6px, transparent 6px 8px); }
.gslider input::-moz-range-track { height: 6px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--arc-line) 0 6px, transparent 6px 8px); }
.gslider input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; margin-top: -6px; border-radius: 3px; background: var(--arc-accent); box-shadow: 0 2px 0 #7a4c12; }
.gslider input::-moz-range-thumb { width: 14px; height: 18px; border: 0; border-radius: 3px; background: var(--arc-accent); box-shadow: 0 2px 0 #7a4c12; }
.game-acts { display: flex; align-items: center; gap: 8px; margin-left: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .arcade { --arc-bg: #1b1b19; --arc-panel: #232320; } }
:root[data-theme="dark"] .arcade { --arc-bg: #1b1b19; --arc-panel: #232320; }
@media (max-width: 600px) { .arc-levels { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--s-3)); padding: 0 var(--s-3) 6px; } .arc-levels::-webkit-scrollbar { display: none; } .arc-levels .abtn { flex: none; } .arc-banner b { font-size: 17px; } }
@media (prefers-reduced-motion: reduce) { .arc-banner.pop, .arcade:not(.running) .arc-banner b { animation: none; } }
@media (max-width: 600px) {
  .arcade { padding: var(--s-3) var(--s-3) var(--s-4); border-radius: 12px; margin: 0 calc(-1 * var(--s-2)); }
  .arc-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arc-hud dd { font-size: 18px; }
  .arc-screen { padding: var(--s-2); }
  .game-acts { margin-left: 0; flex-wrap: wrap; }
  .gslider { max-width: none; }
  .arc-hi { display: none; }
}
.game-result { min-height: 3.2em; font-size: var(--t-sm); color: var(--c-ink-2); margin: 0 0 var(--s-4); max-width: 62ch; }
.game-info { border-top: 1px solid var(--c-line); padding-top: var(--s-3); font-size: var(--t-sm); color: var(--c-ink-2); }
.game-info summary { cursor: pointer; color: var(--c-ink); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.game-info summary::-webkit-details-marker { display: none; }
.game-info summary::before { content: "+"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--c-line); font-size: 12px; color: var(--c-ink-3); }
.game-info[open] summary::before { content: "−"; }
.game-info > div { max-width: 62ch; padding-top: var(--s-3); }
.game-info p { margin-bottom: var(--s-3); }
.game-info b { font-weight: 500; color: var(--c-ink); }
.game-info .refs { font-size: var(--t-xs); color: var(--c-ink-3); }

/* 404 */
.nf { max-width: 520px; margin: 0 auto; padding: 18vh var(--s-5) var(--s-8); }
.nf-mark { width: 40px; height: 40px; margin-bottom: var(--s-6); }
.nf h1 { font: 400 var(--t-xl)/var(--lh-tight) var(--f-serif); letter-spacing: -0.01em; margin-bottom: var(--s-4); }
.nf p { color: var(--c-ink-2); margin-bottom: var(--s-3); }

/* Shown above Working papers while a filter is on */
.filter-note { font-size: var(--t-sm); color: var(--c-ink-3); margin: calc(-1 * var(--s-2)) 0 var(--s-4); }
.filter-note button { border: 0; background: none; padding: 0; font: inherit; color: var(--c-ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--c-line); }
.filter-note button:hover { color: var(--c-accent-ink); }

/* Dark mode: keep the photo from being the brightest thing on the page */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .portrait { filter: brightness(0.88); } }
:root[data-theme="dark"] .portrait { filter: brightness(0.88); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .hero-text, .paper.enter { animation: none; }
}

/* ==========================================================================
   Narrow screens: sidebar becomes a top bar
   ========================================================================== */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; z-index: 10; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: var(--s-3) var(--s-4);
    padding: var(--s-3) var(--s-4);
    background: color-mix(in srgb, var(--c-bg) 97%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--c-line);
  }
  .side-links { margin: 0 0 0 auto; flex-direction: row; gap: var(--s-4); }
  .ilink { font-size: 0; gap: 0; }
  .ilink svg { width: 16px; height: 16px; }
  .nav {
    order: 3; flex-basis: 100%; min-width: 0;
    flex-direction: row; gap: var(--s-5);
    overflow-x: auto; scrollbar-width: none;
    margin: 0 calc(-1 * var(--s-4)); padding: 0 var(--s-4);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
  .nav a::before { display: none; }
  .nav a.active { box-shadow: inset 0 -1.5px 0 var(--c-accent); }
  .main { padding: 0 var(--s-4); }
  .hero { height: 320px; padding-bottom: var(--s-6); }
  .society { inset: 0 calc(-1 * var(--s-4)); width: calc(100% + 2 * var(--s-4)); }
}
@media (max-width: 600px) {
  .about { grid-template-columns: 1fr 88px; gap: var(--s-4); }
  .about .portrait { width: 88px; }
  .rows > div, .sw { grid-template-columns: 1fr; gap: 2px; }
  .sname { grid-row: auto; }
  .cols { grid-template-columns: 1fr; }
  .paper { grid-template-columns: 1fr; gap: 2px; }
  .pyear { flex-direction: row; align-items: center; gap: var(--s-2); }
  .filtering .paper:not(.year-start) .y { display: none; }
  .block-head h2 { flex-basis: 100%; }
  .block-head .filter { flex: 1; }
  .filter input { width: 100%; }
  .topic-bar {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-left: calc(-1 * var(--s-4)); margin-right: calc(-1 * var(--s-4));
    padding: 0 var(--s-4);
  }
  .topic-bar::-webkit-scrollbar { display: none; }
  .topic-bar .pill { flex: none; }
}
