/* Composants de base du style de Theo, en CSS pur. Prérequis dans la page, dans cet ordre : design/gen/tokens.css, puis ce fichier (il charge jetons-web.css).
   Le mode se pose par un attribut sur la racine ou sur une zone : <html data-mode="nuit"> ou "papier". Aucune couleur, police ni taille n'est écrite ici. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
[data-mode] { background: var(--fond); color: var(--texte); }
body, [data-mode] { font-family: var(--police-texte); font-size: var(--t-corps); line-height: var(--interligne); font-variant-numeric: tabular-nums; }

/* Mise en page */
.page { max-width: var(--largeur-page); margin: 0 auto; padding: 0 var(--gouttiere); }
.colonne { max-width: var(--largeur-texte); }
.section { padding: var(--w-8) 0; }
.section > h2:first-child, header > h2:first-child { margin-top: 0; }
.pile > * + * { margin-top: var(--w-3); }
.large { margin-top: var(--w-6); }

/* Titres et texte courant : un seul poids fort, des tailles qui respirent, casse de phrase. */
h1, h2, h3 { font-family: var(--police-texte); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: var(--t-titre); max-width: 18ch; }
h2 { font-size: var(--t-titre-2); margin-top: var(--w-8); }
h3 { font-size: var(--t-sous-titre); line-height: 1.25; letter-spacing: -0.01em; margin-top: var(--w-6); }
p { margin: 0 0 var(--w-3); max-width: var(--largeur-texte); text-wrap: pretty; }
.chapeau { font-size: calc(var(--t-corps) * 1.2); color: var(--texte-second); max-width: var(--largeur-texte); }
.second { color: var(--texte-second); }
.note { font-size: var(--t-note); color: var(--texte-second); }
strong, b { font-weight: 700; }
h1 + *, h2 + *, h3 + * { margin-top: var(--w-3); }
h1 + .chapeau { margin-top: var(--w-4); }

/* Lien : accent, souligné fin. */
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: var(--trait-fin); text-underline-offset: 0.22em; }
a:hover { text-decoration-thickness: var(--trait-fort); }
:focus-visible { outline: var(--trait-fort) solid var(--accent); outline-offset: 3px; }

/* Boutons : le principal est plein, l'accent sur le fond ; le discret n'a que du texte. */
.bouton, .bouton-discret { display: inline-block; font: 600 var(--t-corps) / 1 var(--police-texte); padding: var(--w-2) var(--w-4); border: 0; cursor: pointer; text-decoration: none; }
.bouton { background: var(--accent); color: var(--fond); }
.bouton:hover { background: var(--texte); }
.bouton-discret { background: none; color: var(--texte); padding-left: 0; padding-right: 0; text-decoration: underline; text-decoration-thickness: var(--trait-fin); text-underline-offset: 0.3em; }
.bouton-discret:hover { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--w-3) var(--w-6); }

/* Chiffre avec son libellé, dans la même ligne. */
.chiffre { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--w-1) var(--w-2); }
.chiffre b { font-size: var(--t-chiffre); line-height: 1; letter-spacing: -0.03em; color: var(--accent); }
.chiffre span { font-size: var(--t-corps); font-weight: 500; color: var(--texte-second); }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--w-6); }

/* Carte : posée à plat sur la page, ni case, ni surface, ni filet : du vide autour. */
.cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--w-6) var(--w-8); }
.carte { padding: 0; }
.carte h3 { margin-top: 0; }
.carte p { color: var(--texte-second); margin: var(--w-2) 0 0; }
a.carte { display: block; color: inherit; text-decoration: none; }
a.carte:hover h3 { color: var(--accent); }

/* Liste : le carreau est la puce. */
ul, ol { margin: 0; padding: 0; list-style: none; max-width: var(--largeur-texte); }
li { position: relative; padding-left: var(--w-4); margin-bottom: var(--w-2); }
ul > li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 0.5em; height: 0.5em; background: var(--matiere-2); }
ol { counter-reset: n; }
ol > li { counter-increment: n; padding-left: var(--w-6); }
ol > li::before { content: counter(n); position: absolute; left: 0; top: 0; font-weight: 700; color: var(--accent); }

/* Citation : du corps, de l'air, aucun filet. */
blockquote { margin: var(--w-8) 0; padding: 0; max-width: calc(var(--largeur-texte) * 1.15); }
blockquote p { font-size: var(--t-citation); line-height: 1.3; font-weight: 600; letter-spacing: -0.015em; max-width: none; margin: 0; text-wrap: balance; }
blockquote cite, blockquote footer { display: block; margin-top: var(--w-3); font-size: var(--t-note); font-style: normal; color: var(--texte-second); }

/* Étiquette : un mot de typographie, sans pastille ni capitales. */
.etiquette { display: inline-block; font-size: var(--t-etiquette); font-weight: 600; line-height: 1; color: var(--texte-second); }
.etiquette.vive { color: var(--accent); }

/* Tableau simple : des rangées séparées par du vide, une colonne mise en avant. */
table { border-collapse: collapse; width: 100%; max-width: calc(var(--largeur-texte) * 1.3); font-size: var(--t-corps); }
th, td { text-align: left; padding: var(--w-2) var(--w-3) var(--w-2) 0; font-weight: 400; vertical-align: baseline; }
th { font-size: var(--t-note); font-weight: 600; color: var(--texte-second); }
td.num, th.num { text-align: right; }
th.fort, td.fort { color: var(--accent); font-weight: 700; padding-left: var(--w-3); padding-right: var(--w-3); }
.defile { overflow-x: auto; }

/* Bloc de code : à plat, sans filet ; la police est celle du texte (pas de chasse fixe), les espaces sont gardés. */
pre { margin: 0; padding: var(--w-3) 0; overflow-x: auto; font: 500 var(--t-note) / 1.7 var(--police-mesure); max-width: calc(var(--largeur-texte) * 1.3); }
code { font-family: var(--police-mesure); font-size: 0.95em; }

/* Navigation minimale : la marque, quelques liens, rien d'autre. */
.nav { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--w-1) var(--w-4); padding: var(--w-3) 0; font-size: var(--t-note); font-weight: 600; }
.nav .marque { color: inherit; text-decoration: none; font-weight: 700; font-size: var(--t-corps); }
.nav ul { display: flex; flex-wrap: wrap; gap: var(--w-1) var(--w-4); max-width: none; }
.nav li { padding: 0; margin: 0; }
.nav li::before { display: none; }
.nav a { color: inherit; text-decoration: none; }
.nav a:hover, .nav a[aria-current] { text-decoration: underline; text-decoration-thickness: var(--trait-fin); text-underline-offset: 0.3em; }

/* Pied de page : une ligne de texte, la signature à droite. */
.pied { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--w-2) var(--w-6); padding: var(--w-8) 0 var(--w-6); font-size: var(--t-note); color: var(--texte-second); }
.pied a { color: inherit; }
.pied .signature { color: var(--texte); font-weight: 600; margin-left: auto; }

/* Bandeau de titre posé sur un fond grainé (fond.js). Le fond est toujours sombre : le texte y est du papier dans les deux modes. */
.bandeau { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: clamp(32rem, 100vh, 46rem); background: var(--encre-nuit); color: var(--encre-papier); }
/* fond.js enveloppe le canvas dans .fond-plan, qui porte le fond sombre et le masque du fondu : le bandeau n'a alors plus de fond propre. */
.bandeau:has(> .fond-plan) { background: none; }
.fond-plan { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: var(--encre-nuit); -webkit-mask-image: var(--masque-bandeau); mask-image: var(--masque-bandeau); }
.fond-plan > canvas.fond { position: absolute; display: block; will-change: transform; }
.fond-plan > .calque { position: absolute; inset: 0; will-change: transform; }
.fond-plan .lueur { position: absolute; border-radius: 50%; will-change: transform, opacity; }
.bandeau > .page { position: relative; width: 100%; flex: 1; display: flex; flex-direction: column; }
.bandeau .nav { color: var(--encre-papier); }
.bandeau .titre { margin-top: auto; padding: var(--w-8) 0 var(--w-6); }
.bandeau h1 { color: var(--encre-papier); max-width: 22ch; }
.bandeau .chapeau { color: var(--encre-ciel); max-width: 24rem; }
.bandeau.texte-haut .titre { margin-top: var(--w-2); margin-bottom: auto; padding-top: 0; }
@media (min-width: 40rem) { .bandeau.texte-haut-large .titre { margin-top: var(--w-2); margin-bottom: auto; padding-top: 0; } }
.bandeau a { color: var(--encre-papier); }
.bandeau .bouton { background: var(--encre-papier); color: var(--encre-nuit); }
.bandeau .bouton:hover { background: var(--encre-lavande); }

/* Blocs de donnée (construits par blocs.js) */
figure { margin: 0; }
figcaption, .legende { font-size: var(--t-note); color: var(--texte-second); margin-top: var(--w-3); max-width: var(--largeur-texte); }
.bloc canvas { display: block; }
/* réglette cotée */
.reglette { position: relative; padding: var(--w-6) 0; max-width: 46rem; }
.reglette canvas { width: 100%; height: var(--reglette-hauteur); }
.cote { position: absolute; left: 0; height: var(--trait-filet); background: var(--trait); font-size: var(--t-note); font-weight: 600; }
.cote::before, .cote::after { content: ""; position: absolute; top: calc(var(--w-1) * -0.5); width: var(--trait-filet); height: var(--w-1); background: var(--trait); }
.cote::before { left: 0; } .cote::after { right: 0; }
.cote span { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.cote.haut { top: calc(var(--w-4)); } .cote.haut span { bottom: var(--w-1); }
.cote.bas { bottom: calc(var(--w-4)); width: 100%; } .cote.bas span { top: var(--w-1); }
/* carré dans le carré */
.carre canvas { width: var(--carre-cote); max-width: 100%; aspect-ratio: 1; }
.legendes { display: flex; flex-wrap: wrap; gap: var(--w-1) var(--w-6); margin-top: var(--w-4); font-size: var(--t-note); }
.legendes span::before { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-right: var(--w-1); vertical-align: -0.1em; background: var(--pastille, var(--matiere-2)); }
.legendes .reste { --pastille: var(--discret-2); }
/* barres en dégradé grainé */
.barres .trace { display: flex; align-items: flex-end; gap: var(--w-3); height: var(--barres-hauteur); max-width: 44rem; padding-bottom: 0; border-bottom: var(--trait-filet) solid var(--trait); }
.barres .barre { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; min-width: 0; }
.barres .barre b { font-size: var(--t-note); text-align: center; margin-bottom: var(--w-1); font-weight: 700; }
.barres .barre canvas { width: 100%; }
.barres .noms { display: flex; gap: var(--w-3); max-width: 44rem; margin-top: var(--w-1); font-size: var(--t-etiquette); color: var(--texte-second); }
.barres .noms span { flex: 1; text-align: center; min-width: 0; overflow-wrap: break-word; line-height: 1.25; }
/* pentes à points */
.pentes { font-size: var(--t-note); }
.pentes svg { display: block; width: 100%; max-width: 40rem; height: auto; overflow: visible; font-family: var(--police-texte); }
.pentes .grille { stroke: var(--trait); stroke-width: var(--trait-filet); opacity: var(--grille-opacite); }
.pentes .axe { stroke: var(--trait); stroke-width: var(--trait-filet); opacity: 0.7; }
.pentes .echelle, .pentes .colonne-nom { fill: var(--texte-second); }
.pentes .colonne-nom { fill: var(--texte); font-weight: 600; }
.pentes .point { stroke: var(--fond); stroke-width: var(--trait-fort); }
@media (max-width: 40rem) { .bandeau { min-height: 44rem; --fondu-debut: 56%; } .bandeau.grand { min-height: 66rem; } .bandeau .titre { padding-bottom: var(--w-4); } .large { margin-top: var(--w-4); } .section { padding: var(--w-6) 0; } }
.pentes text { font-size: var(--t-note); font-weight: 600; }
.pentes .echelle { font-weight: 500; font-size: var(--t-etiquette); }
.pentes .colonne-nom { font-size: var(--t-note); }
