:root {
  --grad-a: #dfe7ee;
  --grad-b: #c3d0dc;
  --ink: #16202b;
  --maxw: 900px;

  /* Sistema "glass panel" — vetro smerigliato che galleggia nel meteo */
  --panel-bg: rgba(255,255,255,0.34);
  --panel-brd: rgba(255,255,255,0.5);
  --panel-shadow: 0 14px 40px rgba(15,23,32,0.16);
  --panel-radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100dvh;
  /* Cielo: bagliore luminoso in alto + gradiente verticale della condizione */
  background:
    radial-gradient(140% 90% at 50% -20%, rgba(255,255,255,0.38), transparent 55%),
    linear-gradient(180deg, var(--grad-a), var(--grad-b));
  background-attachment: fixed;
  transition: color 0.6s ease;
  position: relative;
  overflow-x: hidden;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) 1.25rem 5rem;
  position: relative;
  z-index: 1;
}

/* ---------- HERO ---------- */
.hero { text-align: center; }
.hero__intro {
  font-size: clamp(0.72rem, 1.6vw, 0.85rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.65;
}
.hero__icon {
  display: block;
  margin: 0.9rem auto 0.4rem;
  color: inherit;
}
.hero__icon svg {
  width: clamp(3rem, 8vw, 4.75rem);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(15,23,32,0.18));
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hero__dicitura {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: clamp(1.7rem, 5.4vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  max-width: 20ch;
  margin: 0 auto;
  text-wrap: balance;
}

/* Entrata soft all'apertura */
.hero__intro, .hero__icon, .hero__dicitura {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero__intro    { animation-delay: 0.05s; }
.hero__icon     { animation-delay: 0.16s; }
.hero__dicitura { animation-delay: 0.28s; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ---------- Eyebrow di sezione ---------- */
.section-title {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.65;
  margin-bottom: 0.9rem;
}

/* ---------- Colore sfondo + testo per condizione ---------- */
body[data-condition="sereno"]        { --grad-a:#8ed8ff; --grad-b:#ffe08a; --ink:#173a4d; }
body[data-condition="poco-nuvoloso"] { --grad-a:#a9d6f0; --grad-b:#d9e2e8; --ink:#26333d; }
body[data-condition="nuvoloso"]      { --grad-a:#c4ccd3; --grad-b:#9aa6af; --ink:#26313a; }
body[data-condition="pioggia"]       { --grad-a:#8494a6; --grad-b:#4f6172; --ink:#0e1720; }
body[data-condition="temporale"]     { --grad-a:#3a2f5c; --grad-b:#181428; --ink:#f2f0fb;
                                        --panel-bg: rgba(255,255,255,0.12);
                                        --panel-brd: rgba(255,255,255,0.28); }
body[data-condition="neve"]          { --grad-a:#eaf3fb; --grad-b:#b9cfe0; --ink:#20303f; }
body[data-condition="nebbia"]        { --grad-a:#d3d6d8; --grad-b:#aeb3b6; --ink:#2b3237; }

/* ---------- Pannello glass condiviso ---------- */
.tile, .fcard {
  background: var(--panel-bg);
  border: 1px solid var(--panel-brd);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow), inset 0 1px 0 rgba(255,255,255,0.55);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

/* ---------- Dati in tempo reale ---------- */
.realtime {
  margin: clamp(2.2rem, 6vw, 3.8rem) auto 0;
  max-width: 660px;
}
.realtime__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 0.8rem;
  padding: 0 0.2rem;
}
.live { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; }
.live__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2fbf71;
  box-shadow: 0 0 0 0 rgba(47,191,113,0.6);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(47,191,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,191,113,0); }
}
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.tile {
  padding: 1.3rem 0.9rem;
  text-align: center;
}
.tile__value {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: clamp(1.9rem, 5.4vw, 2.7rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile__unit { font-size: 0.44em; font-weight: 600; margin-left: 0.18em; opacity: 0.7; }
.tile__label {
  margin-top: 0.55rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.7;
}

@media (max-width: 480px) {
  .tile__label { font-size: 0.62rem; letter-spacing: 0.06em; }
}
@media (prefers-reduced-motion: reduce) {
  .live__dot { animation: none; }
  .hero__icon svg { animation: none; }
  .hero__intro, .hero__icon, .hero__dicitura { opacity: 1; transform: none; animation: none; }
}

/* ---------- Previsioni 5 giorni ---------- */
.forecast-wrap { margin-top: clamp(2.2rem, 6vw, 3.8rem); }
.forecast {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.8rem;
}
.fcard {
  padding: 1.15rem 0.5rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fcard:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 46px rgba(15,23,32,0.2), inset 0 1px 0 rgba(255,255,255,0.55);
}
.fcard:first-child { --panel-bg: rgba(255,255,255,0.5); }
.fcard__day {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
}
.fcard__icon { margin: 0.6rem 0; color: inherit; }
.fcard__icon svg { width: 36px; height: 36px; }
.fcard__temps { font-family: "Sora", sans-serif; font-weight: 600; font-variant-numeric: tabular-nums; }
.fcard__max { font-weight: 800; }
.fcard__min { opacity: 0.55; margin-left: 0.4em; }

/* Stato connessione API previsioni */
.api-status {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-top: 0.9rem;
  font-family: "Inter", sans-serif;
  font-weight: 600; font-size: 0.75rem;
  letter-spacing: 0.02em; opacity: 0.85;
}
.api-status__dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa4ad; }
.api-status[data-ok="1"] { color: #1f7a4d; }
.api-status[data-ok="1"] .api-status__dot { background: #2fbf71; }
.api-status[data-ok="0"] { color: #c0392b; }
.api-status[data-ok="0"] .api-status__dot { background: #e74c3c; }

@media (max-width: 560px) {
  .forecast { gap: 0.4rem; }
  .fcard { padding: 0.8rem 0.25rem; border-radius: 14px; }
  .fcard__icon svg { width: 27px; height: 27px; }
  .fcard__day { font-size: 0.64rem; }
}

/* ---------- Atmosfera (weather-fx) ---------- */
.weather-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.weather-fx::before, .weather-fx::after {
  content: "";
  position: absolute;
  inset: -20%;
  opacity: 0;
  transition: opacity 0.8s ease;
}

/* SERENO: bagliore del sole che pulsa in alto a destra */
body[data-condition="sereno"] .weather-fx::before {
  opacity: 1;
  background: radial-gradient(38% 38% at 78% 18%, rgba(255,236,150,0.85), transparent 70%);
  animation: sun-glow 6s ease-in-out infinite alternate;
}
@keyframes sun-glow { from { transform: scale(1); } to { transform: scale(1.12); } }

/* POCO-NUVOLOSO: nuvole morbide che derivano lente */
body[data-condition="poco-nuvoloso"] .weather-fx::before {
  opacity: 1;
  background:
    radial-gradient(30% 22% at 20% 30%, rgba(255,255,255,0.55), transparent 70%),
    radial-gradient(34% 24% at 70% 40%, rgba(255,255,255,0.45), transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-4%);} to { transform: translateX(4%);} }

/* NUVOLOSO: grigi tenui uniformi (velo statico, niente deriva) */
body[data-condition="nuvoloso"] .weather-fx::before {
  opacity: 1;
  background:
    radial-gradient(60% 50% at 50% 40%, rgba(255,255,255,0.28), transparent 75%);
}

/* PIOGGIA e TEMPORALE: pioggia (righe diagonali animate, sottili) */
body[data-condition="pioggia"] .weather-fx::before,
body[data-condition="temporale"] .weather-fx::before {
  opacity: 1;
  background-image: repeating-linear-gradient(112deg,
    rgba(255,255,255,0.16) 0 1px, transparent 1px 10px);
  background-size: 100% 100%;
  animation: rain 0.55s linear infinite;
}
@keyframes rain { from { background-position: 0 0; } to { background-position: -66px 240px; } }

/* TEMPORALE: flash di lampo sovrapposto */
body[data-condition="temporale"] .weather-fx::after {
  opacity: 1;
  background: rgba(255,255,255,0.75);
  mix-blend-mode: screen;
  animation: lightning 7s linear infinite;
}
@keyframes lightning {
  0%, 92%, 100% { opacity: 0; }
  93%, 95% { opacity: 0.9; }
  94% { opacity: 0.2; }
}

/* NEVE: fiocchi che scendono */
body[data-condition="neve"] .weather-fx::before {
  opacity: 1;
  background-image:
    radial-gradient(2.5px 2.5px at 20% 10%, #fff 99%, transparent),
    radial-gradient(2px 2px at 60% 30%, #fff 99%, transparent),
    radial-gradient(2.5px 2.5px at 80% 50%, #fff 99%, transparent),
    radial-gradient(2px 2px at 40% 70%, #fff 99%, transparent);
  background-size: 100% 100%;
  animation: snow 8s linear infinite;
}
@keyframes snow { from { background-position: 0 0; } to { background-position: 0 100vh; } }

/* NEBBIA: velo che scorre lento */
body[data-condition="nebbia"] .weather-fx::before {
  opacity: 1;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  background-size: 60% 100%;
  animation: fog 14s linear infinite;
}
@keyframes fog { from { background-position: -60% 0; } to { background-position: 160% 0; } }

@media (prefers-reduced-motion: reduce) {
  .weather-fx::before, .weather-fx::after { animation: none !important; }
  body[data-condition="temporale"] .weather-fx::after { opacity: 0; }
  .fcard { transition: none; }
}

/* ---------- Selettore anteprima (strumento di design) ---------- */
.preview {
  position: fixed;
  right: 0.6rem; bottom: 0.6rem;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  max-width: 60vw;
  justify-content: flex-end;
  background: rgba(0,0,0,0.32);
  padding: 0.45rem 0.55rem;
  border-radius: 14px;
  backdrop-filter: blur(6px);
}
.preview__label {
  color: #fff; font-size: 0.66rem; opacity: 0.8;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.preview__btn {
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.preview__btn:hover { background: rgba(255,255,255,0.3); }
.preview__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
