/* La Contea del Natale — mappa illustrata del parco (acquerello su carta). Disegno e animazioni in js/mappa.js. */

.mappa { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
.mappa > *, .mappa__legenda, .mappa__scheda { min-width: 0; }
.mappa__lato { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 96px; }

/* Legenda: elenco a numeri su desktop, fila di pulsanti scorrevole su telefono */
.mappa__legenda { display: flex; flex-direction: column; gap: 12px; }
.mappa__legenda-titolo { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--testo-3); font-weight: 600; }
.mappa__voci { display: flex; flex-direction: column; gap: 2px; }
.mappa__voce {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 6px 10px 6px 6px;
  border: 0; background: transparent; border-radius: 12px; text-align: left; cursor: pointer;
  font-family: var(--titoli); font-size: 18px; line-height: 1.25; color: var(--bosco);
}
.mappa__voce:hover { background: var(--bordo-chiaro); }
.mappa__voce[aria-pressed="true"] { background: var(--bianco); box-shadow: 0 0 0 1.5px var(--bosco) inset; }
.mappa__voce small { display: block; font-family: var(--corpo); font-size: 13px; color: var(--testo-3); line-height: 1.3; }
.mappa__numero {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--titoli); font-weight: 600; font-size: 15px; color: var(--carta); background: var(--c, var(--oliva));
}
.mappa__numero--lettera { background: var(--carta); color: var(--bosco); box-shadow: 0 0 0 1.5px var(--bosco) inset; font-size: 14px; }

.mappa__scheda { background: var(--crema); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--bordo); min-height: 150px; }
.mappa__tipo { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--c, var(--testo-3)); }
.mappa__scheda h3 { font-family: var(--titoli); font-size: 24px; font-weight: 600; color: var(--bosco); line-height: 1.15; }
.mappa__orario { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mappa__orario::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--oliva)); }
.mappa__scheda p { color: var(--testo-2); font-size: 15px; }

/* Riquadro della mappa (l'area contiene anche lo stato del trenino: sopra la mappa su computer, sotto su telefono) */
.mappa__area { position: relative; min-width: 0; }
.mappa__quadro { position: relative; border-radius: 24px; overflow: hidden; background: #F3EBDC; box-shadow: 0 1px 0 var(--bordo), 0 18px 40px -24px rgba(61, 57, 34, .45); }
/* A tutta larghezza, ma mai più alta della finestra (meno la barra in alto): il parco resta tutto visibile
   al centro e ai lati si vede più paese (preserveAspectRatio "meet" nell'SVG). */
.mappa__svg { display: block; width: 100%; height: auto; aspect-ratio: 1250 / 1400; max-height: max(320px, calc(100vh - 120px)); max-height: max(320px, calc(100svh - 120px)); touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.mappa__svg.zoomata { touch-action: none; }
.mappa__svg.trascina { cursor: grabbing; }
.mappa__grana {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .48 0 0 0 0 .35 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}
.mappa__neve { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mappa__comandi { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.mappa__comandi button, .mappa__ferma {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--carta); color: var(--bosco); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 4px 14px -6px rgba(61, 57, 34, .5);
}
.mappa__comandi button:hover, .mappa__ferma:hover { background: var(--bordo-chiaro); }
.mappa__ferma { position: absolute; left: 12px; bottom: 12px; width: auto; padding: 0 14px; gap: 8px; display: inline-flex; align-items: center; font-size: 14px; font-weight: 500; }
/* Torna alla mappa intera: in alto a sinistra sulla mappa (sotto lo stato del trenino) e in fondo alla scheda */
.mappa__ritorno {
  position: absolute; left: 12px; top: 56px; min-height: 44px; padding: 0 16px 0 12px; border: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; background: var(--bosco); color: var(--carta);
  font-family: var(--corpo); font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px -6px rgba(61, 57, 34, .6);
}
.mappa__ritorno[hidden] { display: none; }
.mappa__ritorno:hover { filter: brightness(1.15); }
.mappa__indietro {
  align-self: flex-start; margin-top: 4px; min-height: 40px; padding: 0 14px 0 8px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; background: var(--bianco); color: var(--bosco); border: 1.5px solid var(--bosco);
  font-family: var(--corpo); font-size: 14px; font-weight: 600;
}
.mappa__indietro:hover { background: var(--bordo-chiaro); }
.mappa__treno {
  position: absolute; left: 12px; top: 12px; max-width: calc(100% - 80px);
  background: var(--carta); border-radius: 999px; padding: 7px 12px 7px 10px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px -6px rgba(61, 57, 34, .5);
}
.mappa__treno i { width: 9px; height: 9px; border-radius: 50%; background: #7A4E6E; flex: none; }
.mappa__treno.fermo i { background: var(--testo-3); }

/* Oggetti disegnati dentro la mappa */
.mappa__svg text { font-family: var(--titoli); }
.mappa__svg .z { transition: opacity .35s ease; }
.mappa__svg .spento { opacity: .22; }
.mappa__svg .zona-area { cursor: pointer; transition: fill-opacity .3s ease; }
.mappa__svg .zona-area:hover { fill-opacity: .42; }
.mappa__svg .attivo .zona-area { fill-opacity: .5; }
.mappa__svg .segnaposto { cursor: pointer; }
.mappa__svg .segnaposto:hover circle { stroke-width: 6; }
.mappa__svg .alone { paint-order: stroke; stroke: #FBF6EC; stroke-width: 9px; stroke-linejoin: round; }
/* Anello che pulsa attorno ai segnaposto della voce scelta (es. ingressi e bagni) */
.mappa__svg .pulsa { opacity: 0; pointer-events: none; transform-box: fill-box; transform-origin: center; }
.mappa__svg .attivo .pulsa { animation: mappa-pulsa 1.4s ease-out infinite; }
/* Ingressi e bagni scelti: diventano rossi pieni, così si trovano subito */
.mappa__svg .z-ingressi.attivo circle:not(.pulsa), .mappa__svg .z-ingressi.attivo rect:not(.pulsa) { fill: #A8352B; stroke: #FBF6EC; }
.mappa__svg .z-ingressi.attivo line { stroke: #A8352B; }
.mappa__svg .z-ingressi.attivo text { fill: #FFFDF8; }
@keyframes mappa-pulsa { 0% { opacity: .95; transform: scale(1); } 100% { opacity: 0; transform: scale(2.3); } }
.mappa__svg .stand { cursor: pointer; }
.mappa__svg .stand text { font-family: var(--corpo); font-weight: 600; font-size: 11px; fill: var(--bosco); opacity: 0; transition: opacity .25s; }
.mappa__svg.vicino .stand text { opacity: 1; }
.mappa__svg .stand.scelto rect { stroke: var(--bacca); stroke-width: 4; }

@media (max-width: 900px) {
  .mappa { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .mappa__lato { display: contents; }
  .mappa__legenda { order: -1; }
  .mappa__legenda-titolo { display: none; }
  .mappa__scorri { overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding: 2px var(--gutter) 6px; scrollbar-width: none; }
  .mappa__scorri::-webkit-scrollbar { display: none; }
  .mappa__voci { flex-direction: row; gap: 8px; width: max-content; }
  .mappa__voce { width: auto; white-space: nowrap; border-radius: 999px; padding: 5px 14px 5px 5px; background: var(--bianco); font-size: 16px; box-shadow: 0 0 0 1px var(--bordo) inset; }
  .mappa__voce small { display: none; }
  .mappa__area { order: 0; }
  .mappa__quadro { border-radius: 18px; }
  .mappa__scheda { order: 1; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mappa__svg .z, .mappa__svg .zona-area, .mappa__svg .stand text { transition: none; }
  .mappa__svg .attivo .pulsa { animation: none; opacity: .8; transform: scale(1.35); }
}

/* Telefono: comandi in una sola colonnina di icone, stato del trenino sotto la mappa */
@media (max-width: 640px) {
  .mappa__comandi { right: 8px; top: 8px; gap: 5px; }
  .mappa__comandi button, .mappa__ferma { width: 38px; height: 38px; border-radius: 12px; }
  .mappa__comandi button.evidente { background: var(--bosco); color: var(--carta); }
  .mappa__ritorno { display: none; }
  .mappa__ferma { left: auto; right: 8px; bottom: auto; top: calc(8px + 3 * 43px); padding: 0; justify-content: center; }
  .mappa__ferma span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mappa__treno { position: static; max-width: none; margin-top: 8px; padding: 0 2px; background: none; box-shadow: none; border-radius: 0; font-size: 13px; color: var(--testo-2); }
}
