/*
 * Meteo Armo — due pagine (valle, dati) dallo stesso modello, stile svizzero: griglia, filetti, un rosso.
 * Leggera: scroll nativo, nessuna sfocatura, nessuna animazione; rilievo morbido solo nella testata.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/css/fonts/inter-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 {
  --ground: #F2F3F5;
  --ink: #1A1A1A;
  --muted: #5E5E5E;
  --rule: #DADCE0;
  --rule-strong: #1A1A1A;
  --soft: #E8EAED;
  --red: #C81E25;
  --red-fill: #C81E25;
  --on-red: #FFFFFF;
  /* rilievo morbido: luce in alto a sinistra, ombra in basso a destra, stesso colore del fondo */
  --lift-light: rgba(255, 255, 255, 0.95);
  --lift-dark: rgba(30, 38, 52, 0.14);
  --ok: #1F7A3A;

  /* 5 misure */
  --t-s: 0.8125rem;
  --t-m: 1rem;
  --t-l: 1.375rem;
  --t-xxl: clamp(4rem, 17vw, 6rem);

  --gap: 16px;
  --pad: 16px;
  --max: 1200px;

  color-scheme: light dark;
  accent-color: var(--red);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #17181A;
    --ink: #F0F0F0;
    --muted: #A6A6A6;
    --rule: #313236;
    --rule-strong: #F0F0F0;
    --soft: #222326;
    --red: #E0353B;
    --red-fill: #C81E25;
    --lift-light: rgba(255, 255, 255, 0.05);
    --lift-dark: rgba(0, 0, 0, 0.55);
    --ok: #4CC174;
  }
}

@media (min-width: 720px) {
  :root { --pad: 32px; --gap: 24px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--t-m) / 1.5 "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
h2 { font-size: var(--t-l); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
h3 { font-size: var(--t-m); font-weight: 700; margin-bottom: 8px; }
a { color: inherit; }
code { font: 500 0.92em / 1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

::selection { background: var(--red-fill); color: var(--on-red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.small { font-size: var(--t-s); line-height: 1.45; }
.muted { color: var(--muted); }

/* ── Testata: un riquadro in rilievo morbido, il rosso solo nel segno ─ */

.bar { padding: 12px var(--pad) 0; }
.bar__inner {
  max-width: calc(var(--max) - 2 * var(--pad));
  margin: 0 auto;
  min-height: 60px;
  padding: 10px 10px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  background: var(--ground);
  border-radius: 18px;
  box-shadow: 6px 6px 16px var(--lift-dark), -6px -6px 16px var(--lift-light);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; line-height: 1.2; }
.brand__mark { width: 10px; height: 10px; border-radius: 3px; background: var(--red); flex: none; }
.brand__text { display: flex; flex-direction: column; }
.brand__name { font-weight: 700; font-size: var(--t-m); }
.brand__place { font-size: var(--t-s); color: var(--muted); }

.lang select {
  font: 600 var(--t-s) / 1 inherit;
  font-family: inherit;
  color: var(--ink);
  background: var(--ground);
  border: 0;
  border-radius: 12px;
  padding: 8px 12px;
  min-height: 40px;
  box-shadow: inset 2px 2px 5px var(--lift-dark), inset -2px -2px 5px var(--lift-light);
  cursor: pointer;
}
.lang select option { color: var(--ink); background: var(--ground); }

/* ── Impaginato ────────────────────────────────────── */

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--pad) 48px; }

.block { padding-top: 40px; }
.block__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px var(--gap);
  border-top: 2px solid var(--rule-strong);
  padding-top: 12px;
  margin-bottom: 16px;
}

/* ── Linguette: Valle | Dati, filetto rosso sopra la pagina aperta come l'ora attuale ─ */

.tabs { display: grid; grid-template-columns: 1fr 1fr; margin-top: 16px; border-bottom: 1px solid var(--rule); }
.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px 11px;
  border-top: 3px solid transparent;
  text-align: center;
  text-decoration: none;
  line-height: 1.25;
  font-weight: 500;
  color: var(--muted);
}
.tabs a + a { border-left: 1px solid var(--rule); }
.tabs small { font-size: var(--t-s); font-weight: 500; color: var(--muted); }
.tabs a[aria-current="page"] { color: var(--red); font-weight: 700; border-top-color: var(--red); }
.tabs a:not([aria-current]):hover { color: var(--ink); background: var(--soft); }
@media (min-width: 720px) {
  .tabs { grid-template-columns: repeat(2, minmax(0, 260px)); }
  .tabs a { align-items: flex-start; text-align: left; padding-left: 0; }
  .tabs a + a { padding-left: 16px; }
}

/* ── Rimando all'altra pagina, in fondo: si apre come una sezione ─ */

.next {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  margin-top: 40px;
  padding: 12px 0 4px;
  border-top: 2px solid var(--rule-strong);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.3;
}
.next small { display: block; font-size: var(--t-s); font-weight: 500; color: var(--muted); margin-top: 2px; }
.next svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.next:hover > span > span:first-child { text-decoration: underline; text-underline-offset: 3px; }

/* ── Adesso ────────────────────────────────────────── */

.now { display: grid; gap: 16px; padding-top: 16px; }

.now__data { display: grid; grid-template-columns: auto 1fr; gap: 0 24px; align-items: start; }
.now__temp {
  font-size: var(--t-xxl);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.04em;
}
.now__unit { font-size: var(--t-l); font-weight: 500; letter-spacing: 0; vertical-align: top; margin-left: 2px; }
.now__data .facts { margin-top: 4px; }
.now__data .status { grid-column: 1 / -1; margin-top: 12px; }

.facts div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.facts div:first-child { border-top: 1px solid var(--rule); }
.facts dt { font-size: var(--t-s); color: var(--muted); }
.facts dd { font-weight: 600; text-align: right; }

.facts--row { margin-top: 16px; }

.test { grid-column: 1 / -1; margin-top: 8px; max-width: 46ch; color: var(--muted); }
.test strong { color: var(--ink); }

.status { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.status.is-off { color: var(--red); font-weight: 600; }
.status.is-off .status__dot { background: var(--red); border-radius: 0; }

@media (min-width: 720px) {
  .now { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--gap); padding-top: var(--pad); }
  /* i fatti chiudono sulla stessa linea della foto */
  .now__data { display: flex; flex-direction: column; align-items: stretch; padding-bottom: 30px; }
  .now__data .facts { margin-top: auto; padding-top: 20px; }
  .facts--row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gap); }
  .facts--row div { border-top: 1px solid var(--rule); }
}

/* pagina dati: niente foto, temperatura a sinistra e fatti a destra a ogni larghezza */
.now--data { padding-top: 24px; }
@media (min-width: 720px) {
  .now--data { display: block; }
  .now--data .now__data { display: grid; grid-template-columns: auto minmax(0, 420px); justify-content: space-between; padding-bottom: 0; }
  .now--data .now__data .facts { margin-top: 4px; padding-top: 0; }
}

/* ── Ultime 24 ore: colonne come un orario ─────────── */

.hours {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  margin: 0 calc(-1 * var(--pad));
  padding: 0 var(--pad);
}
.hours__table { border-collapse: collapse; }
.hours__table th, .hours__table td {
  min-width: var(--col, 58px);
  width: var(--col, 58px);
  padding: 6px 4px;
  text-align: center;
  border-left: 1px solid var(--rule);
  white-space: nowrap;
}
.hours__table tr > :first-child { border-left: 0; }
.hours__table th { font-size: var(--t-s); font-weight: 500; color: var(--muted); border-top: 3px solid transparent; }
.hours__table td { font-weight: 600; }
.hours__table tr + tr td { font-size: var(--t-s); font-weight: 500; color: var(--muted); padding-top: 0; }
.hours__table .is-day { border-left: 2px solid var(--rule-strong); }
.hours__table th.is-day { color: var(--ink); font-weight: 700; }
.hours__table .is-now { color: var(--red); }
.hours__table th.is-now { border-top-color: var(--red); font-weight: 700; }
@media (min-width: 720px) {
  .hours { margin: 0; padding: 0; }
}
@media (min-width: 1100px) {
  .facts--row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.hours__wind { display: inline-flex; align-items: center; gap: 3px; }
.hours__wind svg { width: 12px; height: 12px; fill: currentColor; }

/* ── Controlli ─────────────────────────────────────── */

.seg { display: inline-flex; flex-wrap: wrap; }
.seg button {
  font: inherit;
  font-size: var(--t-s);
  font-weight: 600;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--ink);
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
.seg button + button { margin-left: -1px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.seg--small button { min-height: 36px; padding: 6px 10px; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
}
.btn--main { background: var(--red-fill); border-color: var(--red-fill); color: var(--on-red); }
.btn:disabled, .seg button:disabled { opacity: 0.4; cursor: default; }
.btn:not(:disabled):hover { border-color: var(--red); }
.btn--main:not(:disabled):hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.seg button:not([aria-pressed="true"]):hover { background: var(--soft); }

[data-arc-status].is-error { color: var(--red); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── Grafici ───────────────────────────────────────── */

.charts { display: grid; gap: 28px; }
@media (min-width: 900px) { .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px var(--gap); } }

.chart__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.chart__head .label { font-size: var(--t-s); font-weight: 700; }
.chart__readout { font-size: var(--t-s); font-weight: 600; text-align: right; }
.chart__plot { position: relative; height: 120px; touch-action: pan-y; }
.chart__plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart__empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--t-s); color: var(--muted); }

.c-grid { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.c-axis { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; }
.c-line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.c-now { fill: var(--red); }
.c-bar { fill: var(--ink); }
.c-tick { fill: var(--muted); font-size: 11px; paint-order: stroke; stroke: var(--ground); stroke-width: 4px; stroke-linejoin: round; }
.c-hover line { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; }
.c-hover circle { fill: var(--ground); stroke: var(--ink); stroke-width: 1.5; }

/* ── Valle: foto di adesso e timelapse in un solo visore ─ */

.valle { padding-top: 16px; }
.tl { display: grid; gap: 12px; }
.tl__frame { position: relative; aspect-ratio: 16 / 9; background: var(--soft); margin: 0 calc(-1 * var(--pad)); }
.tl__frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tl__frame img[src=""] { visibility: hidden; }
.tl__status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 16px; text-align: center; }

.glance { display: grid; gap: 10px; }
.glance__temp { font-size: clamp(3.5rem, 15vw, 5rem); font-weight: 600; line-height: 0.9; letter-spacing: -0.04em; }
.glance__side { display: grid; gap: 4px; }
.glance__wind { font-weight: 600; }
.glance__wind .muted { font-size: var(--t-s); font-weight: 500; }

/* Il lettore si apre come una sezione: filetto forte, poi tasti uniti come i segmenti */
.tl__player { display: grid; gap: 4px; border-top: 2px solid var(--rule-strong); padding-top: 12px; margin-top: 4px; }
.tl__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tl__buttons { display: inline-flex; }
.tl__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--ink);
  cursor: pointer;
}
.tl__btn + .tl__btn { margin-left: -1px; }
.tl__btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tl__btn--play { position: relative; min-width: 116px; padding: 0 16px; background: var(--red-fill); border-color: var(--red-fill); color: var(--on-red); }
.tl__btn--play .i-play { fill: currentColor; stroke: none; }
.tl__btn--play .i-pause { display: none; stroke-width: 2.2; }
.tl__btn--play[aria-pressed="true"] .i-play { display: none; }
.tl__btn--play[aria-pressed="true"] .i-pause { display: block; }
.tl__btn:disabled { color: var(--muted); border-color: var(--rule); cursor: default; }
.tl__btn--play:disabled { opacity: 0.4; color: var(--on-red); border-color: var(--red-fill); }
.tl__btn:not(:disabled):not(.tl__btn--play):hover { background: var(--soft); }
.tl__btn--play:not(:disabled):hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.tl__btn:focus-visible { z-index: 2; }
.tl__time { display: grid; justify-items: end; text-align: right; font-weight: 600; line-height: 1.3; }

/* Cursore come un asse dei grafici: filetto, tratto percorso in inchiostro, posizione in rosso */
.tl__track { position: relative; padding-bottom: 18px; margin-top: 4px; }
.tl__scrub {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.tl__scrub:disabled { cursor: default; opacity: 0.4; }
.tl__scrub::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(var(--ink), var(--ink)) 0 / var(--p, 100%) 100% no-repeat, var(--rule);
}
.tl__scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 4px;
  height: 24px;
  margin-top: -11px;
  border: 0;
  border-radius: 1px;
  background: var(--red);
}
.tl__scrub::-moz-range-track { height: 2px; background: var(--rule); }
.tl__scrub::-moz-range-progress { height: 2px; background: var(--ink); }
.tl__scrub::-moz-range-thumb { width: 4px; height: 24px; border: 0; border-radius: 1px; background: var(--red); }
.tl__days { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.tl__days span {
  position: absolute;
  top: 0;
  padding-left: 4px;
  border-left: 1px solid var(--muted);
  font-size: 11px;
  line-height: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.tl__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px var(--gap); margin-top: 8px; }
.valle .test { margin-top: 20px; max-width: 62ch; }

@media (min-width: 720px) { .tl__frame { margin: 0; } }
/* computer: foto a sinistra, temperatura e lettore a destra */
@media (min-width: 960px) {
  .tl { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: var(--gap); }
  .tl__frame { grid-row: 1 / 3; }
  .tl__player { align-self: end; }
}

/* ── Archivio ──────────────────────────────────────── */

.cols { display: grid; gap: 32px; }
.cols p { max-width: 62ch; margin-bottom: 8px; }
.cols .seg { margin-top: 8px; }
@media (min-width: 900px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); } }

.api { margin: 12px 0; }
.api div { padding: 8px 0; border-top: 1px solid var(--rule); }
.api dt { overflow-wrap: anywhere; }
.api dd { font-size: var(--t-s); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: var(--t-s); margin: 8px 0 12px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--ink); padding: 6px 8px 6px 0; }
.table td { border-bottom: 1px solid var(--rule); padding: 6px 8px 6px 0; vertical-align: top; }

/* ── Piede ─────────────────────────────────────────── */

.foot { border-top: 1px solid var(--rule); }
.foot__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px var(--pad) 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px var(--gap);
}
