/* Debug Foundry — visual system distilled from knots-made-easy.pages.dev.
   Warm neutral stage, one accent, fluid type, tabular numbers, quiet chrome. */

:root {
  --ink: #1c2028;
  --muted: #5b6270;
  --paper: #f6f6f3;
  --stage: #ece7de;
  --panel: #fffdf9d1;
  --line: #1c202824;
  --accent: #2f5fb3;            /* one accent, used sparingly */
  --accent-soft: #2f5fb329;
  --radius: 14px;
  --shadow: 0 12px 32px -16px #23201c59;
  --shadow-soft: 0 1px 2px #23201c0f, 0 6px 18px -8px #23201c38;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  --ink: #eceef2;
  --muted: #9ba2ae;
  --paper: #14171c;
  --line: #eceef224;
  --accent: #8fb0ee;
  --accent-soft: #8fb0ee29;
  --card: #1e232b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.icon { fill: none; stroke: currentColor; stroke-width: 1.8px; stroke-linecap: round; stroke-linejoin: round; width: 20px; height: 20px; }

/* Header: wordmark and theme toggle only. Nothing else earns the chrome. */
.site-head { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; padding-block: 22px; font-size: 14px; }
.mark { font-weight: 650; letter-spacing: -0.01em; }
.theme-toggle { position: relative; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: none; overflow: hidden; transition: border-color .15s; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .sun, .theme-toggle .moon { position: absolute; inset: 0; margin: auto; transition: transform 1.1s cubic-bezier(.34,1.2,.64,1), opacity .7s; }
.theme-toggle .sun { color: #e0a21b; }
.theme-toggle .moon { opacity: 0; transform: translateY(150%) rotate(-60deg); }
html[data-theme="dark"] .theme-toggle .sun { opacity: 0; transform: translateY(150%) rotate(90deg); }
html[data-theme="dark"] .theme-toggle .moon { opacity: 1; transform: none; }

.page { max-width: 1200px; margin: 0 auto; }

/* Promise block: one sentence, one sub, one honest line. */
.hero { display: grid; gap: 16px; margin: 8px 0 clamp(28px, 5vw, 56px); max-width: 46em; }
.hero h1 { margin: 0; font-size: clamp(2rem, 4.4vw, 3.6rem); font-weight: 700; line-height: 1.02; letter-spacing: -0.035em; text-wrap: balance; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .sub { margin: 0; color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.15rem); line-height: 1.45; max-width: 34em; }
.hero .honest { margin: 0; color: var(--muted); font-size: 14px; max-width: 32em; }

/* Stage: the simulation, with the poster under it until the renderer is ready. */
.stage {
  position: relative;
  border-radius: var(--radius);
  background: var(--stage);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  height: clamp(340px, 58vh, 560px);
}
.hint { position: absolute; top: 14px; left: 16px; z-index: 2; margin: 0; color: #6d665c; font-size: 12.5px; pointer-events: none; }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; transition: opacity .35s; }
.poster[data-hidden="true"] { opacity: 0; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.scene:active { cursor: grabbing; }

/* Odometer: the traffic counter lives in the DOM, crisp at any zoom. */
.meter {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  background: #f8f7f4d9; color: #23201c;
  border: 1px solid #23201c1f; border-radius: 10px;
  padding: 6px 10px; font-size: 12.5px; text-align: right;
  pointer-events: none; backdrop-filter: blur(3px);
}
.meter .num { font-weight: 650; font-variant-numeric: tabular-nums; }
.meter .cap { color: #6d665c; }

/* Playback dock: floats inside the stage, one line on phone. */
.player {
  position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 3;
  background: #f8f7f4; color: #23201c;
  border: 1px solid #23201c1f; border-radius: 12px;
  padding: 10px 12px 8px; font-size: 13px;
}
.step-line { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; font-weight: 550; line-height: 1.4; min-height: 1.4em; }
.step-num { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.bar { display: flex; align-items: center; gap: 14px; }
.play { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: #f8f7f4; transition: transform .12s; }
.play:active { transform: scale(.94); }
.play .play-glyph { fill: currentColor; stroke: none; }
.track { position: relative; flex: 1; height: 40px; }
.rail { position: absolute; inset: 18px 0 auto; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.rail .played { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); }
.ticks { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
/* Tick buttons must sit above the invisible scrub input or they can't be pressed. */
.ticks button { position: absolute; z-index: 2; top: 12px; width: 16px; height: 16px; margin-left: -8px; padding: 0; border: 0; background: none; }
.ticks button::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #f8f7f4; box-shadow: inset 0 0 0 2px var(--muted); transition: box-shadow .12s; }
.ticks button[aria-current="step"]::after { background: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.scrub { position: absolute; inset: 0; z-index: 1; width: 100%; margin: 0; opacity: 0; cursor: pointer; }
.clock { width: 4ch; flex: none; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.speed { display: flex; flex: none; padding: 3px; border-radius: 999px; background: var(--line); }
.speed label { position: relative; }
.speed input { position: absolute; opacity: 0; }
.speed span { display: block; padding: 4px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; cursor: pointer; }
.speed input:checked + span { background: #f8f7f4; box-shadow: 0 1px 2px #23201c33; }
.speed input:focus-visible + span { outline: 2px solid var(--accent); }
.round { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.round[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
@media (width <= 560px) { .bar { gap: 6px; } .speed, .clock { display: none; } }

/* Sandbox: the compare controls below the stage, quiet and reachable. */
.sandbox { display: grid; gap: 14px; margin-top: 18px; }
.ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 13.5px; }
.ctl .lbl { color: var(--muted); flex: none; }
.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--stage); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.seg input:checked + span { background: var(--paper); box-shadow: 0 1px 2px #23201c33; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
input[type="range"].plain { accent-color: var(--accent); min-width: 160px; flex: 1; max-width: 320px; }
.readout { font-variant-numeric: tabular-nums; font-weight: 600; }
.numbers { display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 13.5px; color: var(--muted); }
.numbers .num { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.numbers .win { color: var(--accent); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Detail sections: short, plain, honest. */
.detail { max-width: 46em; margin-top: clamp(36px, 6vw, 64px); display: grid; gap: 8px; }
.detail h2 { margin: 20px 0 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.detail p, .detail ul { margin: 0; color: var(--ink); }
.detail ul { padding-left: 1.2em; color: var(--muted); }
.detail a { color: var(--accent); }
.step-list { padding: 0; list-style: none; display: grid; gap: 2px; }
.step-list button { display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 8px 0; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.step-list button .n { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 12px; flex: none; }
.step-list button:hover { color: var(--accent); }

/* Reference control: one quiet button, sources on demand. */
.ref { margin-top: 20px; }
.ref summary { display: inline-block; cursor: pointer; color: var(--muted); font-size: 13.5px; border-bottom: 1px solid var(--line); list-style: none; }
.ref summary::-webkit-details-marker { display: none; }
.ref summary:hover { color: var(--accent); }
.ref ul { margin-top: 8px; }
.next-link { margin-top: 28px; font-size: 14px; }
.next-link a { color: var(--accent); }

/* Book cover (home): a table of contents, not a dashboard. */
.toc { display: grid; gap: 8px; margin-bottom: clamp(36px, 6vw, 64px); }
.part { margin-top: clamp(24px, 4vw, 40px); }
.part h2 { margin: 0 0 4px; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chapters { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.chapter-card {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center;
  padding: 12px; border-radius: var(--radius); background: var(--card, var(--stage));
  box-shadow: var(--shadow-soft); transition: transform .15s;
}
.chapter-card:hover { transform: translateY(-1px); }
.chapter-card img { width: 120px; height: 63px; object-fit: cover; border-radius: 8px; display: block; }
.chapter-card .kick { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chapter-card .name { font-weight: 650; font-size: 1.05rem; letter-spacing: -0.01em; margin: 2px 0; }
.chapter-card .line { color: var(--muted); font-size: 13.5px; margin: 0; }
@media (width <= 560px) { .chapter-card { grid-template-columns: 84px 1fr; gap: 12px; } .chapter-card img { width: 84px; height: 84px; } }
.colophon { margin-top: clamp(40px, 7vw, 72px); padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
