/* ==========================================================================
   APWB — mise en forme (mobile d'abord)
   ========================================================================== */

:root {
  --turquoise: #4BC1C7;          /* couleur du logo */
  --turquoise-fonce: #137A82;    /* boutons (contraste suffisant avec le blanc) */
  --turquoise-tres-fonce: #0B4F55;
  --texte: #1B2629;
  --texte-doux: #56656A;
  --fond: #FFFFFF;
  --fond-doux: #EEF2F3;
  --bordure: #D5DEE0;
  --erreur: #B3261E;
  --ombre: 0 4px 16px rgba(0, 0, 0, .18);
  --rayon: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texte);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--fond-doux);
}

/* --- En-tête -------------------------------------------------------------- */
.entete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
}
.entete__logo { width: 40px; height: 40px; flex: none; }
.entete__textes { min-width: 0; }
.entete__titre {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1.1;
  color: var(--turquoise-tres-fonce);
}
.entete__sous-titre {
  margin: 0;
  overflow: hidden;
  font-size: .8125rem;
  color: var(--texte-doux);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --- Compte (prénom et déconnexion, dans l'en-tête) ----------------------------- */
.compte { position: relative; flex: none; margin-left: auto; }
.compte__bouton {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 40vw;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--fond);
  font: inherit;
  font-weight: 600;
  color: var(--turquoise-tres-fonce);
  cursor: pointer;
}
.compte__bouton svg { flex: none; }
.compte__bouton span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.compte__bouton:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }
.compte__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1300;
  min-width: 210px;
  padding: 6px;
  border-radius: var(--rayon);
  background: var(--fond);
  box-shadow: var(--ombre);
}
.compte__menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--texte);
  cursor: pointer;
}
.compte__menu button:hover,
.compte__menu button:focus-visible { outline: none; background: var(--fond-doux); }

/* --- Écrans d'accès (mot de passe, prénom) ------------------------------------ */
.ecran {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--fond-doux);
}
.ecran__contenu {
  width: 100%;
  max-width: 420px;
  margin: auto 0;
  padding: 28px 22px;
  border-radius: 18px;
  background: var(--fond);
  box-shadow: var(--ombre);
}
.ecran__logo { display: block; width: 132px; height: 132px; margin: 0 auto 12px; }
.ecran__titre { margin: 0 0 6px; font-size: 1.4rem; text-align: center; color: var(--turquoise-tres-fonce); }
.ecran__texte { margin: 0 0 4px; text-align: center; color: var(--texte-doux); }
.ecran__pied { margin-top: 18px; text-align: center; }
.champ-mdp { display: flex; gap: 8px; }
.champ-mdp input { flex: 1; min-width: 0; }
.champ-mdp__voir {
  flex: none;
  min-width: 92px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  background: var(--fond);
  font: inherit;
  font-weight: 600;
  color: var(--turquoise-tres-fonce);
  cursor: pointer;
}
.champ-mdp__voir:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }
.encadre-donnees {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: var(--rayon);
  background: var(--fond-doux);
  font-size: .9rem;
  color: var(--texte-doux);
}
.encadre-donnees h3 { margin: 0; font-size: 1rem; color: var(--texte); }
.encadre-donnees p { margin: 6px 0 0; }

.bandeau-demo {
  margin: 0;
  padding: 6px 12px;
  font-size: .8125rem;
  text-align: center;
  background: #FFF3C4;
  color: #5B4600;
  border-bottom: 1px solid #F0DC8A;
}

/* --- Carte ------------------------------------------------------------------ */
.carte { flex: 1; min-height: 0; background: #F4F4F4; }
.leaflet-container { font: inherit; background: #F4F4F4; }

/* Fond OSM désaturé (réglage dans config.js) */
.fond-osm { filter: var(--filtre-fond, none); }

/* Les rues colorées « se multiplient » avec le fond : les noms de rue
   imprimés sur le fond restent lisibles à travers les traits. */
.leaflet-rues-pane { mix-blend-mode: multiply; }

/* Boutons de zoom assez grands pour le doigt */
.leaflet-bar a,
.leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; font-size: 22px; }
.leaflet-control-attribution { font-size: 11px; }

.erreur-chargement { margin: 24px; padding: 16px; border-radius: var(--rayon); background: #FCE8E6; color: var(--erreur); font-weight: 600; }

/* --- Légende -------------------------------------------------------------- */
.legende {
  min-width: 170px;
  padding: 4px 8px 8px;
  border-radius: var(--rayon);
  background: var(--fond);
  box-shadow: var(--ombre);
  font-size: .8125rem;
  line-height: 1.3;
}
.legende__titre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 4px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--texte);
  cursor: pointer;
}
.legende__titre::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.legende__titre[aria-expanded="false"]::after { transform: translateY(2px) rotate(-135deg); }
.legende__titre[aria-expanded="false"] { min-height: 32px; }
.legende__titre:focus-visible { outline: 3px solid var(--turquoise); border-radius: 8px; }
.legende__liste { margin: 0; padding: 0 4px; list-style: none; }
.legende__liste li { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.legende__trait { flex: none; width: 26px; height: 6px; border-radius: 3px; }

/* --- Me localiser ----------------------------------------------------------- */
.bouton-localiser {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--fond);
  box-shadow: var(--ombre);
  color: var(--turquoise-fonce);
  cursor: pointer;
}
.bouton-localiser svg { width: 26px; height: 26px; }
.bouton-localiser:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }
.bouton-localiser--recherche svg { animation: pulsation 1s ease-in-out infinite; }
.bouton-localiser--actif { color: #1A73E8; }
@keyframes pulsation { 50% { opacity: .3; } }

.point-position {
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1A73E8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .35), 0 1px 4px rgba(0, 0, 0, .4);
}

/* --- Panneau du bas --------------------------------------------------------- */
.panneau {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  max-height: 78dvh;
  overflow-y: auto;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--fond);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .2);
  transform: translateY(100%);
  transition: transform .22s ease-out;
}
.panneau--ouvert { transform: none; }
@media (min-width: 640px) {
  .panneau { left: 50%; right: auto; width: 560px; margin-left: -280px; }
}
.panneau__fermer {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--fond-doux);
  color: var(--texte);
  cursor: pointer;
}
.panneau__titre { margin: 0 52px 4px 0; font-size: 1.3rem; line-height: 1.25; }
.panneau__troncon { margin: 0 52px 6px 0; font-size: .9375rem; color: var(--texte-doux); }
.panneau__etat {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 2px;
  font-size: 1.0625rem;
  font-weight: 700;
}
.pastille { flex: none; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.panneau__detail { margin: 2px 0 0 26px; color: var(--texte-doux); }
.panneau__commentaire { margin: 6px 0 0 26px; font-style: italic; }

.zone-action { margin-top: 18px; }

/* --- Boutons -------------------------------------------------------------------- */
.bouton {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border: 2px solid transparent;
  border-radius: var(--rayon);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
}
.bouton--principal { background: var(--turquoise-fonce); color: #fff; }
.bouton--principal:active { background: var(--turquoise-tres-fonce); }
.bouton--principal:disabled { opacity: .6; cursor: progress; }
.bouton--secondaire { border-color: var(--bordure); background: var(--fond); color: var(--turquoise-tres-fonce); }
.bouton:focus-visible,
.bouton-lien:focus-visible,
.panneau__fermer:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }

.ma-saisie {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
  margin: 10px 0 0;
  font-size: .9375rem;
  color: var(--texte-doux);
}
.ma-saisie--merci { margin-top: 0; font-size: 1.0625rem; font-weight: 700; color: #146C2E; }
.bouton-lien {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--turquoise-tres-fonce);
  text-decoration: underline;
  cursor: pointer;
}

/* --- Formulaire -------------------------------------------------------------- */
.formulaire { display: grid; gap: 6px; margin-top: 14px; }
.formulaire label { margin-top: 8px; font-weight: 700; }
.facultatif { font-weight: 400; color: var(--texte-doux); }
.formulaire input,
.formulaire textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #A9B8BC;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 1rem;  /* 16 px minimum : évite le zoom automatique sur iPhone */
  color: var(--texte);
}
.formulaire textarea { min-height: 84px; resize: vertical; }
.formulaire .case-a-cocher {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-top: 6px;
  font-weight: 400;
  cursor: pointer;
}
.formulaire .case-a-cocher input {
  flex: none;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--turquoise-fonce);
}
.formulaire input:focus,
.formulaire textarea:focus { outline: 3px solid var(--turquoise); outline-offset: 0; border-color: var(--turquoise-fonce); }
.aide { margin: 0; font-size: .875rem; color: var(--texte-doux); }
.erreur { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: #FCE8E6; color: var(--erreur); font-weight: 600; }
.formulaire__boutons { display: grid; gap: 10px; margin-top: 12px; }

/* --- Message temporaire ------------------------------------------------------- */
.toast {
  position: fixed;
  top: calc(var(--haut-carte, 64px) + 12px);
  left: 50%;
  z-index: 1300;
  max-width: min(92vw, 520px);
  padding: 12px 16px;
  border-radius: var(--rayon);
  background: #1F2A2C;
  color: #fff;
  box-shadow: var(--ombre);
  font-size: .9375rem;
  transform: translateX(-50%);
}

@media (prefers-reduced-motion: reduce) {
  .panneau { transition: none; }
  .bouton-localiser--recherche svg { animation: none; }
}
