/* =====================================================================
   FamiliPass : apparence
   Les couleurs principales sont regroupées ici : les modifier suffit
   pour changer l'identité visuelle.
   ===================================================================== */
:root {
  --bleu-passeport: #16325B;
  --bleu-clair: #E8EEF7;
  --papier: #FFFFFF;
  --texte: #1A2230;
  --texte-doux: #5B6475;
  --or: #FFD700;
  --argent: #C0C0C0;
  --bronze: #CD7F32;
  --focus: #F2B632;

  --police-titre: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --police-texte: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--police-texte);
  font-size: 16px;
  color: var(--texte);
  background: var(--bleu-clair);
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Carte plein écran ---------- */
#carte {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ---------- Bandeau du haut ---------- */
.bandeau {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--bleu-passeport);
  color: var(--papier);
  box-shadow: 0 2px 10px rgba(22, 50, 91, 0.35);
}

.logo {
  margin: 0 0 8px 4px;
  font-family: var(--police-titre);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.filtres {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filtres::-webkit-scrollbar { display: none; }

.filtre {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: transparent;
  color: var(--papier);
  font: 700 0.95rem/1 var(--police-texte);
  cursor: pointer;
}
.filtre[aria-pressed="true"] {
  background: var(--papier);
  border-color: var(--papier);
  color: var(--bleu-passeport);
}

/* ---------- Marqueurs : des tampons de passeport ---------- */
.tampon {
  background: none;
  border: none;
}
.tampon span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c);
  font-size: 20px;
  box-shadow: 0 0 0 3px var(--papier), 0 3px 8px rgba(0, 0, 0, 0.35);
  position: relative;
  transition: transform 0.15s;
}
/* anneau pointillé intérieur, comme un tampon */
.tampon span::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.8);
}
.tampon:hover span,
.tampon.actif span { transform: scale(1.15); }

/* Point bleu de l'utilisateur */
.ma-position {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2F80ED;
  border: 3px solid var(--papier);
  box-shadow: 0 0 0 6px rgba(47, 128, 237, 0.25);
}

/* ---------- Bouton géolocalisation ---------- */
.bouton-position {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  z-index: 1000;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--papier);
  color: var(--bleu-passeport);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* ---------- Message d'alerte sur une fiche (fermeture, travaux…) ---------- */
.fiche-alerte {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #FDECEC;
  color: #B3261E;
  font-weight: 700;
}

/* ---------- Bouton plan / satellite ---------- */
.bouton-fond {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  z-index: 1000;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid var(--papier);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: #5b6b4a url("https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/jpeg&TILEMATRIX=13&TILEROW=2837&TILECOL=4188") center / cover;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.bouton-fond.vue-photo {
  background-image: url("https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&TILEMATRIX=13&TILEROW=2837&TILECOL=4188");
}
.bouton-fond span {
  width: 100%;
  padding: 2px 0 3px;
  background: rgba(22, 50, 91, 0.85);
  color: var(--papier);
  font: 700 0.62rem/1.1 var(--police-texte);
  text-align: center;
}

/* ---------- Message d'état ---------- */
.message {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  transform: translateX(-50%);
  z-index: 1100;
  width: min(92vw, 420px);
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--texte);
  color: var(--papier);
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
}

/* ---------- Fiche lieu (panneau qui monte du bas) ---------- */
.fiche {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1200;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--papier);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(105%);
  transition: transform 0.28s ease-out;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fiche.ouverte { transform: translateY(0); }

/* Sur grand écran : panneau latéral à gauche */
@media (min-width: 760px) {
  .fiche {
    left: 16px; right: auto; top: 130px; bottom: 16px;
    width: 400px;
    max-height: none;
    border-radius: 20px;
    transform: translateX(-120%);
  }
  .fiche.ouverte { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .fiche, .tampon span { transition: none; }
}

.fiche-fermer {
  position: sticky; /* reste visible quand on fait défiler la fiche */
  top: 10px;
  display: block;
  margin: 10px 10px -50px auto; /* calée à droite, sans décaler la photo */
  z-index: 2;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--texte);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.fiche-photo {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.fiche-credit {
  margin: 2px 8px 0;
  font-size: 0.6rem;
  line-height: 1.2;
  color: var(--texte-doux);
  text-align: right;
}

.fiche-corps { padding: 20px 20px 24px; position: relative; }

/* Le tampon du type, posé de travers dans le coin de la fiche */
.fiche-tampon {
  position: absolute;
  top: 14px; right: 58px;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px double var(--c);
  color: var(--c);
  display: grid;
  place-items: center;
  text-align: center;
  font: 800 0.62rem/1.05 var(--police-titre);
  transform: rotate(-12deg);
  opacity: 0.9;
}
.fiche-tampon b { display: block; font-size: 1.4rem; line-height: 1; }

.fiche-nom {
  margin: 0 0 6px 0;
  font-family: var(--police-titre);
  font-weight: 800;
  font-size: 1.6rem;
  line-height: 1.1;
  color: var(--bleu-passeport);
}

.fiche-adresse {
  margin: 0 0 14px;
  color: var(--texte-doux);
  font-size: 0.95rem;
  line-height: 1.4;
}

.fiche-description { margin: 0 0 16px; line-height: 1.55; max-width: 60ch; }

.badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--texte);
}
.badge-or { background: var(--or); }
.badge-argent { background: var(--argent); }
.badge-bronze { background: var(--bronze); color: var(--papier); }

.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.etiquette {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--c, var(--bleu-clair));
  color: var(--texte);
  font-size: 0.85rem;
}

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--bleu-passeport);
  background: var(--papier);
  color: var(--bleu-passeport);
  font: 700 0.95rem/1.2 var(--police-texte);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.action-principale {
  grid-column: 1 / -1;
  background: var(--bleu-passeport);
  color: var(--papier);
}

/* Attribution de la carte, discrète */
.leaflet-control-attribution { font-size: 10px; }


/* ---------- Bulles de regroupement des marqueurs proches ---------- */
.grappe { background: none; border: none; }
.grappe span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bleu-passeport);
  color: var(--papier);
  font: 800 1.05rem/1 var(--police-titre);
  box-shadow: 0 0 0 3px var(--papier), 0 0 0 6px rgba(22, 50, 91, 0.35), 0 3px 8px rgba(0, 0, 0, 0.35);
}

/* ---------- Type du lieu, en étiquette sous le titre de la fiche ---------- */
.fiche-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 3px 12px 3px 8px;
  border: 2px solid var(--c);
  border-radius: 999px;
  color: var(--texte);
  font: 700 0.85rem/1.3 var(--police-texte);
}
/* Fiche sans photo : le titre laisse la place au bouton de fermeture */
.fiche-corps:first-child .fiche-nom { margin-right: 44px; }


/* ---------- Fondu sur les bords des filtres : signale qu'on peut faire défiler ---------- */
.filtres {
  --fondu-g: 0px;
  --fondu-d: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fondu-g), #000 calc(100% - var(--fondu-d)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fondu-g), #000 calc(100% - var(--fondu-d)), transparent 100%);
}
.filtres.fondu-gauche { --fondu-g: 36px; }
.filtres.fondu-droite { --fondu-d: 56px; }


/* ---------- Défilement des filtres à la souris (PC seulement) ---------- */
.filtres-cadre { position: relative; }
.fleche-filtres { display: none; }
@media (hover: hover) and (pointer: fine) {
  .filtres { user-select: none; }
  .filtres.glisse, .filtres.glisse .filtre { cursor: grabbing; }
  .fleche-filtres {
    display: flex;
    position: absolute;
    top: calc(50% - 1px);
    transform: translateY(-50%);
    z-index: 2;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    padding: 0 0 3px;
    border: 0;
    border-radius: 50%;
    background: var(--papier);
    color: var(--bleu-passeport);
    font: 800 1.4rem/1 var(--police-texte);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
    cursor: pointer;
  }
  .fleche-filtres.gauche { left: 0; }
  .fleche-filtres.droite { right: 0; }
  .fleche-filtres[hidden] { display: none; }
}


/* ---------- Recherche d'un lieu (loupe du bandeau) ---------- */
.bouton-recherche {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 46px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  color: var(--papier);
  cursor: pointer;
}
/* Zone de toucher élargie sans grossir la loupe */
.bouton-recherche::after { content: ""; position: absolute; inset: -8px; }

/* Le panneau couvre l'écran d'un fond assombri ; la recherche est en haut. */
.recherche {
  position: fixed;
  inset: 0;
  z-index: 1150;
  background: rgba(22, 50, 91, 0.45);
}
.recherche[hidden] { display: none; }
.recherche-boite {
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 12px;
  background: var(--bleu-passeport);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.recherche-barre { display: flex; align-items: center; gap: 8px; }
.recherche-barre input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--papier);
  color: var(--texte);
  font: 400 1rem var(--police-texte); /* 16 px : évite le zoom automatique sur iPhone */
}
/* On masque la petite croix du navigateur : la nôtre suffit. */
.recherche-barre input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.recherche-fermer {
  flex: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: var(--papier);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.recherche-resultats {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--papier);
}
.recherche-resultats:empty { display: none; }
.recherche-resultats button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--bleu-clair);
  background: none;
  color: var(--texte);
  font: 400 1rem/1.3 var(--police-texte);
  text-align: left;
  cursor: pointer;
}
.recherche-resultats li:last-child button { border-bottom: none; }
.recherche-icone { flex: none; font-size: 1.2rem; }
.recherche-commune { display: block; font-size: 0.85rem; color: var(--texte-doux); }
.recherche-vide { padding: 12px 14px; color: var(--texte-doux); }
@media (min-width: 760px) {
  .recherche-boite { max-width: 520px; margin: 0 auto; border-radius: 0 0 16px 16px; }
}

/* ---------- Bouton « i » du bandeau : vers la page À propos ---------- */
.bouton-info {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  color: var(--papier);
  font: 800 0.85rem/1 Georgia, "Times New Roman", serif;
  font-style: italic;
  text-decoration: none;
}
.bouton-info:hover { background: rgba(255, 255, 255, 0.15); }
/* Zone de toucher élargie (~40 px) sans grossir le bouton visible */
.bouton-info::after { content: ""; position: absolute; inset: -8px; }

/* ---------- Bouton « Installer » (bandeau) et aide à l'installation ---------- */
.bouton-installer {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 80px;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  background: none;
  color: var(--papier);
  font: 700 0.8rem/1 var(--police-titre);
  cursor: pointer;
}
.bouton-installer[hidden] { display: none; }
.aide-installation {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(22, 50, 91, 0.45);
}
.aide-installation[hidden] { display: none; }
.aide-installation-boite {
  position: relative;
  max-width: 360px;
  padding: 20px 20px 16px;
  border-radius: 16px;
  background: #fff;
  color: var(--bleu-passeport);
  line-height: 1.5;
}
.aide-installation-boite h2 { margin: 0 28px 10px 0; font-family: var(--police-titre); font-size: 1.15rem; }
.aide-installation-boite ol { margin: 0 0 10px; padding-left: 20px; }
.aide-installation-boite li { margin-bottom: 6px; }
.aide-installation-boite li svg { vertical-align: -3px; }
.aide-installation-boite p { margin: 0; font-size: 0.9rem; }
.aide-installation-fermer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

