/* Meteo — direzione A "Cielo vivo". Token delle 12 scene = .context/design/scene.json (verificati per contrasto). */

/* Registrati per poter dissolvere il cambio di scena (400 ms); senza supporto il cambio è immediato. */
@property --sky-top { syntax: '<color>'; inherits: true; initial-value: #3a9be6; }
@property --sky-bottom { syntax: '<color>'; inherits: true; initial-value: #b5e3fc; }
@property --text { syntax: '<color>'; inherits: true; initial-value: #04131f; }
@property --text-soft { syntax: '<color>'; inherits: true; initial-value: #08202f; }
@property --glass-a { syntax: '<number>'; inherits: true; initial-value: 0.3; }

:root {
  /* scena iniziale (prima che arrivi il primo dato): sereno, giorno o notte secondo il dispositivo */
  --sky-top: #3a9be6; --sky-bottom: #b5e3fc; --text: #04131f; --text-soft: #08202f; --glass-a: 0.3; --ink: 6, 24, 38;
  /* intestazione fissa: spazio sopra (area sicura inclusa) e sotto; ne dipende scroll-padding-top */
  --top-pt: max(18px, env(safe-area-inset-top)); --top-pb: var(--s2);
  --radius: 22px; --radius-sm: 16px; --gap: 14px; --pad: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --alert-yellow-bg: #ffd166; --alert-yellow-fg: #2b2100;
  --alert-orange-bg: #ff9f43; --alert-orange-fg: #2b1500;
  --alert-red-bg: #d62828; --alert-red-fg: #ffffff;
  --blur: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --sky-top: #0a1630; --sky-bottom: #1f3a63; --text: #ffffff; --text-soft: #d4dfec; --glass-a: 0.12; --ink: 255, 255, 255; }
}

body[data-scene="sereno-giorno"]    { --sky-top: #3a9be6; --sky-bottom: #b5e3fc; --text: #04131f; --text-soft: #08202f; --glass-a: 0.3;  --ink: 6, 24, 38; }
body[data-scene="nuvoloso-giorno"]  { --sky-top: #7f95aa; --sky-bottom: #c3cfda; --text: #0b1b2a; --text-soft: #18293a; --glass-a: 0.3;  --ink: 6, 24, 38; }
body[data-scene="nebbia-giorno"]    { --sky-top: #a3acb4; --sky-bottom: #dde1e4; --text: #141b21; --text-soft: #252e36; --glass-a: 0.3;  --ink: 6, 24, 38; }
body[data-scene="pioggia-giorno"]   { --sky-top: #2b4157; --sky-bottom: #435d74; --text: #ffffff; --text-soft: #edf2f6; --glass-a: 0.1;  --ink: 255, 255, 255; }
body[data-scene="neve-giorno"]      { --sky-top: #a9bfd4; --sky-bottom: #e9eff5; --text: #0d1c2b; --text-soft: #1c2d3e; --glass-a: 0.3;  --ink: 6, 24, 38; }
body[data-scene="temporale-giorno"] { --sky-top: #2a3247; --sky-bottom: #4a5570; --text: #ffffff; --text-soft: #e4e7f0; --glass-a: 0.1;  --ink: 255, 255, 255; }
body[data-scene="sereno-notte"]     { --sky-top: #0a1630; --sky-bottom: #1f3a63; --text: #ffffff; --text-soft: #d4dfec; --glass-a: 0.12; --ink: 255, 255, 255; }
body[data-scene="nuvoloso-notte"]   { --sky-top: #1a2430; --sky-bottom: #3a4a5c; --text: #ffffff; --text-soft: #d8e0e8; --glass-a: 0.12; --ink: 255, 255, 255; }
body[data-scene="nebbia-notte"]     { --sky-top: #242b33; --sky-bottom: #46505b; --text: #ffffff; --text-soft: #dde3e8; --glass-a: 0.12; --ink: 255, 255, 255; }
body[data-scene="pioggia-notte"]    { --sky-top: #121d2a; --sky-bottom: #2c4055; --text: #ffffff; --text-soft: #d6e1eb; --glass-a: 0.12; --ink: 255, 255, 255; }
body[data-scene="neve-notte"]       { --sky-top: #1c2839; --sky-bottom: #384a5f; --text: #ffffff; --text-soft: #dbe4ee; --glass-a: 0.12; --ink: 255, 255, 255; }
body[data-scene="temporale-notte"]  { --sky-top: #110e22; --sky-bottom: #2b2847; --text: #ffffff; --text-soft: #dcdaf0; --glass-a: 0.12; --ink: 255, 255, 255; }

*, *::before, *::after { box-sizing: border-box; }
/* un elemento che riceve il focus non resta sotto l'intestazione fissa (altezza = spazio sopra + 44 px dei tasti + spazio sotto) */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-pt) + 44px + var(--top-pb) + 8px); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  color: var(--text); background: var(--sky-bottom);
  font-size: 1rem; line-height: 1.5;
  --glow: var(--sky-bottom); --line: rgba(var(--ink), 0.3);
  --glass: rgba(255, 255, 255, var(--glass-a));
  transition: --sky-top 0.4s ease-out, --sky-bottom 0.4s ease-out, --text 0.4s ease-out, --text-soft 0.4s ease-out, --glass-a 0.4s ease-out;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { flex: none; display: block; }
/* sole giallo: disco pieno con contorno ambra (il giallo si vede sugli azzurri medi e di notte, il contorno sugli azzurri chiari) */
.sun { stroke: #d98200; }
.sun-disc { fill: #ffc933; }
/* luna delle icone (sereno e poco nuvoloso di notte): riempimento chiaro, contorno currentColor (scuro di giorno, bianco di notte) */
.moon { fill: #e8edf7; }
[hidden] { display: none !important; }
/* i testi .vh sono absolute: i contenitori che scorrono o ritagliano devono essere il loro riferimento, altrimenti allargano la pagina */
.card, .scroller, .city-item, .banner, .alert-band, .state { position: relative; }

:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.skip { position: absolute; left: var(--s4); top: -100px; z-index: 100; padding: var(--s3) var(--s4); border-radius: 999px; background: var(--sky-top); color: var(--text); }
.skip:focus { top: var(--s2); }

/* ---- cielo e precipitazioni (solo CSS) ---- */
.sky {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(120% 60% at 70% 0%, var(--glow) 0%, transparent 60%), linear-gradient(var(--sky-top), var(--sky-bottom));
}
.fx { position: absolute; inset: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.fx-layer { position: absolute; inset: -40%; transform: rotate(14deg); }
.fx-layer::before { content: ""; position: absolute; left: 0; right: 0; top: -200px; bottom: 0; background-repeat: repeat; }
/* --fx-rgb/--fx-a: colore e opacità di picco dell'effetto, scelti perché il contrasto del testo resti >= 4.5:1 (test/scene.test.mjs).
   Sulle scene scure con testo bianco la pioggia di giorno è scura (non può schiarire lo sfondo); di notte e con la neve il bianco è molto tenue. */
body[data-scene="pioggia-giorno"], body[data-scene="temporale-giorno"] { --fx-rgb: 0, 12, 28; --fx-a: 0.5; }
body[data-scene="pioggia-notte"] { --fx-rgb: 255, 255, 255; --fx-a: 0.07; }
body[data-scene="temporale-notte"] { --fx-rgb: 255, 255, 255; --fx-a: 0.1; }
body[data-scene="neve-giorno"] { --fx-rgb: 255, 255, 255; --fx-a: 0.85; }
body[data-scene="neve-notte"] { --fx-rgb: 255, 255, 255; --fx-a: 0.04; }
body[data-scene^="pioggia"] .fx, body[data-scene^="temporale"] .fx, body[data-scene^="neve"] .fx { opacity: 1; }
body[data-scene^="pioggia"] .fx-layer::before, body[data-scene^="temporale"] .fx-layer::before {
  --fx: rgba(var(--fx-rgb), var(--fx-a));
  background-image:
    radial-gradient(1.5px 18px at 20px 30px, var(--fx), transparent),
    radial-gradient(1px 13px at 60px 120px, var(--fx), transparent),
    radial-gradient(1.5px 20px at 90px 70px, var(--fx), transparent);
  background-size: 73px 200px, 101px 100px, 59px 200px;
  animation: fall 0.8s linear infinite;
}
body[data-scene^="neve"] .fx-layer::before {
  --fx: rgba(var(--fx-rgb), var(--fx-a));
  background-image:
    radial-gradient(circle 3px at 20px 30px, var(--fx), transparent),
    radial-gradient(circle 2px at 70px 110px, var(--fx), transparent),
    radial-gradient(circle 2.5px at 110px 60px, var(--fx), transparent);
  background-size: 137px 200px, 97px 100px, 151px 200px;
  animation: fall 6s linear infinite;
}
/* sereno di giorno: il sole in alto a destra sopra l'alone e il gradiente (nessuna animazione) */
body[data-scene="sereno-giorno"] .sky {
  background:
    radial-gradient(circle at 84% 14%, rgba(255, 240, 170, .95) 0, rgba(255, 214, 102, .6) 6%, rgba(255, 214, 102, 0) 34%),
    radial-gradient(120% 60% at 70% 0%, var(--glow) 0%, transparent 60%),
    linear-gradient(var(--sky-top), var(--sky-bottom));
}
/* sereno di notte: stelle ferme (puntini bianchi di 1-1.5 px, opacità 0.4-0.8) a passi diversi per non formare una griglia, sfumate fino al 60% dell'altezza.
   ::before = strati radi (codici 1 e 2, e senza dati); ::after = altri due strati, solo col codice 0 (data-stars="full", impostato da applyScene). Nessuna animazione. */
body[data-scene="sereno-notte"] .sky::before, body[data-scene="sereno-notte"][data-stars="full"] .sky::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background-repeat: repeat;
  -webkit-mask-image: linear-gradient(to bottom, #000 15%, transparent 60%); mask-image: linear-gradient(to bottom, #000 15%, transparent 60%);
}
body[data-scene="sereno-notte"] .sky::before {
  background-image:
    radial-gradient(circle 1px at 114px 107px, rgba(255, 255, 255, 0.8) 45%, transparent),
    radial-gradient(circle 1.5px at 83px 50px, rgba(255, 255, 255, 0.5) 45%, transparent),
    radial-gradient(circle 1px at 31px 45px, rgba(255, 255, 255, 0.65) 45%, transparent),
    radial-gradient(circle 1px at 157px 134px, rgba(255, 255, 255, 0.45) 45%, transparent),
    radial-gradient(circle 1.5px at 116px 67px, rgba(255, 255, 255, 0.75) 45%, transparent);
  background-size: 131px 137px, 131px 137px, 173px 163px, 173px 163px, 173px 163px;
}
body[data-scene="sereno-notte"][data-stars="full"] .sky::after {
  background-image:
    radial-gradient(circle 1px at 42px 70px, rgba(255, 255, 255, 0.55) 45%, transparent),
    radial-gradient(circle 1px at 135px 19px, rgba(255, 255, 255, 0.7) 45%, transparent),
    radial-gradient(circle 1px at 85px 128px, rgba(255, 255, 255, 0.8) 45%, transparent),
    radial-gradient(circle 1.5px at 35px 46px, rgba(255, 255, 255, 0.5) 45%, transparent),
    radial-gradient(circle 1px at 189px 154px, rgba(255, 255, 255, 0.65) 45%, transparent);
  background-size: 97px 101px, 211px 197px, 211px 197px, 211px 197px, 211px 197px;
}
/* luna nella fase reale (js/icons.js moonPhaseSvg): accanto alla temperatura, solo con la scena sereno-notte; nel DOM c'è sempre, così si vede anche se la scena cambia o viene forzata */
.hero-temp { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s4); }
.moon-phase { display: none; flex: none; width: 64px; height: 64px; filter: drop-shadow(0 0 12px rgba(220, 230, 255, .35)); }
.moon-phase.south { transform: scaleX(-1); }
body[data-scene="sereno-notte"] .moon-phase { display: block; }
@keyframes fall { to { transform: translateY(200px); } }
@keyframes shimmer { 50% { opacity: 0.45; } }

/* ---- struttura ---- */
#app {
  --pad-l: max(var(--pad), env(safe-area-inset-left)); --pad-r: max(var(--pad), env(safe-area-inset-right));
  position: relative; max-width: 1180px; margin: 0 auto; display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr);
  /* niente padding sopra: lo spazio in alto è dell'intestazione fissa */
  padding: 0 var(--pad-r) max(var(--s6), env(safe-area-inset-bottom)) var(--pad-l);
  align-content: start;
}
#app > * { min-width: 0; }
#view { outline: none; }
/* intestazione fissa: a tutta larghezza della colonna (margini negativi = padding di #app), sopra le schede (z 20) e sotto pannelli (50), avvisi (70) e link "Vai al contenuto" (100) */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  margin: 0 calc(var(--pad-r) * -1) 0 calc(var(--pad-l) * -1);
  padding: var(--top-pt) var(--pad-r) var(--top-pb) var(--pad-l);
  background: var(--sky-top);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) and (background: color-mix(in srgb, red 50%, transparent)) {
  .top { background: color-mix(in srgb, var(--sky-top) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}
.city-title { min-width: 0; flex: 1 1 auto; font-size: 1.15rem; font-weight: 600; }
.city { display: flex; align-items: center; gap: 6px; max-width: 100%; min-height: 44px; padding: 0 var(--s1); background: none; border: 0; font-size: 1.15rem; font-weight: 600; }
#app-title.city { cursor: default; }
#city-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: var(--s2); flex: none; }

.icon-btn, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; border: 1px solid rgba(var(--ink), 0.45); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.icon-btn { width: 44px; padding: 0; border-radius: 50%; }
.btn { padding: 0 18px; border-radius: 999px; font-weight: 600; }
.btn-sm { padding: 0 14px; font-size: 0.9rem; }
.btn-block { width: 100%; margin-top: var(--s3); }
.btn-primary { background: var(--text); color: var(--sky-bottom); border-color: var(--text); }
.btn-ghost { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.icon-btn:active, .btn:active, .day-row:active, .cal-day:active { opacity: 0.75; }
.btn[disabled], .icon-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm); font-weight: 600;
  background: var(--glass); border: 1px solid rgba(var(--ink), 0.45);
}
.banner-soft { justify-content: flex-start; font-weight: 500; }

.card {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
.card h2, .card h3, .card-head {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); font-weight: 600; margin-bottom: var(--s3);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 32px; }
.card-head h2 { margin: 0; }
.link-btn { min-height: 44px; padding: 0 var(--s3); font-size: 0.8rem; }

/* ---- vista principale ---- */
.home { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.home > * { min-width: 0; }
.alert-band {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; text-align: left;
  border: 0; border-radius: var(--radius-sm); padding: var(--s3) 14px; font-weight: 600;
}
.alert-band .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.alert-band[data-color="yellow"] { background: var(--alert-yellow-bg); color: var(--alert-yellow-fg); }
.alert-band[data-color="orange"] { background: var(--alert-orange-bg); color: var(--alert-orange-fg); }
.alert-band[data-color="red"] { background: var(--alert-red-bg); color: var(--alert-red-fg); }

.hero { padding: 28px var(--s1) var(--s2); }
.temp { font-size: clamp(6rem, 28vw, 10rem); font-weight: 200; line-height: 0.9; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.cond { font-size: 1.35rem; margin-top: 6px; display: flex; align-items: center; gap: var(--s3); }
.meta { color: var(--text-soft); margin-top: var(--s1); }

.rain-phrase { display: flex; align-items: center; gap: 6px; margin: calc(var(--s1) * -1) 0 var(--s3); font-weight: 600; }
.scroller { overflow-x: auto; padding-bottom: var(--s1); scrollbar-width: thin; scrollbar-color: rgba(var(--ink), 0.5) transparent; }
.hours { display: flex; gap: 18px; width: max-content; padding: 0 2px; }
.hour { display: grid; justify-items: center; gap: 6px; min-width: 44px; font-variant-numeric: tabular-nums; }
.hour .t { color: var(--text-soft); font-size: 0.85rem; }
.hour b { font-weight: 700; }
.rainp { display: inline-flex; align-items: center; gap: 2px; font-size: 0.8rem; color: var(--text-soft); }

.days { display: grid; }
.days li { border-top: 1px solid var(--line); }
.days li:first-child { border-top: 0; }
.day-row {
  display: grid; grid-template-columns: minmax(0, 4.2rem) 28px minmax(0, 2.4rem) minmax(16px, 1fr) minmax(0, 2.4rem); align-items: center; gap: 10px; overflow-wrap: anywhere;
  width: 100%; min-height: 48px; padding: 6px 2px; background: none; border: 0; border-radius: 10px; text-align: left;
  font-variant-numeric: tabular-nums;
}
.day-row .lo { color: var(--text-soft); text-align: right; }
.day-row .hi { text-align: right; }
.bar { height: 6px; border-radius: 3px; background: rgba(var(--ink), 0.2); position: relative; }
.bar span { position: absolute; top: 0; bottom: 0; min-width: 6px; border-radius: 3px; background: linear-gradient(90deg, #8fd3ff, #ffd166); }
body[data-scene$="giorno"]:not([data-scene^="pioggia"]):not([data-scene^="temporale"]) .bar span { background: linear-gradient(90deg, #1b6ca8, #b8740a); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.tile { min-height: 110px; }
.tile b { display: block; font-size: 1.8rem; font-weight: 400; margin-top: var(--s1); line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile b.na { font-size: 1.1rem; font-weight: 600; padding: 6px 0; }
.tile p { color: var(--text-soft); font-size: 0.9rem; }

/* ---- estensione v2: confronto, consigli, prossima ora, grafico, dettagli ---- */
.cmp { margin-top: 10px; font-size: 0.95rem; color: var(--text-soft); }
.advice { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px var(--s3); border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); font-size: 0.9rem; overflow-wrap: anywhere;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.chip b { font-weight: 600; }

.now15 .bars15 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; height: 76px; margin-top: var(--s2); }
.now15 .b { display: grid; gap: var(--s1); justify-items: stretch; height: 100%; align-content: end; font-size: 0.8rem; color: var(--text-soft); text-align: center; font-variant-numeric: tabular-nums; }
.now15 .b i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: rgba(var(--ink), 0.55); }
.now15 .est { font-size: 0.75rem; color: var(--text-soft); margin-top: 6px; }
.now15.none { display: flex; align-items: center; gap: var(--s2); font-weight: 600; padding-block: var(--s3); }

.card-head2 { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.card-head2 h2 { margin: 0; }
.seg { display: inline-flex; border-radius: 999px; background: rgba(var(--ink), 0.08); border: 1px solid var(--line); }
.seg button { min-height: 44px; min-width: 44px; padding: 0 var(--s4); border: 0; border-radius: 999px; background: none; font-size: 0.85rem; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--glass); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); outline: 1px solid var(--line); outline-offset: -1px; }
.seg button:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.graph .plot { height: 150px; }
.graph svg { display: block; width: 100%; height: 150px; }
.graph .sum { font-size: 0.8rem; color: var(--text-soft); margin-top: var(--s1); }

.details { grid-column: 1 / -1; display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-top: var(--s2); align-items: start; }
.details > h2.sec { grid-column: 1 / -1; font-size: 1.1rem; font-weight: 600; margin: 10px 0 0; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--s4); font-size: 0.92rem; }
.kv dt { color: var(--text-soft); overflow-wrap: anywhere; }
.kv dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.note { font-size: 0.75rem; color: var(--text-soft); margin-top: var(--s2); }

/* ---- Confronta ---- */
.daypick { display: flex; gap: var(--s2); padding: 4px 2px 10px; }
.daypick button { flex: none; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); font-weight: 600; }
.daypick button[aria-pressed="true"] { background: var(--text); color: var(--sky-top); border-color: var(--text); }
.compare { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.compare .cc h3 { margin: 0 0 6px; font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--text); overflow-wrap: anywhere; }
.compare .cc .cond { font-size: 1.15rem; margin: 0 0 var(--s1); }
.compare .cc .big { font-size: 1.6rem; font-weight: 300; margin-bottom: var(--s2); font-variant-numeric: tabular-nums; }
.compare .cc .msg { margin: 0; }
.cmp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.cmp-tools .note { margin: 0; }
.choose { margin: 0; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--glass); }
.choose legend { padding: 0 var(--s1); font-weight: 600; }
.pick { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 44px; cursor: pointer; }
.pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pick .box { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--text); }
.pick .box .ic { visibility: hidden; }
.pick input:checked + .box { background: var(--text); color: var(--sky-top); }
.pick input:checked + .box .ic { visibility: visible; }
.pick input:focus-visible + .box { outline: 3px solid var(--text); outline-offset: 3px; }
.pick input:disabled { cursor: not-allowed; }
.pick input:disabled ~ * { opacity: 0.6; }
.pick .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---- calendario e dettaglio ---- */
.sub { width: 100%; max-width: 760px; margin: 0 auto; display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.sub > * { min-width: 0; }
.sub.sub-wide { max-width: none; }
.subhead { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.subhead h2 { font-size: 1.25rem; font-weight: 600; outline: none; }
/* su telefono la griglia sta senza scheda attorno, così ogni cella resta larga almeno 44 px (a 360 px e oltre) */
.cal-card { padding: 0; background: none; border: 0; border-radius: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.cal { display: grid; gap: 3px; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { text-align: center; font-size: 0.8rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.cal-cell { min-width: 0; }
.cal-day {
  width: 100%; min-height: 84px; padding: 6px 2px; display: grid; justify-items: center; align-content: center; gap: 2px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px; font-variant-numeric: tabular-nums; line-height: 1.25;
}
.cal-day .n { font-size: 0.85rem; font-weight: 600; }
.cal-day .hi { font-weight: 700; font-size: 0.9rem; }
.cal-day .lo { color: var(--text-soft); font-size: 0.85rem; }
.cal-day.weak { border-style: dashed; border-width: 2px; }
.cal-day .weak-txt { display: none; font-size: 0.7rem; color: var(--text-soft); }
.legend { display: flex; align-items: center; gap: var(--s2); color: var(--text-soft); font-size: 0.9rem; }
.legend .sample { width: 22px; height: 16px; border: 2px dashed var(--text); border-radius: 6px; flex: none; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s4); }
.facts dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); font-weight: 600; }
.facts dd { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.day-top { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); }
.day-top .big { font-size: 1.35rem; }
.day-top .mm { color: var(--text-soft); }
.stepper { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); }

/* ---- stati: vuoto, caricamento, errore ---- */
.state { max-width: 520px; margin: var(--s5) auto 0; text-align: center; display: grid; gap: var(--s3); justify-items: center; padding: var(--s6) var(--s4); }
.state h2 { font-size: 1.35rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.state p { color: var(--text-soft); }
.state .btn { width: 100%; max-width: 320px; }
.sk { background: rgba(var(--ink), 0.16); border-radius: 12px; animation: shimmer 1.4s ease-in-out infinite; }
.sk-temp { width: 9rem; height: 6.5rem; border-radius: 18px; }
.sk-line { height: 1rem; margin-top: var(--s3); }
.sk-col { display: grid; gap: var(--s2); }
.sk-row { height: 44px; margin-top: var(--s2); }
.sk-tile { min-height: 110px; border-radius: var(--radius); }
.sk-title { height: 1rem; width: 40%; }
.sk-w11 { width: 11rem; }
.sk-w15 { width: 15rem; max-width: 100%; }
.sk-tall { height: 92px; }
.legend.mb { margin-bottom: var(--s3); }

footer { color: var(--text-soft); font-size: 0.8rem; text-align: center; padding: var(--s2) 0; }

/* ---- pannelli ---- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.sheet {
  width: 100%; max-width: 520px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--radius) var(--radius) 0 0; padding: var(--s4) var(--s4) max(var(--s4), env(safe-area-inset-bottom));
  background: linear-gradient(var(--sky-top), var(--sky-bottom)); color: var(--text); border: 1px solid var(--line);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.sheet-head h2 { font-size: 1.25rem; font-weight: 600; }
.field-label { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field {
  width: 100%; min-height: 48px; padding: 0 var(--s4); border-radius: 12px; border: 2px solid rgba(var(--ink), 0.55);
  background: var(--glass); font-size: 1rem;
}
.field::placeholder { color: var(--text-soft); opacity: 0.8; }
.msg { min-height: 1.5rem; margin-top: var(--s2); color: var(--text-soft); font-size: 0.95rem; }
.msg:empty { min-height: 0; margin: 0; }
.results { display: grid; gap: 2px; margin-top: var(--s1); }
.opt { display: flex; align-items: center; min-height: 48px; padding: 6px var(--s3); border-radius: 12px; cursor: pointer; overflow-wrap: anywhere; }
.opt[aria-selected="true"] { background: var(--glass); outline: 2px solid var(--text); outline-offset: -2px; }
@media (hover: hover) { .opt:hover { background: var(--glass); } }
.cities { display: grid; gap: var(--s2); }
.city-item { display: grid; gap: 2px; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 14px; background: var(--glass); }
.city-line { display: flex; align-items: center; gap: var(--s3); }
.city-pick { flex: 1; min-width: 0; min-height: 44px; display: grid; gap: 0; text-align: left; background: none; border: 0; padding: 0; align-content: center; }
.city-pick .nm { font-weight: 600; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }
.city-pick .sub-nm { color: var(--text-soft); font-size: 0.85rem; overflow-wrap: anywhere; }
.city-temp { font-size: 1.35rem; font-weight: 300; font-variant-numeric: tabular-nums; }
.city-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 var(--s1); background: none; border: 0; font-weight: 600; }
.switch .track { position: relative; width: 48px; height: 28px; flex: none; border-radius: 999px; border: 2px solid var(--text); }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform 0.2s ease-out; }
.switch[aria-checked="true"] .track { background: var(--text); }
.switch[aria-checked="true"] .thumb { transform: translateX(20px); background: var(--sky-bottom); }
.switch .st { font-weight: 400; color: var(--text-soft); font-size: 0.85rem; }
.switch[disabled] { opacity: 0.6; cursor: not-allowed; }
.switch[aria-busy="true"] .thumb { opacity: 0.5; }
.alert-item { display: grid; gap: var(--s1); padding: var(--s3); border-radius: 14px; margin-bottom: var(--s3); }
.alert-item[data-color="yellow"] { background: var(--alert-yellow-bg); color: var(--alert-yellow-fg); }
.alert-item[data-color="orange"] { background: var(--alert-orange-bg); color: var(--alert-orange-fg); }
.alert-item[data-color="red"] { background: var(--alert-red-bg); color: var(--alert-red-fg); }
.alert-item h3 { font-size: 1.05rem; overflow-wrap: anywhere; }
.alert-item p { overflow-wrap: anywhere; }
.alert-note { color: var(--text-soft); font-size: 0.9rem; margin-top: var(--s2); }
.toast {
  position: fixed; left: 50%; bottom: max(var(--s4), env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  width: max-content; max-width: calc(100vw - 32px); padding: var(--s3) var(--s4); border-radius: var(--radius-sm); font-weight: 600;
  background: var(--sky-top); color: var(--text); border: 1px solid rgba(var(--ink), 0.5);
}
.toast:empty { display: none; }
.noscript { padding: var(--s4); text-align: center; }
body.modal-open { overflow: hidden; }

@media (min-width: 600px) {
  .cal-card { padding: var(--s4); background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); }
  .cal, .cal-row { gap: 6px; }
  .overlay { align-items: center; padding: var(--s5); }
  .sheet { border-radius: var(--radius); }
  .cal-day { min-height: 104px; }
  .cal-day .weak-txt { display: block; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  :root { --top-pt: max(28px, env(safe-area-inset-top)); }
  .moon-phase { width: 80px; height: 80px; }
  .home { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .home .alert-band { grid-column: 1 / -1; }
  .home .hero { grid-column: 1; grid-row: span 3; padding-top: 60px; }
  .home.no-now .hero { grid-row: span 2; }
  .home .now15, .home .card-hours, .home .card-days { grid-column: 2; }
  .home .tiles { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-transparency: reduce) {
  .card, .icon-btn, .btn, .banner, .cal-day, .field, .city-item, .chip {
    -webkit-backdrop-filter: none; backdrop-filter: none;
    background: linear-gradient(var(--glass), var(--glass)), var(--sky-bottom);
  }
  .top { background: var(--sky-top); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
