/* HandiRando — interface pensée pour le doigt et la lisibilité :
   cibles de 48 px minimum, texte 17 px, contrastes forts, rien qui exige un geste fin. */
:root {
  --vert: #14532d; --vert-2: #1d6b3c; --vert-clair: #e7f2ea;
  --sable: #faf7f0; --encre: #1c1f1d; --gris: #5b625e; --trait: #dcd6c8;
  --ok: #15803d; --moyen: #e07b00; --non: #b91c1c; --inconnu: #8a94a3;
  --rayon: 14px; --ombre: 0 6px 24px rgb(0 0 0 / .16);
  --haut: 58px; --bas: 66px;
  font-size: 17px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--encre); background: var(--sable); line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--vert-2); }
:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- en-tête ---------- */
.entete {
  position: fixed; inset: 0 0 auto 0; height: calc(var(--haut) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0;
  display: flex; align-items: center; gap: 8px; background: var(--vert); color: #fff; z-index: 20;
}
.marque { display: flex; align-items: center; gap: 7px; color: #fff; text-decoration: none; font-size: 1.12rem; letter-spacing: .01em; flex: none; }
.marque b { color: #bef264; }
.recherche { position: relative; flex: 1; min-width: 0; }
.recherche input { width: 100%; height: 42px; border: 0; border-radius: 21px; padding: 0 16px; background: #fff; color: var(--encre); }
.suggestions { position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: #fff; color: var(--encre); border-radius: 12px; box-shadow: var(--ombre); z-index: 30; }
.suggestions li button { width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; min-height: 48px; border-radius: 8px; cursor: pointer; }
.suggestions li button:hover, .suggestions li button:focus { background: var(--vert-clair); }
.suggestions small { color: var(--gris); display: block; }
.puce-profil { flex: none; height: 42px; border-radius: 21px; border: 2px solid #ffffff66; background: #ffffff1f; color: #fff; padding: 0 12px; cursor: pointer; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .marque span { display: none; } .puce-profil .long { display: none; } }

/* ---------- carte ---------- */
#carte { position: fixed; top: calc(var(--haut) + env(safe-area-inset-top)); left: 0; right: 0; bottom: calc(var(--bas) + env(safe-area-inset-bottom)); }
.maplibregl-ctrl-attrib { font-size: 11px; }
.flottants { position: fixed; right: 10px; top: calc(var(--haut) + env(safe-area-inset-top) + 10px); display: flex; flex-direction: column; gap: 10px; z-index: 10; }
.rond { width: 50px; height: 50px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--ombre); font-size: 1.3rem; cursor: pointer; color: var(--vert); font-weight: 700; }
.rond.actif { background: var(--vert); color: #fff; }
.bulle-zoom { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--haut) + env(safe-area-inset-top) + 12px); background: #1c1f1dde; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: .9rem; z-index: 10; pointer-events: none; max-width: calc(100vw - 140px); text-align: center; }
.bulle-zoom.chargement { top: calc(var(--haut) + env(safe-area-inset-top) + 54px); }

/* ---------- onglets ---------- */
.onglets { position: fixed; inset: auto 0 0 0; height: calc(var(--bas) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: #fff; border-top: 1px solid var(--trait); z-index: 20; }
.onglets a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; text-decoration: none; color: var(--gris); font-size: .82rem; font-weight: 600; }
.onglets a span { font-size: 1.35rem; line-height: 1; }
.onglets a[aria-current="page"] { color: var(--vert); box-shadow: inset 0 3px 0 var(--vert); }

/* ---------- panneau ---------- */
.panneau {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bas) + env(safe-area-inset-bottom)); z-index: 15;
  background: var(--sable); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgb(0 0 0 / .18);
  max-height: 58%; display: flex; flex-direction: column; transition: max-height .2s ease;
}
.panneau.grand { max-height: calc(100% - var(--haut) - var(--bas) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px); }
.panneau.petit { max-height: 34%; }
.poignee { flex: none; height: 26px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.poignee span { width: 46px; height: 5px; border-radius: 3px; background: #b9b2a2; }
.panneau-contenu { overflow-y: auto; padding: 0 16px 18px; overscroll-behavior: contain; }
@media (min-width: 900px) {
  .panneau, .panneau.grand, .panneau.petit { top: calc(var(--haut) + 12px); bottom: 12px; left: 12px; right: auto; width: 410px; max-height: none; border-radius: 18px; }
  .poignee { display: none; }
  .panneau-contenu { padding-top: 16px; }
  .onglets { inset: auto auto 12px 434px; width: 380px; border-radius: 16px; border: 1px solid var(--trait); box-shadow: var(--ombre); height: var(--bas); padding: 0; overflow: hidden; }
  #carte { bottom: 0; }
  .flottants { right: 12px; }
}

/* ---------- éléments communs ---------- */
h1, h2, h3 { line-height: 1.2; margin: .3em 0 .45em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.sous { color: var(--gris); font-size: .92rem; margin: 0 0 .7em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 2px solid var(--vert); background: var(--vert); color: #fff; font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn.second { background: #fff; color: var(--vert); }
.btn.discret { background: none; border-color: transparent; color: var(--vert-2); padding: 0 10px; }
.btn.danger { background: #fff; color: var(--non); border-color: var(--non); }
.btn.large { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.rangee { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.rangee > .btn { flex: 1 1 auto; }
.carte-bloc { background: #fff; border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px; margin: 12px 0; }
label.champ { display: block; margin: 12px 0; font-weight: 600; }
label.champ input, label.champ textarea, label.champ select { display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 10px 12px; border: 2px solid var(--trait); border-radius: 10px; background: #fff; font-weight: 400; }
label.champ textarea { min-height: 96px; resize: vertical; }
label.champ small { display: block; font-weight: 400; color: var(--gris); }
.choix { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.choix button, .choix label {
  min-height: 64px; border: 2px solid var(--trait); border-radius: 12px; background: #fff; padding: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; font-weight: 600;
}
.choix .ico { font-size: 1.5rem; line-height: 1.1; }
.choix small { font-weight: 400; color: var(--gris); font-size: .82rem; }
.choix [aria-pressed="true"], .choix label:has(input:checked) { border-color: var(--vert); background: var(--vert-clair); box-shadow: inset 0 0 0 1px var(--vert); }
.choix label input { position: absolute; opacity: 0; pointer-events: none; }
.choix label:has(input:focus-visible) { outline: 3px solid #2563eb; }

.curseur { margin: 14px 0; }
.curseur .tete { display: flex; justify-content: space-between; font-weight: 600; }
.curseur output { white-space: nowrap; margin-left: 10px; font-variant-numeric: tabular-nums; color: var(--vert); font-weight: 750; }
.curseur input[type=range] { width: 100%; height: 44px; accent-color: var(--vert); }
.curseur .aide { color: var(--gris); font-size: .88rem; margin-top: -4px; }

/* badges de niveau */
.niv { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: .86rem; color: #fff; white-space: nowrap; }
.niv-0 { background: var(--ok); } .niv-1 { background: var(--moyen); } .niv-2 { background: var(--non); } .niv--1 { background: var(--inconnu); }
.verdict { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--rayon); color: #fff; margin: 10px 0; }
.verdict .gros { font-size: 1.8rem; line-height: 1; }
.verdict strong { display: block; font-size: 1.08rem; }
.verdict.niv-0 { background: var(--ok); } .verdict.niv-1 { background: #b45f00; } .verdict.niv-2 { background: var(--non); } .verdict.niv--1 { background: #5f6773; }
.barre-niv { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eee; margin: 6px 0; }
.barre-niv span { display: block; }
.liste-raisons { list-style: none; padding: 0; margin: 8px 0; }
.liste-raisons li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--trait); }
.liste-raisons li:last-child { border: 0; }
.pastille { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; transform: translateY(1px); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 10px 0; }
.stats div { background: #fff; border: 1px solid var(--trait); border-radius: 12px; padding: 8px 10px; }
.stats b { display: block; font-size: 1.15rem; }
.stats small { color: var(--gris); }
.modes-mini { display: flex; gap: 8px; flex-wrap: wrap; }
.modes-mini span { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--trait); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: .88rem; }

/* liste de balades */
.balade-carte { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--trait); border-radius: var(--rayon); padding: 12px 14px; margin: 10px 0; cursor: pointer; text-decoration: none; color: inherit; }
.balade-carte:hover { border-color: var(--vert); }
.balade-carte h3 { margin: 0 0 4px; }
.balade-carte .meta { color: var(--gris); font-size: .9rem; display: flex; gap: 10px; flex-wrap: wrap; }
.balade-carte .haut { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.filtres button { min-height: 44px; border-radius: 22px; border: 2px solid var(--trait); background: #fff; padding: 0 14px; cursor: pointer; font-weight: 600; }
.filtres button[aria-pressed="true"] { border-color: var(--vert); background: var(--vert-clair); color: var(--vert); }

/* profil en long */
.profil-alt { width: 100%; height: 150px; display: block; background: #fff; border: 1px solid var(--trait); border-radius: 12px; touch-action: pan-y; }

/* retours */
.retour { border-top: 1px solid var(--trait); padding: 10px 0; }
.retour .qui { color: var(--gris); font-size: .88rem; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.photos img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; cursor: zoom-in; }

/* légende */
.legende-ligne { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.legende-ligne svg { flex: none; }

/* dialogue */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: var(--ombre); background: var(--sable); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .dialogue-contenu { padding: 18px; overflow-y: auto; max-height: calc(100dvh - 40px); }
dialog img.plein { width: 100%; border-radius: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bas) + env(safe-area-inset-bottom) + 16px); background: #1c1f1d; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: var(--ombre); }
.toast.erreur { background: var(--non); }

/* mode dessin */
.dessin-aide { background: var(--vert-clair); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: .95rem; }
.interrupteur { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; font-weight: 600; }
.interrupteur input { width: 24px; height: 24px; accent-color: var(--vert); }
.vide { text-align: center; color: var(--gris); padding: 18px 8px; }
.note { font-size: .86rem; color: var(--gris); }
.marqueur-etape { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 4px solid var(--vert); box-shadow: 0 1px 4px #0006; }
.marqueur-etape.depart { border-color: #2563eb; width: 26px; height: 26px; }
.marqueur-ici { width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 4px solid #fff; box-shadow: 0 0 0 6px #2563eb44; }
.marqueur-cible { font-size: 34px; line-height: 1; transform: translateY(-14px); filter: drop-shadow(0 2px 2px #0007); }

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