/* Identité : 3 couleurs (bordeaux, or champagne, ivoire) + encre et blanc neutres.
   Les valeurs entre {{ }} viennent de config.json, remplacées à la fabrication. */
:root {
  --wine: #3a0f1d;
  --gold: #c9a96e;
  --ivory: #f4ead9;
  --gold-deep: #8f6f2f;
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #111111;
  --muted: #555555;
  --line: #e2d6bf;
  --surface: var(--ivory);      /* fonds des cartes, schéma, quiz, lignes de résultat */
  --sec: var(--wine);           /* droite AB du schéma */
  --target: var(--gold-deep);   /* tangente et chiffre cible */
  --res: var(--wine);           /* résultats du tableau */
  --font: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Cormorant Garamond", Garamond, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --paper: #1b1b1b; --ink: #f4f4f4; --muted: #aaaaaa; --line: #3a2a30;
    --surface: #2a1119; --sec: var(--ivory); --target: #d9bd82; --res: var(--gold);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --paper: #1b1b1b; --ink: #f4f4f4; --muted: #aaaaaa; --line: #3a2a30;
  --surface: #2a1119; --sec: var(--ivory); --target: #d9bd82; --res: var(--gold);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.65; font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; text-wrap: balance; }
h1 { font-weight: 500; letter-spacing: -0.03em; line-height: 0.9; }
h2 { font-size: clamp(2.3rem, 5vw, 3.2rem); letter-spacing: -0.015em; line-height: 1; }
h3 { font-size: 1.6rem; letter-spacing: -0.01em; line-height: 1.15; }
p { margin: 0; }
b { font-weight: 600; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--surface); padding: 1px 6px; white-space: nowrap; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 0 5px #111; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--wine); color: #ffffff; }
.topbar .wrap { display: flex; align-items: center; gap: 28px; }
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; padding: 14px 0; color: inherit; text-decoration: none; }
.nav { display: flex; overflow-x: auto; min-width: 0; margin-left: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #b8b8b8; text-decoration: none; white-space: nowrap; font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; font-weight: 600; padding: 16px 11px 13px; border-bottom: 3px solid transparent; transition: color 0.15s; }
.nav a i { font-style: normal; margin-right: 6px; opacity: 0.6; }
.nav a:hover { color: #ffffff; }
.nav a.active { color: var(--gold); border-bottom-color: var(--gold); }
.nav a.active i { opacity: 1; }
.lang { flex: none; color: var(--gold); text-decoration: none; font-size: 0.72rem; letter-spacing: 0.09em; font-weight: 600; border: 1px solid var(--gold); padding: 3px 8px; }
.lang:hover { background: var(--gold); color: #1a0a10; }
.topbar .nav + .lang { margin-left: 4px; }
.topbar .brand + .lang { margin-left: auto; }
.progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); }
@media (max-width: 700px) { .topbar .wrap { gap: 12px; } .fiche-page .brand { display: none; } .nav { margin-left: 0; } }

/* En-tête */
.hero { background: var(--wine); color: var(--ivory); position: relative; overflow: hidden; }
.hero .wrap { padding-top: 36px; padding-bottom: 0; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--gold); padding-bottom: 10px; color: var(--gold); }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
.hero-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: center; padding: 44px 0 40px; }
.hero h1 { font-size: clamp(3.6rem, 11.5vw, 8.6rem); letter-spacing: -0.05em; line-height: 0.86; color: var(--ivory); font-weight: 500; }
.lead { font-size: 1.22rem; max-width: 40ch; margin-top: 28px; color: #e6d9c3; }
.big4 { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.disc { position: relative; width: 290px; height: 290px; border-radius: 50%; border: 2px solid var(--gold); color: var(--gold); display: grid; place-items: center; }
.disc b { font-family: var(--serif); font-size: 8.4rem; letter-spacing: -0.02em; line-height: 1; font-weight: 500; }
.big4 span { color: var(--gold); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; text-align: center; max-width: 190px; line-height: 1.4; }
@media (max-width: 760px) {
  .hero-main { grid-template-columns: 1fr; }
  .disc { width: 220px; height: 220px; }
  .disc b { font-size: 6.2rem; }
}
.speed { display: flex; gap: 10px; align-items: center; font-size: 0.85rem; margin-top: 18px; }
.speed select { font: inherit; color: #111111; background: var(--ivory); border: 0; border-radius: 0; padding: 4px 8px; }
.speed[hidden], .listen[hidden] { display: none; }
.plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 40px; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--gold); }
.plan a { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; text-decoration: none; color: var(--ivory); padding: 11px 0; border-bottom: 1px solid rgba(201, 169, 110, 0.3); font-size: 0.98rem; line-height: 1.3; font-weight: 500; transition: transform 0.15s; }
.plan a:hover { transform: translateX(6px); }
.plan .n { font-size: 0.78rem; font-weight: 600; width: 30px; height: 30px; display: grid; place-items: center; color: var(--gold); border: 1px solid var(--gold); }
.bar { height: 4px; margin-top: 44px; background: var(--gold); }

/* Sections : grille à deux colonnes, bordeaux et or en alternance */
main { max-width: 1040px; margin: 0 auto; padding: 0 24px 72px; }
section { --c: var(--wine); --on-c: var(--ivory); display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 32px; border-top: 6px solid var(--c); padding-top: 22px; margin-top: 80px; }
section:nth-of-type(even) { --c: var(--gold); --on-c: #1a0a10; }
.rail { position: relative; }
.mark { position: sticky; top: 84px; display: flex; flex-direction: column; align-items: flex-start; }
.mark b { font-family: var(--serif); font-size: 4.4rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1; background: var(--c); color: var(--on-c); padding: 8px 14px 12px; }
.mark small { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 12px; font-weight: 600; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col > * { max-width: 60ch; }
.col > .wide, .col > .listen { max-width: none; }
@media (max-width: 760px) {
  section { grid-template-columns: 1fr; gap: 14px; margin-top: 56px; }
  .mark { position: static; flex-direction: row; align-items: center; gap: 14px; }
  .mark b { font-size: 2.8rem; padding: 4px 12px 8px; }
  .mark small { margin-top: 0; }
}

.takeaway { background: var(--gold); color: #1a0a10; padding: 20px 24px; font-family: var(--serif); font-size: 1.9rem; font-weight: 600; font-style: italic; line-height: 1.15; }
.route { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { padding: 14px 18px 16px; display: flex; flex-direction: column; background: var(--wine); color: var(--ivory); }
.stat:nth-child(even) { background: var(--gold); color: #1a0a10; }
.stat b { font-family: var(--serif); font-size: 4rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.stat span { font-size: 0.9rem; margin-top: 8px; line-height: 1.35; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--surface); color: var(--ink); border-top: 10px solid var(--wine); padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 10px; transition: transform 0.15s; }
.card:hover { transform: translateY(-3px); }
.card:nth-child(even) { border-top-color: var(--gold); }
.card:nth-child(1) { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; row-gap: 10px; align-content: start; }
.card:nth-child(1) .tag { grid-column: 1 / -1; }
@media (max-width: 700px) { .card:nth-child(1) { grid-template-columns: 1fr; } }
.card .tag { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; line-height: 1.05; }
.card p { font-size: 1rem; line-height: 1.6; }

/* Schéma interactif */
.lab { background: var(--surface); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.ctrl { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ctrl label { font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.ctrl input[type=range] { flex: 1; min-width: 160px; accent-color: var(--target); height: 28px; }
.ctrl output { min-width: 74px; text-align: right; font-weight: 600; }
.plot { width: 100%; height: auto; display: block; background: var(--paper); }
.plot .axis { stroke: var(--ink); stroke-width: 1; }
.plot .grid { stroke: var(--line); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.plot .curve { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.plot .tan { stroke: var(--target); stroke-width: 3; stroke-dasharray: 8 6; }
.plot .sec { stroke: var(--sec); stroke-width: 3; }
.plot .pa { fill: var(--ink); }
.plot .pb { fill: var(--sec); stroke: var(--paper); stroke-width: 2.5; }
.plot .lbl { fill: var(--ink); font-size: 14px; font-weight: 600; font-family: var(--font); }
.legend { display: flex; gap: 24px; flex-wrap: wrap; font-size: 0.88rem; }
.legend i { display: inline-block; width: 24px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 8px; }
.legend .l-sec { border-color: var(--sec); }
.legend .l-tan { border-top-style: dashed; border-color: var(--target); }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.readout { background: var(--paper); padding: 10px 16px 12px; }
.readout span { display: block; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.readout b { font-family: var(--serif); font-size: 4.3rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; color: var(--sec); }
.readout.target b { color: var(--target); }
.msg { min-height: 56px; font-weight: 600; }
.caption { color: var(--muted); font-size: 0.95rem; }

/* Exercice */
.goal { display: grid; gap: 12px; }
.goal p { background: var(--surface); padding: 14px 18px 16px; }
.goal p b { display: inline-block; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; background: var(--c); color: var(--on-c); padding: 2px 8px; margin-bottom: 8px; }
.tablewrap { overflow-x: auto; max-width: 100%; }

/* Chez les pros : le vrai code, sur fond bordeaux comme un éditeur */
.codebox { margin: 0; background: var(--wine); color: var(--ivory); border: 2px solid var(--ink); }
.codebox figcaption { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); padding: 12px 20px 0; }
.codebox pre { margin: 0; padding: 12px 20px 18px; overflow-x: auto; font-family: var(--mono); font-size: 0.95rem; line-height: 1.7; }
.codebox pre code { background: none; padding: 0; font-size: inherit; white-space: pre; color: inherit; }
.codebox .out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; border-top: 1px solid rgba(244, 234, 217, 0.25); padding: 12px 20px 16px; }
.codebox .out span { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.codebox .out samp { font-family: var(--mono); font-size: 1.15rem; color: var(--ivory); }
.lignes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lignes li { display: grid; gap: 6px; border-left: 4px solid var(--gold); padding: 4px 0 4px 16px; }
.lignes code { justify-self: start; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 12px 18px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; background: var(--wine); color: var(--ivory); }
th:first-child, td:first-child { text-align: left; }
td { font-size: 1.05rem; }
td.res { font-family: var(--serif); color: var(--res); font-weight: 600; font-size: 2.1rem; line-height: 1.2; background: var(--surface); }
td.start { color: var(--muted); font-style: italic; }
.steps { display: flex; flex-direction: column; gap: 14px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
.steps li { --sc: var(--wine); --son: var(--ivory); counter-increment: step; display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: 20px; row-gap: 8px; background: var(--paper); border: 2px solid var(--ink); padding: 0 18px 20px 0; }
.steps li:nth-child(even) { --sc: var(--gold); --son: #1a0a10; }
.steps li > * { grid-column: 2; }
.steps li > :first-child { margin-top: 18px; }
.steps li::before { content: counter(step); grid-column: 1; grid-row: 1 / span 8; background: var(--sc); color: var(--son); display: grid; place-items: start center; padding-top: 12px; font-family: var(--serif); font-size: 3.4rem; font-weight: 600; line-height: 1; }
.why { color: var(--muted); font-size: 0.95rem; }
.why b { color: var(--ink); }
.note { font-size: 0.9rem; color: var(--muted); }

/* Quiz */
.quiz { background: var(--surface); padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.qcount { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.dots { display: flex; gap: 6px; }
.dots span { width: 28px; height: 6px; background: var(--line); }
.dots span.done { background: var(--gold); }
.dots span.now { background: var(--wine); }
.qctx { background: var(--paper); border-left: 6px solid var(--gold); padding: 12px 16px; font-size: 1rem; }
.qctx[hidden] { display: none; }
.q { font-family: var(--serif); font-size: 2.1rem; font-weight: 600; line-height: 1.1; min-height: 2.4em; }
.opts { display: grid; gap: 10px; }
.opt { font: inherit; font-weight: 600; font-size: 1.08rem; text-align: left; cursor: pointer; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 0; padding: 0; min-height: 54px; display: flex; align-items: stretch; transition: transform 0.12s; }
.opt i { font-family: var(--serif); font-style: normal; font-size: 1.4rem; width: 54px; display: grid; place-items: center; flex: none; background: var(--wine); color: var(--ivory); font-weight: 600; }
.opt:nth-child(2) i { background: var(--gold); color: #1a0a10; }
.opt span { flex: 1; padding: 14px 18px; }
.opt:hover:not(:disabled) { transform: translateX(6px); }
.opt:disabled { cursor: default; }
.opt.sel { box-shadow: 0 0 0 4px var(--gold); transform: translateX(6px); }
.opt.sel i { background: var(--gold); color: #1a0a10; }
.opt.right { background: #1f9d5c; color: #ffffff; border-color: #111111; }
.opt.right i { background: #111111; color: #ffffff; }
.opt.wrong { background: #c62828; color: #ffffff; border-color: #111111; }
.opt.wrong i { background: #111111; color: #ffffff; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { font: inherit; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 0; padding: 8px 14px; transition: background 0.12s; }
.btn:hover { background: var(--gold); color: #111111; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--paper); color: var(--ink); }
.btn[hidden] { display: none; }
#validate:not(:disabled) { background: var(--wine); color: var(--ivory); border-color: var(--wine); }
#validate:not(:disabled):hover { background: var(--gold); color: #1a0a10; border-color: #1a0a10; }
.feedback { background: var(--paper); border-left: 8px solid var(--gold); padding: 12px 16px; display: none; font-weight: 500; }
.feedback.show { display: block; }
.feedback.ok { background: #e3f5ea; color: #1a0a10; border-left-color: #1f9d5c; }
.feedback.ko { background: #fbe4e4; color: #1a0a10; border-left-color: #c62828; }
.verdict { display: block; font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; margin-bottom: 4px; }
.feedback.ok .verdict { color: #14703f; }
.feedback.ko .verdict { color: #a31515; }
.hint { color: var(--muted); display: none; }
.hint.show { display: block; }

/* Lecture à voix haute */
.listen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.listen .btn { display: inline-flex; align-items: center; gap: 8px; font-size: 0.72rem; padding: 6px 12px; }
.listen .btn[hidden] { display: none; }
.listen .btn svg { width: 14px; height: 14px; flex: none; }
.listen .btn.on { background: var(--gold); color: #111111; }
.listen .status { font-size: 0.85rem; color: var(--muted); }
.reading { background: var(--surface); box-shadow: 0 0 0 6px var(--surface); }

/* Pied de page */
footer { background: var(--wine); color: var(--gold); }
footer .wrap { padding-top: 22px; padding-bottom: 40px; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
footer .bar { margin-top: 0; height: 4px; background: var(--gold); }

/* Accueil : liste des fiches */
.home-hero .hero-main { grid-template-columns: 1fr; padding-bottom: 56px; }
.home-hero h1 { font-size: clamp(3rem, 9vw, 6.4rem); }
.home h2 { margin-bottom: 28px; }
.fiches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.fiches a { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 18px; height: 100%; background: var(--surface); color: var(--ink); text-decoration: none; border-top: 10px solid var(--wine); padding: 18px 20px 20px; transition: transform 0.15s; }
.fiches li:nth-child(even) a { border-top-color: var(--gold); }
.fiches a:hover { transform: translateY(-3px); }
.fiches .num { grid-row: 1 / span 3; font-family: var(--serif); font-size: 3.4rem; font-weight: 600; line-height: 1; color: var(--res); }
.fiches .t { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; line-height: 1.05; }
.fiches .d { font-size: 1rem; line-height: 1.55; margin-top: 8px; }
.fiches .go { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; color: var(--muted); margin-top: 12px; }
.home section { display: block; border-top-color: var(--gold); }
.page-404 { min-height: 100vh; display: flex; flex-direction: column; }
.page-404 .hero { flex: 1; }
