/* =====================================================================
   Meteo Porano — stile coordinato con la Rete LineaMeteo
   Token ripresi da retemeteo.lineameteo.it (map_rete_5.css)
   ===================================================================== */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --lm-blue: #0c4a8a;
  --lm-blue-2: #1769c2;
  --lm-ink: #172033;
  --lm-muted: #5b6577;
  --lm-surface: rgba(255, 255, 255, .94);
  --lm-solid: #ffffff;
  --lm-raised: #f7f9fc;
  --lm-raised-2: #ffffff;
  --lm-hover: #edf5fd;
  --lm-line: rgba(23, 32, 51, .11);
  --lm-shadow: 0 8px 30px rgba(15, 31, 56, .12);
  --lm-shadow-sm: 0 2px 10px rgba(15, 31, 56, .08);
  --lm-radius: 16px;
  --lm-cold: #1769c2;
  --lm-hot: #d73737;
  --lm-cold-text: #1769c2;
  --lm-hot-text: #c62828;
  --lm-green: #2f8a3e;
  --lm-bg: #e3eaf2;
  --lm-bg-2: #d8e2ed;
  --lm-hero-a: #0b3974;
  --lm-hero-b: #147bc4;
  --chart-grid: rgba(23, 32, 51, .08);
  --chart-text: #5b6577;
  --page-max: 1240px;
  --gutter: clamp(14px, 3vw, 28px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --lm-blue: #8ec5ff;
  --lm-blue-2: #3b8ae0;
  --lm-ink: #e6ebf2;
  --lm-muted: #9aa6b6;
  --lm-surface: rgba(22, 28, 36, .93);
  --lm-solid: #161c24;
  --lm-raised: #1f2731;
  --lm-raised-2: #28323e;
  --lm-hover: rgba(142, 197, 255, .10);
  --lm-line: rgba(214, 226, 242, .10);
  --lm-shadow: 0 10px 32px rgba(0, 0, 0, .45);
  --lm-shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  --lm-cold: #3b8ae0;
  --lm-hot: #ef5350;
  --lm-cold-text: #6fb3ff;
  --lm-hot-text: #ff7a7a;
  --lm-green: #6cc27a;
  --lm-bg: #0f141a;
  --lm-bg-2: #0f141a;
  --lm-hero-a: #0a2a52;
  --lm-hero-b: #0f5a97;
  --chart-grid: rgba(214, 226, 242, .08);
  --chart-text: #9aa6b6;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--lm-ink);
  background: linear-gradient(180deg, var(--lm-bg-2) 0, var(--lm-bg) 420px);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--lm-blue-2); }
:root[data-theme="dark"] a { color: var(--lm-blue); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums lining-nums; }

svg.i { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 16px; height: 16px; }
svg.i-lg { width: 24px; height: 24px; }

:focus-visible { outline: 3px solid rgba(23, 105, 194, .35); outline-offset: 2px; border-radius: 6px; }
:root[data-theme="dark"] :focus-visible { outline-color: rgba(142, 197, 255, .45); }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 2000; padding: 10px 14px; border-radius: 10px; background: var(--lm-blue-2); color: #fff; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------- */
/* Barra superiore                                                       */
/* --------------------------------------------------------------------- */
.topbar-wrap { position: sticky; top: 0; z-index: 900; padding: calc(10px + var(--safe-top)) var(--gutter) 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  max-width: var(--page-max); min-height: 56px; margin: 0 auto; padding: 6px 8px 6px 12px;
  border: 1px solid var(--lm-line); border-radius: 15px;
  background: var(--lm-surface); box-shadow: var(--lm-shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 12px; border-right: 1px solid var(--lm-line); color: var(--lm-ink); text-decoration: none; }
:root[data-theme="dark"] .brand { color: var(--lm-ink); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(145deg, var(--lm-hero-a), var(--lm-hero-b)); color: #fff; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: grid; line-height: 1.1; }
.brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.brand-text small { color: var(--lm-muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.brand-text small b { color: var(--lm-blue-2); font-weight: 800; }
:root[data-theme="dark"] .brand-text small b { color: var(--lm-blue); }

.nav { display: flex; align-items: center; gap: 2px; margin-left: 4px; }
.nav a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 11px;
  border-radius: 10px; color: var(--lm-ink); font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap;
}
.nav a svg { width: 17px; height: 17px; color: var(--lm-blue-2); }
:root[data-theme="dark"] .nav a svg { color: var(--lm-blue); }
.nav a:hover { background: var(--lm-hover); color: var(--lm-blue-2); }
:root[data-theme="dark"] .nav a:hover { color: var(--lm-blue); }
.nav a[aria-current="page"] { background: var(--lm-blue-2); color: #fff; }
.nav a[aria-current="page"] svg { color: #fff; }
.nav .nav-ext svg.ext { width: 13px; height: 13px; opacity: .55; }

.topbar-end { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; min-height: 32px; border-radius: 999px; background: var(--lm-raised); border: 1px solid var(--lm-line); color: var(--lm-muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #2f9e44; box-shadow: 0 0 0 3px rgba(47, 158, 68, .18); }
.status-pill.is-stale .dot { background: #e8890c; box-shadow: 0 0 0 3px rgba(232, 137, 12, .2); }
.status-pill.is-offline .dot { background: #d73737; box-shadow: 0 0 0 3px rgba(215, 55, 55, .2); }
.status-pill strong { color: var(--lm-ink); }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--lm-hover); color: var(--lm-blue-2); }
.menu-btn { display: none; }

/* Drawer mobile */
.backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(15, 23, 42, .34); opacity: 0; pointer-events: none; transition: opacity .22s; }
.backdrop.is-visible { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); display: flex; flex-direction: column; background: var(--lm-solid); box-shadow: 0 0 42px rgba(8, 24, 48, .24); transform: translateX(-104%); transition: transform .24s ease; }
.drawer.is-open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: calc(10px + var(--safe-top)) 12px 10px 16px; border-bottom: 1px solid var(--lm-line); }
.drawer-body { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 10px 12px calc(20px + var(--safe-bottom)); }
.drawer h2 { margin: 14px 6px 8px; color: var(--lm-muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.link-list { display: grid; gap: 2px; }
.link-list a { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 0 10px; border-radius: 10px; color: var(--lm-ink); font-weight: 650; text-decoration: none; }
.link-list a svg { color: var(--lm-blue-2); }
:root[data-theme="dark"] .link-list a svg { color: var(--lm-blue); }
.link-list a:hover { background: var(--lm-hover); }
.link-list a[aria-current="page"] { background: var(--lm-hover); color: var(--lm-blue-2); }
.link-list a .ext { margin-left: auto; width: 14px; height: 14px; opacity: .5; }

/* --------------------------------------------------------------------- */
/* Layout                                                                */
/* --------------------------------------------------------------------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: 18px var(--gutter) 40px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 2px 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 19px; font-weight: 800; }
.section-head p { color: var(--lm-muted); font-size: 13px; }
.eyebrow { color: var(--lm-blue-2); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
:root[data-theme="dark"] .eyebrow { color: var(--lm-blue); }

.panel { border: 1px solid var(--lm-line); border-radius: var(--lm-radius); background: var(--lm-solid); box-shadow: var(--lm-shadow-sm); }
.panel-pad { padding: 18px; }

.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 2px 18px; }
.page-title h1 { margin-top: 4px; font-size: clamp(26px, 3.4vw, 34px); font-weight: 800; letter-spacing: -.02em; }
.page-title p { max-width: 62ch; margin-top: 6px; color: var(--lm-muted); }

/* --------------------------------------------------------------------- */
/* Hero stazione (home)                                                  */
/* --------------------------------------------------------------------- */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 14px; }
.station-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 360px; padding: 22px 24px; border-radius: 20px; color: #fff;
  background: linear-gradient(145deg, var(--lm-hero-a), var(--lm-hero-b));
  box-shadow: var(--lm-shadow);
}
.station-hero .hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s; }
.station-hero.has-webcam .hero-bg { opacity: 1; }
.station-hero::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(2, 18, 38, .62) 0%, rgba(2, 18, 38, .22) 42%, rgba(2, 18, 38, .84) 100%); }
.station-hero > *:not(.hero-bg):not(.hero-link) { position: relative; z-index: 2; pointer-events: none; }
.station-hero .hero-link { position: absolute; inset: 0; z-index: 3; border-radius: inherit; }
.station-hero .hero-link:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.station-hero .hero-bg { transition: opacity .6s, transform .5s ease; }
.station-hero:hover .hero-bg { transform: scale(1.025); }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-top h1 { margin-top: 4px; font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -.02em; }
.hero-top .eyebrow, :root[data-theme="dark"] .hero-top .eyebrow { color: rgba(255, 255, 255, .9); }
.hero-top, .hero-perc { text-shadow: 0 1px 3px rgba(0, 0, 0, .7), 0 0 12px rgba(0, 0, 0, .45); }
.hero-sub { margin-top: 4px; color: #fff; font-size: 13px; font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px; border-radius: 9px; background: rgba(4, 20, 43, .42); color: #fff; font-size: 12px; font-weight: 650; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.chip svg { width: 15px; height: 15px; }
.chip.is-stale { border: 1px solid rgba(255, 218, 128, .7); background: rgba(151, 86, 0, .85); color: #fff4d0; }
.chip.is-critical { border: 1px solid rgba(255, 177, 177, .78); background: rgba(151, 25, 25, .86); }

.hero-reading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.big-temp { display: flex; align-items: flex-start; gap: 4px; line-height: .9; }
.big-temp strong { font-size: clamp(64px, 9vw, 100px); font-weight: 750; letter-spacing: -.05em; text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.big-temp span { margin-top: .32em; font-size: clamp(22px, 2.8vw, 30px); font-weight: 600; opacity: .9; }
.hero-meta { display: grid; gap: 8px; justify-items: end; }
.hero-minmax { display: flex; gap: 8px; }
.mm { display: grid; gap: 1px; min-width: 104px; padding: 8px 12px; border-radius: 12px; background: rgba(4, 20, 43, .45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.mm small { color: rgba(255, 255, 255, .78); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.mm strong { font-size: 20px; font-weight: 800; }
.mm.is-min strong { color: #9fd0ff; }
.mm.is-max strong { color: #ffb3a8; }
.mm.is-rain strong { color: #9fe8d8; }
.mm.is-rain strong small { font-size: 12px; font-weight: 650; margin-left: 1px; }
.mm em { color: rgba(255, 255, 255, .75); font-size: 11px; font-style: normal; }
.trend-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font-size: 12px; font-weight: 750; white-space: nowrap; }
.trend-badge svg { width: 15px; height: 15px; }
.hero-perc { color: #fff; font-size: 13px; font-weight: 600; }
.hero-perc strong { color: #fff; }

/* Bussola del vento */
.wind-panel { display: flex; flex-direction: column; padding: 18px; }
.wind-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wind-panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.wind-panel-head h2 svg { color: var(--lm-blue-2); }
:root[data-theme="dark"] .wind-panel-head h2 svg { color: var(--lm-blue); }
.wind-body { display: grid; grid-template-columns: minmax(150px, 190px) 1fr; align-items: center; gap: 16px; margin-top: 10px; flex: 1; }
.compass { position: relative; width: 100%; aspect-ratio: 1; }
.compass svg { width: 100%; height: 100%; display: block; }
.compass .ring { fill: var(--lm-raised); stroke: var(--lm-line); stroke-width: 1; }
.compass .tick { stroke: var(--lm-muted); stroke-width: 1; opacity: .5; }
.compass .tick.major { stroke-width: 2; opacity: .8; }
.compass .card-label { fill: var(--lm-muted); font-size: 11px; font-weight: 800; font-family: inherit; }
.compass .card-label.n { fill: var(--lm-hot); }
.compass .needle { transition: transform 1s cubic-bezier(.3, 1.4, .5, 1); transform-origin: 100px 100px; }
.compass .needle path { fill: var(--lm-blue-2); }
.compass .center-val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.compass .center-val strong { display: block; font-size: 26px; font-weight: 800; line-height: 1; }
.compass .center-val small { display: block; margin-top: 2px; color: var(--lm-muted); font-size: 11px; font-weight: 700; }
.wind-stats { display: grid; gap: 8px; }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 10px; background: var(--lm-raised); }
.kv span { color: var(--lm-muted); font-size: 12px; font-weight: 600; }
.kv > div { text-align: right; }
.kv strong { font-size: 15px; font-weight: 800; white-space: nowrap; }
.kv strong small { font-size: 11px; font-weight: 600; color: var(--lm-muted); }
.kv em { display: block; color: var(--lm-muted); font-size: 11px; font-style: normal; text-align: right; }

/* Card dati */
.data-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.data-card { position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 15px 16px; border: 1px solid var(--lm-line); border-radius: 15px; background: var(--lm-solid); box-shadow: var(--lm-shadow-sm); }
.data-card-head { display: flex; align-items: center; gap: 8px; }
.data-card-head > span:first-child { margin-right: auto; }
.data-card-head span { color: var(--lm-muted); font-size: 12px; font-weight: 700; }
.data-card-head svg { width: 19px; height: 19px; color: var(--lm-blue-2); }
:root[data-theme="dark"] .data-card-head svg { color: var(--lm-blue); }
.data-card .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.data-card .value small { margin-left: 2px; color: var(--lm-muted); font-size: 14px; font-weight: 650; letter-spacing: 0; }
.data-card .sub { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--lm-muted); font-size: 12px; font-weight: 600; }
.data-card .sub b { font-weight: 800; }
.data-card .sub .lo b { color: var(--lm-cold-text); }
.data-card .sub .hi b { color: var(--lm-hot-text); }
.data-card.is-na .value { color: var(--lm-muted); font-size: 22px; }
/* schede dati collegate ai report NOAA (pioggia giorno, mese, anno) */
a.data-card { color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
a.data-card:hover, a.data-card:focus-visible { border-color: var(--lm-blue-2); box-shadow: var(--lm-shadow); }
.data-card-head .card-go { width: 14px; height: 14px; color: var(--lm-muted); opacity: .55; transition: color .15s ease, opacity .15s ease, transform .15s ease; }
a.data-card:hover .card-go, a.data-card:focus-visible .card-go { color: var(--lm-blue-2); opacity: 1; transform: translateX(2px); }
.na-note { color: var(--lm-muted); font-size: 12px; }
.meter { height: 6px; border-radius: 6px; background: var(--lm-raised); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--lm-blue-2); transition: width .8s ease; }

/* Grafici */
.seg { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--lm-line); border-radius: 11px; background: var(--lm-raised); }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--lm-muted); font-size: 12px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--lm-blue-2); }
.seg button[aria-pressed="true"] { background: var(--lm-raised-2); color: var(--lm-blue); box-shadow: 0 1px 5px rgba(15, 31, 56, .15); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { color: var(--lm-blue); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-card { min-width: 0; padding: 14px 14px 10px; }
.chart-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 4px 8px; }
.chart-card-head h3 { font-size: 14px; font-weight: 800; }
.chart-card-head span { color: var(--lm-muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chart-box { position: relative; height: 220px; }
.chart-box canvas { display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--lm-muted); font-size: 13px; text-align: center; }

/* Riepiloghi */
.split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.summary-item { padding: 11px 12px; border-radius: 11px; background: var(--lm-raised); }
.summary-item span { display: block; color: var(--lm-muted); font-size: 11px; font-weight: 700; }
.summary-item strong { display: block; margin-top: 2px; font-size: 18px; font-weight: 800; }
.summary-item em { display: block; color: var(--lm-muted); font-size: 11px; font-style: normal; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h2, .panel-title h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.panel-title svg { color: var(--lm-blue-2); }
:root[data-theme="dark"] .panel-title svg { color: var(--lm-blue); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid var(--lm-line); border-radius: 10px; background: var(--lm-solid); color: var(--lm-blue); font-size: 13px; font-weight: 750; text-decoration: none; cursor: pointer; white-space: nowrap; }
:root[data-theme="dark"] .btn { background: var(--lm-raised); }
.btn:hover { background: var(--lm-hover); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { border-color: var(--lm-blue-2); background: var(--lm-blue-2); color: #fff; }
.btn.primary:hover { background: #125aa8; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.webcam-thumb { position: relative; display: block; overflow: hidden; border-radius: 12px; aspect-ratio: 16 / 9; background: #0b1119; }
.webcam-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.webcam-thumb:hover img { transform: scale(1.03); }
.webcam-thumb .chip { position: absolute; left: 10px; bottom: 10px; }

.link-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.link-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--lm-line); border-radius: 14px; background: var(--lm-solid); color: var(--lm-ink); text-decoration: none; box-shadow: var(--lm-shadow-sm); transition: border-color .15s, transform .15s; }
:root[data-theme="dark"] .link-card { color: var(--lm-ink); }
.link-card:hover { border-color: rgba(23, 105, 194, .45); transform: translateY(-1px); }
.link-card > svg:first-child { width: 24px; height: 24px; color: var(--lm-blue-2); }
:root[data-theme="dark"] .link-card > svg:first-child { color: var(--lm-blue); }
.link-card div { min-width: 0; }
.link-card strong { display: block; font-size: 14px; font-weight: 800; }
.link-card small { display: block; color: var(--lm-muted); font-size: 12px; }
.link-card .ext { margin-left: auto; width: 15px; height: 15px; opacity: .45; }

/* --------------------------------------------------------------------- */
/* Meteo live                                                            */
/* --------------------------------------------------------------------- */
.map-shell { position: relative; overflow: hidden; height: min(72vh, 680px); min-height: 440px; border-radius: 20px; border: 1px solid var(--lm-line); box-shadow: var(--lm-shadow); background: #dce7f0; }
:root[data-theme="dark"] .map-shell { background: #1a2028; }
#map { position: absolute; inset: 0; }
.leaflet-container { font: inherit; background: transparent; }
.leaflet-control-attribution { max-width: min(78vw, 620px); border-radius: 8px 0 0 0; font-size: 10px; }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(17, 22, 29, .78); color: #9aa6b6; }
.leaflet-control-zoom { border: 1px solid var(--lm-line) !important; border-radius: 12px !important; overflow: hidden; box-shadow: var(--lm-shadow) !important; }
.leaflet-control-zoom a { width: 38px !important; height: 38px !important; line-height: 38px !important; background: var(--lm-surface) !important; color: var(--lm-ink) !important; border-bottom-color: var(--lm-line) !important; }
.glass { border: 1px solid var(--lm-line); background: var(--lm-surface); box-shadow: var(--lm-shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.map-layers { position: absolute; z-index: 800; top: 12px; left: 12px; display: grid; gap: 4px; width: 236px; padding: 10px; border-radius: 14px; }
.map-layers h2 { margin: 2px 6px 4px; color: var(--lm-muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.layer-opt { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 9px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; font-size: 13px; font-weight: 650; }
.layer-opt svg { width: 18px; height: 18px; color: var(--lm-blue-2); }
:root[data-theme="dark"] .layer-opt svg { color: var(--lm-blue); }
.layer-opt:hover { background: var(--lm-hover); }
.layer-opt[aria-pressed="true"] { background: var(--lm-blue-2); color: #fff; }
.layer-opt[aria-pressed="true"] svg { color: #fff; }
.layer-opt .tag { margin-left: auto; font-size: 10px; font-weight: 700; opacity: .7; }
.layer-sep { height: 1px; margin: 4px 6px; background: var(--lm-line); }
.map-toggle { display: none; }

.player { position: absolute; z-index: 800; left: 50%; bottom: 26px; display: flex; align-items: center; gap: 8px; width: min(560px, calc(100% - 24px)); min-height: 50px; padding: 6px 10px; border-radius: 15px; transform: translateX(-50%); }
.player button { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.player button:hover { background: var(--lm-hover); color: var(--lm-blue-2); }
.player button.play { background: var(--lm-blue-2); color: #fff; }
.player button.play:hover { background: #125aa8; color: #fff; }
.player input[type="range"] { flex: 1 1 auto; min-width: 60px; accent-color: var(--lm-blue-2); }
.player time { min-width: 108px; font-size: 13px; font-weight: 800; text-align: center; white-space: nowrap; }
.player .loading { color: var(--lm-muted); font-size: 12px; font-weight: 600; }

.legend { position: absolute; z-index: 800; right: 12px; top: 12px; display: grid; gap: 6px; width: 250px; padding: 10px 12px; border-radius: 13px; }
.legend-row { display: grid; gap: 3px; }
.legend-title { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; }
.legend-title span { color: var(--lm-muted); font-weight: 600; }
.legend-bar { height: 10px; border: 1px solid rgba(0, 0, 0, .12); border-radius: 6px; }
.legend-vals { display: flex; justify-content: space-between; color: var(--lm-muted); font-size: 10px; font-weight: 600; }
.legend-src { color: var(--lm-muted); font-size: 10px; line-height: 1.35; }
.legend-src a { font-weight: 700; }

.station-marker { width: 0 !important; height: 0 !important; }
/* etichetta compatta e trasparente: il pallino bianco resta esattamente
   sul punto della stazione a ogni livello di zoom (ancoraggio al pallino) */
.station-marker .pin { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 3px; padding: 1px 4px 1px 1px; border: 0; border-radius: 999px; background: transparent; color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, .95), 0 0 5px rgba(0, 0, 0, .8); transform: translate(-5px, -50%); }
.station-marker .pin i { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .45); }

.embed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.embed-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.embed-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--lm-line); }
.embed-card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.embed-card-head h3 svg { color: var(--lm-blue-2); }
:root[data-theme="dark"] .embed-card-head h3 svg { color: var(--lm-blue); }
.embed-card-head p { width: 100%; color: var(--lm-muted); font-size: 12px; }
.embed-frame { position: relative; height: 460px; background: var(--lm-raised); }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-frame .placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; color: var(--lm-muted); font-size: 13px; }
.embed-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--lm-line); }

/* --------------------------------------------------------------------- */
/* Webcam                                                                */
/* --------------------------------------------------------------------- */
.webcam-stage { position: relative; overflow: hidden; border-radius: 20px; background: #0b1119; box-shadow: var(--lm-shadow); }
.webcam-stage img { display: block; width: 100%; height: auto; max-height: 78vh; object-fit: contain; margin: 0 auto; }
.webcam-overlay { position: absolute; left: 14px; right: 14px; bottom: 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.webcam-overlay > * { pointer-events: auto; }
.webcam-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* --------------------------------------------------------------------- */
/* Archivio                                                              */
/* --------------------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; border-radius: 12px; border: 1px solid var(--lm-line); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums lining-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--lm-line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; z-index: 1; background: var(--lm-raised); color: var(--lm-muted); font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
table.data tbody tr:hover { background: var(--lm-hover); }
table.data td.hi { color: var(--lm-hot-text); font-weight: 750; }
table.data td.lo { color: var(--lm-cold-text); font-weight: 750; }
table.data td.rain { color: var(--lm-blue-2); font-weight: 750; }
:root[data-theme="dark"] table.data td.rain { color: var(--lm-blue); }
table.data td small { color: var(--lm-muted); font-size: 11px; margin-left: 4px; }
table.data tfoot td { font-weight: 800; background: var(--lm-raised); }
table.data tr.is-empty td { color: var(--lm-muted); opacity: .6; }
.kpi-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 12px 14px; border: 1px solid var(--lm-line); border-radius: 13px; background: var(--lm-solid); }
.kpi span { display: block; color: var(--lm-muted); font-size: 11px; font-weight: 700; }
.kpi strong { display: block; margin-top: 3px; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.kpi em { display: block; color: var(--lm-muted); font-size: 11px; font-style: normal; }
.kpi.hot strong { color: var(--lm-hot-text); }
.kpi.cold strong { color: var(--lm-cold-text); }
.kpi.rain strong { color: var(--lm-blue-2); }
:root[data-theme="dark"] .kpi.rain strong { color: var(--lm-blue); }
.file-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.file-list a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--lm-line); border-radius: 12px; background: var(--lm-solid); color: var(--lm-ink); text-decoration: none; font-weight: 700; font-size: 13px; }
:root[data-theme="dark"] .file-list a { color: var(--lm-ink); }
.file-list a:hover { background: var(--lm-hover); }
.file-list a svg { color: var(--lm-blue-2); }
.file-list a small { display: block; color: var(--lm-muted); font-weight: 600; font-size: 11px; }

/* --------------------------------------------------------------------- */
/* Ubicazione                                                            */
/* --------------------------------------------------------------------- */
.loc-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 14px; }
.loc-map { position: relative; min-height: 420px; overflow: hidden; border-radius: 18px; border: 1px solid var(--lm-line); box-shadow: var(--lm-shadow-sm); }
.loc-map #locmap { position: absolute; inset: 0; }
.facts { display: grid; gap: 6px; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--lm-raised); font-size: 13px; }
.fact span { color: var(--lm-muted); font-weight: 600; }
.fact strong { font-weight: 800; text-align: right; }
.prose { max-width: 72ch; }
.prose p { margin: 0 0 1em; line-height: 1.7; }
.prose h3 { margin: 1.6em 0 .5em; font-size: 17px; font-weight: 800; }
.prose .source { color: var(--lm-muted); font-size: 13px; }
.story { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; align-items: start; }
.toc { position: sticky; top: 90px; display: grid; gap: 2px; padding: 14px; }
.toc a { padding: 7px 10px; border-radius: 8px; color: var(--lm-ink); font-size: 13px; font-weight: 650; text-decoration: none; }
:root[data-theme="dark"] .toc a { color: var(--lm-ink); }
.toc a:hover { background: var(--lm-hover); color: var(--lm-blue-2); }

/* --------------------------------------------------------------------- */
/* Footer                                                                */
/* --------------------------------------------------------------------- */
.footer { max-width: var(--page-max); margin: 10px auto 0; padding: 0 var(--gutter) calc(28px + var(--safe-bottom)); }
.footer-inner { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 20px; padding: 22px; border-radius: 18px; border: 1px solid var(--lm-line); background: var(--lm-solid); }
.footer h2 { margin-bottom: 10px; color: var(--lm-muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.footer ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.footer ul a { color: var(--lm-ink); font-weight: 600; text-decoration: none; }
:root[data-theme="dark"] .footer ul a { color: var(--lm-ink); }
.footer ul a:hover { color: var(--lm-blue-2); text-decoration: underline; }
.footer p { color: var(--lm-muted); font-size: 13px; }
.lm-word { display: inline-flex; align-items: baseline; gap: 0; margin-bottom: 10px; color: var(--lm-blue); font-size: 22px; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
:root[data-theme="dark"] .lm-word { color: var(--lm-ink); }
.lm-word b { color: var(--lm-blue-2); font-weight: 800; }
:root[data-theme="dark"] .lm-word b { color: var(--lm-blue); }
.lm-word small { margin-left: 8px; color: var(--lm-muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.footer-bottom { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 0 6px; color: var(--lm-muted); font-size: 12px; }

/* Skeleton */
.sk { display: inline-block; min-width: 3ch; border-radius: 6px; background: linear-gradient(90deg, var(--lm-raised) 0%, var(--lm-line) 50%, var(--lm-raised) 100%); background-size: 200% 100%; color: transparent !important; animation: sk 1.4s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.toast { position: fixed; z-index: 1500; left: 50%; bottom: calc(22px + var(--safe-bottom)); max-width: min(420px, calc(100vw - 30px)); padding: 10px 15px; border-radius: 11px; background: rgba(18, 25, 38, .94); color: #fff; box-shadow: var(--lm-shadow); font-size: 13px; transform: translateX(-50%); }

/* --------------------------------------------------------------------- */
/* Responsive                                                            */
/* --------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .nav a { padding: 0 9px; }
  .nav .nav-label-long { display: none; }
  .status-pill .lbl { display: none; }
}
@media (max-width: 1060px) {
  .nav { display: none; }
  .menu-btn { display: inline-grid; }
  .hero-grid { grid-template-columns: 1fr; }
  .data-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .loc-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .story { grid-template-columns: 1fr; }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .tabs .seg { display: flex; flex-wrap: wrap; width: 100%; }
  .tabs .seg button { flex: 1 1 40%; }
  .chart-grid, .embed-grid, .link-cards, .file-list { grid-template-columns: 1fr; }
  .status-pill { display: none; }
  .station-hero { min-height: 420px; padding: 18px; }
  .hero-reading { flex-direction: column; align-items: flex-start; }
  .hero-meta { justify-items: start; }
  .wind-body { grid-template-columns: 1fr; justify-items: center; }
  .compass { max-width: 200px; }
  .wind-stats { width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-shell { height: 74vh; min-height: 480px; border-radius: 16px; }
  .map-layers { top: 10px; left: 10px; width: auto; max-width: calc(100% - 20px); }
  .map-layers:not(.is-open) .layer-list { display: none; }
  .map-toggle { display: flex; }
  .legend { top: auto; right: 10px; left: 10px; bottom: 92px; width: auto; }
  .legend.is-collapsed .legend-row:not(:first-child), .legend .legend-src { display: none; }
  .player { bottom: 28px; }
  .leaflet-control-zoom { display: none; }
  .player time { min-width: 86px; font-size: 12px; }
  .embed-frame { height: 380px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-inner { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .brand-text small { display: none; }
  .data-grid { gap: 8px; }
  .data-card { padding: 13px; }
  .data-card .value { font-size: 25px; }
  .hero-minmax { flex-wrap: wrap; }
  .mm { min-width: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Mobile: i dati della stazione escono dall'immagine e vanno in una fascia sotto la foto */
@media (max-width: 720px) {
  .webcam-overlay { position: static; padding: 10px 12px; gap: 8px; background: #0b1119; justify-content: flex-start; }
  .webcam-overlay .chip-row { gap: 6px; }
  .webcam-overlay .chip { font-size: 12.5px; }
}

/* Visualizzatore foto webcam a piena risoluzione */
html.lb-on, html.lb-on body { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: #070b11; color: #e6edf5; }
.lightbox[hidden] { display: none; }
.lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(11, 17, 25, .96); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.lb-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lb-head strong { font-size: 15px; }
.lb-hint { font-size: 12px; color: #9fb0c3; }
.lb-bar .btn { flex: none; }
.lb-wrap { position: relative; flex: 1; overflow: auto; display: grid; place-items: center; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
.lb-wrap img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; cursor: zoom-in; opacity: 0; transition: opacity .2s; }
.lightbox.ready .lb-wrap img { opacity: 1; }
.lightbox.ready .lb-wait { display: none; }
.lb-wait { position: absolute; color: #9fb0c3; font-size: 14px; }
.lightbox.zoom .lb-wrap { display: block; }
.lightbox.zoom .lb-wrap img { max-width: none; max-height: none; cursor: zoom-out; }
.lb-m { display: none; }
@media (max-width: 720px) { .lb-d { display: none; } .lb-m { display: inline; } }
