/* Layout : un dossier long, une preuve par chapitre. Chaque chapitre = l'affirmation, une démo qu'on manipule, puis la preuve technique. */
:root {
  --night: #0e0b19;
  --night-2: #17122a;
  --ink: #f4ede4;
  --dim: #a59db4;
  --sunset: #ff7a3d;
  --sea: #3aa7d9;
  --debug: #52e2ff;
  --lod1: #ffd447;
  --lod2: #c48bff;
  --debug-bg: #071321;
  --grid: rgba(82, 226, 255, 0.13);
  --line: rgba(244, 237, 228, 0.12);
  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { background: var(--night); color: var(--ink); font-family: var(--f-body); font-size: 17px; line-height: 1.65; overflow-x: hidden; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--debug); outline-offset: 3px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sunset); }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--night); }
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: rgba(14, 11, 25, 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; gap: 20px; padding-block: 12px; }
.brand { font-family: var(--f-display); font-weight: 900; font-size: 22px; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none; line-height: 1; }
.brand span { color: var(--sunset); }
.crumb { display: none; font-family: var(--f-mono); font-size: 12px; color: var(--dim); }
.progress { margin-left: auto; font-family: var(--f-mono); font-size: 12px; color: var(--debug); font-variant-numeric: tabular-nums; }
.bar { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--debug); width: 0; }
@media (max-width: 560px) { .crumb { display: none; display: none; } }

/* Ouverture */
.open { padding-block: 72px 48px; border-bottom: 1px solid var(--line); }
.open h1 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: clamp(52px, 9vw, 124px); line-height: 0.86; margin: 14px 0 22px; text-wrap: balance; max-width: 12ch; }
.open h1 em { font-style: normal; color: transparent; -webkit-text-stroke: 1.5px var(--debug); }
.open .lede { max-width: 58ch; color: var(--dim); margin: 0; font-size: 19px; }
.meta { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 28px; font-family: var(--f-mono); font-size: 12px; color: var(--dim); }
.meta b { color: var(--ink); font-weight: 600; }
.toc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 40px; border-top: 1px solid var(--line); }
.toc a { padding: 14px 16px 14px 0; text-decoration: none; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.toc a:hover b { color: var(--debug); }
.toc span { font-family: var(--f-mono); font-size: 11px; color: var(--sunset); }
.toc b { font-weight: 500; font-size: 15px; line-height: 1.35; }
@media (max-width: 760px) { .toc { grid-template-columns: minmax(0, 1fr); } }

/* Chapitres */
.ch { padding-block: 80px; border-bottom: 1px solid var(--line); scroll-margin-top: 60px; }
.ch-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 48px; align-items: start; }
@media (max-width: 920px) { .ch-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
.ch-text { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.ch h2 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: clamp(38px, 5vw, 62px); line-height: 0.94; margin: 0; text-wrap: balance; }
.ch p { margin: 0; max-width: 60ch; }
.ch p.dim { color: var(--dim); }
.proof { border: 1px solid rgba(82, 226, 255, 0.35); border-radius: 3px; background: var(--debug-bg); font-family: var(--f-mono); font-size: 13px; color: var(--debug); }
.proof .ph { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid rgba(82, 226, 255, 0.2); color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.proof pre { margin: 0; padding: 12px; white-space: pre; overflow-x: auto; line-height: 1.6; font-family: inherit; }
.proof .fn { color: var(--lod1); }
.proof .c { color: var(--dim); }
.status { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--lod1); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.demo { border: 1px solid var(--line); border-radius: 4px; background: var(--night-2); overflow: hidden; }
.demo canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; max-width: 100%; touch-action: none; cursor: crosshair; }
.ctrls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.ctrls .read { margin-left: auto; font-family: var(--f-mono); font-size: 12px; color: var(--debug); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { background: transparent; color: var(--dim); border: 0; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--debug); color: var(--debug-bg); }
.rng { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 12px; color: var(--dim); flex: 1 1 220px; min-width: 0; }
.rng input { flex: 1; min-width: 0; accent-color: var(--debug); }
.tip { font-family: var(--f-mono); font-size: 12px; color: var(--dim); padding: 0 16px 14px; }

.end { padding-block: 80px; }
.end .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 800px) { .end .wrap { grid-template-columns: minmax(0, 1fr); } }
.card { border: 1px solid var(--line); border-radius: 4px; background: var(--night-2); padding: 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.card h3 { margin: 0; font-family: var(--f-display); font-weight: 900; font-size: 38px; text-transform: uppercase; line-height: 0.95; }
.card p { margin: 0; color: var(--dim); }
.card.hot { border-color: rgba(255, 122, 61, 0.4); background: linear-gradient(135deg, rgba(255, 122, 61, 0.16), transparent 60%), var(--night-2); }
.btn { justify-self: start; display: inline-block; text-decoration: none; font-weight: 700; padding: 11px 18px; border-radius: 3px; background: var(--sunset); color: #1a0d05; }
.btn.ghost { background: transparent; color: var(--debug); border: 1px solid rgba(82, 226, 255, 0.5); }
.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.btn-txt { font-family: var(--f-mono); font-size: 13px; color: var(--dim); }
.btn-txt:hover { color: var(--ink); }
footer { padding-block: 32px 56px; color: var(--dim); font-size: 13px; border-top: 1px solid var(--line); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: space-between; }

/* ---------- Navigation entre dossiers ---------- */
.dnav { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.dnav a { font-family: var(--f-mono); font-size: 12px; text-decoration: none; color: var(--dim); padding: 6px 10px; border-radius: 3px; white-space: nowrap; }
.dnav a:hover { color: var(--ink); background: rgba(244, 237, 228, 0.06); }
.dnav a[aria-current="page"] { color: var(--debug-bg); background: var(--debug); }
@media (max-width: 700px) { .progress { display: none; } .dnav { margin-left: auto; } }
.dnav .sm { display: none; }
@media (max-width: 560px) { .dnav a[aria-current="page"]:not(:first-child) { display: none; } .dnav .lg { display: none; } .dnav .sm { display: inline; } }
.demo .stage { position: relative; }
.demo .stage canvas { cursor: grab; }
.demo .hud3d { position: absolute; left: 12px; top: 12px; display: grid; gap: 4px; pointer-events: none; font-family: var(--f-mono); font-size: 11px; }
.demo .hud3d span { background: var(--debug); color: var(--debug-bg); padding: 3px 6px; justify-self: start; }
.demo .hud3d span.y { background: var(--lod1); } .demo .hud3d span.p { background: var(--lod2); } .demo .hud3d span.o { background: var(--sunset); }
.btn-line { background: transparent; color: var(--debug); border: 1px solid rgba(82, 226, 255, 0.5); border-radius: 3px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.btn-line:hover { background: rgba(82, 226, 255, 0.1); }
.note { font-family: var(--f-mono); font-size: 12px; color: var(--dim); border-left: 2px solid var(--lod1); padding-left: 12px; }
table.data { border-collapse: collapse; width: 100%; font-family: var(--f-mono); font-size: 12px; }
table.data th, table.data td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--dim); font-weight: 400; text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em; }
table.data td.n { color: var(--lod1); font-variant-numeric: tabular-nums; }
.tbl { overflow-x: auto; }
