/* Polices embarquées (licence SIL OFL), aucun appel à un service tiers */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --encre: #16203a;
  --sourdine: #56627c;
  --papier: #eef1f6;
  --surface: #ffffff;
  --trait: #d3dae6;
  --accent: #b3245a;
  --accent-pale: #fbe9f0;
  --p0: #f2cf5b;
  --p1: #7fc36d;
  --p2: #1f9c8a;
  --p3: #2f4b8c;
  --titre: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --texte: "Figtree", "Segoe UI", system-ui, sans-serif;
  --volet: 468px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--texte);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--encre);
  background: var(--papier);
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 0; background: var(--encre); color: #fff; padding: .5rem 1rem; z-index: 2000; }
.skip:focus { left: 0; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: var(--volet) 1fr; height: 100%; }
.volet {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--trait);
  overflow-y: auto; overscroll-behavior: contain;
}
.carte-zone { position: relative; min-height: 0; }
#carte { position: absolute; inset: 0; background: #dfe6ef; }

.entete { padding: 1.2rem 1.5rem .2rem; }
.entete h1 {
  font-family: var(--titre); font-weight: 700; font-size: 1.5rem; line-height: 1.1;
  letter-spacing: -.02em; margin: 0;
}
.sous-titre { margin: .3rem 0 0; color: var(--sourdine); font-size: .92rem; }
/* Le crédit reste épinglé en haut de la colonne quand on la fait défiler */
.credit-sentinelle { height: 1px; margin-bottom: -1px; }
.credit-bar { position: sticky; top: 0; z-index: 1100; background: var(--surface); padding: .45rem 1.5rem .5rem; }
.credit-bar.colle { box-shadow: 0 1px 0 var(--trait), 0 8px 16px rgba(22, 32, 58, .08); }
.credit { margin: 0; font-size: .92rem; font-weight: 700; }
.credit a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.credit a:hover { text-decoration-thickness: 2px; }
.credit-livre { margin-top: .1rem; font-weight: 400; }
.credit-livre a { font-weight: 700; font-style: italic; }
/* Le livre clignote pour attirer l'oeil ; l'animation est coupée pour les personnes qui ont demandé moins de mouvement (règle en fin de fichier) */
.clignote { display: inline-block; margin-right: .15rem; font-style: normal; animation: clignote 1.1s steps(1, end) infinite; }
@keyframes clignote { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .15; } }

/* ---------- Recherche ---------- */
.recherche { padding: .45rem 1.5rem 0; }
.recherche label, .etiquette { display: block; font-size: .82rem; font-weight: 700; color: var(--sourdine); margin-bottom: .3rem; }
.champ { position: relative; }
.champ input {
  width: 100%; padding: .7rem .85rem; border: 2px solid var(--encre); border-radius: 10px; background: var(--surface);
}
.champ input::placeholder { color: #7d879c; }
.suggestions {
  position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
  background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; box-shadow: 0 14px 34px rgba(22, 32, 58, .18);
  max-height: 22rem; overflow-y: auto;
}
.suggestions li { padding: .5rem .6rem; border-radius: 7px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--accent-pale); }
.suggestions .s-nom { display: block; font-weight: 700; }
.suggestions .s-lieu { display: block; font-size: .85rem; color: var(--sourdine); }
.suggestions .vide { cursor: default; color: var(--sourdine); }
.suggestions .vide:hover { background: none; }

/* ---------- Filtres ---------- */
.filtres { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1rem; padding: .9rem 1.5rem 1rem; border-bottom: 1px solid var(--trait); }
.filtre-annee, .filtre-mesure, .filtre:last-child { grid-column: 1 / -1; }
.segments.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 2px solid var(--encre); border-radius: 10px; overflow: hidden; }
.segments.deux button { border: 0; border-radius: 0; padding: .55rem .4rem; font-size: .95rem; }
.segments.deux button + button { border-left: 2px solid var(--encre); }
select {
  width: 100%; padding: .55rem 2rem .55rem .7rem; border: 1px solid #9aa5ba; border-radius: 8px; background: var(--surface);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--encre) 50%), linear-gradient(135deg, var(--encre) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.pastilles, .segments { display: flex; flex-wrap: wrap; gap: .35rem; }
.pastilles button, .segments button {
  padding: .36rem .66rem; border: 1px solid #9aa5ba; border-radius: 999px; background: var(--surface); font-size: .9rem;
}
.pastilles button[aria-pressed="true"], .segments button[aria-pressed="true"] {
  background: var(--encre); border-color: var(--encre); color: #fff; font-weight: 700;
}
.pastilles button:disabled { opacity: .45; cursor: default; }
.pastilles button.sans-score { border-style: dashed; }
.note-filtre { margin: .35rem 0 0; font-size: .8rem; color: var(--sourdine); }

.bascule { display: none; }

/* ---------- Contenu du volet ---------- */
.contenu { padding: 1.1rem 1.5rem 1.5rem; flex: 1 0 auto; }
.contenu:focus { outline: none; }

.fil { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .4rem; font-size: .9rem; margin: 0 0 .7rem; padding: 0; list-style: none; color: var(--sourdine); }
.fil li + li::before { content: "›"; margin-right: .4rem; color: #9aa5ba; }
.fil button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.contenu h2 { font-family: var(--titre); font-weight: 700; font-size: 1.42rem; line-height: 1.12; letter-spacing: -.015em; margin: 0; }
.contexte { margin: .3rem 0 0; color: var(--sourdine); font-size: .93rem; }
.fiche-meta { margin: .45rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; list-style: none; font-size: .86rem; }
.fiche-meta li { background: var(--papier); border-radius: 6px; padding: .16rem .5rem; }
.fiche-meta button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.bloc { margin-top: 1.5rem; }
.bloc h3 { font-family: var(--titre); font-weight: 650; font-size: 1.04rem; margin: 0 0 .15rem; }
.bloc .aide { margin: 0 0 .6rem; font-size: .86rem; color: var(--sourdine); }
.bloc-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.tri { border: 0; background: none; padding: 0; font-size: .86rem; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

/* ---------- L'escalier : répartition par palier ---------- */
.escalier { display: flex; align-items: flex-end; gap: 2px; height: var(--h, 64px); }
.escalier .marche { min-width: 0; border-radius: 3px 3px 0 0; }
.escalier .m0 { background: var(--p0); height: 46%; }
.escalier .m1 { background: var(--p1); height: 64%; }
.escalier .m2 { background: var(--p2); height: 82%; }
.escalier .m3 { background: var(--p3); height: 100%; }
.escalier .nc { height: 30%; background: repeating-linear-gradient(135deg, #c3cad8 0 4px, #e3e7ef 4px 8px); }
.escalier.mini { --h: 20px; gap: 1px; }
.escalier.mini .marche { border-radius: 2px 2px 0 0; }

.synthese { margin-top: 1rem; }
.synthese .escalier { --h: 84px; border-bottom: 2px solid var(--encre); }
.paliers { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .7rem 0 0; padding: 0; list-style: none; }
.paliers li { border-top: 5px solid var(--c); padding-top: .3rem; }
.paliers .nom { display: block; font-size: .82rem; color: var(--sourdine); }
.paliers .part { display: block; font-family: var(--titre); font-weight: 700; font-size: 1.3rem; line-height: 1.1; }
.paliers .nb { display: block; font-size: .8rem; color: var(--sourdine); }

.note-nc { margin: .7rem 0 0; font-size: .86rem; color: var(--sourdine); }
.note-nc i { display: inline-block; width: .8rem; height: .8rem; margin-right: .4rem; vertical-align: -1px; border-radius: 2px; background: repeating-linear-gradient(135deg, #c3cad8 0 3px, #e3e7ef 3px 6px); }
.chiffres { display: flex; flex-wrap: wrap; gap: .3rem 1.6rem; margin: .95rem 0 0; padding: 0; list-style: none; font-size: .93rem; }
.chiffres strong { font-family: var(--titre); font-size: 1.08rem; }

.avis { margin-top: 1rem; padding: .8rem 1rem; border-left: 4px solid var(--p0); background: #fdf8e3; border-radius: 0 8px 8px 0; font-size: .94rem; }
.avis p { margin: 0; }
.avis p + p { margin-top: .4rem; }

/* ---------- Onglets et classement ---------- */
.onglets { display: flex; gap: 1.4rem; margin: 1rem 0 0; border-bottom: 1px solid var(--trait); }
.onglets button { border: 0; background: none; padding: .45rem 0; margin-bottom: -1px; border-bottom: 3px solid transparent; font-weight: 700; color: var(--sourdine); }
.onglets button[aria-selected="true"] { color: var(--encre); border-bottom-color: var(--accent); }
.onglets button:hover { color: var(--encre); }
.classement { counter-reset: none; }
.ligne.rang { grid-template-columns: 2.1rem minmax(0, 1.35fr) minmax(0, .9fr) 3.1rem; gap: .6rem; }
.ligne.rang .rg { font-family: var(--titre); font-weight: 700; font-size: 1.15rem; color: var(--accent); text-align: right; }
.classement li:nth-child(n+4) .rg { color: var(--sourdine); }
.puces { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.puces button { padding: .36rem .7rem; border: 1px solid var(--encre); border-radius: 999px; background: var(--surface); font-size: .9rem; }
.puces button:hover { background: var(--encre); color: #fff; }
.bloc-tete .segments button { padding: .28rem .62rem; font-size: .86rem; }

.pastille-rang { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--encre); color: #fff; border: 2px solid #fff; font-family: var(--titre); font-weight: 700; font-size: .72rem; box-shadow: 0 1px 4px rgba(22, 32, 58, .4); cursor: pointer; }
.pastille-rang.podium { background: var(--accent); }

/* ---------- Score de certification ---------- */
.score-tete { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; margin: 1rem 0 .2rem; }
.score-tete strong { font-family: var(--titre); font-weight: 700; font-size: 3rem; line-height: 1; letter-spacing: -.03em; }
.score-tete .unite { font-family: var(--titre); font-weight: 600; font-size: 1.2rem; }
.score-tete .legende-score { flex-basis: 100%; color: var(--sourdine); font-size: .93rem; }
.jauge { position: relative; height: 20px; background: linear-gradient(var(--trait), var(--trait)) center / 100% 2px no-repeat; }
.jauge .boite { position: absolute; top: 5px; height: 10px; border-radius: 3px; background: var(--p2); opacity: .55; }
.jauge .mediane { position: absolute; top: 2px; width: 3px; height: 16px; margin-left: -1.5px; background: var(--p3); border-radius: 1px; }
.jauge .point { position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.jauge.grande { height: 34px; margin-top: .7rem; }
.jauge.grande .boite { top: 8px; height: 18px; }
.jauge.grande .mediane { top: 3px; height: 28px; width: 4px; margin-left: -2px; }
.jauge.grande .point { top: 9px; width: 16px; height: 16px; margin-left: -8px; }
.axe { display: flex; justify-content: space-between; font-size: .8rem; color: var(--sourdine); margin-top: .1rem; }
.rang { margin: .8rem 0 0; font-size: .95rem; }
.partie { margin-top: 2rem; padding-top: 1.1rem; border-top: 3px solid var(--encre); }
.partie h3 { font-family: var(--titre); font-weight: 700; font-size: 1.22rem; margin: 0; }
.partie p { margin: .15rem 0 0; font-size: .88rem; color: var(--sourdine); }
.fiche-meta + .partie { margin-top: 1.2rem; }

/* ---------- Lignes de comparaison ---------- */
.lignes { margin: .3rem 0 0; padding: 0; list-style: none; }
.lignes li { border-top: 1px solid var(--trait); }
.lignes li:last-child { border-bottom: 1px solid var(--trait); }
.ligne {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 3.1rem; gap: .75rem; align-items: center;
  width: 100%; padding: .5rem .3rem; border: 0; background: none; text-align: left;
}
button.ligne:hover { background: var(--papier); }
.ligne[aria-current="true"], .ligne[aria-pressed="true"] { background: var(--accent-pale); box-shadow: inset 4px 0 0 var(--accent); padding-left: .65rem; }
.ligne .lib { min-width: 0; }
.ligne .lib b { display: block; font-weight: 700; overflow-wrap: anywhere; }
.ligne .lib small { display: block; font-size: .82rem; color: var(--sourdine); }
.ligne .indice { text-align: right; font-family: var(--titre); font-weight: 700; }
.ligne .nc { grid-column: 2 / -1; font-size: .85rem; color: var(--sourdine); }
.plus { margin-top: .7rem; padding: .5rem .9rem; border: 1px solid var(--encre); border-radius: 999px; background: var(--surface); font-size: .93rem; }

/* ---------- Courbe d'évolution ---------- */
.courbe svg { display: block; width: 100%; height: auto; overflow: visible; }
.courbe .grille { stroke: var(--trait); stroke-width: 1; }
.courbe text { font-family: var(--texte); font-size: 11.5px; fill: var(--sourdine); }
.courbe .annee-active { fill: var(--encre); font-weight: 700; }
.cles { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin: 0 0 .5rem; padding: 0; list-style: none; font-size: .86rem; }
.cles li::before { content: ""; display: inline-block; width: 1.3rem; height: 0; border-top: 3px solid var(--c); margin-right: .4rem; vertical-align: middle; }
.cles li.tirets::before { border-top-style: dashed; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.actions button { padding: .5rem .9rem; border: 1px solid var(--encre); border-radius: 999px; background: var(--surface); font-size: .93rem; }
.actions button:hover, .plus:hover { background: var(--encre); color: #fff; }

/* ---------- Pied ---------- */
.pied { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1rem; padding: .8rem 1.5rem 1rem; border-top: 1px solid var(--trait); font-size: .84rem; color: var(--sourdine); }
.lien { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Carte ---------- */
.territoires { position: absolute; z-index: 800; top: 12px; right: 12px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem; max-width: 70%; }
.territoires button { padding: .3rem .65rem; border: 1px solid var(--trait); border-radius: 999px; background: var(--surface); font-size: .84rem; box-shadow: 0 2px 6px rgba(22, 32, 58, .14); }
.territoires button:hover, .territoires select:hover { border-color: var(--encre); }
.territoires select { width: auto; padding: .3rem 1.7rem .3rem .65rem; border: 1px solid var(--trait); border-radius: 999px; font-size: .84rem; box-shadow: 0 2px 6px rgba(22, 32, 58, .14); background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; }
.legende {
  position: absolute; z-index: 800; left: 12px; bottom: 24px; width: 236px; padding: .7rem .8rem .6rem;
  background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; box-shadow: 0 2px 8px rgba(22, 32, 58, .14); font-size: .83rem;
}
.legende b { display: block; margin-bottom: .4rem; font-size: .86rem; }
.legende .rampe { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--p0), var(--p1), var(--p2), var(--p3)); }
.legende .bornes { display: flex; justify-content: space-between; margin-top: .2rem; color: var(--sourdine); }
.legende .gris { display: flex; align-items: center; gap: .4rem; margin-top: .45rem; color: var(--sourdine); }
.legende .gris.texte { display: block; line-height: 1.3; }
.legende .gris i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #8d97aa; background: #fff; flex: none; }
.leaflet-container { font-family: var(--texte); }
.leaflet-tooltip.bulle { border: 0; border-radius: 8px; padding: .4rem .6rem; box-shadow: 0 6px 18px rgba(22, 32, 58, .25); color: var(--encre); font-size: .86rem; }
.bulle b { display: block; }

/* ---------- Filigrane de la carte ---------- */
:root { --filigrane-opacite: .17; } /* à augmenter pour un filigrane plus marqué, à réduire pour plus de discrétion */
.filigrane-cadre { position: absolute; left: 0; top: 0; overflow: hidden; pointer-events: none; }
.filigrane {
  position: absolute; left: -50%; top: -50%; width: 200%; height: 200%; transform: rotate(-24deg);
  display: flex; flex-wrap: wrap; justify-content: space-around; align-content: space-around; gap: 118px 84px;
  pointer-events: none; user-select: none; opacity: var(--filigrane-opacite);
}
.filigrane span { font-family: var(--titre); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; white-space: nowrap; color: var(--encre); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.filigrane span:nth-child(3n) { margin-left: 70px; }
.signature-carte {
  position: absolute; z-index: 800; left: 12px; top: 12px; padding: .2rem .55rem; border-radius: 6px;
  font-family: var(--titre); font-weight: 700; font-size: .86rem; color: var(--encre); text-decoration: none;
  background: rgba(255, 255, 255, .78); box-shadow: 0 1px 4px rgba(22, 32, 58, .15);
}
.signature-carte:hover { background: #fff; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Boîte "comprendre ces données" ---------- */
.apropos { width: min(44rem, calc(100% - 2rem)); max-height: calc(100% - 2rem); border: 0; border-radius: 14px; padding: 1.6rem 1.8rem; color: var(--encre); box-shadow: 0 30px 80px rgba(22, 32, 58, .4); }
.apropos::backdrop { background: rgba(22, 32, 58, .5); }
.apropos h2 { font-family: var(--titre); font-size: 1.4rem; margin: 0 0 .6rem; }
.apropos h3 { font-family: var(--titre); font-size: 1.02rem; margin: 1.1rem 0 .2rem; }
.apropos p, .apropos li { max-width: 68ch; }
.apropos p { margin: .3rem 0; }
.apropos a { color: var(--accent); }
.apropos .fermer { float: right; padding: .35rem .8rem; border: 1px solid var(--encre); border-radius: 999px; background: var(--surface); }

.etat { padding: 2rem 0; }
.etat h2 { margin-bottom: .5rem; }
.etat code { background: var(--papier); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }

/* ---------- Petits écrans ---------- */
@media (max-width: 920px) {
  .app { display: flex; flex-direction: column; height: auto; min-height: 100%; }
  .volet { border-right: 0; overflow: visible; }
  .entete { padding: 1.1rem 1.1rem .3rem; }
  .entete h1 { font-size: 1.4rem; max-width: none; }
  .recherche { padding: .4rem 1.1rem 0; }
  .credit-bar { padding: .4rem 1.1rem .45rem; }
  .credit { font-size: .88rem; }
  .contenu { scroll-margin-top: calc(var(--credit-h, 0px) + 3.4rem); }
  .filtres { padding: .9rem 1.1rem 1rem; }
  .contenu { padding: 1rem 1.1rem 1.3rem; }
  .pied { padding: .8rem 1.1rem 1rem; }
  .bascule { display: flex; position: sticky; top: var(--credit-h, 0px); z-index: 900; background: var(--surface); border-bottom: 1px solid var(--trait); }
  .bascule button { flex: 1; padding: .7rem; border: 0; background: none; border-bottom: 3px solid transparent; font-weight: 700; color: var(--sourdine); }
  .app[data-vue="carte"] .bascule button[data-vue="carte"],
  .app[data-vue="donnees"] .bascule button[data-vue="donnees"] { color: var(--encre); border-bottom-color: var(--accent); }
  .carte-zone { height: 68vh; min-height: 360px; }
  .app[data-vue="carte"] .contenu, .app[data-vue="carte"] .pied { display: none; }
  .app[data-vue="donnees"] .carte-zone { display: none; }
  .sous-titre { display: none; }
  .territoires { left: 12px; right: 12px; max-width: none; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .territoires button { flex: none; }
  .legende { width: 200px; bottom: 28px; }
  .signature-carte { top: 52px; font-size: .8rem; }
  .filigrane { gap: 88px 40px; }
  .filigrane span { font-size: .95rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
