/*
THESIS: il dato misurato apre ogni superficie; il portale di icone decorative è l’anti-modello.
OWN-WORLD: inchiostro del Golfo, carta fredda, segnale marino, righe da bollettino e numeri pieni.
STORY: leggere valore, unità, età e fonte; poi passare a previsione, radar e archivio.
FIRST VIEWPORT: navigazione compatta, luogo e rete, misura dominante, provenienza nello stesso campo.
FORM: “Bollettino del Golfo”, direzione fissata dal brief e costruita in modalità Operate/Read.
*/

:root {
  --gulf-ink: #071923;
  --gulf-deep: #0b2d3a;
  --gulf-mid: #12495a;
  --sea-signal: #007d96;
  --sea-link: #00647a;
  --sun-signal: #ffb000;
  --paper: #f7faf9;
  --paper-bright: #ffffff;
  --mist: #e4eceb;
  --rule: #a8b9b7;
  --text: #10272f;
  --text-soft: #39555d;
  --danger: #8d2020;
  --danger-bg: #ffe8e8;
  --focus: #ffbd2e;
  --radius-control: 8px;
  --radius-surface: 12px;
  --container: 1120px;
  --weather-surface: linear-gradient(128deg, #0d5669 0%, #0b2d3a 66%, #071923 100%);
  --shadow-raised: 0 12px 30px rgba(7, 25, 35, 0.18);
}

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

html {
  background: var(--paper);
  color: var(--text);
  font-family: "Trebuchet MS", Aptos, sans-serif;
  font-size: 16px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--text);
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

body.weather-night {
  --weather-surface: linear-gradient(128deg, #07121d 0%, #10233f 58%, #191f3b 100%);
}

body.weather-cloud {
  --weather-surface: linear-gradient(128deg, #263f4a 0%, #405b63 54%, #1a303a 100%);
}

body.weather-rain {
  --weather-surface: linear-gradient(128deg, #101e2a 0%, #24414e 50%, #162b39 100%);
}

body.weather-wind .live-hero {
  background-size: 160% 160%;
  animation: weather-shift 8s cubic-bezier(0.16, 1, 0.3, 1) infinite alternate;
}

@keyframes weather-shift {
  from { background-position: 10% 50%; }
  to { background-position: 90% 50%; }
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--sea-link);
  font-weight: 700;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  text-decoration-thickness: 0.15em;
}

button,
select {
  color: inherit;
  font: inherit;
}

button {
  min-height: 44px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(100% - 32px, var(--container));
  margin-inline: auto;
}

.prose {
  max-width: 72ch;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: var(--radius-control);
  background: var(--paper-bright);
  color: var(--gulf-ink);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 1px solid #2e515c;
  background: var(--gulf-ink);
  color: var(--paper);
}

.header-inner {
  display: grid;
  gap: 8px;
  padding-block: 10px 8px;
}

.logo {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  font-size: 1.05rem;
  text-decoration: none;
}

.logo strong {
  color: #8ed7e4;
}

.logo-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #8ed7e4;
  border-radius: 50%;
  color: #8ed7e4;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.header-nav {
  display: flex;
  max-width: 100%;
  gap: 22px;
  overflow-x: auto;
  padding: 4px 2px 7px;
  scrollbar-width: thin;
}

.header-nav a {
  flex: 0 0 auto;
  border-bottom: 2px solid transparent;
  color: #d7e7e8;
  font-size: 0.88rem;
  text-decoration: none;
}

.header-nav a[aria-current="page"] {
  border-color: var(--sun-signal);
  color: #ffffff;
}

h1,
h2,
h3,
p,
dl,
ol,
ul {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: inherit;
  line-height: 1.05;
  text-wrap: balance;
}

h1 {
  max-width: 16ch;
  margin-bottom: 18px;
  font-size: clamp(2.8rem, 11vw, 6.7rem);
  font-weight: 750;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 12px;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
}

.kicker,
.source-kind {
  margin-bottom: 10px;
  color: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.lede {
  max-width: 64ch;
  margin-bottom: 0;
  font-size: clamp(1.08rem, 2.5vw, 1.35rem);
  line-height: 1.55;
}

.live-hero,
.page-intro-dark,
.hero {
  background: var(--weather-surface);
  color: #f8ffff;
}

.hero {
  padding-block: clamp(52px, 9vw, 104px);
}

.hero-inner {
  max-width: 58rem;
}

.hero-date {
  margin-bottom: 10px;
  color: #d3e5e7;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 18ch;
  font-size: clamp(2.4rem, 8vw, 5.6rem);
  line-height: 0.96;
}

.live-hero {
  min-height: min(760px, calc(100svh - 96px));
  padding-block: clamp(42px, 8vw, 86px);
  transition: background 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

.live-hero a,
.page-intro-dark a,
.hero a {
  color: #a8ebf5;
}

.hero-heading {
  display: grid;
  gap: 2px;
}

.hero-heading h1 {
  margin-bottom: 10px;
}

.hero-source,
.reading-age,
.network-line {
  color: #d3e5e7;
}

.primary-reading {
  display: grid;
  gap: 18px;
  margin-top: clamp(36px, 7vw, 68px);
  border-top: 1px solid #73939a;
  border-bottom: 1px solid #73939a;
  padding-block: 22px;
}

.reading-place {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.reading-place p {
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.reading-place span {
  color: #d3e5e7;
  font-size: 0.82rem;
}

.hero-temperature {
  margin-bottom: 0;
  color: #ffffff;
  font-size: clamp(5rem, 29vw, 12rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 0.78;
}

.hero-temperature .unit {
  margin-left: 0.04em;
  color: #b4e6ed;
  font-size: 0.3em;
  letter-spacing: -0.01em;
  vertical-align: top;
}

.reading-age {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.reading-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 0;
  background: #73939a;
}

.reading-strip > div {
  min-width: 0;
  padding: 14px 12px;
  background: var(--gulf-deep);
}

.reading-strip dt,
.fact-list dt {
  color: inherit;
  font-size: 0.76rem;
  font-weight: 700;
}

.reading-strip dd,
.fact-list dd {
  margin: 3px 0 0;
  font-size: 1rem;
  font-weight: 800;
}

.network-line {
  margin: 18px 0 0;
  font-size: 0.88rem;
}

.hero-outage {
  max-width: 700px;
  margin-top: 48px;
  border: 1px solid #ffb7b7;
  border-radius: var(--radius-surface);
  padding: 22px;
  background: #401d25;
  color: #fff4f4;
}

.outage-title {
  margin-bottom: 8px;
  font-size: 1.35rem;
  font-weight: 800;
}

.page-intro {
  padding-block: clamp(52px, 9vw, 104px);
}

.page-intro:not(.page-intro-dark) {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.page-intro:not(.page-intro-dark) h1 {
  color: var(--gulf-ink);
}

.content-section,
.forecast-ribbon,
.measure-section,
.map-section,
.info-section,
.stations-section {
  padding-block: clamp(52px, 8vw, 92px);
}

.content-section,
.info-section {
  background: var(--paper-bright);
}

.measure-section,
.forecast-ribbon {
  border-block: 1px solid var(--rule);
  background: var(--mist);
}

.map-section,
.stations-section {
  background: var(--gulf-deep);
  color: #f7ffff;
}

.map-section a,
.stations-section a {
  color: #a8ebf5;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 34px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading > a {
  width: fit-content;
}

.forecast-row {
  display: grid;
  grid-auto-columns: minmax(132px, 1fr);
  grid-auto-flow: column;
  gap: 1px;
  overflow-x: auto;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.forecast-day {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 170px;
  padding: 16px 14px;
  background: var(--paper-bright);
}

.forecast-day time,
.forecast-day span {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.forecast-day strong {
  color: var(--gulf-ink);
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.source-note {
  margin: 16px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.map-section .source-note,
.stations-section .source-note {
  color: #cce0e3;
}

.map-grid,
.split-grid,
.evidence-grid {
  display: grid;
  gap: 32px;
}

.section-copy {
  max-width: 58ch;
}

.map-shell {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid #7b9ba2;
  border-radius: var(--radius-surface);
  background: #102832;
}

.map-canvas {
  width: 100%;
  height: 420px;
}

.compact-map,
.compact-map .map-canvas {
  min-height: 360px;
  height: 360px;
}

.map-state {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 450;
  max-width: calc(100% - 20px);
  margin: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #071923;
  color: #f7ffff;
  font-size: 0.78rem;
  box-shadow: var(--shadow-raised);
}

.leaflet-control-attribution {
  color: #10272f !important;
  font-size: 0.7rem !important;
}

.fact-list {
  margin: 0;
  border-top: 1px solid var(--rule);
}

.fact-list > div {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  padding-block: 14px;
}

.fact-list dt {
  color: var(--text-soft);
}

.fact-list dd {
  overflow-wrap: anywhere;
  color: var(--text);
}

.inline-state {
  margin: 18px 0 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  padding: 18px;
  background: var(--paper);
  color: var(--text);
}

.inline-state p:last-child {
  margin-bottom: 0;
}

.error-state {
  border-color: #d78686;
  background: var(--danger-bg);
  color: #6e1515;
}

.forecast-table-wrap,
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
}

.forecast-table,
.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--paper-bright);
  font-variant-numeric: tabular-nums;
}

.forecast-table th,
.forecast-table td,
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--rule);
  padding: 14px 12px;
  text-align: left;
}

.forecast-table thead th,
.data-table thead th {
  background: var(--gulf-ink);
  color: #ffffff;
  font-size: 0.78rem;
}

.forecast-table tbody th {
  color: var(--gulf-ink);
}

.history-dashboard {
  display: grid;
}

.history-controls {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.range-controls {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.range-controls button,
.history-controls select,
.cbx-actions button {
  border: 1px solid #55727a;
  border-radius: var(--radius-control);
  padding: 9px 14px;
  background: var(--paper-bright);
  color: var(--gulf-ink);
  font-weight: 800;
}

.range-controls button[aria-pressed="true"] {
  border-color: var(--sea-signal);
  background: var(--sea-signal);
  color: #ffffff;
}

.history-controls label {
  font-size: 0.82rem;
  font-weight: 800;
}

.history-controls select {
  width: min(100%, 260px);
}

.history-plot {
  position: relative;
  min-height: 340px;
  border: 1px solid var(--rule);
  background: #ffffff;
}

.history-plot svg {
  width: 100%;
  min-height: 320px;
}

.history-plot [data-history-state] {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--rule);
  color: var(--text-soft);
  font-size: 0.82rem;
}

.chart-grid {
  stroke: #c7d3d2;
  stroke-width: 1;
}

.chart-axis-label {
  fill: #39555d;
  font-family: "Trebuchet MS", Aptos, sans-serif;
  font-size: 11px;
}

.chart-line {
  fill: none;
  stroke: var(--sea-signal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.air-series,
.station-register,
.dataset-status {
  display: grid;
  gap: 28px;
}

.air-source,
.station-register article,
.dataset-status article {
  border-top: 4px solid var(--gulf-ink);
  padding-top: 18px;
}

.air-source.primary-source {
  border-color: var(--sea-signal);
}

.air-source header,
.station-register header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.quality-tag,
.station-state {
  flex: 0 0 auto;
  border: 1px solid #55727a;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.air-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 18px 0 0;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.air-values > div {
  padding: 16px;
  background: var(--paper);
}

.air-values dt {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.air-values dd {
  margin: 5px 0;
  color: var(--gulf-ink);
  font-size: 1.65rem;
  font-weight: 800;
}

.air-values dd span,
.air-values small {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.evidence-levels {
  display: grid;
  gap: 1px;
  padding: 0;
  background: var(--rule);
  border: 1px solid var(--rule);
  list-style: none;
  counter-reset: evidence;
}

.evidence-levels li {
  display: grid;
  gap: 6px;
  padding: 20px;
  background: var(--paper-bright);
  counter-increment: evidence;
}

.evidence-levels strong::before {
  content: counter(evidence) " — ";
  color: var(--sea-link);
}

.evidence-levels span {
  color: var(--text-soft);
}

.source-register {
  display: grid;
  gap: 0;
}

.source-register > h2 {
  margin-bottom: 30px;
}

.source-register article {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding-block: 24px;
}

.source-register article:last-child {
  border-bottom: 1px solid var(--rule);
}

.source-register h3 {
  margin-bottom: 0;
}

.source-register p {
  max-width: 72ch;
  margin-bottom: 0;
}

.source-register .source-kind {
  color: var(--sea-link);
}

.source-terms {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.info-section .container {
  max-width: 78ch;
}

.info-section h2:not(:first-child) {
  margin-top: 52px;
}

.info-section li {
  margin-block: 8px;
}

.section-title {
  margin-bottom: 20px;
}

.site-footer {
  padding-block: 42px;
  background: var(--gulf-ink);
  color: #d2e2e4;
}

.footer-grid {
  display: grid;
  gap: 22px;
}

.footer-logo {
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
}

.site-footer p {
  margin-bottom: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.footer-nav a {
  color: #b5e6ee;
}

.cbx-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 900;
  display: grid;
  gap: 16px;
  max-width: 760px;
  margin-inline: auto;
  border: 1px solid #789097;
  border-radius: var(--radius-surface);
  padding: 18px;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow-raised);
}

.cbx-panel h2 {
  margin-bottom: 6px;
  font-size: 1.3rem;
}

.cbx-panel p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.cbx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cbx-actions .action {
  border-color: var(--sea-signal);
  background: var(--sea-signal);
  color: #ffffff;
}

@media (min-width: 560px) {
  .reading-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .fact-list > div {
    grid-template-columns: minmax(130px, 0.45fr) 1fr;
    gap: 24px;
  }

  .history-controls {
    grid-template-columns: 1fr auto minmax(180px, 240px);
    align-items: center;
  }

  .cbx-panel {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

@media (min-width: 760px) {
  .header-inner {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 32px;
    padding-block: 12px;
  }

  .header-nav {
    justify-content: flex-end;
    padding: 8px 2px;
  }

  .primary-reading {
    grid-template-columns: 0.7fr 1.3fr;
    align-items: end;
  }

  .reading-place {
    display: grid;
    align-self: start;
  }

  .hero-temperature {
    grid-column: 2;
    grid-row: 1 / span 2;
    text-align: right;
  }

  .reading-age {
    grid-column: 1;
  }

  .reading-strip {
    grid-column: 1 / -1;
  }

  .section-heading {
    flex-direction: row;
    align-items: end;
    justify-content: space-between;
  }

  .map-grid,
  .split-grid,
  .evidence-grid {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
    gap: clamp(42px, 7vw, 90px);
  }

  .station-register,
  .dataset-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .evidence-levels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-register article {
    grid-template-columns: minmax(200px, 0.42fr) minmax(0, 1fr);
    column-gap: 38px;
  }

  .source-register .source-terms {
    grid-column: 2;
  }

  .footer-grid {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .range-controls button[aria-pressed="true"],
  .cbx-actions .action {
    border: 2px solid ButtonText;
  }
}
