/**
 * Pagina mappa fullscreen
 *
 * Layout: sidebar (380px) + canvas mappa (1fr). La mappa è fullscreen
 * (100vh) e si estende sotto al header trasparente — quando si è sulla
 * pagina mappa diamo al header uno sfondo opaco (vedi sotto) altrimenti
 * il testo dell'header sarebbe illeggibile sulle tile della mappa.
 */

/* Header opaco sulla pagina mappa: copre la prima fascia di mappa così
   il testo resta leggibile anche se le tile sono colorate (es. satellite).
   Uso lo STESSO colore della testata sidebar (var(--crema)) così le due
   zone visivamente si fondono — niente "doppio bordo cream" all'incrocio. */
body.vtds-map-fullscreen .header {
  background: var(--crema);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border-bottom: 1px solid var(--crema-warm);   /* unico sottilissimo divider */
}

/* Sulla pagina mappa il body non deve scrollare: tutto sta in 100vh */
body.vtds-map-fullscreen { overflow: hidden; }
body.vtds-map-fullscreen .footer { display: none; }   /* nessuno scrolla, niente footer */

.mappa-page {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  /* niente padding-top: header è fixed e ha sfondo opaco;
     compensiamo con padding-top SOLO sulla testata sidebar e sui control
     della mappa, così il canvas riempie l'intero viewport. */
}
@media (max-width: 900px) {
  .mappa-page { grid-template-columns: 1fr; height: auto; }
  body.vtds-map-fullscreen { overflow: auto; }
  body.vtds-map-fullscreen .footer { display: block; }
  .mappa-canvas { height: 60vh; }
}

/* ──────────────────────────────────────────────────────────────────────── */
/* Sidebar                                                                  */
/* ──────────────────────────────────────────────────────────────────────── */

.mappa-sidebar {
  background: var(--bianco);
  border-right: 1px solid var(--crema-warm);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  /* NIENTE padding-top qui: lo spostiamo dentro a __head (vedi sotto) così
     l'area "sotto al header fixed" è coperta dallo stesso bg crema del __head
     invece che dal bg bianco della sidebar. Risultato: zero strip biancastra
     visibile sotto al bordo del header. */
}

.mappa-sidebar__head {
  /* padding-top abbondante = spazio del header fixed (~82px) + spaziatura
     interna 1.25rem. La parte sopra al border-bottom del header è nascosta
     SOTTO al header — ma è già crema, quindi anche se restano 1-2px di
     scoperto è visivamente identico al header. */
  padding: calc(82px + 1.25rem) 1.5rem 1.1rem;
  border-bottom: 1px solid var(--crema-warm);
  background: var(--crema);
}
@media (max-width: 900px) {
  .mappa-sidebar__head { padding-top: calc(72px + 1.25rem); }
}
.mappa-sidebar__title {
  font-family: var(--ff-display);
  font-size: 1.35rem;
  line-height: 1.15;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}
.mappa-sidebar__sub {
  font-size: 0.85rem;
  color: var(--grigio);
  margin: 0 0 0.9rem;
  line-height: 1.45;
}

.mappa-search {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--crema-warm);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: white;
  box-sizing: border-box;
}
.mappa-search:focus { outline: 2px solid var(--terra); border-color: var(--terra); outline-offset: 0; }

/* Filtri principali (categoria) */
.mappa-quickfilters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}
.mappa-quickfilters button {
  background: white;
  border: 1px solid var(--crema-warm);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.mappa-quickfilters button:hover { border-color: var(--terra); color: var(--terra); }
.mappa-quickfilters button.active { background: var(--terra); color: white; border-color: var(--terra); }

/* Sub-filtri (chip per tipo, popolati da JS quando attivi) */
.mappa-subfilters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--crema-warm);
  animation: vtds-subfilter-in 0.25s ease;
}
.mappa-subfilters[hidden] { display: none; }
@keyframes vtds-subfilter-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mappa-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: white;
  border: 1px solid var(--crema-warm);
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--seppia);
  line-height: 1;
  transition: all 0.18s;
}
.mappa-chip:hover { border-color: var(--ocra); color: var(--ocra-dark); }
.mappa-chip.active {
  background: var(--adriatico);
  border-color: var(--adriatico);
  color: white;
}
.mappa-chip__count {
  font-size: 0.68rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.07);
  color: inherit;
  opacity: 0.85;
}
.mappa-chip.active .mappa-chip__count { background: rgba(255,255,255,0.22); }

/* ──────────────────────────────────────────────────────────────────────── */
/* Sidebar — lista per categoria                                            */
/* ──────────────────────────────────────────────────────────────────────── */

.mappa-sidebar__categories { padding: 0.5rem 0 1rem; }
.mappa-loading { padding: 1.5rem; color: var(--grigio); font-style: italic; }

.mappa-cat { border-bottom: 1px solid var(--crema-warm); }
.mappa-cat:last-child { border-bottom: none; }

.mappa-cat__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--seppia);
  text-align: left;
}
.mappa-cat__header:hover { background: var(--crema); }
.mappa-cat__count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--grigio);
  margin-left: 0.35rem;
}

/* Chevron rotante: orizzontale = collapsed, ruotato 90° = open */
.mappa-cat__chevron {
  display: inline-block;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--grigio);
  transform: rotate(0deg);
  transition: transform 0.25s ease;
}
.mappa-cat.is-open .mappa-cat__chevron { transform: rotate(90deg); color: var(--terra); }

/* Lista item — IMPORTANTE: nessun divider sulla riga singola.
   Il divider esiste solo TRA due item adiacenti (border-top sull'item
   non-primo), così se la categoria contiene un solo POI non vedi il
   "trattino di troppo" che c'era prima. */
.mappa-cat__list {
  padding: 0 1.5rem 0.6rem;
  display: none;
}
.mappa-cat.is-open .mappa-cat__list { display: block; }

.mappa-cat__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0;
  font-size: 0.88rem;
  color: var(--seppia);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(0,0,0,0.05);   /* solo tra item adiacenti */
  text-align: left;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
}
.mappa-cat__item:first-child { border-top: none; }
.mappa-cat__item:hover,
.mappa-cat__item:focus-visible {
  color: var(--terra);
  background: rgba(160, 64, 48, 0.04);
  outline: none;
}
.mappa-cat__item:hover .mappa-cat__type,
.mappa-cat__item:focus-visible .mappa-cat__type { color: var(--terra); }

/* Type prefix: piccolo, maiuscoletto, sopra al nome (es. "Ristorante") */
.mappa-cat__type {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--grigio);
  font-weight: 600;
  line-height: 1;
}
.mappa-cat__name {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.25;
  color: inherit;
}

/* ──────────────────────────────────────────────────────────────────────── */
/* Canvas mappa                                                              */
/* ──────────────────────────────────────────────────────────────────────── */

.mappa-canvas { position: relative; }
.mappa-leaflet { width: 100%; height: 100%; }

/* Su mobile la mappa segue la sidebar nello scroll della pagina — non
   serve padding-top sul canvas, lo offset al header lo dà già la sidebar
   sopra. */

/* I controlli Leaflet (zoom, layer, geo) vanno spinti sotto al header su mobile;
   su desktop il header non interferisce perché sta sopra alla sidebar. */
body.vtds-map-fullscreen .leaflet-top { top: 88px; }
@media (max-width: 900px) {
  body.vtds-map-fullscreen .leaflet-top { top: 78px; }
}

/* ──────────────────────────────────────────────────────────────────────── */
/* Pin SVG (marker)                                                          */
/* ──────────────────────────────────────────────────────────────────────── */

.vtds-pin-wrap { background: none !important; border: none !important; }
.vtds-pin {
  display: block;
  transition: transform 0.18s cubic-bezier(.4,1.4,.6,1);
  /* origine sulla punta del gambo (15/30, 44/46) così lo scale al hover
     non sposta il punto di ancoraggio sulla mappa */
  transform-origin: 50% 96%;
  cursor: pointer;
}
.vtds-pin-wrap:hover .vtds-pin,
.vtds-pin-wrap:focus-visible .vtds-pin { transform: scale(1.15); }

/* Cluster custom (override leaflet.markercluster default) */
.marker-cluster-vtds {
  background: var(--terra) !important;
  color: white !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.88rem;
  border: 3px solid white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
.marker-cluster-vtds div { background: transparent !important; }

/* ──────────────────────────────────────────────────────────────────────── */
/* User location (dot pulsante stile Google Maps)                            */
/* ──────────────────────────────────────────────────────────────────────── */

.vtds-userdot-wrap { background: none !important; border: none !important; }
.vtds-userdot {
  position: relative;
  width: 22px; height: 22px;
}
.vtds-userdot__core {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  z-index: 2;
}
.vtds-userdot__pulse {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(26, 115, 232, 0.35);
  z-index: 1;
  animation: vtds-userpulse 2s ease-out infinite;
}
@keyframes vtds-userpulse {
  0%   { transform: scale(0.8); opacity: 0.75; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ──────────────────────────────────────────────────────────────────────── */
/* Pulsante "Mostra la mia posizione" (nella sidebar)                        */
/* ──────────────────────────────────────────────────────────────────────── */

.mappa-locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.65rem 0.9rem;
  background: white;
  border: 1px solid var(--crema-warm);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--seppia);
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.1;
}
.mappa-locate-btn:hover {
  border-color: #1a73e8;
  color: #1a73e8;
  background: #f6faff;
}
.mappa-locate-btn:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}
.mappa-locate-btn.is-active {
  background: #1a73e8;
  border-color: #1a73e8;
  color: white;
}
.mappa-locate-btn.is-active:hover { background: #1864c8; }
.mappa-locate-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.mappa-locate-btn__icon { flex-shrink: 0; }
.mappa-locate-btn.is-loading .mappa-locate-btn__icon { animation: vtds-spin 1s linear infinite; }
@keyframes vtds-spin { to { transform: rotate(360deg); } }

/* Toast consenso geolocazione */
.mappa-geo-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: white;
  border: 1px solid var(--crema-warm);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(15, 38, 56, 0.18);
  padding: 1.1rem 1.25rem;
  width: min(440px, calc(100vw - 2rem));
  z-index: 9000;
  animation: vtds-toast-in 0.25s ease;
  font-family: var(--ff-body);
}
.mappa-geo-toast.is-leaving { animation: vtds-toast-out 0.2s ease forwards; }
.mappa-geo-toast--error {
  background: #fff3f0;
  border-color: #e0c0b8;
  color: var(--terra);
}
.mappa-geo-toast__title {
  margin: 0 0 0.4rem;
  font-family: var(--ff-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--seppia);
}
.mappa-geo-toast__body {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--grigio);
}
.mappa-geo-toast__body strong { color: var(--seppia); }
.mappa-geo-toast__body a { color: var(--terra); }
.mappa-geo-toast__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
@keyframes vtds-toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes vtds-toast-out {
  to { opacity: 0; transform: translate(-50%, 10px); }
}

/* ──────────────────────────────────────────────────────────────────────── */
/* Layer switcher (Leaflet default, ritoccato a tema)                        */
/* ──────────────────────────────────────────────────────────────────────── */

.leaflet-control-layers {
  border: none !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18) !important;
  font-family: var(--ff-body) !important;
}
.leaflet-control-layers-toggle {
  width: 34px !important; height: 34px !important;
  background-size: 18px 18px !important;
}
.leaflet-control-layers-expanded {
  padding: 0.6rem 0.8rem !important;
  background: white !important;
  color: var(--seppia) !important;
  font-size: 0.85rem !important;
}
.leaflet-control-layers-expanded label {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.2rem 0;
  cursor: pointer;
}
.leaflet-control-layers-expanded input[type=radio] { accent-color: var(--terra); }

/* ──────────────────────────────────────────────────────────────────────── */
/* Popup                                                                     */
/* ──────────────────────────────────────────────────────────────────────── */

.leaflet-popup-content { margin: 0 !important; padding: 0 !important; }
.leaflet-popup-content-wrapper { border-radius: 10px; padding: 0; overflow: hidden; box-shadow: 0 6px 22px rgba(0,0,0,0.22); }
.vtds-popup { width: 240px; font-family: var(--ff-body); }
.vtds-popup__media {
  width: 100%;
  height: 130px;
  background-size: cover;
  background-position: center;
  background-color: var(--crema-warm);
}
.vtds-popup__body { padding: 0.9rem 1rem 1rem; }
.vtds-popup__tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background: var(--ocra-light);
  color: var(--ocra-dark);
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.vtds-popup__title {
  font-family: var(--ff-display);
  font-size: 1.08rem;
  margin: 0.2rem 0 0.4rem;
  line-height: 1.2;
}
.vtds-popup__cta {
  font-size: 0.85rem;
  color: var(--terra);
  font-weight: 500;
}

/* ============ "Vicino a te" panel ============ */
.mappa-nearme {
  padding: 1rem 1.1rem 1.2rem;
  margin: 0 0.6rem 0.8rem;
  background: linear-gradient(135deg, var(--crema) 0%, rgba(200,153,104,0.12) 100%);
  border-radius: 10px;
  border: 1px solid rgba(160,64,48,0.18);
}
.mappa-nearme[hidden] { display: none; }
.mappa-nearme__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font: 500 0.9rem/1 'Fraunces', serif;
  color: var(--terra);
  margin: 0 0 0.7rem;
}
.mappa-nearme__title svg { flex-shrink: 0; }
.mappa-nearme__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.mappa-nearme__item { margin: 0; }
.mappa-nearme__link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--seppia);
  transition: background .12s ease;
}
.mappa-nearme__link:hover { background: rgba(255,255,255,0.6); }
.mappa-nearme__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--terra);
  color: white;
  border-radius: 50%;
  font: 600 0.72rem/1 'Inter', sans-serif;
}
.mappa-nearme__body { flex: 1; min-width: 0; }
.mappa-nearme__name {
  display: block;
  font: 500 0.85rem/1.2 'Inter', sans-serif;
  color: var(--adriatico);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mappa-nearme__type {
  display: block;
  font: 400 0.72rem/1 'Inter', sans-serif;
  color: var(--grigio);
  margin-top: 0.15rem;
  letter-spacing: 0.02em;
}
.mappa-nearme__dist {
  flex-shrink: 0;
  font: 600 0.78rem/1 'Inter', sans-serif;
  color: var(--terra);
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(160,64,48,0.2);
}

/* Walking time + Google Maps directions link */
.mappa-nearme__item { display: flex; align-items: stretch; gap: 0.3rem; }
.mappa-nearme__meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.18rem; }
.mappa-nearme__walk {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font: 500 0.72rem/1 'Inter', sans-serif;
  color: var(--lecceta);
}
.mappa-nearme__walk-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--adriatico);
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(31,24,19,0.1);
  font: 500 1rem/1 'Inter', sans-serif;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.mappa-nearme__walk-link:hover { background: var(--adriatico); color: white; border-color: var(--adriatico); }
