/* ───────────────────────────────────────────────────────────────────────────
   Rando semi-nocturne — école Sainte-Marie, Saint-Benoît-sur-Loire

   Thème sombre : la page se lit de nuit, à la frontale, sur un téléphone en
   luminosité basse. Couleurs reprises de la bannière de l'école.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --nuit-0:      #0d1418;   /* fond de page */
  --nuit-1:      #132029;   /* fiches, panneaux */
  --nuit-2:      #1d2f3a;   /* bordures, éléments en relief */
  --creme:       #f7f6f1;   /* texte principal */
  --creme-doux:  #aebcc4;   /* texte secondaire */
  --orange:      #e8833a;   /* boucle 5 km, accent chaud */
  --turquoise:   #29a9ce;   /* extension 4 km, liens */
  --vert:        #7cb342;   /* position, validation */
  --rouge:       #d94436;

  --rayon: 12px;
  --ombre: 0 2px 14px rgba(0, 0, 0, .45);
  --largeur-texte: 44rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Les fiches sont atteintes par ancre (#point-12) depuis les QR codes :
   sans cette marge, le titre se colle au bord haut de l'écran. */
:target { scroll-margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  padding: 0;
  background: var(--nuit-0);
  color: var(--creme);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

.contenu {
  max-width: var(--largeur-texte);
  margin: 0 auto;
  padding-inline: 16px;
}

/* ── En-tête ──────────────────────────────────────────────────────────────── */

.entete {
  padding: 2.2rem 0 1.4rem;
  text-align: center;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(232, 131, 58, .16), transparent 70%),
    var(--nuit-0);
  border-bottom: 1px solid var(--nuit-2);
}

.entete h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.02em;
}

.entete .ecole {
  margin: .4rem 0 0;
  color: var(--turquoise);
  font-weight: 600;
  font-size: 1rem;
}

.entete .accroche {
  margin: 1rem auto 0;
  max-width: 34rem;
  color: var(--creme-doux);
}

.pastilles {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin-top: 1.2rem;
}

.pastille {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .85rem;
  border: 1px solid var(--nuit-2);
  border-radius: 999px;
  background: var(--nuit-1);
  font-size: .9rem;
  font-weight: 600;
}

.pastille::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--couleur, var(--orange));
}

/* ── Infos pratiques ──────────────────────────────────────────────────────── */

.infos {
  margin: 1.5rem auto;
  border: 1px solid var(--nuit-2);
  border-radius: var(--rayon);
  background: var(--nuit-1);
  overflow: hidden;
}

.infos > summary {
  padding: .9rem 1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
}

.infos > summary::-webkit-details-marker { display: none; }

.infos > summary::after {
  content: "▾";
  color: var(--creme-doux);
  transition: transform .2s;
}

.infos[open] > summary::after { transform: rotate(180deg); }

.infos-corps { padding: 0 1rem 1rem; }

.infos dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .4rem 1rem;
  margin: 0 0 1rem;
}

.infos dt { color: var(--creme-doux); }
.infos dd { margin: 0; font-weight: 600; }

.conseils {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--creme-doux);
}

.conseils li { margin-bottom: .3rem; }

/* ── Carte ────────────────────────────────────────────────────────────────── */

.bloc-carte {
  margin: 1.5rem auto;
  max-width: var(--largeur-texte);
  padding-inline: 16px;
}

#carte {
  height: 58vh;
  min-height: 320px;
  max-height: 560px;
  border-radius: var(--rayon);
  border: 1px solid var(--nuit-2);
  box-shadow: var(--ombre);
  background: var(--nuit-1);
  z-index: 0;                       /* reste sous le bouton flottant */
}

.commandes {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}

.bouton {
  flex: 1 1 auto;
  min-height: 44px;                 /* cible tactile confortable, avec des gants */
  padding: .55rem 1rem;
  border: 1px solid var(--nuit-2);
  border-radius: 999px;
  background: var(--nuit-1);
  color: var(--creme);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.bouton:hover { background: var(--nuit-2); }

.bouton:focus-visible {
  outline: 2px solid var(--turquoise);
  outline-offset: 2px;
}

.bouton[aria-pressed="true"] {
  background: var(--turquoise);
  border-color: var(--turquoise);
  color: #04222c;
}

.bouton.actif-vert[aria-pressed="true"] {
  background: var(--vert);
  border-color: var(--vert);
  color: #16240a;
}

.choix-distance {
  display: flex;
  gap: .4rem;
  flex: 1 1 100%;
  padding: .25rem;
  border: 1px solid var(--nuit-2);
  border-radius: 999px;
  background: var(--nuit-1);
}

.choix-distance .bouton {
  border-color: transparent;
  background: transparent;
}

.choix-distance .bouton[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #2b1405;
}

/* Rappel du parcours choisi : distance réellement mesurée sur le tracé. */
.resume {
  margin: .7rem 0 0;
  font-size: .92rem;
  font-weight: 600;
  color: var(--creme);
}

.etat {
  margin-top: .6rem;
  min-height: 1.4rem;
  font-size: .9rem;
  color: var(--creme-doux);
}

.etat.erreur { color: var(--rouge); }
.etat.succes { color: var(--vert); }

.progression {
  width: 100%;
  height: 6px;
  margin-top: .4rem;
  border-radius: 3px;
  background: var(--nuit-2);
  overflow: hidden;
}

.progression span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--vert);
  transition: width .2s;
}

/* Marqueurs numérotés dessinés par Leaflet (L.divIcon) */
.pastille-point {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #2b1405;
  background: var(--orange);
  color: #2b1405;
  font: 700 14px/1 system-ui, sans-serif;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .5);
  transition: transform .15s;
}

.pastille-point.courant {
  background: var(--vert);
  border-color: #16240a;
  color: #16240a;
  transform: scale(1.35);
  z-index: 500;
}

.pastille-choix {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #04222c;
  background: var(--turquoise);
  color: #04222c;
  font: 700 16px/1 system-ui, sans-serif;
}

.leaflet-popup-content { margin: .7rem .9rem; font: inherit; }
.leaflet-popup-content b { display: block; margin-bottom: .2rem; }
.leaflet-container { font: inherit; }

/* ── Les fiches des panneaux ──────────────────────────────────────────────── */

.titre-section {
  margin: 2.5rem auto .5rem;
  text-align: center;
  font-size: 1.4rem;
}

.sous-titre-section {
  margin: 0 auto 1.5rem;
  text-align: center;
  color: var(--creme-doux);
  font-size: .95rem;
}

.fiche {
  margin: 0 0 1.5rem;
  border: 1px solid var(--nuit-2);
  border-radius: var(--rayon);
  background: var(--nuit-1);
  overflow: hidden;
  scroll-margin-top: 1rem;
  transition: border-color .3s, box-shadow .3s;
}

.fiche.surligne {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(232, 131, 58, .35);
}

.fiche-entete {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--nuit-2);
}

.fiche-numero {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--orange);
  color: #2b1405;
  font-weight: 700;
}

.fiche-entete h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.fiche figure { margin: 0; }

.fiche img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--nuit-2);
}

.fiche figcaption {
  padding: .6rem 1rem;
  color: var(--creme-doux);
  font-size: .88rem;
  border-bottom: 1px solid var(--nuit-2);
}

.fiche-texte { padding: 1rem; }
.fiche-texte p { margin: 0 0 .8rem; }
.fiche-texte p:last-child { margin-bottom: 0; }

.a-completer {
  color: var(--creme-doux);
  font-style: italic;
  opacity: .75;
}

.fiche-pied {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 1rem;
}

.credit {
  color: var(--creme-doux);
  font-size: .8rem;
}

.lien-carte {
  min-height: 44px;
  padding: .45rem .9rem;
  border: 1px solid var(--nuit-2);
  border-radius: 999px;
  background: transparent;
  color: var(--turquoise);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.lien-carte:hover { background: var(--nuit-2); }

/* ── Bouton flottant de retour à la carte ─────────────────────────────────── */

.retour-carte {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 48px;
  padding: .6rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--orange);
  color: #2b1405;
  font: 600 .95rem system-ui, sans-serif;
  box-shadow: var(--ombre);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.retour-carte.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ── Pied de page ─────────────────────────────────────────────────────────── */

.pied {
  margin-top: 3rem;
  padding: 1.5rem 16px calc(5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--nuit-2);
  color: var(--creme-doux);
  font-size: .85rem;
  text-align: center;
}

.pied a { color: var(--turquoise); }

/* ── Écrans larges ────────────────────────────────────────────────────────── */

@media (min-width: 900px) {
  #carte { height: 62vh; }
  .fiche { display: grid; grid-template-columns: 1fr 1fr; }
  .fiche-entete { grid-column: 1 / -1; }
  .fiche figure { border-right: 1px solid var(--nuit-2); }
  .fiche figcaption { border-bottom: none; }
  .fiche-texte { grid-column: 2; }
  .fiche-pied { grid-column: 1 / -1; }
  :root { --largeur-texte: 58rem; }
}
