/* Computer Graphics: Past to Present — shared chapter styles.
   Every chapter page links this file plus book.js. Visual language matches
   docs/3dgs_training.html (warm paper / ember accent, Fraunces + Hanken Grotesk). */

:root {
  --bg:      #efe9dd;  --bg2: #e7dfd1;  --surface: #faf6ee;
  --ink:     #241f18;  --muted: #6c6252; --faint: #8f8674;
  --line:    rgba(40,30,16,0.14);  --line2: rgba(40,30,16,0.08);
  --accent:  #c9791b;  --accent-ink: #a8620f;  --accent-soft: rgba(201,121,27,0.13);
  --glow:    rgba(201,121,27,0.20);
  --c-red: #d0503f;  --c-green: #3f9a4f;  --c-blue: #3c6fd0;
  --c-a: #d98a2b;  --c-b: #c25a6b;  --c-c: #2f8f86;
  --code-bg: #211a12;  --code-ink: #ece3d2;  --code-c: #9a8f78;  --code-kw: #e8a13c; --code-str:#8fb98f; --code-num:#d99a8a;
  --eq-bg:   #f6efe2;
  --screen:  #0d0b08;
  --shadow:  0 1px 2px rgba(40,30,16,.06), 0 8px 30px rgba(40,30,16,.08);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14110d; --bg2: #1a160f; --surface: #211b14;
  --ink: #f2ebdf; --muted: #a99f8e; --faint: #857c6c;
  --line: rgba(242,235,223,0.13); --line2: rgba(242,235,223,0.06);
  --accent: #e8a13c; --accent-ink: #f0b968; --accent-soft: rgba(232,161,60,0.14);
  --glow: rgba(232,161,60,0.28);
  --c-red: #e8735f; --c-green: #6cc27a; --c-blue: #6f9cf0;
  --c-a: #e8a13c; --c-b: #e27e90; --c-c: #57beb2;
  --code-bg: #0d0b08; --code-ink: #ece3d2; --code-c: #7c7362; --code-kw: #e8a13c; --code-str:#7cae7c; --code-num:#e0a493;
  --eq-bg: #1b1710;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  font-size: 18px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
.wrap { max-width: 730px; margin: 0 auto; padding: 0 24px; }
.wide { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
p { margin: 0 0 1.1em; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
strong { font-weight: 700; color: var(--ink); }
h1,h2,h3,h4 { font-family: "Fraunces", Georgia, serif; text-wrap: balance; line-height: 1.1; margin: 0; }

/* ── top bar + chapter drawer ─────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line2); }
.topbar .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.brand b { color: var(--ink); font-weight: 600; }
.toggle, .menu-btn { font: inherit; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  cursor: pointer; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.menu-btn { padding: 7px 10px; }
.menu-btn svg { display: block; }
.toggle:hover, .menu-btn:hover { border-color: var(--accent); }
.toggle:focus-visible, .menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.drawer-scrim { position: fixed; inset: 0; background: rgba(10,8,5,.45); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(380px, 88vw); z-index: 100; background: var(--surface);
  border-right: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(-102%); transition: transform .24s ease;
  display: flex; flex-direction: column; }
body.nav-open .drawer { transform: none; }
body.nav-open .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--line2); }
.drawer-head a { font-family: "Fraunces", serif; font-size: 1.1rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.drawer-close { font: inherit; font-size: 20px; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.drawer nav { overflow-y: auto; padding: 8px 0 30px; }
.drawer .part { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-ink);
  padding: 16px 20px 6px; }
.drawer a.ch, .drawer span.ch { display: grid; grid-template-columns: 28px 1fr; gap: 6px; padding: 6px 20px; font-size: 15px; line-height: 1.35;
  color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.drawer a.ch:hover { background: var(--accent-soft); }
.drawer a.ch.current { border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.drawer span.ch { color: var(--faint); cursor: default; }
.drawer .ch .num { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--faint); padding-top: 2px; }
.drawer .soon { font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 6px; white-space: nowrap; }

/* ── hero ──────────────────────────────────────────────────────────────── */
.hero { padding: 56px 0 30px; position: relative; overflow: hidden; }
.hero::before { content:""; position:absolute; inset:-30% 0 auto 0; height: 560px;
  background: radial-gradient(60% 100% at 72% 0%, var(--glow), transparent 70%); pointer-events:none; z-index:-1; }
.eyebrow { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 18px; }
h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 600; font-optical-sizing: auto; letter-spacing: -0.02em; margin-bottom: 20px; }
h1 em { font-style: italic; color: var(--accent-ink); font-weight: 500; }
.byline { font-size: 1.05rem; color: var(--muted); margin: -8px 0 0; }
.byline b { color: var(--ink); font-weight: 600; }
.standfirst { font-size: clamp(1.1rem, 2.3vw, 1.36rem); color: var(--muted); max-width: 46ch; }
.standfirst b { color: var(--ink); font-weight: 600; }

figure { margin: 0; }
.stage { margin: 34px 0 8px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--screen); box-shadow: var(--shadow); position: relative; }
.stage canvas { display: block; width: 100%; height: auto; }
.stage-hud { position: absolute; left: 14px; top: 12px; font-family: "IBM Plex Mono", monospace; font-size: 12px; color: #f2ebdf;
  text-shadow: 0 1px 4px rgba(0,0,0,.8); display: flex; gap: 18px; align-items: baseline; pointer-events: none; }
.stage-hud b { color: #f0b968; font-weight: 500; font-variant-numeric: tabular-nums; }
.stage-controls { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stage-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 10px 12px; background: #15120d; border-top: 1px solid rgba(255,255,255,.07); }
.stage-btn { font: inherit; font-size: 12.5px; padding: 6px 12px; cursor: pointer; color: #14110d; background: #e8a13c; border: 0; border-radius: 999px; font-weight: 600; }
.stage-btn.ghost { background: rgba(255,255,255,.14); color: #f2ebdf; backdrop-filter: blur(4px); }
.stage-btn[aria-pressed="true"] { background: #e8a13c; color: #14110d; }
.stage-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
figcaption { font-size: 14px; color: var(--faint); margin-top: 12px; font-style: italic; }
figcaption b { font-style: normal; font-weight: 600; color: var(--muted); }

/* ── sections ──────────────────────────────────────────────────────────── */
section { padding: 22px 0; }
.section-head { margin: 36px 0 6px; }
.kicker { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 12px; display: block; }
h2 { font-size: clamp(1.75rem, 3.8vw, 2.5rem); font-weight: 500; letter-spacing: -0.015em; }
h3 { font-size: 1.4rem; font-weight: 600; margin: 34px 0 6px; letter-spacing: -0.01em; }
h4 { font-size: 1.06rem; margin: 26px 0 4px; font-weight: 600; letter-spacing: -0.01em; }
.lede { font-size: 1.2rem; color: var(--muted); margin-top: 12px; }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 50px auto; max-width: 730px; }
.part-tab { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent-ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; display: inline-block; margin-bottom: 18px; }
.prose ol, .prose ul { margin: 0 0 1.1em; padding-left: 1.35em; }
.prose li { margin: 0 0 .5em; }

code { font-family: "IBM Plex Mono", monospace; font-size: 0.85em; background: var(--accent-soft); color: var(--accent-ink); padding: 1px 6px; border-radius: 5px; }
.mono { font-family: "IBM Plex Mono", monospace; font-size: .82em; }

/* "the idea in plain words" panel — this book's stand-in for equations */
.math { background: var(--eq-bg); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 18px 20px; margin: 22px 0; }
.math .tag { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); display: block; margin-bottom: 10px; }
.math p:last-child { margin-bottom: 0; }
.eqline { font-family: "IBM Plex Mono", monospace; font-size: 1.02rem; text-align: center; margin: 12px 0; line-height: 1.6; overflow-x: auto; color: var(--ink); }
.eqline .op { color: var(--accent-ink); padding: 0 .15em; }
.where { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; color: var(--muted); }
.where li { display: grid; grid-template-columns: minmax(64px, auto) 1fr; gap: 12px; align-items: baseline; }
.where .sym { font-family: "IBM Plex Mono", monospace; color: var(--ink); font-size: .92rem; text-align: right; }

/* code panels: write <div class="code" data-file="gfx.js"><pre><code>…</code></pre></div>;
   book.js highlights the contents. */
.code { background: var(--code-bg); border-radius: 10px; margin: 22px 0; overflow: hidden; box-shadow: var(--shadow); }
.code .filelabel { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .06em; color: var(--code-c);
  padding: 9px 16px; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; justify-content: space-between; }
.code .filelabel .lang { color: var(--code-kw); }
.code pre { margin: 0; padding: 16px; overflow-x: auto; max-height: 620px; }
.code code, .playground code { background: none; color: var(--code-ink); padding: 0; font-size: 13px; line-height: 1.6; }
.tok-c { color: var(--code-c); font-style: italic; }
.tok-k { color: var(--code-kw); }
.tok-s { color: var(--code-str); }
.tok-n { color: var(--code-num); }
.tok-t { color: #8fb3d9; }

.aside { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; margin: 24px 0; box-shadow: var(--shadow); }
.aside .tag { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); display: block; margin-bottom: 8px; }
.aside p:last-child { margin-bottom: 0; }
.note { border-left: 2px solid var(--accent); padding: 2px 0 2px 16px; color: var(--muted); margin: 20px 0; font-size: .98em; }

/* numbered steps */
.step { display: grid; grid-template-columns: 58px 1fr; gap: 20px; margin: 30px 0; align-items: start; }
.step-num { font-family: "Fraunces", serif; font-size: 2.2rem; font-weight: 500; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; border-top: 2px solid var(--accent); padding-top: 8px; }
.step h3 { margin: 2px 0 6px; }
.step p:last-child { margin-bottom: 0; }

/* card strip */
.pipe { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 24px 0; }
.pipe.four { grid-template-columns: repeat(4,1fr); }
.pipe .card { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 15px; }
.pipe .card .n { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--accent-ink); letter-spacing: .1em; }
.pipe .card h4 { font-weight: 600; font-size: 1.02rem; margin: 5px 0; }
.pipe .card p { margin: 0; font-size: .86em; color: var(--muted); }

/* data table */
.table-wrap { overflow-x: auto; margin: 22px 0; }
table.data { border-collapse: collapse; width: 100%; font-size: .92em; }
table.data th { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink);
  text-align: left; font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
table.data td.num { font-family: "IBM Plex Mono", monospace; font-size: .9em; text-align: right; white-space: nowrap; }

/* svg diagrams */
.diagram { margin: 24px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram text { font-family: "IBM Plex Mono", monospace; fill: var(--muted); font-size: 12px; }
.diagram .ink { fill: var(--ink); }
.diagram .acc { fill: var(--accent-ink); }
.diagram .s-ink { stroke: var(--ink); fill: none; }
.diagram .s-acc { stroke: var(--accent); fill: none; }
.diagram .s-line { stroke: var(--line); fill: none; }
.diagram .f-surf { fill: var(--bg2); }
.diagram .f-acc { fill: var(--accent-soft); }

/* ── interactive demos ─────────────────────────────────────────────────── */
.demo { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 24px 0; box-shadow: var(--shadow); }
.demo .dhead { font-family:"IBM Plex Mono",monospace; font-size:11px; letter-spacing:.14em; text-transform:uppercase; color:var(--accent-ink); margin-bottom:12px; display:flex; align-items:center; gap:8px; }
.demo .dhead::before { content:"▶"; font-size:9px; }
.panels { display:flex; gap:12px; flex-wrap:wrap; }
.panel { flex:1 1 0; min-width:180px; display:flex; flex-direction:column; gap:6px; }
.panel .plabel { font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--faint); letter-spacing:.02em; }
.panel .plabel b { color:var(--accent-ink); font-weight:500; }
.demo canvas { width:100%; height:auto; display:block; border-radius:7px; border:1px solid var(--line); background:var(--screen); touch-action: none; }
.controls { display:flex; align-items:center; gap:10px 16px; flex-wrap:wrap; margin-top:14px; font-size:13px; color:var(--muted); }
.controls label { display:flex; align-items:center; gap:9px; }
.controls .cval { font-family:"IBM Plex Mono",monospace; color:var(--ink); min-width:44px; font-size:12.5px; }
.controls .readout { font-family:"IBM Plex Mono",monospace; font-size:12.5px; color:var(--ink); }
.controls .readout b { color: var(--accent-ink); font-weight: 500; }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:999px; overflow:hidden; flex-wrap: wrap; }
.seg button, .btn { font: inherit; font-size: 12.5px; padding: 5px 12px; cursor: pointer; background: var(--bg); color: var(--ink); border: 0; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #14110d; font-weight: 600; }
.btn { border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.btn:hover, .seg button:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #14110d; border-color: var(--accent); font-weight: 600; }
.btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range] { -webkit-appearance:none; appearance:none; height:4px; border-radius:2px; background:var(--line); outline:none; width:150px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; width:16px; height:16px; border-radius:50%; background:var(--accent); cursor:pointer; border:2px solid var(--surface); }
input[type=range]::-moz-range-thumb { width:16px; height:16px; border-radius:50%; background:var(--accent); cursor:pointer; border:2px solid var(--surface); }
input[type=range]:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.demo figcaption { margin-top:12px; }

/* ── live-code playground ──────────────────────────────────────────────── */
.playground { background: var(--code-bg); border-radius: 12px; margin: 24px 0; overflow: hidden; box-shadow: var(--shadow); }
/* playgrounds break out of the 730px prose column so the editor has room */
.wrap .playground { width: min(1040px, calc(100vw - 32px)); margin-left: calc(50% - min(520px, 50vw - 16px)); }
.playground .pg-head { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .06em; color: var(--code-c);
  padding: 9px 12px 9px 16px; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.playground .pg-head .lang { color: var(--code-kw); }
.playground .pg-btns { display: flex; gap: 6px; align-items: center; }
.playground .pg-status { font-size: 11px; color: #8fb98f; margin-right: 6px; white-space: nowrap; }
.playground .pg-status.err { color: #f08a7a; }
.playground .pg-btns button { font: inherit; font-size: 11.5px; padding: 4px 11px; cursor: pointer; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: transparent; color: var(--code-ink); }
.playground .pg-btns button.run { background: #e8a13c; color: #14110d; border-color: #e8a13c; font-weight: 600; }
.playground .pg-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.playground .pg-editor { position: relative; min-height: 220px; border-right: 1px solid rgba(255,255,255,.07); }
.playground .pg-editor pre, .playground .pg-editor textarea {
  margin: 0; padding: 14px 16px; font-family: "IBM Plex Mono", monospace; font-size: 13px; line-height: 1.6; tab-size: 2;
  white-space: pre; overflow: auto; position: absolute; inset: 0; border: 0; letter-spacing: 0; }
.playground .pg-editor pre { pointer-events: none; color: var(--code-ink); }
.playground .pg-editor textarea { background: transparent; color: transparent; caret-color: #f0b968; resize: none; outline: none; }
.playground .pg-editor textarea::selection { background: rgba(232,161,60,.3); color: transparent; }
.playground .pg-out { display: flex; flex-direction: column; background: #0a0806; }
.playground .pg-out canvas { width: 100%; height: auto; display: block; background: #fff; image-rendering: auto; }
.playground .pg-out canvas.pixelated { image-rendering: pixelated; }
.playground .pg-log { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--code-c); padding: 8px 12px; min-height: 30px; white-space: pre-wrap; }
.playground .pg-log.err { color: #f08a7a; }
@media (max-width: 760px) {
  .playground .pg-body { grid-template-columns: 1fr; }
  .playground .pg-editor { min-height: 300px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.07); }
}

/* exercises */
.exercises { counter-reset: ex; list-style: none; padding: 0; margin: 20px 0; display: flex; flex-direction: column; gap: 14px; }
.exercises > li { display: grid; grid-template-columns: 30px 1fr; gap: 14px; }
.exercises > li::before { counter-increment: ex; content: counter(ex); font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--accent-ink);
  border: 1px solid var(--line); border-radius: 7px; width: 28px; height: 28px; display: grid; place-items: center; }
.exercises details { margin-top: 6px; font-size: .95em; color: var(--muted); }
.exercises summary { cursor: pointer; color: var(--accent-ink); font-size: .92em; }

/* prev / next */
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 50px 0 0; }
.chapter-nav > a, .chapter-nav > span { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--ink); }
.chapter-nav > a:hover { border-color: var(--accent); }
.chapter-nav .dir { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); display: block; margin-bottom: 4px; }
.chapter-nav .t { font-family: "Fraunces", serif; font-size: 1.05rem; font-weight: 600; }
.chapter-nav .next { text-align: right; grid-column: 2; }
.chapter-nav > span { color: var(--faint); }

/* cover page table of contents */
.toc-part { margin: 34px 0 10px; }
.toc-part h3 { margin: 4px 0 4px; }
.toc-part p { color: var(--muted); font-size: .96em; margin: 0 0 10px; }
.toc-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line2); }
.toc-list li { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line2); align-items: baseline; }
.toc-list .num { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--faint); }
.toc-list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.toc-list a:hover { color: var(--accent-ink); }
.toc-list .t { font-weight: 600; color: var(--faint); }
.toc-list .sub { display: block; font-size: .88em; color: var(--muted); font-weight: 400; }
.toc-list .status { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.toc-list .status.ready { color: var(--accent-ink); }

footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 38px 0 68px; color: var(--faint); font-size: 14px; }
footer p { margin: 0 0 6px; }
footer a { color: var(--accent-ink); }
footer .contact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
footer .contact a {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); text-decoration: none; transition: color 0.15s, border-color 0.15s;
}
footer .contact a:hover { color: var(--accent-ink); border-color: var(--accent); }
footer .contact svg { width: 15px; height: 15px; fill: currentColor; flex: none; }

@media (max-width: 720px) {
  body { font-size: 17px; }
  .pipe, .pipe.four { grid-template-columns: 1fr; }
  .step { grid-template-columns: 42px 1fr; gap: 14px; }
  .step-num { font-size: 1.8rem; }
  .stage-hud { font-size: 11px; gap: 11px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav .next { grid-column: 1; }
  .topbar { padding: 9px 14px; }
}

/* ── "source" links on figures, and the source viewer ──────────────────── */
.demo .dhead .srcbtn { margin-left: auto; font: inherit; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--accent-ink); }
.demo .dhead .srcbtn:hover { border-color: var(--accent); }
.demo .dhead .srcbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
dialog.srcdlg { width: min(1040px, calc(100vw - 32px)); max-height: 88vh; padding: 0; border: 0; border-radius: 12px; overflow: auto;
  background: var(--code-bg); color: var(--code-ink); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
dialog.srcdlg::backdrop { background: rgba(12,9,6,.62); }
.srcdlg .srchead { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--code-bg); border-bottom: 1px solid rgba(255,255,255,.08); font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--code-kw); }
.srcdlg button { font: inherit; font-family: "IBM Plex Mono", monospace; font-size: 11px; text-transform: none; letter-spacing: 0; cursor: pointer;
  background: transparent; color: var(--code-ink); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 3px 10px; }
.srcdlg .srcpart { border-bottom: 1px solid rgba(255,255,255,.06); }
.srcdlg .srclabel { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px 0;
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .04em; color: var(--code-c); }
.srcdlg .srclabel .lang { color: var(--code-kw); margin-right: 8px; }
.srcdlg pre { margin: 0; padding: 10px 16px 16px; overflow-x: auto; font-family: "IBM Plex Mono", monospace; font-size: 12.5px; line-height: 1.55; tab-size: 2; }
.srcdlg code { background: none; color: var(--code-ink); padding: 0; font-size: 12.5px; line-height: 1.55; }
.srcdlg .srcnotes { padding: 12px 16px 16px; font-size: 13px; color: var(--code-c); line-height: 1.6; }
.srcdlg .srcnotes a { color: var(--code-kw); }
.srcdlg .srcnotes code { font-size: 12px; color: var(--code-ink); }
.srcdlg .srclabel button { margin-left: 6px; }
