/* Leakproof v3, direction A « Instrument ». Contrat : docs/ARCHITECTURE.md s.4, guide : docs/DESIGN.md. Papier clair par defaut, variante sombre sous prefers-color-scheme. Encre = actions, liens ; rouge = leak ou valeur hors fourchette, rien d'autre. */
/* Archivo variable (wdth 62..125, wght 100..900), SIL OFL : src/fonts/OFL.txt. Latin seulement : le cyrillique retombe sur la pile systeme. */
@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
  src: url("/fonts/archivo-latin-wdth-normal.woff2") format("woff2");
}
:root {
  /* surfaces (ratios AA : docs/DESIGN.md) */
  --paper: #f3f4f1;       /* fond de page */
  --surface: #ffffff;     /* cartes, panneaux */
  --surface-2: #e9ece7;   /* imbrique, code, survol */
  --line: #c9cec9;        /* filets decoratifs */
  --line-3: #747f79;      /* bordures de champs (>= 3:1) */
  /* texte et actions */
  --ink: #14202a;         /* texte, boutons pleins, liens, focus */
  --on-ink: #f3f4f1;      /* texte sur --ink */
  --muted: #4a5852;
  /* leak / alerte / hors fourchette */
  --red: #c21f3a;
  --red-text: #a3162e;
  --red-soft: #fbe8eb;
  /* OK : fond / bordure (--ok), texte (--ok-text) */
  --ok: #2e7d5b;
  --ok-text: #1f6044;
  --ok-soft: #dceadf;
  /* a decider */
  --amber: #b87d14;
  --amber-text: #7a4e08;
  --amber-soft: #f6e7c1;
  /* tapis des tables SVG (src/spot/table.mjs) */
  --felt: #cfe0d6;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* espacement */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --r: 10px; --r-s: 6px;  /* rayons panneaux / champs et boutons */
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f171e;
    --surface: #16212a;
    --surface-2: #1e2b36;
    --line: #2b3841;
    --line-3: #6c7c87;
    --ink: #e9edea;
    --on-ink: #0f171e;
    --muted: #a6b3ad;
    --red: #f0646a;
    --red-text: #ff9096;
    --red-soft: #3a1618;
    --ok: #5dbb91;
    --ok-text: #7fd0ab;
    --ok-soft: #10301f;
    --amber: #e3b341;
    --amber-text: #e3b341;
    --amber-soft: #2c2410;
    --felt: #143124;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 56px); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.6 var(--sans);
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem); overflow-wrap: break-word; }
img, svg { max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
code, .num { font-variant-numeric: tabular-nums; }
code { font-family: var(--mono); font-size: .9em; }
b, strong { font-weight: 650; }

/* titres : larges et serres (axe wdth), echelle fluide */
h1, h2, h3 { line-height: 1.1; text-wrap: balance; hyphens: auto; }
h1 { font-size: clamp(2.125rem, 1.5rem + 3.6vw, 4rem); line-height: 1; letter-spacing: -.025em; font-weight: 820; font-stretch: 118%; margin: 0 0 var(--s4); }
h1 { hyphens: manual; } :lang(de) h1, :lang(ru) h1 { hyphens: auto; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem); letter-spacing: -.02em; font-weight: 780; font-stretch: 112%; margin: var(--s7) 0 var(--s3); }
h3 { font-size: 1.25rem; letter-spacing: -.01em; font-weight: 700; font-stretch: 108%; margin: var(--s5) 0 var(--s2); }
h2:first-child, h3:first-child { margin-top: 0; }
p { margin: 0 0 var(--s4); }
.lead { font-size: clamp(1.0625rem, 1rem + .5vw, 1.1875rem); line-height: 1.55; color: var(--muted); max-width: 34em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }

/* coquille : en-tete collant (bureau). Mobile : marque + langue + membre, nav en lignes qui passent a la ligne (pas de defilement cache), en-tete non collant */
main { display: block; }
.site-header { position: static; z-index: 50; background: var(--paper); border-bottom: 1px solid var(--line); }
.site-header > .container { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s2); min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; min-height: 44px; margin-right: auto; font-weight: 850; font-stretch: 125%;
  font-size: 1.125rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.nav { order: 3; flex: 1 0 100%; display: flex; flex-wrap: wrap; column-gap: var(--s1); padding: 0 0 var(--s1); }
.nav a, .app-nav a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s3); color: var(--muted);
  text-decoration: none; font-size: .9375rem; font-weight: 550; border-bottom: 2px solid transparent; }
.nav a:hover, .app-nav a:hover { color: var(--ink); }
.nav a[aria-current], .app-nav a[aria-current] { color: var(--ink); font-weight: 650; border-bottom-color: var(--ink); }
.lang-switch { position: relative; }
.lang-switch summary { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3); cursor: pointer;
  list-style: none; color: var(--muted); font-size: .875rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg) translateY(-2px); }
.lang-switch summary:hover, .lang-switch[open] summary { color: var(--ink); }
.lang-switch[open] summary::after { transform: rotate(-135deg); }
.lang-switch > :not(summary) { position: absolute; right: 0; top: 100%; z-index: 60; width: 14rem; max-width: calc(100vw - 2 * var(--gutter));
  margin: 0; padding: var(--s1); list-style: none; background: var(--surface); border: 1px solid var(--line-3); border-radius: var(--r); }
.lang-switch li { margin: 0; }
.lang-switch a { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-s); color: var(--ink); text-decoration: none; }
.lang-switch a:hover { background: var(--surface-2); }
.lang-switch a[aria-current] { font-weight: 700; }
.btn.member-btn { background: transparent; border-color: var(--ink); color: var(--ink); font-weight: 600; }
.btn.member-btn:hover { background: var(--surface-2); border-color: var(--ink); color: var(--ink); }
@media (min-width: 900px) {
  .site-header { position: sticky; }
  .site-header > .container { flex-wrap: nowrap; column-gap: var(--s3); }
  .brand { margin-right: var(--s4); }
  .nav { order: 0; flex: 1 1 auto; flex-wrap: nowrap; padding: 0; }
  .nav a { height: var(--header-h); min-height: 44px; }
}

/* mise en page */
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: var(--gutter); }
.hero { padding-block: clamp(40px, 8vw, 96px) clamp(32px, 6vw, 72px); }
.hero-grid { display: grid; gap: var(--s6); align-items: start; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: var(--s7); } }
.section { padding-block: clamp(40px, 6vw, 72px); }
.section + .section { border-top: 1px solid var(--line); }
.section > h2:first-child, .section > .container > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid-2, .grid-3 { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .grid-2, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.stack > * { margin-block: 0; }
.stack > * + * { margin-top: var(--stack, var(--s4)); }

/* boutons : plein = encre, ghost = filet encre */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s5);
  border: 1.5px solid var(--ink); border-radius: var(--r-s); background: var(--ink); color: var(--on-ink);
  font: inherit; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--muted); border-color: var(--muted); color: var(--on-ink); text-decoration: none; }
.btn.ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--ink); color: var(--ink); }
.btn.small { padding: 0 var(--s4); font-size: .9375rem; }

/* cartes */
.card { display: block; padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: var(--ink); text-decoration: none; }
a.card:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.card p { margin: 0; color: var(--muted); font-size: .9375rem; }
.card h3 { margin-top: 0; }
.card-tool { position: relative; display: flex; flex-direction: column; gap: var(--s1); padding-bottom: var(--s6); }
.card-tool .tag { align-self: flex-start; }
a.card-tool::after { content: "\2192"; position: absolute; right: var(--s5); bottom: var(--s3); color: var(--ink); font-size: 1.125rem; }
.card-lesson { position: relative; display: flex; flex-direction: column; gap: var(--s1); }
.card-lesson .tag { align-self: flex-start; }
/* cadenas en CSS pur : ::before = corps, ::after = anse */
.card-lesson.locked { background: transparent; border-style: dashed; padding-right: 56px; }
.card-lesson.locked h3, .card-lesson.locked p { color: var(--muted); }
.card-lesson.locked::before { content: ""; position: absolute; top: 31px; right: 22px; width: 16px; height: 12px; border-radius: 3px; background: var(--muted); }
.card-lesson.locked::after { content: ""; position: absolute; top: 21px; right: 25px; width: 10px; height: 12px; border: 2px solid var(--muted);
  border-bottom: 0; border-radius: 6px 6px 0 0; }
.tag { display: inline-block; margin-bottom: var(--s2); padding: 4px 9px; border: 1px solid var(--line-3); border-radius: 99px;
  color: var(--muted); font: 650 .6875rem/1.2 var(--sans); text-transform: uppercase; letter-spacing: .08em; }
.tag.ok { border-color: var(--ok); color: var(--ok-text); }
.badge-pro { display: inline-block; padding: 3px 8px; border-radius: 4px; background: var(--ink); color: var(--on-ink);
  font: 700 .6875rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; vertical-align: middle; }

/* chiffre cle : 1er enfant = valeur, le reste = legende */
.kpi { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4) var(--s5); border: 1px solid var(--line); border-left: 3px solid var(--ink);
  border-radius: var(--r); background: var(--surface); }
.kpi > :first-child { font: 760 clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem)/1.1 var(--sans); font-stretch: 112%; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi > :not(:first-child) { color: var(--muted); font-size: .875rem; line-height: 1.4; }

/* etapes numerotees */
.steps { counter-reset: s; list-style: none; margin: var(--s4) 0; padding: 0; display: grid; gap: var(--s3); }
.steps li { counter-increment: s; position: relative; padding: var(--s4) var(--s4) var(--s4) 60px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.steps li::before { content: counter(s, decimal-leading-zero); position: absolute; left: var(--s4); top: var(--s4); font: 750 1.25rem/1.4 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); }

/* tableaux : defilement horizontal sous 640 px, jamais de debordement de page */
.table, .lesson table { display: block; max-width: 100%; margin: var(--s4) 0; overflow-x: auto; border-collapse: collapse; font-size: .9375rem; }
@media (min-width: 640px) { .table, .lesson table { display: table; width: 100%; } }
.table th, .table td, .lesson th, .lesson td { padding: 10px var(--s3); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th, .lesson th { color: var(--ink); font-size: .8125rem; font-weight: 650; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.table .num, .lesson .num { text-align: right; white-space: nowrap; }

/* messages */
.note { margin: var(--s4) 0; padding: var(--s3) var(--s4); border-left: 3px solid var(--ink); background: var(--surface); border-radius: 0 var(--r-s) var(--r-s) 0; color: var(--muted); }
:is(.note, .alert, .empty, .lesson blockquote) > :last-child { margin-bottom: 0; }
.pending { display: inline-block; padding: 1px 7px; border: 1px dashed var(--amber); border-radius: 4px; background: var(--amber-soft); color: var(--amber-text); font-size: .9em; }
.alert { margin: var(--s4) 0; padding: var(--s3) var(--s4); border: 1px solid var(--red); border-left-width: 4px; border-radius: var(--r-s); background: var(--red-soft); color: var(--ink); }
.alert strong, .alert b { color: var(--red-text); }
.alert.ok { border-color: var(--ok); background: var(--ok-soft); }
.alert.ok strong, .alert.ok b { color: var(--ok-text); }
.empty { padding: var(--s6) var(--s5); border: 1px dashed var(--line-3); border-radius: var(--r); text-align: center; color: var(--muted); }

/* FAQ sur <details> */
.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); min-height: 56px; padding: var(--s3) 0; cursor: pointer;
  list-style: none; font-weight: 650; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font: 400 1.5rem/1 var(--sans); color: var(--ink); }
.faq details[open] summary::after { content: "\2212"; }
.faq details > :not(summary) { color: var(--muted); }
.faq details > :last-child { margin-bottom: var(--s4); }

/* tarifs */
.pricing { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: stretch; }
.plan { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.plan h3 { margin: 0; }
.plan p { margin: 0; color: var(--muted); font-size: .9375rem; }
.plan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); font-size: .9375rem; }
.plan li { position: relative; padding-left: 24px; }
.plan li::before { content: "\2713"; position: absolute; left: 0; color: var(--ok-text); font-weight: 700; }
.plan .btn { margin-top: auto; }
.plan.featured { border: 2px solid var(--ink); }
.plan-price { margin: 0; color: var(--ink); font: 800 clamp(2rem, 1.6rem + 1.6vw, 2.75rem)/1.1 var(--sans); font-stretch: 112%; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.plan-price small { color: var(--muted); font: 400 .9375rem/1.4 var(--sans); font-stretch: 100%; letter-spacing: 0; }

/* lecon : prose a largeur de lecture */
.lesson { max-width: 68ch; margin-inline: auto; }
.lesson h2 { margin: var(--s7) 0 var(--s3); padding-top: var(--s5); border-top: 1px solid var(--line); }
.lesson h2:first-child { border-top: 0; padding-top: 0; }
.lesson h3 { margin: var(--s6) 0 var(--s2); }
.lesson p, .lesson ul, .lesson ol { margin: 0 0 var(--s4); }
.lesson ul, .lesson ol { padding-left: 1.4em; }
.lesson li { margin-bottom: var(--s2); }
.lesson code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }
.lesson pre { margin: var(--s4) 0; padding: var(--s4); overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); font-size: .875rem; }
.lesson pre code { padding: 0; background: none; }
.lesson blockquote { margin: var(--s5) 0; padding: var(--s1) 0 var(--s1) var(--s4); border-left: 3px solid var(--ink); color: var(--muted); }
.lesson img { display: block; height: auto; margin: var(--s5) auto; border-radius: var(--r-s); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin: 0 0 var(--s5); padding: 0 0 var(--s4); list-style: none;
  border-bottom: 1px solid var(--line); color: var(--muted); font: .8125rem/1.5 var(--sans); font-variant-numeric: tabular-nums; }
.toc { margin: var(--s5) 0; padding: var(--s4) var(--s5); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: .9375rem; }
.lesson .toc h2, .toc h2, .toc h3, .sources h2, .sources h3 { margin: 0 0 var(--s2); padding: 0; border: 0; color: var(--muted);
  font: 700 .75rem/1.4 var(--sans); font-stretch: 100%; letter-spacing: .1em; text-transform: uppercase; }
.toc ol, .toc ul { margin: 0; padding-left: 1.3em; }
.toc a { display: block; padding: 10px 0; color: var(--ink); text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.sources { margin: var(--s7) 0 0; padding-top: var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.sources a { color: var(--ink); }
.sources ol, .sources ul { margin: 0; padding-left: 1.3em; }
.sources li { margin-bottom: var(--s1); overflow-wrap: anywhere; }

/* spot de l'accueil : table SVG rendue au build (src/spot/table.mjs) + chiffres du calc. Le SVG lit les tokens papier/encre de :root : il suit le theme sombre */
.spot-fig { margin: 0; padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.spot-fig figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s1) var(--s4); align-items: baseline; margin-bottom: var(--s3); }
.spot-fig figcaption b { font-size: 1.125rem; font-weight: 700; font-stretch: 110%; }
.spot-fig svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto var(--s4); border-radius: var(--r-s); }
.spot-nums { display: grid; gap: var(--s3); grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.spot-nums > div { margin: 0; }
.spot-nums dt { color: var(--muted); font-size: .8125rem; line-height: 1.4; }
.spot-nums dd { margin: 0; font: 760 1.625rem/1.2 var(--sans); font-stretch: 112%; font-variant-numeric: tabular-nums; }
.spot-fig .small { margin: var(--s3) 0 0; }

/* formulaires */
.form { display: grid; gap: var(--s4); max-width: 28rem; }
.form label { display: grid; gap: var(--s2); font-size: .9375rem; font-weight: 650; }
.input { width: 100%; min-height: 44px; padding: 10px var(--s3); border: 1px solid var(--line-3); border-radius: var(--r-s);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; }
.input::placeholder { color: var(--muted); opacity: 1; }
.input:focus-visible { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 1px; }

/* espace membre */
.app-shell { display: grid; gap: var(--s5); padding-block: var(--s5) var(--s8); }
.app-shell > * { min-width: 0; }
.app-nav { display: flex; gap: var(--s1); margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
@media (min-width: 900px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); gap: var(--s6); align-items: start; }
  .app-nav { flex-direction: column; margin: 0; padding: 0; overflow: visible; border: 0; position: sticky; top: calc(var(--header-h) + var(--s5)); }
  .app-nav a { padding: 0 var(--s3); border-bottom: 0; border-left: 2px solid transparent; border-radius: 0 var(--r-s) var(--r-s) 0; }
  .app-nav a:hover { background: var(--surface-2); }
  .app-nav a[aria-current] { border-left-color: var(--ink); background: var(--surface); }
}

/* graphiques SVG inline : <figure class="chart"><svg viewBox="..."> avec .axis .line .bar .leak */
.chart { display: block; width: 100%; height: auto; margin: var(--s4) 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.chart .axis { stroke: var(--line-3); fill: none; }
.chart .line { stroke: var(--ink); stroke-width: 2; fill: none; }
.chart .bar { fill: var(--ink); }
.chart .leak { fill: var(--red); stroke: var(--red); }

/* pied de page */
footer { margin-top: var(--s8); padding: var(--s5) 0 var(--s7); border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.site-footer { margin-top: 0; }
footer a { color: var(--ink); }
footer nav { display: flex; flex-wrap: wrap; gap: 0 var(--s4); }
footer nav a { display: inline-flex; align-items: center; min-height: 44px; }

/* ancienne coquille laterale (HTML v1) : repliee en bandeau simple pendant la transition */
.side { padding: var(--s4) var(--gutter); border-bottom: 1px solid var(--line); background: var(--surface); }
.side ul { display: flex; flex-wrap: wrap; gap: 0 var(--s4); margin: 0; padding: 0; list-style: none; }
.side h2 { display: none; }
.side li a { display: block; padding: 10px 0; color: var(--muted); text-decoration: none; }
.side li a:hover, .side li a[aria-current] { color: var(--ink); }
.shell main { max-width: 980px; padding: var(--s6) var(--gutter) var(--s8); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
