/**
 * Carte d'exploration — chargée par carte/index.php seulement.
 *
 * Mobile first : la base reprend l'écran 6 du guide — carte plein écran,
 * recherche et filtres posés dessus en haut, fiches en bas. À partir de 992 px,
 * la liste passe dans une colonne de 400 px à gauche de la carte.
 */

/* ---- Pleine hauteur, sans pied de page ----------------------------- */

body.t-page-carte {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

body.t-page-carte > main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.t-explorer {
  position: relative;
  flex: 1 1 auto;
  min-height: 480px;
  overflow: hidden;
  background: var(--t-green-light);
}

.t-explorer__carte {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.t-explorer .leaflet-container { font-family: var(--t-font-texte); background: var(--t-green-light); }
.t-explorer .leaflet-control-attribution { font-size: 10.5px; }

/* ---- Ce qui recouvre la carte ------------------------------------- */

/* La couche ne capte les gestes que là où elle a du contenu : entre la
   recherche et les fiches, la carte reste manipulable. */
.t-explorer__cote {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.t-explorer__haut,
.t-explorer__panneau { pointer-events: auto; }

.t-explorer__haut { padding: 12px var(--t-pad-mobile) 0; }

.t-explorer__recherche {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  background: rgba(247, 244, 238, .97);
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-md);
  backdrop-filter: blur(8px);
  box-shadow: var(--t-shadow-douce);
}

.t-explorer__recherche:focus-within { border-color: var(--t-primary); box-shadow: 0 0 0 3px rgba(14, 127, 163, .18); }

.t-explorer__recherche input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--t-ink);
}

.t-explorer__filtres { margin-top: 10px; }

.t-explorer__filtres .t-chip {
  background: rgba(247, 244, 238, .97);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.t-explorer__filtres .t-chip.is-active { background: var(--t-ink); border-color: var(--t-ink); color: var(--t-bg); }
.t-chip__nombre { opacity: .6; }

/* ---- Outils ------------------------------------------------------- */

/* Sur mobile, les outils se posent juste au-dessus des fiches, dont la hauteur
   est tenue à jour dans --panneau par le script : placés à mi-hauteur, ils
   recouvraient les fiches dès que le panneau grandissait. */
.t-explorer__outils {
  position: absolute;
  z-index: 600;
  right: 12px;
  bottom: calc(var(--panneau, 170px) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* En mode liste, les fiches couvrent la moitié de l'écran : les outils de la
   carte n'y ont plus leur place. */
.t-explorer.is-liste .t-explorer__outils { display: none; }

/* L'attribution d'OpenStreetMap doit rester lisible : elle remonte au-dessus
   des fiches au lieu de passer dessous. */
.t-explorer .leaflet-bottom { bottom: var(--panneau, 0px); }

@media (min-width: 992px) {
  .t-explorer__outils { bottom: auto; }
  .t-explorer.is-liste .t-explorer__outils { display: flex; }
  .t-explorer .leaflet-bottom { bottom: 0; }
}

.t-explorer__outil {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--t-border);
  border-radius: 11px;
  background: var(--t-bg);
  color: var(--t-ink-2);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--t-shadow-douce);
}

.t-explorer__outil:hover { color: var(--t-ink); border-color: var(--t-border-strong); }
.t-explorer__outil svg { stroke: currentColor; fill: none; }
.t-explorer__outil:disabled { opacity: .6; cursor: progress; }

.t-explorer__outil:focus-visible,
.t-explorer__bascule:focus-visible,
.t-fiche-carte:focus-visible { outline: 3px solid var(--t-primary); outline-offset: 2px; }

.t-explorer__message {
  position: absolute;
  z-index: 700;
  left: 50%;
  top: 130px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(90%, 360px);
  margin: 0;
  padding: 9px 14px;
  border-radius: var(--t-r-sm);
  background: var(--t-ink);
  color: var(--t-bg);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

/* ---- Panneau des fiches ------------------------------------------- */

.t-explorer__panneau {
  padding: 28px var(--t-pad-mobile) 16px;
  background: linear-gradient(180deg, rgba(247, 244, 238, 0) 0%, rgba(247, 244, 238, .95) 36%);
}

.t-explorer__panneau-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.t-explorer__compteur { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--t-ink-2); }

.t-explorer__bascule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 0;
  border-radius: var(--t-r-pill);
  background: var(--t-ink);
  color: var(--t-bg);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.t-explorer__bascule svg { stroke: currentColor; fill: none; }

.t-explorer__liste {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.t-explorer__fiche { flex: 0 0 240px; scroll-snap-align: start; }
.t-explorer__vide { margin: 0; font-size: 14px; color: var(--t-muted); }

.t-fiche-carte {
  display: flex;
  gap: 10px;
  height: 100%;
  padding: 10px;
  background: var(--t-surface);
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-md);
  box-shadow: 0 6px 18px rgba(23, 26, 29, .08);
  color: var(--t-ink);
}

.t-fiche-carte:hover { color: var(--t-ink); border-color: var(--t-border-strong); }
.is-selectionne > .t-fiche-carte { border-color: var(--t-primary); box-shadow: 0 0 0 2px var(--t-primary); }

.t-fiche-carte__vignette {
  flex: 0 0 58px;
  height: 58px;
  border-radius: var(--t-r-xs);
  overflow: hidden;
  background: var(--t-hatch-a);
}

.t-fiche-carte__vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.t-fiche-carte__corps { flex: 1; min-width: 0; }

.t-fiche-carte__nom {
  display: block;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t-fiche-carte__lieu { display: block; font-size: 12px; color: var(--t-muted); }

.t-fiche-carte__badge {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--t-primary-soft);
  font-size: 11px;
  font-weight: 700;
  color: var(--t-primary-dark);
  white-space: nowrap;
}

/* Mode liste, sur mobile : les fiches s'empilent sur une moitié d'écran */
.t-explorer.is-liste .t-explorer__panneau {
  padding-top: 14px;
  background: var(--t-bg);
  border-top: 1px solid var(--t-border);
}

.t-explorer.is-liste .t-explorer__liste {
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 55vh;
  max-height: 55dvh;
  scroll-snap-type: none;
}

.t-explorer.is-liste .t-explorer__fiche { flex: 0 0 auto; }

/* ---- Points et grappes -------------------------------------------- */

.t-point { background: transparent; border: 0; }

.t-point span {
  display: block;
  width: 14px;
  height: 14px;
  margin: 2px;
  border-radius: 50%;
  background: var(--t-primary);
  box-shadow: 0 0 0 6px rgba(14, 127, 163, .18);
  transition: transform .15s ease;
}

.t-point--carnet span { background: var(--t-warm); box-shadow: 0 0 0 6px rgba(196, 98, 45, .2); }
.t-point.is-actif span,
.t-point:focus-visible span { transform: scale(1.4); }

.t-grappe { background: transparent; border: 0; }

.t-grappe span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: var(--t-r-pill);
  background: var(--t-ink);
  color: var(--t-bg);
  font: 700 12.5px/1 var(--t-font-texte);
  box-shadow: 0 4px 12px rgba(23, 26, 29, .22);
}

/* ---- Desktop : liste à gauche, carte à droite ---------------------- */

@media (min-width: 992px) {
  .t-explorer__carte { left: 400px; }

  .t-explorer__cote {
    right: auto;
    width: 400px;
    justify-content: flex-start;
    pointer-events: auto;
    background: var(--t-bg);
    border-right: 1px solid var(--t-border);
  }

  .t-explorer__haut { padding: 18px 20px 0; }

  .t-explorer__panneau {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 20px 20px;
    background: none;
  }

  .t-explorer__bascule[data-action] { display: none; }

  .t-explorer__liste {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 4px;
    scroll-snap-type: none;
  }

  .t-explorer__fiche { flex: 0 0 auto; }
  .t-explorer__outils { top: 16px; right: 16px; transform: none; }
  .t-explorer__message { top: 24px; left: calc(400px + (100% - 400px) / 2); }
}
