/* ------------------------------------------------------------------ *
 * Mappa ed elementi sovrapposti
 * ------------------------------------------------------------------ */
.map-block { position: relative; height: min(80vh, 860px); min-height: 460px; border-radius: var(--r-xl); overflow: hidden; background: #e9eae9; max-width: none !important; }
#map { position: absolute; inset: 0; }

.map-legend {
  position: absolute; left: 18px; bottom: 18px; z-index: 2;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: var(--r-l);
  padding: 18px 20px; max-width: 250px; font-size: 13px; color: var(--ink-2);
  display: flex; flex-direction: column; gap: 12px;
}
.map-legend:empty { display: none; }
.lg-title { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.lg-rows { display: flex; flex-direction: column; gap: 6px; }
.lg-row { display: flex; align-items: center; gap: 10px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.lg-row i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.lg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lg-toggle { display: none; border: 0; background: none; font-size: 12px; color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; padding: 0; }

.map-card {
  position: absolute; left: 18px; top: 18px; z-index: 3; width: min(280px, calc(100% - 36px));
  background: var(--white); border-radius: var(--r-l); padding: 20px 22px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.08);
}
.map-card h4 { margin: 0; font: 500 20px/1.15 var(--ff); letter-spacing: -.02em; padding-right: 24px; }
.map-card .mc-row { display: flex; gap: 22px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-card .mc-row b { display: block; font: 600 22px/1.2 var(--ff); color: var(--ink); }
.map-card .mc-row b.acc { color: var(--accent); }
.map-card .x { position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; font-size: 18px; color: var(--muted); }

.map-status { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 4; background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 18px; font-size: 13px; pointer-events: none; white-space: nowrap; }
.map-status:empty { display: none; }
.map-status.warn { background: var(--ink-2); white-space: normal; max-width: min(440px, 90%); text-align: center; border-radius: var(--r-m); }
.map-summary { margin-top: 18px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-summary b { color: var(--ink); font-weight: 500; }

/* Popup */
.maplibregl-popup { z-index: 5; }
.maplibregl-popup-content { border-radius: var(--r-l); padding: 22px 22px 18px; box-shadow: 0 18px 40px rgba(0,0,0,.12); font-family: var(--ff); color: var(--ink); }
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { font-size: 20px; width: 30px; height: 30px; right: 8px; top: 8px; color: var(--muted); border-radius: 50%; }
.pop { min-width: 230px; max-width: 270px; display: flex; flex-direction: column; gap: 10px; }
.pop-kind { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.pop-kind i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pop h3 { font: 500 17px/1.3 var(--ff); padding-right: 20px; }
.pop .where { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.pop table { border-collapse: collapse; width: 100%; font-size: 13px; }
.pop td { padding: 6px 0; border-top: 1px solid var(--line); color: var(--muted); }
.pop tr:first-child td { border-top: 0; }
.pop td.n { text-align: right; font-weight: 400; color: var(--ink); white-space: nowrap; padding-left: 12px; font-variant-numeric: tabular-nums; }
.pop tr:first-child td.n { color: var(--accent); }
.pop td.nd { color: var(--faint); }
.pop .note { font-size: 12px; margin: 0; }
.pop .acts { gap: 16px; }
.pop .acts a { font-size: 13px; color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 5px; }

.maplibregl-popup.tip-popup .maplibregl-popup-content { padding: 8px 12px; border-radius: 12px; box-shadow: 0 8px 20px rgba(0,0,0,.08); }
.tip { font-size: 13px; }
.tip b { font-weight: 500; }
.tip span { color: var(--muted); margin-left: 8px; font-variant-numeric: tabular-nums; }

.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: none !important; }
.maplibregl-ctrl-scale { border-color: var(--ink-2); color: var(--ink-2); background: rgba(255,255,255,.8); font-family: var(--ff); }
.maplibregl-ctrl-attrib { font-size: 10.5px; }
.maplibregl-ctrl-bottom-right { right: 8px; bottom: 8px; }
.maplibregl-cooperative-gesture-screen { font-family: var(--ff); font-size: 17px; background: rgba(20,20,20,.5); }

/* Scheda del comparto su schermi stretti: pannello in basso dentro la mappa */
.map-sheet {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 6;
  max-height: 62%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--white); border-radius: var(--r-l); padding: 20px 20px 16px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.14);
  transform: translateY(16px); opacity: 0; transition: transform .3s var(--ease, ease), opacity .2s;
}
.map-sheet.on { transform: none; opacity: 1; }
.sheet-open .map-card, .sheet-open .map-legend { display: none; }
.map-sheet .pop { min-width: 0; max-width: none; }
.map-sheet .pop h3 { padding-right: 36px; }
.sheet-x { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--bg); font-size: 20px; line-height: 1; color: var(--ink-2); }

@media (max-width: 760px) {
  .map-block { height: 72svh; min-height: 420px; border-radius: var(--r-l); }
  .map-legend { left: 10px; bottom: 10px; max-width: 200px; padding: 12px 14px; }
  .map-legend.collapsed > :not(.lg-head) { display: none; }
  .lg-toggle { display: inline-block; }
  .map-card { left: 10px; top: 10px; }
}
