/* Tourisme Rougemont — carte des artisans
   Palette reprise de l'affiche 2026 */
:root{
  --rouge:#ED5A59;
  --rouge-fonce:#D8423F;
  --vert:#1E7C46;
  --vert-pale:#DDE9C8;
  --encre:#22262B;
  --gris:#6B7280;
  --gris-pale:#E9ECEF;
  --fond:#FFFFFF;
  --rayon:14px;
  --ombre:0 2px 14px rgba(20,25,30,.10);
  --entete-h:56px;
  --onglets-h:48px;

  /* Niveaux de superposition.
     Leaflet utilise jusqu'à 1000 pour ses couches et ses contrôles : tout ce
     qui doit passer PAR-DESSUS une carte doit donc dépasser 1000. C'est
     l'erreur qui faisait s'ouvrir la fiche derrière la carte. */
  --z-carte-outils:1050;   /* boutons posés sur une carte */
  --z-onglets:1080;
  --z-recherche:1090;
  --z-entete:1100;
  --z-voile:2000;
  --z-fiche:2010;
  --z-journal:3000;        /* panneau de diagnostic */
}
*{box-sizing:border-box}
/* L'attribut hidden doit l'emporter sur les display:flex/grid ci-dessous */
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--fond); color:var(--encre);
  font:16px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* ---------- En-tête ---------- */
.entete{
  position:sticky; top:0; z-index:var(--z-entete); height:var(--entete-h);
  padding:0 12px; padding-top:env(safe-area-inset-top);
  height:calc(var(--entete-h) + env(safe-area-inset-top));
  display:flex; align-items:center; justify-content:space-between;
  background:var(--rouge); color:#fff;
}
.entete-titre{display:flex; align-items:center; gap:11px}
.entete-titre strong{font-size:20px; letter-spacing:.1px; line-height:1.1}
.logo-pomme{
  width:30px;height:30px;border-radius:50%;background:#fff;
  position:relative; flex:none;
}
.logo-pomme::after{
  content:""; position:absolute; inset:7px;
  border-radius:50%; background:var(--rouge);
}
.btn-icone{
  background:rgba(255,255,255,.16); border:0; color:#fff;
  width:36px;height:36px;border-radius:50%; display:grid;place-items:center; cursor:pointer;
}
.btn-icone:active{background:rgba(255,255,255,.3)}

/* ---------- Recherche ---------- */
.barre-recherche{
  position:sticky; top:calc(var(--entete-h) + env(safe-area-inset-top)); z-index:var(--z-recherche);
  display:flex; gap:8px; padding:8px 12px; background:#fff; border-bottom:1px solid var(--gris-pale);
}
.barre-recherche input{
  flex:1; border:1px solid var(--gris-pale); background:#F6F7F8;
  border-radius:10px; padding:9px 12px; font-size:16px; color:var(--encre);
}
.barre-recherche input:focus{outline:2px solid var(--rouge); outline-offset:-1px; background:#fff}
.btn-texte{background:none;border:0;color:var(--rouge);font-size:15px;font-weight:600;cursor:pointer}

/* ---------- Onglets ---------- */
.onglets{
  position:sticky; top:calc(var(--entete-h) + env(safe-area-inset-top)); z-index:var(--z-onglets);
  display:flex; background:#fff; border-bottom:1px solid var(--gris-pale);
  height:var(--onglets-h);
}
.onglets.decale{top:calc(var(--entete-h) + 53px + env(safe-area-inset-top))}
.onglet{
  flex:1; background:none; border:0; padding:0 6px; cursor:pointer;
  font-size:13.5px; font-weight:600; color:var(--gris);
  border-bottom:2.5px solid transparent;
}
.onglet.actif{color:var(--rouge); border-bottom-color:var(--rouge)}

/* ---------- Vues ---------- */
#contenu{position:relative}
.vue{display:none}
.vue.active{display:block}
.hauteur-carte{
  height:calc(100vh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
  height:calc(100dvh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
}

/* ---------- Les deux cartes ---------- */
/* L'affiche illustrée et la carte géographique sont toutes deux rendues par
   Leaflet : mêmes dimensions, mêmes marqueurs, mêmes bulles. */
#vue-illustree,#vue-reelle{position:relative}
#carte-geo{
  height:calc(100vh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
  height:calc(100dvh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
  background:var(--vert-pale);
}
/* L'affiche est en paysage : elle n'a pas besoin de toute la hauteur d'un
   écran de téléphone. On lui en donne assez pour être lisible, et le reste
   sert aux raccourcis. */
/* La vue occupe toute la hauteur : la carte prend ce que les raccourcis ne
   prennent pas, sans laisser de blanc en bas. */
#vue-illustree.active{
  display:flex; flex-direction:column;
  height:calc(100vh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
  height:calc(100dvh - var(--entete-h) - var(--onglets-h) - env(safe-area-inset-top));
}
#carte-illustree{
  flex:1 1 auto; min-height:200px;
  background:var(--vert-pale);
}
/* Dès qu'on zoome, la carte prend tout l'écran : à sa taille de repos elle
   serait trop petite pour explorer. Elle reprend sa place en dézoomant. */
#vue-illustree.plein-ecran .raccourcis{display:none}
.raccourcis{flex:0 0 auto}
/* Le marqueur mesure 36 px pour rester confortable au doigt ; la pastille
   colorée n'en occupe que 30, centrée, pour ne pas masquer la carte. */
.epingle{
  width:30px;height:30px;margin:3px;border-radius:50%;
  background:var(--rouge); color:#fff; border:2.5px solid #fff;
  box-shadow:0 2px 6px rgba(0,0,0,.35);
  display:grid;place-items:center; font-size:12.5px; font-weight:700;
  -webkit-tap-highlight-color:transparent;
}
/* Sur l'affiche, les pastilles numérotées sont DÉJÀ DESSINÉES dans l'image.
   Le marqueur ne sert donc que de zone tactile : le redessiner par-dessus
   produisait un double cercle disgracieux. On le laisse transparent. */
#carte-illustree .epingle{
  width:36px; height:36px; margin:0;
  background:transparent; border:0; box-shadow:none; color:transparent;
  transition:background .12s;
}
#carte-illustree .epingle:active{ background:rgba(255,255,255,.4) }
@media (hover:hover){
  #carte-illustree .epingle:hover{ background:rgba(255,255,255,.28) }
}
.epingle.annee{border-color:var(--vert); box-shadow:0 0 0 1.5px #fff,0 2px 6px rgba(0,0,0,.3)}
.leaflet-container{background:var(--vert-pale); font:inherit}
/* L'affiche est une image : on la veut nette, sans lissage à fort zoom. */
#carte-illustree .leaflet-image-layer{image-rendering:auto}
.leaflet-popup-content{margin:12px 14px; font:inherit; min-width:180px}
.leaflet-popup-content-wrapper{border-radius:14px}
.pop-nom{font-weight:700; font-size:15.5px; display:block; margin-bottom:2px; line-height:1.25}
.pop-sec{color:var(--gris); font-size:12.5px; display:block; margin-bottom:10px}
/* Cible tactile pleine largeur : viser un petit lien au doigt est pénible. */
.pop-lien{
  display:block; width:100%; margin:0; padding:11px 14px;
  background:var(--rouge); color:#fff; border:0; border-radius:10px;
  font:inherit; font-weight:600; font-size:14.5px; text-align:center;
  cursor:pointer; -webkit-tap-highlight-color:transparent;
}
.pop-lien:active{background:var(--rouge-fonce)}
/* La croix de fermeture par défaut est minuscule au doigt. */
.leaflet-popup-close-button{
  width:32px !important; height:32px !important;
  font-size:22px !important; line-height:30px !important; padding:0 !important;
}
.btn-position{
  position:absolute; right:12px; bottom:calc(24px + env(safe-area-inset-bottom)); z-index:var(--z-carte-outils);
  width:44px;height:44px;border-radius:50%; border:1px solid var(--gris-pale);
  background:#fff; color:var(--encre); box-shadow:var(--ombre); cursor:pointer;
  display:grid;place-items:center;
}
.btn-position.actif{color:#2C7BE5; border-color:#BBD5F5}
.btn-position.cherche{color:var(--rouge)}
.btn-position.cherche svg{animation:tourne 1s linear infinite}
@keyframes tourne{to{transform:rotate(360deg)}}

/* ---------- Indicateur « vous êtes ici » ---------- */
.ma-position{position:relative; width:38px; height:38px}
.mp-point{
  position:absolute; inset:9px; border-radius:50%;
  background:#2C7BE5; border:3px solid #fff;
  box-shadow:0 2px 7px rgba(0,0,0,.45);
}
.mp-halo{
  position:absolute; inset:0; border-radius:50%;
  background:rgba(44,123,229,.30);
  animation:battement 2.2s ease-out infinite;
}
@keyframes battement{
  0%   {transform:scale(.5); opacity:.85}
  75%  {transform:scale(1);  opacity:0}
  100% {transform:scale(1);  opacity:0}
}
/* Respecte le réglage « réduire les animations » du système */
@media (prefers-reduced-motion:reduce){
  .mp-halo{animation:none; transform:scale(1); opacity:.35}
  .btn-position.cherche svg{animation:none}
}

/* ---------- Raccourcis sous l'affiche ---------- */
.raccourcis{
  padding:14px 12px calc(24px + env(safe-area-inset-bottom));
  display:grid; gap:9px; max-width:640px; margin:0 auto;
}
.raccourci{
  display:flex; align-items:center; gap:12px; width:100%;
  padding:12px 14px; border:1px solid var(--gris-pale); border-radius:var(--rayon);
  background:#fff; color:inherit; text-decoration:none; text-align:left;
  font:inherit; cursor:pointer; -webkit-tap-highlight-color:transparent;
}
.raccourci:active{background:#FAFAFB; border-color:#DADFE4}
.rac-ico{
  flex:none; width:38px; height:38px; border-radius:10px;
  background:var(--vert-pale); color:var(--vert);
  display:grid; place-items:center;
}
.rac-ico svg{width:20px;height:20px}
.rac-txt{flex:1; min-width:0}
.rac-txt strong{display:block; font-size:14.5px; line-height:1.3}
.rac-txt em{display:block; font-style:normal; font-size:12.5px; color:var(--gris); margin-top:1px}
.rac-fleche{flex:none; color:var(--rouge); font-size:17px; font-weight:600}

.reseaux{display:flex; gap:9px}
.reseau{
  flex:1; display:flex; align-items:center; justify-content:center; gap:8px;
  padding:12px; border:1px solid var(--gris-pale); border-radius:var(--rayon);
  background:#fff; color:var(--encre); text-decoration:none;
  font-weight:600; font-size:14px; -webkit-tap-highlight-color:transparent;
}
.reseau svg{width:19px;height:19px;color:var(--rouge)}
.reseau:active{background:#FAFAFB}

.raccourcis-pied{
  margin:6px 2px 0; font-size:11.5px; color:var(--gris); text-align:center; line-height:1.5;
}

/* ---------- Liste ---------- */
#vue-liste{padding:12px 12px calc(28px + env(safe-area-inset-bottom))}
.filtres{display:flex; gap:7px; overflow-x:auto; padding-bottom:10px; scrollbar-width:none}
.filtres::-webkit-scrollbar{display:none}
.puce{
  flex:none; border:1px solid var(--gris-pale); background:#fff; color:var(--encre);
  border-radius:99px; padding:7px 13px; font-size:13.5px; font-weight:500; cursor:pointer;
  white-space:nowrap;
}
.puce.on{background:var(--rouge); border-color:var(--rouge); color:#fff}
.compte{margin:2px 0 12px; color:var(--gris); font-size:13px}
.grille{display:grid; gap:11px}
.carte-membre{
  display:flex; gap:12px; align-items:center; text-align:left; width:100%;
  background:#fff; border:1px solid var(--gris-pale); border-radius:var(--rayon);
  padding:10px; cursor:pointer; font:inherit; color:inherit;
}
.carte-membre:active{background:#FAFAFB}
.vignette{
  width:70px;height:70px;border-radius:10px; object-fit:cover; flex:none; background:var(--vert-pale);
}
.carte-txt{min-width:0; flex:1}
.carte-nom{font-weight:700; font-size:15px; margin:0 0 2px; display:flex; align-items:center; gap:7px}
.no-mini{
  flex:none; width:21px;height:21px;border-radius:50%; background:var(--rouge); color:#fff;
  font-size:11px; font-weight:700; display:grid;place-items:center;
}
.no-mini.annee{box-shadow:0 0 0 2px var(--vert)}
.carte-sec{color:var(--gris); font-size:12.5px; margin:0 0 4px}
.carte-adr{color:var(--gris); font-size:12.5px; margin:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.vide{text-align:center; color:var(--gris); padding:40px 20px}

/* ---------- Fiche ---------- */
.voile{position:fixed; inset:0; background:rgba(20,24,28,.45); z-index:var(--z-voile); animation:fondu .2s}
@keyframes fondu{from{opacity:0}to{opacity:1}}
.fiche{
  position:fixed; z-index:var(--z-fiche); left:0; right:0; bottom:0;
  background:#fff; border-radius:20px 20px 0 0; box-shadow:0 -6px 30px rgba(0,0,0,.22);
  max-height:88vh; max-height:88dvh; display:flex; flex-direction:column;
  animation:monte .28s cubic-bezier(.22,1,.36,1);
}
@keyframes monte{from{transform:translateY(100%)}to{transform:translateY(0)}}
.fiche-defile{overflow-y:auto; -webkit-overflow-scrolling:touch}
.fiche-fermer{
  position:absolute; z-index:2; right:12px; top:12px;
  width:32px;height:32px;border-radius:50%; border:0; cursor:pointer;
  background:rgba(20,24,28,.55); color:#fff; font-size:21px; line-height:1;
}
.fiche-photo{background:var(--vert-pale)}
.fiche-photo img{display:block; width:100%; height:190px; object-fit:cover}
.fiche-photo:empty,.fiche-photo img:not([src]){display:none}
.fiche-corps{padding:14px 18px calc(24px + env(safe-area-inset-bottom))}
.fiche-haut{display:flex; align-items:center; gap:9px; margin-bottom:9px}
.pastille-no{
  width:30px;height:30px;border-radius:50%; background:var(--rouge); color:#fff;
  font-weight:700; font-size:14px; display:grid;place-items:center; flex:none;
}
.pastille-no.annee{box-shadow:0 0 0 2.5px var(--vert)}
.etiquette{font-size:11.5px; font-weight:600; padding:4px 10px; border-radius:99px; background:var(--gris-pale); color:var(--gris)}
.etiquette.annee{background:#E4F1E9; color:var(--vert)}
.fiche h2{margin:0 0 3px; font-size:21px; line-height:1.25}
.fiche-section{margin:0 0 11px; color:var(--gris); font-size:13.5px}
.fiche-desc{margin:0 0 13px; font-size:14.5px; color:#3A4048}
.fiche-tags{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:16px}
.tag{font-size:12px; background:var(--vert-pale); color:#3D5A2B; padding:4px 10px; border-radius:99px}
.fiche-actions{display:flex; gap:9px; margin-bottom:16px}
/* Reprend mot pour mot la mention de l'affiche papier. Placée après les
   coordonnées : le visiteur voit d'abord comment joindre le commerçant,
   puis pourquoi il devrait le faire. */
.fiche-avis{
  margin:14px 0 0; font-size:12.5px; line-height:1.45; color:var(--gris);
  background:#F6F7F8; border-radius:9px; padding:10px 12px;
}
.bouton{
  flex:1; display:flex; align-items:center; justify-content:center; gap:7px;
  padding:12px; border-radius:11px; border:1px solid var(--gris-pale);
  background:#fff; color:var(--encre); text-decoration:none; font-weight:600; font-size:14.5px;
}
.bouton.primaire{background:var(--rouge); border-color:var(--rouge); color:#fff}
.bouton[hidden]{display:none}
.fiche-infos{margin:0; border-top:1px solid var(--gris-pale); padding-top:13px}
.fiche-infos>div{display:flex; gap:12px; padding:6px 0; font-size:14px}
.fiche-infos dt{color:var(--gris); width:78px; flex:none}
.fiche-infos dd{margin:0}
.fiche-infos a{color:var(--rouge); word-break:break-word}

/* ---------- Panneau de diagnostic (?debug=1) ---------- */
#dbg{
  position:fixed; left:0; right:0; bottom:0; z-index:var(--z-journal);
  background:rgba(20,24,28,.96); color:#DDE9C8; font-size:11px;
  font-family:ui-monospace,Menlo,Consolas,monospace;
  border-top:2px solid var(--rouge); max-height:42vh; display:flex; flex-direction:column;
}
#dbg.replie #dbg-txt{display:none}
#dbg-barre{
  padding:7px 10px; background:var(--rouge); color:#fff; font-weight:600;
  display:flex; justify-content:space-between; align-items:center; cursor:pointer;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; font-size:12px;
}
#dbg-copier{
  background:#fff; color:var(--rouge); border:0; border-radius:6px;
  padding:5px 12px; font:inherit; font-weight:700; cursor:pointer;
}
#dbg-txt{
  margin:0; padding:8px 10px; overflow-y:auto; white-space:pre-wrap;
  word-break:break-word; flex:1; line-height:1.45;
}

@media (min-width:700px){
  .fiche{left:50%; right:auto; bottom:auto; top:50%; transform:translate(-50%,-50%);
         width:520px; border-radius:18px; max-height:86vh; animation:fondu .2s}
  .grille{grid-template-columns:1fr 1fr}
  #vue-liste{max-width:900px; margin:0 auto}
}
