/* Inside the Network: shared design tokens and components.
   Layout: a ~66ch reading column, with figures breaking out onto a wide bench.
   Blue/orange carry sign and class everywhere; --loss is the one sequential hue for loss maps (deeper = lower). */
:root {
  --paper: #f3f4f6;
  --sheet: #ffffff;
  --well: #f5f6f8;
  --ink: #14171c;
  --ink-2: #4a515e;
  --ink-3: #656d7b;
  --rule: #dcdfe5;
  --pos: #2a78d6;
  --neg: #eb6834;
  --loss: #5b3fc4;
  --shadow: rgba(20, 23, 28, 0.06);
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1014; --sheet: #15181e; --well: #1b1f26; --ink: #e8eaee; --ink-2: #b0b6c1; --ink-3: #8b929e;
    --rule: #2a2f38; --pos: #3987e5; --neg: #d95926; --loss: #9b84f2; --shadow: rgba(0, 0, 0, 0.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1014; --sheet: #15181e; --well: #1b1f26; --ink: #e8eaee; --ink-2: #b0b6c1; --ink-3: #8b929e;
  --rule: #2a2f38; --pos: #3987e5; --neg: #d95926; --loss: #9b84f2; --shadow: rgba(0, 0, 0, 0.35); color-scheme: dark;
}


/* base: page, type, controls */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 18px; line-height: 1.6; }
.page { padding-block: 28px 72px; padding-inline: 20px; }
.col { max-width: 680px; margin-inline: auto; }
.bench { max-width: 1180px; margin: 36px auto; }
@media (max-width: 520px) { .page { padding-inline: 16px; padding-block: 20px 56px; } body { font-size: 17px; } }
.crumbs { max-width: 680px; margin: 0 auto 28px; font: 14px/1.4 var(--font-display); color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); text-underline-offset: 3px; }
.eyebrow { font: 600 12px/1 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
h1 { font-family: var(--font-display); font-weight: 650; font-size: clamp(38px, 6vw, 60px); line-height: 1.02; letter-spacing: -0.025em; margin: 14px 0 18px; text-wrap: balance; }
.dek { font-size: 22px; line-height: 1.42; color: var(--ink-2); margin: 0 0 8px; text-wrap: pretty; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 1.2; letter-spacing: -0.01em; margin: 48px 0 12px; text-wrap: balance; }
.intro h2:first-child { margin-top: 28px; }
p { margin: 0 0 14px; }
b, strong { font-weight: 600; }
a { color: var(--ink); text-underline-offset: 3px; }
kbd { font: 500 0.82em var(--font-display); padding: 1px 6px; border: 1px solid var(--rule); border-radius: 5px; background: var(--sheet); }
code.i { font: 0.84em var(--font-mono); background: var(--sheet); border: 1px solid var(--rule); border-radius: 5px; padding: 0 5px; white-space: nowrap; }
.jump { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 20px 0 4px; }
.jump-note { font: 15px/1.4 var(--font-body); color: var(--ink-3); }
.jump-pill { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 10; font: 600 14px/1 var(--font-display); background: var(--ink); color: var(--sheet); padding: 12px 16px; border-radius: 99px; text-decoration: none; box-shadow: 0 4px 18px var(--shadow); }
#playground, #film { scroll-margin-top: 16px; }
.lab { font: 600 11px/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: 560 14px/1 var(--font-display); padding: 10px 14px; border-radius: 9px; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--sheet); min-width: 96px; justify-content: center; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--well); border: 1px solid var(--rule); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { font: 520 13px/1 var(--font-display); border: 0; background: transparent; color: var(--ink-2); padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--rule), 0 1px 2px var(--shadow); }
.tog { display: inline-flex; align-items: center; gap: 7px; font: 13px/1.2 var(--font-display); color: var(--ink-2); cursor: pointer; }
.tog input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }
input[type="range"] { accent-color: var(--ink); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible, summary:focus-visible, .chips button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* figures inside the reading column */
.card { margin: 18px 0 22px; padding: 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.card .cap { font: 15.5px/1.45 var(--font-body); color: var(--ink-2); margin: 10px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { font: 600 10.5px/1 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); background: transparent; border: 1px solid var(--rule); border-radius: 99px; padding: 6px 8px; cursor: pointer; }
.chips button.on { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.lab .nc { text-transform: none; letter-spacing: 0; font-size: 13px; }
select { font: 500 13px/1.2 var(--font-mono); padding: 8px 8px; border-radius: 8px; border: 1px solid var(--rule); background: var(--well); color: var(--ink); }

/* math notes */
details.math { margin: 4px 0 18px; }
summary { cursor: pointer; font: 560 15px/1.4 var(--font-display); color: var(--ink); }
.eqs { margin-top: 10px; border-top: 1px solid var(--rule); }
.eq-row { display: grid; grid-template-columns: minmax(14em, auto) 1fr; gap: 4px 20px; padding: 7px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.eq-row code { font: 14px/1.5 var(--font-mono); color: var(--ink); white-space: nowrap; }
.eq-row span { font-size: 16px; color: var(--ink-2); line-height: 1.4; }
@media (max-width: 600px) { .eq-row { grid-template-columns: minmax(0, 1fr); } .eq-row code { white-space: normal; } }

/* film */
.film { margin: 18px 0 22px; padding: 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.film-stage { position: relative; }
.film-ticker { font: 500 13px/1.5 var(--font-mono); color: var(--ink); background: var(--well); border-radius: 8px; padding: 8px 12px; margin-top: 8px; min-height: 1.5em; overflow-x: auto; white-space: pre; font-variant-numeric: tabular-nums; }
.film-over { position: absolute; inset: 0; background: var(--sheet); display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 8px 4px; }
.over-title { font: 600 12px/1.3 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.film-progress { height: 3px; background: var(--rule); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.film-progress i { display: block; height: 100%; width: 0; background: var(--ink); }
.film-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 12px; }
.film-cap { font: 17px/1.5 var(--font-body); color: var(--ink-2); margin: 12px 0 0; min-height: 4.5em; }
.film-cap b { color: var(--ink); }

/* numbered steps, algorithm blocks, the Words · Math · Code switch */
ol.seq { list-style: none; counter-reset: seq; padding: 0; margin: 4px 0 18px; }
ol.seq > li { counter-increment: seq; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0 10px; margin-bottom: 10px; }
ol.seq > li::before { content: counter(seq); width: 22px; height: 22px; margin-top: 4px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--sheet); font: 500 12px/1 var(--font-mono); }
/* annotated code */
.annot { display: grid; gap: 0; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--sheet); margin: 8px 0 20px; }
.ablock { display: grid; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--rule); min-width: 0; }
.ablock:first-child { border-top: 0; }
.atitle { font: 600 15px/1.3 var(--font-display); color: var(--ink); display: flex; gap: 10px; align-items: baseline; }
.atitle .n { font: 500 12px var(--font-mono); color: var(--ink-3); }
/* one idea, three ways to say it */
.lens { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 14px 0 8px; }
.ctl .lens { margin: 0; }
.rep { min-width: 0; }
.rep-lab { display: none; font: 600 10.5px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.show-all .rep-lab { display: block; }
.rep.words p { font: 16.5px/1.5 var(--font-body); color: var(--ink-2); margin: 0; }
.rep.words p b { color: var(--ink); }
.rep.math .mb { font: 17px/1.8 var(--font-body); color: var(--ink); background: var(--well); border-radius: 8px; padding: 9px 12px; overflow-x: auto; font-variant-numeric: tabular-nums; }
.rep.math .mb span { display: block; white-space: nowrap; }
.rep.math i { font-style: italic; }
.rep.code pre { margin: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font: 12.5px/1.6 var(--font-mono); color: var(--ink); font-variant-ligatures: none; }
.explain .rep + .rep { margin-top: 12px; }

/* playground */
.fig { background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; padding: 18px 20px 20px; box-shadow: 0 1px 2px var(--shadow), 0 10px 30px var(--shadow); }
@media (max-width: 520px) { .fig { padding: 14px 12px 16px; border-radius: 12px; } }
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.ctl { display: flex; flex-direction: column; gap: 7px; }
.slider-row { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; flex-wrap: wrap; }
.slider-row label { font: 14px/1.3 var(--font-display); color: var(--ink-2); }
.slider-row input { flex: 1 1 160px; min-width: 0; }

/* reading guide, roadmap, chapter links, footer */
dl.read { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px 20px; margin: 0; }
dl.read dt { font: 600 14px/1.6 var(--font-display); color: var(--ink); padding-top: 2px; }
dl.read dd { margin: 0; }
@media (max-width: 520px) { dl.read { grid-template-columns: minmax(0, 1fr); gap: 2px; } dl.read dd { margin-bottom: 10px; } }
ul.tries { padding-left: 1.1em; margin: 0; }
ul.tries li { margin-bottom: 10px; padding-left: 4px; }
ol.road { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
ol.road li { display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule); font: 16px/1.35 var(--font-display); color: var(--ink-2); }
ol.road .n { font: 500 13px var(--font-mono); color: var(--ink-3); }
ol.road .tag { font: 600 10.5px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 99px; padding: 5px 8px; }
ol.road li.here { color: var(--ink); font-weight: 600; }
ol.road li.here .tag { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
ol.road li.branch { padding-left: 1.2em; }
ol.road a { color: inherit; }
.chapnav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 20px; margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--rule); font: 15px/1.4 var(--font-display); color: var(--ink-3); }
.chapnav a { color: var(--ink); }
.foot { margin-top: 18px; font: 14px/1.5 var(--font-display); color: var(--ink-3); }
.foot a { color: var(--ink-2); }

/* code fonts */
pre, code, .mono { font-variant-ligatures: none; }

/* hover and focus descriptions */
.tt { position: fixed; left: 0; top: 0; z-index: 30; max-width: min(300px, calc(100vw - 24px)); background: var(--ink); color: var(--sheet); font: 13px/1.45 var(--font-display); padding: 8px 11px; border-radius: 8px; box-shadow: 0 6px 22px var(--shadow); pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity 0.12s ease, transform 0.12s ease; }
.tt.on { opacity: 1; transform: none; }
.tt b { font-weight: 650; }
.tt .k { font-family: var(--font-mono); font-size: 12px; }
.tt .hint { display: block; margin-top: 4px; font-size: 12px; opacity: 0.72; }
@media (prefers-reduced-motion: reduce) { .tt { transition: none; } }

/* switch boxes */
[data-reps] > .rep + .rep { margin-top: 12px; }
