/* --ok/--warn/--fail : contraste WCAG AA vérifié (test/contrast.test.js) sur
   chaque paire texte/fond réellement utilisée — pas juste une couleur qui
   "a l'air" assez sombre. Toute retouche de ces trois variables doit
   repasser par ce test avant d'être considérée correcte. */
:root {
  --jaune: #ffd320;
  --noir: #141414;
  --sable: #ead9b0;
  --fond: #faf7f0;
  --carte: #ffffff;
  --bord: #ddd5c2;
  --texte: #222;
  --texte2: #6b6b6b;
  --ok: #27764a;
  --warn: #a15818;
  --fail: #b01c2f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
/* Anneau de focus clavier cohérent avec la palette plutôt que le style par
   défaut du navigateur, peu visible sur les boutons à fond sombre.
   :focus-visible (pas :focus) : n'apparaît qu'au clavier, jamais au clic
   souris, pour ne pas ajouter un halo permanent sur chaque bouton cliqué. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--jaune);
  outline-offset: 2px;
}
header.topbar {
  background: var(--noir);
  color: var(--jaune);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 20px;
  height: 52px;
  position: relative;
}
header.topbar .logo { font-weight: 800; font-size: 1.15em; letter-spacing: 0.5px; }
header.topbar .logo span { color: #fff; }
header.topbar nav { display: flex; gap: 4px; height: 100%; }
header.topbar nav a {
  color: #eee; text-decoration: none; padding: 0 14px;
  display: flex; align-items: center; font-size: 0.92em;
}
header.topbar nav a:hover { background: #2a2a2a; }
header.topbar nav a.active { background: var(--jaune); color: var(--noir); font-weight: 600; }
header.topbar .offline-badge {
  margin-left: auto; font-size: 0.75em; background: #444; color: #ffce54;
  padding: 3px 10px; border-radius: 12px; display: none;
}
header.topbar .user-badge { margin-left: auto; font-size: 0.82em; color: #ccc; white-space: nowrap; }
header.topbar .user-badge a { color: var(--jaune); text-decoration: none; }
header.topbar .user-badge a:hover { text-decoration: underline; }
header.topbar .nav-toggle {
  display: none; background: none; border: none; color: var(--jaune);
  font-size: 1.3em; line-height: 1; padding: 4px 6px; cursor: pointer;
}
/* Nav qui déborde d'un viewport étroit (pas de flex-wrap) : au lieu de laisser
   toute la page défiler horizontalement (les liens au-delà de "Cols" devenaient
   alors inatteignables sans le deviner), la nav bascule en menu déroulant sous
   un bouton ☰ en dessous de 720px. */
@media (max-width: 720px) {
  header.topbar { gap: 10px; }
  header.topbar nav { display: none; }
  header.topbar .nav-toggle { display: inline-block; }
  header.topbar.nav-open nav {
    display: flex; flex-direction: column; position: absolute;
    top: 52px; left: 0; right: 0; height: auto; background: var(--noir);
    z-index: 1000; padding: 6px 0; box-shadow: 0 6px 12px rgba(0,0,0,0.25);
  }
  header.topbar.nav-open nav a { padding: 12px 20px; }
  header.topbar .offline-badge, header.topbar .user-badge {
    font-size: 0.68em; max-width: 108px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }
}
main { max-width: 1160px; margin: 0 auto; padding: 18px 20px 60px; }
h1 { font-size: 1.45em; margin: 12px 0; }
h2 { font-size: 1.12em; margin: 22px 0 10px; border-bottom: 2px solid var(--jaune); padding-bottom: 4px; }
/* <details>/<summary> natif : divulgation progressive sans JS (archives.js
   par édition, archives.html pour la méthode de reconstitution — #22). */
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
details > :not(summary) { margin-left: 2px; }
/* Affordance de défilement horizontal (#23) : deux dégradés locaux (qui
   défilent avec le contenu, invisibles une fois arrivé au bout) + deux
   ombres fixes à l'écran (toujours à l'endroit exact du bord, discrètes) —
   pattern connu sous le nom de « scroll shadows ». Généralise à toute
   carte/table le pattern déjà posé pour #cmp-table (PR #24), qui masquait
   la deuxième moitié d'une comparaison sans qu'aucun indice ne le montre. */
.scrollx {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--carte) 30%, rgba(255,255,255,0)),
    linear-gradient(to left, var(--carte) 30%, rgba(255,255,255,0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.18), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), rgba(0,0,0,0)) 100% 0;
  background-repeat: no-repeat;
  background-color: var(--carte);
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.card {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 10px;
  padding: 16px; margin: 14px 0;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 240px; }
label.field { display: block; font-size: 0.82em; color: var(--texte2); margin-bottom: 10px; }
label.field input, label.field select {
  display: block; width: 100%; margin-top: 3px; padding: 7px 9px;
  border: 1px solid var(--bord); border-radius: 6px; font-size: 1.05em; background: #fff;
}
button, a.btn {
  background: var(--noir); color: var(--jaune); border: none; border-radius: 6px;
  padding: 8px 16px; font-size: 0.95em; cursor: pointer; text-decoration: none;
  display: inline-block;
}
button:hover, a.btn:hover { background: #333; }
button.secondary, a.btn.secondary { background: #eee; color: #333; border: 1px solid #ccc; }
button.danger { background: var(--fail); color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }
/* select:disabled : sans cette règle, frontend/tourmap.js désactivant
   #sel-edition pendant une animation retombait sur le rendu natif du
   navigateur — visuellement incohérent avec button:disabled (opacity 0.5
   explicite) juste au-dessus, alors que les deux contrôles sont désactivés
   ensemble, au même instant (trouvaille de relecture adverse, 27/08/2026). */
select:disabled { opacity: 0.5; cursor: default; }
/* a.btn[aria-disabled] : un <a> sans href n'est déjà pas navigable, mais
   restait visuellement identique à un bouton actif (trouvaille de
   revue-personas, 27/08/2026 — persona utilisateur peu technophile,
   frontend/tourmap.js "Mini-site HTML autonome" avant sélection d'édition)
   — clic sans effet, sans rien pour expliquer pourquoi. pointer-events
   redondant avec l'absence de href mais documente l'intention. */
a.btn[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.wp-list { list-style: none; margin: 0; padding: 0; }
.wp-list li {
  display: flex; gap: 8px; align-items: center; padding: 6px 0;
  border-bottom: 1px dashed var(--bord); position: relative;
}
.wp-list .idx { width: 26px; text-align: center; font-weight: 700; color: var(--texte2); }
.wp-list input.label { flex: 1; padding: 6px 8px; border: 1px solid var(--bord); border-radius: 6px; }
.wp-list select { padding: 6px; border: 1px solid var(--bord); border-radius: 6px; }
.wp-list .coords { font-size: 0.75em; color: var(--texte2); width: 120px; }
.wp-list button { padding: 4px 8px; font-size: 0.8em; }
/* Ligne de waypoint : idx + champ + select + coordonnées + 3 boutons ne
   tiennent pas sur une largeur mobile (~366px de contenu à taille fixe avant
   même le champ texte, qui a lui-même un contenu minimal incompressible) —
   ça forçait toute la page en scroll horizontal. En dessous de 600px, la
   ligne peut passer sur deux lignes plutôt que déborder. */
@media (max-width: 600px) {
  .wp-list li { flex-wrap: wrap; }
  .wp-list input.label { flex: 1 1 100%; }
  .suggest { right: 12px; }
}
.suggest {
  position: absolute; top: 100%; left: 34px; right: 220px; z-index: 1000;
  background: #fff; border: 1px solid var(--bord); border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); max-height: 220px; overflow: auto;
}
.suggest div { padding: 7px 10px; cursor: pointer; font-size: 0.9em; }
.suggest div:hover { background: var(--sable); }
#map, .stagemap { height: 420px; border-radius: 10px; border: 1px solid var(--bord); }
.stagemap { height: 380px; }
table.kmtable { border-collapse: collapse; width: 100%; font-size: 0.88em; }
table.kmtable th, table.kmtable td { border: 1px solid var(--bord); padding: 4px 8px; text-align: right; }
table.kmtable th { background: var(--sable); cursor: pointer; user-select: none; position: sticky; top: 0; }
table.kmtable tr:nth-child(even) { background: #f6f1e4; }
.kmtable-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--bord); border-radius: 8px; }
.checks li { margin: 4px 0; font-size: 0.92em; list-style: none; }
.checks .st { display: inline-block; width: 20px; font-weight: 700; }
.checks .ok .st { color: var(--ok); }
.checks .warn .st { color: var(--warn); }
.checks .fail .st { color: var(--fail); }
.badge {
  display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: 0.75em;
  background: #eee; color: #333; margin-left: 6px;
}
.badge.done { background: #d9efe1; color: var(--ok); }
.badge.generating { background: #fdf0d8; color: var(--warn); }
.badge.error { background: #fbdcdc; color: var(--fail); }
.badge.draft { background: #e8e8e8; }
.badge.done-checkfail { background: #fbdcdc; color: var(--fail); }
.sourced-badge { background: #d9efe1; color: var(--ok); }
.partial-badge { background: #fdf0d8; color: var(--warn); }
.progress-box { padding: 24px; text-align: center; }
.progress-bar { height: 10px; background: #eee; border-radius: 5px; overflow: hidden; margin: 12px auto; max-width: 480px; }
.progress-bar > div { height: 100%; background: var(--jaune); width: 0; transition: width 0.4s; }
.meta-line { color: var(--texte2); font-size: 0.9em; margin: 4px 0 12px; }
.note {
  background: #fdf6dd; border: 1px solid #e8d48a; border-radius: 8px;
  padding: 10px 14px; font-size: 0.88em; margin: 10px 0;
}
.reconstruction {
  background: #eef3fb; border: 1px solid #b8cbe8; border-radius: 8px;
  padding: 10px 14px; font-size: 0.92em; margin: 10px 0;
}
.stage-list { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.stage-list td, .stage-list th { padding: 7px 10px; border-bottom: 1px solid var(--bord); text-align: left; }
.stage-list tr:hover { background: #f6f1e4; }
.climb-card { margin: 18px 0; }
.fauxplat-list { list-style: none; margin: 0; padding: 0; }
.fauxplat-item { margin: 6px 0; font-size: 0.92em; }
.fauxplat-badge { background: #fdf0d8; color: var(--warn); margin-left: 0; margin-right: 8px; }
footer.attrib {
  border-top: 1px solid var(--bord); margin-top: 40px; padding: 14px 20px;
  font-size: 0.75em; color: var(--texte2); text-align: center;
}
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.mythic-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.mythic-card {
  background: var(--noir); color: var(--jaune); border: none; border-radius: 8px;
  padding: 10px 14px; cursor: pointer; text-align: left; min-width: 160px; flex: 1 1 200px;
  font-family: inherit;
}
.mythic-card:hover { background: #333; }
.mythic-card .year { display: block; font-weight: 700; font-size: 1.1em; }
.mythic-card .highlight { display: block; font-size: 0.85em; color: var(--sable); margin-top: 2px; }
.explorer-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.explorer-tile {
  border: none; border-radius: 6px; min-width: 52px; padding: 6px 4px;
  font-weight: 700; font-size: 0.85em; cursor: pointer; font-family: inherit; color: var(--noir);
}
.explorer-tile-unexplored { background: var(--bord); color: var(--texte); }
.explorer-tile-partial { background: #fdf0d8; color: var(--noir); }
.explorer-tile-complete { background: #d9efe1; color: var(--noir); }
.explorer-legend-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 2px;
}
.explorer-legend-swatch.explorer-tile-unexplored { background: var(--bord); }
.explorer-legend-swatch.explorer-tile-partial { background: #fdf0d8; }
.explorer-legend-swatch.explorer-tile-complete { background: #d9efe1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85em; margin: 8px 0; }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.pill { display:inline-flex; align-items:center; justify-content:center; width: 22px; height: 22px; border-radius: 50%; font-size: 0.72em; font-weight: 700; color:#fff; margin-right:6px; }
button.tab { border-radius: 6px 6px 0 0; }
button.tab.active { background: var(--jaune); color: var(--noir); font-weight: 700; }
table.stats { border-collapse: collapse; width: 100%; font-size: 0.9em; }
table.stats th, table.stats td { border-bottom: 1px solid var(--bord); padding: 6px 10px; text-align: right; }
table.stats th { background: var(--sable); cursor: pointer; user-select: none; white-space: nowrap; }
table.stats td:first-child, table.stats th:first-child { text-align: left; }
table.stats tr:hover { background: #f6f1e4; }
table.stats tfoot td { font-weight: 700; background: #f3ecd9; }
/* Comparateur (#cmp-table) : sur mobile, une vraie table à 3 colonnes (Métrique,
   Étape A, Étape B) fait sortir la colonne Étape B de l'écran — la moitié de la
   comparaison disparaît sans indice qu'elle existe. En dessous de 640px, chaque
   ligne devient un bloc empilé (métrique en titre, valeurs des deux étapes
   labellisées via data-label) plutôt que de compter sur un défilement horizontal
   invisible. */
@media (max-width: 640px) {
  #cmp-table thead { display: none; }
  #cmp-table, #cmp-table tbody, #cmp-table tr, #cmp-table td { display: block; width: 100%; }
  #cmp-table tr { border: 1px solid var(--bord); border-radius: 8px; margin: 10px 0; padding: 8px 10px; }
  #cmp-table td { border: none; padding: 3px 0; text-align: left; }
  #cmp-table td:first-child { font-weight: 700; border-bottom: 1px dashed var(--bord); padding-bottom: 5px; margin-bottom: 3px; }
  #cmp-table td:not(:first-child)::before { content: attr(data-label) " : "; color: var(--texte2); font-weight: 600; }
}
.statgrid { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.stat { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; padding: 10px 18px; text-align: center; flex: 1; min-width: 130px; }
.stat .v { font-size: 1.5em; font-weight: 800; }
.stat .l { font-size: 0.75em; color: var(--texte2); }
@media print {
  header.topbar, .toolbar, button, a.btn, footer.attrib { display: none !important; }
  .card, #map, .stagemap { border: none; box-shadow: none; }
  body { background: #fff; }
}
/* Visite guidée (Sprint 8) : recouvre toute la page, jamais scrollable
   sous elle (évite qu'un clic « au travers » sur mobile atteigne un lien de
   la page derrière — même préoccupation que le menu mobile ci-dessus). */
.tour-overlay {
  position: fixed; inset: 0; background: rgba(20,20,20,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px;
}
.tour-card {
  position: relative;
  background: var(--carte); border-radius: 12px; padding: 24px 28px;
  max-width: 480px; width: 100%; box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.tour-card h2 { margin: 4px 0 10px; padding-right: 24px; }
.tour-progress { color: var(--texte2); font-size: 0.8em; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.tour-actions { flex-wrap: wrap; margin-top: 16px; }
.tour-close-btn {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--texte2);
  width: 30px; height: 30px; border-radius: 6px; font-size: 1.1em; line-height: 1;
  cursor: pointer; padding: 0;
}
.tour-close-btn:hover { background: var(--bord); color: var(--texte); }
