/* Terra Aurunca Oggi · portale
   Colori come token: chiaro di default, scuro da sistema o da interruttore.
   Serie dei grafici validate per daltonismo (dataviz validate_palette):
   notizie = terracotta, terremoti = blu, in entrambi i temi. */

:root {
  color-scheme: light;
  --bg: #F5F2EB;
  --surface: #FBF9F4;
  --surface-2: #F0ECE3;
  --ink: #1F1F1F;
  --heading: #1A2B4C;
  --text-2: #4A4A4A;
  --muted: #6B6B6B;
  --line: rgba(26, 43, 76, .12);
  --line-2: rgba(26, 43, 76, .22);
  --accent: #A8422D;          /* testo e link in evidenza (5.6:1 sulla carta) */
  --accent-bg: #A8422D;
  --on-accent: #FBF9F4;
  --navy: #1A2B4C;
  --on-navy: #FBF9F4;
  --s-news: #C4553D;
  --s-quake: #2A78D6;
  --sea: #DCE5EB;
  --land: #F0ECE3;
  --river: #8DB0CC;
  --grid: #E1DED5;
  --axis: #C3C2B7;
  --ok: #0A7F0A;
  --bad: #C03030;
  --pill: rgba(26, 43, 76, .07);
  --shadow: 0 12px 40px rgba(26, 43, 76, .18);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1240px;
  --gut: clamp(16px, 4vw, 32px);
  --r: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11151B; --surface: #171B22; --surface-2: #1E232C;
    --ink: #ECE8E1; --heading: #F1EDE6; --text-2: #C9C5BE; --muted: #A29E97;
    --line: rgba(255, 255, 255, .10); --line-2: rgba(255, 255, 255, .20);
    --accent: #EBA48F; --accent-bg: #B5492F; --on-accent: #FFF8F4;
    --navy: #2B3C5E; --on-navy: #F1EDE6;
    --s-news: #D9694F; --s-quake: #3987E5;
    --sea: #1B2A38; --land: #1A1F27; --river: #3B6585;
    --grid: #2A2F38; --axis: #3A404A;
    --ok: #2FBF2F; --bad: #F06A6A;
    --pill: rgba(255, 255, 255, .08);
    --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151B; --surface: #171B22; --surface-2: #1E232C;
  --ink: #ECE8E1; --heading: #F1EDE6; --text-2: #C9C5BE; --muted: #A29E97;
  --line: rgba(255, 255, 255, .10); --line-2: rgba(255, 255, 255, .20);
  --accent: #EBA48F; --accent-bg: #B5492F; --on-accent: #FFF8F4;
  --navy: #2B3C5E; --on-navy: #F1EDE6;
  --s-news: #D9694F; --s-quake: #3987E5;
  --sea: #1B2A38; --land: #1A1F27; --river: #3B6585;
  --grid: #2A2F38; --axis: #3A404A;
  --ok: #2FBF2F; --bad: #F06A6A;
  --pill: rgba(255, 255, 255, .08);
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { margin: 0; color: var(--heading); line-height: 1.2; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--s-news); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--navy); color: var(--on-navy); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.note, .credit { font-size: 12px; color: var(--muted); margin-top: 10px; }
.credit a { color: inherit; }

/* ---------------------------------------------------------------- bottoni */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font-size: 14.5px; font-weight: 600; text-decoration: none; background: none; }
.btn.full { width: 100%; }
.btn-primary { background: var(--accent-bg); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line-2); color: var(--heading); background: var(--surface); }
.btn-ghost:hover { border-color: var(--heading); }
.btn-light { background: var(--on-accent); color: var(--accent-bg); }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; color: var(--heading); }
.icon-btn svg { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- testata */
.masthead { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.masthead-inner { height: 64px; display: flex; align-items: center; gap: 24px; }
.wordmark { font-family: var(--serif); font-size: 24px; font-weight: 600; color: var(--heading); text-decoration: none; white-space: nowrap; }
.wordmark span { color: var(--s-news); }
.wordmark.light { color: var(--on-navy); }
.nav { display: flex; gap: 20px; font-size: 15px; flex: 1; }
.nav a, .nav .link-btn { color: var(--text-2); font-weight: 500; text-decoration: none; }
.nav a:hover, .nav .link-btn:hover { color: var(--heading); }
.masthead-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------------------------------------------------------------- apertura */
.hero { padding: 28px 0 10px; }
.hero-date { font-family: var(--serif); font-weight: 500; font-size: clamp(32px, 6vw, 52px); letter-spacing: -.01em; margin-top: 6px; }
.hero-date::first-letter { text-transform: uppercase; }
.hero-sub { margin-top: 10px; color: var(--text-2); font-size: 15.5px; max-width: 70ch; }
.hero-sub .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }

/* ---------------------------------------------------------------- filtri */
.filters { padding: 14px 0 6px; display: grid; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex: 0 0 auto; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--heading); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.chip .n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--pill); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.chip[aria-checked="true"] { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.chip[aria-checked="true"] .n { background: var(--s-news); color: #fff; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field select, .field input { height: 40px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 14px; font-size: 14.5px; }
.field.search { position: relative; flex: 1 1 220px; max-width: 380px; }
.field.search input { width: 100%; padding-left: 38px; }
.field.search svg { position: absolute; left: 14px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--muted); }

/* ---------------------------------------------------------------- schede */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 12px; }
.card-accent { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--on-accent); display: grid; gap: 10px; }
.card-accent h2 { color: var(--on-accent); }
.card-accent p { font-size: 14px; opacity: .9; }

/* ---------------------------------------------------------------- panoramica */
.panorama { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; padding: 14px 0 6px; }
.map-wrap { position: relative; border-radius: 12px; overflow: hidden; background: var(--land); }
.map-wrap svg { display: block; width: 100%; height: auto; }
.map-town { cursor: pointer; }
.map-town .bubble { fill: var(--s-news); fill-opacity: .85; stroke: var(--surface); stroke-width: 2; transition: fill-opacity .15s; }
.map-town:hover .bubble, .map-town:focus .bubble { fill-opacity: 1; }
.map-town.dim .bubble { fill-opacity: .25; }
.map-town.on .bubble { stroke: var(--heading); stroke-width: 2.5; }
.map-town .hit { fill: transparent; }
.map-label { font: 600 calc(13px * var(--mapk, 1.6)) var(--sans); fill: var(--heading); paint-order: stroke; stroke: var(--land); stroke-width: calc(4px * var(--mapk, 1.6)); stroke-linejoin: round; pointer-events: none; }
.map-label.sea { fill: var(--muted); font-weight: 500; font-style: italic; stroke: var(--sea); }
.map-label.ref { fill: var(--muted); font-weight: 500; }
.quake { fill: none; stroke: var(--s-quake); stroke-width: 2; }
.quake-hit { fill: transparent; cursor: help; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.legend .toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.key-news { background: var(--s-news); }
.key-quake { border: 2px solid var(--s-quake); }

.panorama-side { display: grid; gap: 20px; align-content: start; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 30px; font-weight: 600; color: var(--heading); line-height: 1.1; margin-top: 4px; }
.stat .sub { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--s-news); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar, .chart .col.hover .bar { filter: brightness(1.15); }
.chart .col.sel .bar { fill: var(--heading); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .tick { font: 11px var(--sans); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .val { font: 600 11px var(--sans); fill: var(--text-2); }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 2.2rem; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-label .kind, .src .kind { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); flex: 0 0 auto; }
.kind.ente { border-color: var(--s-quake); color: var(--s-quake); }
.kind.redazione, .kind.lettori { border-color: var(--accent); color: var(--accent); }
.hbar-track { height: 10px; }
.hbar-fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--s-news); min-width: 2px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.chart-table table, .table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chart-table th, .chart-table td, .table-wrap th, .table-wrap td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.chart-table td.num, .table-wrap td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- impaginato */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; padding: 24px 0 64px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--heading); padding-bottom: 8px; margin-bottom: 4px; }
.section-head h2 { font-size: 24px; }
.count { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.day-head { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 22px 0 6px; }
.item { display: grid; gap: 6px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); }
.item h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; line-height: 1.3; }
.item h3 a { color: var(--heading); text-decoration: none; }
.item h3 a:hover { color: var(--accent); text-decoration: underline; }
.item .sum { color: var(--text-2); font-size: 14.5px; line-height: 1.5; }
.item-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--pill); color: var(--heading); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.town { background: none; border: 1px solid var(--line-2); }
.pill.town.soft { border-style: dashed; color: var(--muted); }
.pill.cat-avvisi { background: color-mix(in srgb, var(--s-news) 18%, transparent); }
.src { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-2); }
.src .kind { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); }
.src .kind.ente { border-color: var(--s-quake); color: var(--s-quake); }
.src .kind.redazione, .src .kind.lettori { border-color: var(--accent); color: var(--accent); }
.more-src { font-size: 13px; }
.more-src summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.more-src summary::-webkit-details-marker { display: none; }
.more-src ul { margin: 8px 0 0; padding: 0 0 0 14px; display: grid; gap: 4px; }
.feed .more { margin-top: 20px; }
.empty { padding: 40px 20px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r); margin-top: 16px; color: var(--text-2); }
.loading { opacity: .5; transition: opacity .2s; }

/* ---------------------------------------------------------------- colonna laterale */
.side { display: grid; gap: 20px; align-content: start; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.mini-list li { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: start; }
.mini-list .date { width: 46px; height: 46px; border-radius: 12px; background: var(--navy); color: var(--on-navy); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.mini-list .date b { font-size: 18px; }
.mini-list .date small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.mini-list a { color: var(--heading); font-weight: 600; font-size: 14px; line-height: 1.35; text-decoration: none; }
.mini-list a:hover { color: var(--accent); text-decoration: underline; }
.mini-list .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mini-list.plain li { grid-template-columns: 1fr; }

.meteo table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.meteo th { font-size: 11px; font-weight: 600; color: var(--muted); text-align: right; padding: 0 4px 6px; text-transform: uppercase; letter-spacing: .05em; }
.meteo th:first-child { text-align: left; }
.meteo td { padding: 7px 4px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meteo td:first-child { text-align: left; font-weight: 600; color: var(--heading); white-space: normal; }
.meteo .now { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.meteo .lo { color: var(--muted); }
.wx { width: 18px; height: 18px; vertical-align: -4px; color: var(--text-2); }

.quake-row { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.quake-row:first-child { border-top: 0; }
.quake-row .mag { font-weight: 700; font-size: 17px; color: var(--heading); font-variant-numeric: tabular-nums; }
.quake-row .bar { height: 4px; border-radius: 2px; background: var(--s-quake); margin-top: 4px; }
.quake-row a { color: var(--heading); font-weight: 600; text-decoration: none; }
.quake-row a:hover { text-decoration: underline; }
.quake-row .meta { color: var(--muted); font-size: 12px; }

.lvl { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.lvl::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--lvl); flex: 0 0 auto; }
.lvl-verde { --lvl: #0ca30c; }
.lvl-gialla { --lvl: #fab219; }
.lvl-arancione { --lvl: #ec835a; }
.lvl-rossa { --lvl: #d03b3b; }
.alert-banner { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); border-left: 6px solid var(--lvl); font-size: 14.5px; color: var(--ink); max-width: 75ch; }
.alert-banner a { font-weight: 600; }
.fonti-summary { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

/* ---------------------------------------------------------------- finestre */
dialog.sheet { border: 0; padding: 0; width: min(640px, 100vw - 24px); max-height: 88vh; border-radius: 20px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
dialog.sheet.wide { width: min(900px, 100vw - 24px); }
dialog.sheet::backdrop { background: rgba(17, 21, 27, .55); backdrop-filter: blur(3px); }
.sheet-body { padding: 22px var(--gut) 26px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 24px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sheet h3 { margin-top: 8px; }
.form label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.form input, .form select, .form textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); padding: 10px 12px; font-size: 15px; font-weight: 400; color: var(--ink); }
.form .hp { position: absolute; left: -9999px; }
.form-msg { font-size: 14px; min-height: 1.2em; }
.form-msg.err { color: var(--bad); }
.form-msg.ok { color: var(--ok); }
.method { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14.5px; color: var(--text-2); }
.table-wrap { overflow-x: auto; }
.dn-meta { display: grid; gap: 0; margin: 4px 0 0; border-top: 1px solid var(--line); }
.dn-meta div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.dn-meta dt { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding-top: 2px; }
.dn-meta dd { margin: 0; color: var(--heading); font-weight: 500; }

.loc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.loc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; font-size: 13.5px; }
.loc b { color: var(--heading); font-size: 15px; }
.loc .meta { color: var(--muted); font-size: 12.5px; }

.tooltip { position: fixed; z-index: 80; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); max-width: 260px; }
.tooltip strong { display: block; font-size: 15px; color: var(--heading); }

/* ---------------------------------------------------------------- piè di pagina */
.footer { background: var(--navy); color: color-mix(in srgb, var(--on-navy) 80%, transparent); padding: 40px 0 34px; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px; font-size: 14px; }
.footer p { margin-top: 10px; max-width: 40ch; }
.footer h3 { color: var(--on-navy); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 10px; opacity: .7; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer a { color: var(--on-navy); }

/* ---------------------------------------------------------------- schermi stretti */
@media (max-width: 980px) {
  .panorama { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 24px; }
  .item h3 { font-size: 18px; }
  .masthead-actions .btn { padding: 0 12px; }
  dialog.sheet { max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (forced-colors: active) { .map-town .bubble, .chart .bar { forced-color-adjust: none; } }
