/* giorni.css — mappa dei valori giornalieri per località.
   Le variabili di colore vengono da app.css (tema chiaro/scuro già gestito lì). */

.gm-main { max-width: 1180px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }

.gm-intro h1 { font-size: clamp(1.5rem, 3.4vw, 2.15rem); line-height: 1.15; margin: 0 0 .5rem; }
.gm-intro p { max-width: 62ch; margin: 0 0 .45rem; line-height: 1.55; }
.gm-meta { font-size: .87rem; opacity: .78; max-width: none; }

.gm-controls { margin: 1.1rem 0 .7rem; display: flex; flex-direction: column; gap: .55rem; }
.gm-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.gm-chips, .gm-pills { display: flex; gap: .4rem; flex-wrap: wrap; }

.gm-chip, .gm-pill, .gm-unit {
  font: inherit; font-size: .88rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text-primary); border-radius: 999px; padding: .38rem .82rem;
  transition: background .15s, border-color .15s, opacity .15s;
}
.gm-chip:hover, .gm-pill:hover:not(:disabled), .gm-unit:hover { border-color: var(--primary); }
.gm-chip.is-on, .gm-pill.is-on {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
}
.gm-pill.is-off, .gm-pill:disabled { opacity: .38; cursor: not-allowed; text-decoration: line-through; }
.gm-unit { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Statistica: sceglie COSA del ventaglio di scenari si guarda. Sta sotto le
   variabili perché la sceglie dopo, e appare solo quando c'è un ensemble dietro. */
.gm-stats { margin-top: -.15rem; }
.gm-chip--stat { font-size: .82rem; padding: .3rem .72rem; opacity: .92; }
.gm-chip--stat.is-on { background: #6d4bb8; border-color: #6d4bb8; color: #fff; opacity: 1; }

/* Catena modellistica: sceglie CHI fa la previsione, non cosa si guarda. È una
   decisione di rango diverso dalla variabile e dal giorno, quindi i suoi chip
   sono visivamente più leggeri e stanno su una riga propria, sopra le altre.
   Fossero identici, l'occhio li leggerebbe come una quarta variabile. */
.gm-chains { margin-bottom: .1rem; }
.gm-chip--chain {
  font-size: .8rem; padding: .28rem .7rem;
  background: transparent; border-style: dashed;
}
.gm-chip--chain.is-on { background: var(--text-primary); border-color: var(--text-primary); border-style: solid; }
/* Il lucchetto dice che serve l'accesso PRIMA di cliccare: scoprirlo dopo, con
   un messaggio di errore al posto della mappa, è una porta in faccia. */
.gm-chip--chain.is-gated::after { content: ' \1F512'; font-size: .8em; opacity: .8; }

.gm-state { padding: 2.2rem 1rem; text-align: center; border: 1px dashed var(--border); border-radius: 12px; }
.gm-state__sub { font-size: .9rem; opacity: .75; margin-top: .5rem; }

.gm-mapwrap { position: relative; margin-top: .5rem; }
.gm-map {
  width: 100%; height: min(72vh, 680px); min-height: 380px;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
}
.gm-count {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; font-size: .78rem;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 7px; padding: .22rem .5rem; pointer-events: none;
}

.gm-legend {
  /* In alto a sinistra: in basso a destra finirebbe sopra l'attribution di MapLibre,
     che non è spostabile né nascondibile (ed è dovuta a Protomaps e OSM).
     Semi-trasparente e stretta: una legenda opaca larga un terzo della carta
     copre territorio, e su una mappa il territorio è il contenuto. */
  position: absolute; left: 10px; top: 10px; width: min(252px, 46vw);
  background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  border: 1px solid var(--border); backdrop-filter: blur(2px);
  border-radius: 7px; padding: .3rem .42rem .22rem; pointer-events: none;
}
.gm-legend__bar { display: flex; height: 7px; border-radius: 2px; overflow: hidden; }
.gm-legend__bar i { flex: 1 1 0; }
.gm-legend__ticks { display: flex; font-size: .58rem; opacity: .78; margin-top: 2px; }
.gm-legend__ticks span { flex: 1 1 0; text-align: center; white-space: nowrap; }
.gm-legend__unit { font-size: .7rem; opacity: .82; text-align: right; margin-top: 1px; }
.gm-legend__unit b { font-variant-numeric: tabular-nums; }

.gm-pop h3 { margin: 0 0 .1rem; font-size: 1rem; }
.gm-pop__sub { margin: 0 0 .45rem; font-size: .76rem; opacity: .75; }
.gm-pop table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.gm-pop th { text-align: left; font-weight: 500; opacity: .82; padding: .12rem 0; }
.gm-pop td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.gm-pop a { display: inline-block; margin-top: .5rem; font-size: .82rem; }

/* ── Il ventaglio dentro il popup ──────────────────────────────────────────
   La mappa mostra una statistica alla volta; qui torna la distribuzione intera.
   Colori NON intercambiabili: la banda e la mediana vengono dai membri di un
   sistema ensemble, il valore dalla corsa deterministica — sono due modelli
   diversi della stessa famiglia, e il disegno non deve suggerire che siano lo
   stesso numero visto in due modi. */
.gm-pop tr.is-on th,
.gm-pop tr.is-on td { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.gm-pop tr.is-on th { border-radius: 4px 0 0 4px; }
.gm-pop tr.is-on td:last-child { border-radius: 0 4px 4px 0; }
.gm-pop__thead td {
  font-size: .64rem; font-weight: 500; opacity: .58; padding-bottom: .08rem;
}
.gm-pop__fan {
  padding-left: .5rem; font-weight: 500 !important; opacity: .74;
  font-size: .77rem; white-space: nowrap;
}

.gm-pop__ens { margin-top: .48rem; border-top: 1px solid var(--border); padding-top: .36rem; }
.gm-pop__ens h4 { margin: 0 0 .12rem; font-size: .78rem; font-weight: 600; line-height: 1.28; }

.gm-fan { display: block; width: 100%; height: auto; }
.gm-fan__band { fill: var(--primary); opacity: .18; }
/* Sul fondo scuro il 18% di azzurro sparisce: la banda è il soggetto del
   disegno e deve restare distinguibile dallo sfondo del popup. */
[data-theme="dark"] .gm-fan__band { opacity: .28; }
/* Un giorno solo: la banda non ha larghezza e resta il segmento fra gli estremi. */
.gm-fan__band1 { stroke: var(--primary); stroke-width: 2.6; opacity: .3; stroke-linecap: round; }
.gm-fan__p50 { fill: none; stroke: var(--primary); stroke-width: 1.7; stroke-linejoin: round; }
.gm-fan__p50-dot { fill: var(--primary); }
.gm-fan__det { fill: none; stroke: var(--text-primary); stroke-width: 1.3; stroke-dasharray: 3.5 2.5; opacity: .8; }
.gm-fan__det-dot { fill: var(--text-primary); opacity: .8; }
.gm-fan__day { stroke: var(--text-hint); stroke-width: 1; stroke-dasharray: 2 2; }
.gm-fan__ax { font-size: 7.5px; fill: var(--text-secondary); text-anchor: end; font-variant-numeric: tabular-nums; }
.gm-fan__dow { font-size: 8px; fill: var(--text-hint); text-anchor: middle; }
.gm-fan__dow.is-on { fill: var(--text-primary); font-weight: 700; }

.gm-pop__key {
  margin: .1rem 0 .22rem; font-size: .65rem; opacity: .72;
  display: flex; flex-wrap: wrap; align-items: center; gap: .05rem .18rem;
}
.gm-pop__key i { display: inline-block; width: 13px; height: 0; margin-right: .12rem; }
.gm-pop__key .k-band { height: 7px; border-radius: 2px; background: color-mix(in srgb, var(--primary) 26%, transparent); }
.gm-pop__key .k-p50 { border-top: 2px solid var(--primary); margin-left: .34rem; }
.gm-pop__key .k-det { border-top: 2px dashed var(--text-primary); opacity: .8; margin-left: .34rem; }

.gm-pop__fanline { margin: .1rem 0; font-size: .78rem; font-variant-numeric: tabular-nums; }
.gm-pop__fanline--off { opacity: .72; font-style: italic; }
.gm-pop__prov { margin: .04rem 0 .18rem; font-size: .67rem; opacity: .68; line-height: 1.35; }
.gm-pop__prob { margin: .15rem 0 0; font-size: .75rem; line-height: 1.5; }
.gm-pop__prob span { white-space: nowrap; }
.gm-pop__prob span + span::before { content: ' · '; opacity: .45; }
.gm-pop__prob b { font-variant-numeric: tabular-nums; }
.maplibregl-popup-content {
  background: var(--bg-primary); color: var(--text-primary); border-radius: 10px;
  /* Il tetto in pixel lo mette giorni-app.js sull'altezza vera della carta. */
  overflow-y: auto; overscroll-behavior: contain;
}
.maplibregl-popup-tip { border-top-color: var(--bg-primary) !important; }

.gm-notes { margin-top: 1.8rem; max-width: 68ch; }
.gm-notes h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
.gm-notes ul { margin: 0; padding-left: 1.1rem; }
.gm-notes li { margin-bottom: .5rem; line-height: 1.55; }

@media (max-width: 640px) {
  .gm-map { height: 62vh; }
  .gm-legend { width: min(260px, 64vw); }
  .gm-unit { margin-left: 0; }
}


/* ── Modalità embed (?embed=1) ─────────────────────────────────────────────
   Serve al render headless che produce le immagini statiche pubblicate in
   /previsioni-mappe/: solo la mappa, con titolo e credito impressi dentro
   l'immagine, perché quelle immagini circolano da sole (rassegna stampa). */
.gm-embed-title, .gm-embed-credit { display: none; }

body.gm-embed { overflow: hidden; }
body.gm-embed .home-header,
body.gm-embed .home-header__mobile-nav,
body.gm-embed .gm-intro,
body.gm-embed .gm-controls,
body.gm-embed .gm-state,
body.gm-embed .gm-notes { display: none !important; }
body.gm-embed .gm-main { max-width: none; margin: 0; padding: 0; }
body.gm-embed .gm-mapwrap { margin: 0; }
body.gm-embed .gm-map { height: 100vh; border-radius: 0; border: 0; }
body.gm-embed .gm-count { display: none; }
/* Nell'immagine non hanno senso: nessuno ci clicca sopra. */
body.gm-embed .maplibregl-ctrl-top-right,
body.gm-embed .cookie-banner,
body.gm-embed #cookie-banner { display: none !important; }
/* L'attribution invece RESTA: è la licenza di Protomaps e OpenStreetMap, e queste
   immagini circolano da sole. Solo resa più leggibile sul fondo scuro. */
body.gm-embed .maplibregl-ctrl-bottom-right { opacity: .95; }

body.gm-embed .gm-embed-title {
  display: block; position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  background: linear-gradient(to bottom, rgba(8,12,22,.86), rgba(8,12,22,0));
  color: #fff; padding: .62rem 1rem 1.7rem; letter-spacing: .01em;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
/* Gerarchia su due righe: cosa e quando in evidenza, la provenienza sotto e
   più quieta. Tutto in una riga sola costringerebbe a leggere per intero una
   stringa che per tre quarti è metadato. */
body.gm-embed .gm-embed-title .t1 { display: block; font-size: 1.12rem; }
body.gm-embed .gm-embed-title .t1 em { font-style: normal; opacity: .92; }
body.gm-embed .gm-embed-title .t1 .sep { font-style: normal; opacity: .45; margin: 0 .42rem; }
body.gm-embed .gm-embed-title .t1 .u { opacity: .68; font-size: .8em; }
body.gm-embed .gm-embed-title .t2 {
  display: block; font-size: .72rem; opacity: .72; margin-top: .12rem;
  letter-spacing: .02em;
}
body.gm-embed .gm-embed-credit {
  /* In alto a destra: in basso finirebbe sopra l'attribution di MapLibre. */
  display: block; position: absolute; right: 12px; top: 10px; z-index: 4;
  font-size: .78rem; color: #fff; opacity: .92; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
body.gm-embed .gm-legend { top: auto; bottom: 14px; left: 12px; width: 300px; }


/* Scala grafica: sobria, sopra la carta senza rubarle spazio. */
.gm-mapwrap .maplibregl-ctrl-scale {
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  border: 1px solid var(--border); border-top: 0;
  color: var(--text-primary); font-size: 10.5px; line-height: 1.35;
  padding: 0 4px; margin: 0 10px 8px;
}
body.gm-embed .maplibregl-ctrl-scale {
  background: rgba(255,255,255,.86); border-color: rgba(0,0,0,.25);
  color: #10161f; margin: 0 12px 40px;
}
