/* ============================================================
   Clean Air Litigation Database — R2CA · University of Turin
   Identità: design system UniTo (tema.unito.it) — Titillium Web,
   variante tematica Blu #235689; semantici dalle varianti UniTo
   (Arancione #D44406, Verde #048567, Amaranto #B91734).
   ============================================================ */

:root {
  --blue: #235689;
  --blue-deep: #17395c;
  --blue-tint: #e3ecf4;
  --sky: #f2f6fa;
  --ink: #1a1a1a;
  --body-c: #3d4349;
  --grey: #54565a;
  --muted: #83898f;
  --line: #dde2e7;
  --bg: #f7f8fa;
  --card: #ffffff;
  --shadow: 0 2px 10px rgba(23, 57, 92, 0.08);
  --shadow-hover: 0 6px 18px rgba(23, 57, 92, 0.14);
  --link: #235689;
  --focus: #235689;
  --chip-ink: #ffffff;

  --pending: #d44406;
  --enforce: #048567;
  --preview: #b91734;

  --map-0: #e9ecef;
  --map-1: #b9cfe2;
  --map-2: #7fa4c6;
  --map-3: #40729f;
  --map-4: #235689;
  --map-stroke: #ffffff;

  --font: "Titillium Web", "Segoe UI", Tahoma, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --blue: #7ba7cf;
    --blue-deep: #a8c6e2;
    --blue-tint: #22303e;
    --sky: #1b2229;
    --ink: #eef1f4;
    --body-c: #c3c9cf;
    --grey: #aab1b8;
    --muted: #8b939b;
    --line: #333a42;
    --bg: #14181c;
    --card: #1d2329;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.55);
    --link: #8fb6da;
    --focus: #8fb6da;
    --chip-ink: #14181c;

    --pending: #e0793f;
    --enforce: #3fae8f;
    --preview: #e06478;

    --map-0: #242b32;
    --map-1: #31465c;
    --map-2: #3f6288;
    --map-3: #5b86b3;
    --map-4: #7ba7cf;
    --map-stroke: #14181c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #7ba7cf;
  --blue-deep: #a8c6e2;
  --blue-tint: #22303e;
  --sky: #1b2229;
  --ink: #eef1f4;
  --body-c: #c3c9cf;
  --grey: #aab1b8;
  --muted: #8b939b;
  --line: #333a42;
  --bg: #14181c;
  --card: #1d2329;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.55);
  --link: #8fb6da;
  --focus: #8fb6da;
  --chip-ink: #14181c;

  --pending: #e0793f;
  --enforce: #3fae8f;
  --preview: #e06478;

  --map-0: #242b32;
  --map-1: #31465c;
  --map-2: #3f6288;
  --map-3: #5b86b3;
  --map-4: #7ba7cf;
  --map-stroke: #14181c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body-c);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
button { font-family: var(--font); }

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }

.kicker {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--blue); margin: 0 0 6px;
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 60;
  background: var(--card); border-bottom: 3px solid var(--blue);
}
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 66px; flex-wrap: wrap; padding-block: 8px; }
.logos { display: flex; gap: 8px; }
.logo-slot {
  width: 74px; height: 40px; border: 1.5px dashed var(--line); border-radius: 6px;
  display: grid; place-content: center; text-align: center;
  font-size: 9px; line-height: 1.25; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}
.masthead { line-height: 1.2; }
.masthead .t { display: block; color: var(--ink); font-weight: 700; font-size: 18px; }
.masthead .s { display: block; color: var(--muted); font-size: 12px; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topnav a {
  padding: 7px 13px; border-radius: 6px; font-size: 13.5px; font-weight: 600; color: var(--grey);
}
.topnav a:hover { background: var(--sky); color: var(--blue); text-decoration: none; }
.badge-preview {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--preview); border: 1.5px solid var(--preview);
  border-radius: 4px; padding: 3px 9px; margin-left: 6px;
}

/* ---------- intro ---------- */
.intro { padding-block: 34px 10px; }
.intro h1 {
  color: var(--ink); font-weight: 700; font-size: clamp(26px, 4vw, 40px);
  line-height: 1.12; margin: 0 0 10px; text-wrap: balance; max-width: 22ch;
}
.intro .lead { max-width: 68ch; margin: 0; font-size: 16px; font-weight: 300; }
.intro .lead b { font-weight: 600; color: var(--ink); }
.stats { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 20px; }
.stat .n { display: block; font-size: 30px; font-weight: 700; color: var(--blue); line-height: 1; font-variant-numeric: tabular-nums; }
.stat .l { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 4px; }

.sample-note {
  margin-top: 22px; padding: 11px 16px; border-left: 4px solid var(--pending);
  background: var(--card); border-radius: 0 8px 8px 0; font-size: 13px; box-shadow: var(--shadow);
}
.sample-note b { color: var(--ink); }

/* ---------- mappa + pannello ---------- */
.map-section { padding-block: 22px 8px; }
.map-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(240px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .map-grid { grid-template-columns: 1fr; } }

.map-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; box-shadow: var(--shadow);
}
#map { display: block; width: 100%; height: auto; }
#map .country { stroke: var(--map-stroke); stroke-width: .5; }
#map .country.has-cases { cursor: pointer; }
#map .country.has-cases:hover { stroke: var(--ink); stroke-width: 1; }
#map .country.active { stroke: var(--ink); stroke-width: 1.2; }

.map-legend { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.map-legend .cell { display: inline-flex; align-items: center; gap: 5px; }
.map-legend .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }

.map-tip {
  position: fixed; z-index: 80; pointer-events: none;
  background: var(--ink); color: var(--bg);
  font-size: 12.5px; padding: 6px 10px; border-radius: 6px; line-height: 1.35;
  max-width: 240px;
}

.side { display: grid; gap: 14px; }
.side-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.side-box h2 {
  margin: 0 0 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--grey);
}
.court-btns { display: grid; gap: 8px; }
.court-btn, .country-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px; color: var(--ink);
}
.court-btn:hover, .country-btn:hover { border-color: var(--blue); }
.court-btn.active, .country-btn.active { background: var(--blue-tint); border-color: var(--blue); }
.count-pill {
  flex: none; min-width: 26px; text-align: center;
  background: var(--blue); color: var(--chip-ink); border-radius: 12px;
  font-size: 12px; font-weight: 700; padding: 1px 8px; font-variant-numeric: tabular-nums;
}
.country-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }

/* ---------- filtri ---------- */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 16px; margin-top: 26px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.filters input[type="search"], .filters select {
  font-family: var(--font); font-size: 13.5px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 11px;
}
.filters input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.filters select { flex: 0 1 auto; }
.filters label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.active-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--blue); color: var(--chip-ink); border: 0; cursor: pointer;
  border-radius: 15px; padding: 6px 13px; font-size: 12.5px; font-weight: 600;
}
.active-chip .x { font-weight: 700; }
.result-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* ---------- lista casi ---------- */
.cases { display: grid; gap: 12px; padding: 0; margin: 18px 0 0; list-style: none; }
.case-card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 20px; color: var(--body-c);
  box-shadow: var(--shadow); transition: box-shadow .25s ease, border-color .25s ease;
}
.case-card:hover { text-decoration: none; box-shadow: var(--shadow-hover); border-color: var(--blue); }
.case-card h3 { margin: 0 0 5px; font-size: 16.5px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.case-card .issue { margin: 0 0 10px; font-size: 13.5px; }
.meta-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  border-radius: 4px; padding: 2px 8px; letter-spacing: .02em;
  background: var(--sky); color: var(--grey); border: 1px solid var(--line);
}
.tag.geo { background: var(--blue-tint); color: var(--blue-deep); border-color: transparent; }
.tag.year { font-variant-numeric: tabular-nums; }
.status {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; border-radius: 4px; padding: 2px 9px;
}
.status.decided { background: var(--blue); color: var(--chip-ink); }
.status.pending { background: transparent; color: var(--pending); border: 1.5px solid var(--pending); }
.status.enforce { background: transparent; color: var(--enforce); border: 1.5px solid var(--enforce); }
.no-results { padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- dettaglio caso ---------- */
.case-detail { margin-top: 18px; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 13.5px; font-weight: 600; }
.detail-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.detail-head { padding: 24px 28px 18px; border-bottom: 1px solid var(--line); background: var(--sky); }
.detail-head h2 { margin: 4px 0 10px; font-size: clamp(19px, 2.6vw, 26px); font-weight: 700; color: var(--ink); line-height: 1.25; text-wrap: balance; }
.sample-chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--pending); border: 1.5px solid var(--pending); border-radius: 4px; padding: 2px 8px;
}
.detail-body { padding: 22px 28px 28px; }
.fact-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin: 0 0 22px; padding: 0; list-style: none;
}
.fact b { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 3px; }
.fact span { font-size: 13.5px; color: var(--ink); }
.detail-body h4 {
  margin: 24px 0 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--blue);
}
.detail-body .abstract { margin: 0; max-width: 75ch; font-size: 15px; }
.topics { display: flex; gap: 7px; flex-wrap: wrap; }

.proc-table-wrap { overflow-x: auto; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.proc-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line);
}
.proc-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.proc-table td.d { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.proc-table tr:last-child td { border-bottom: 0; }

.sources-list { margin: 0; padding-left: 18px; font-size: 13.5px; }
.sources-list li { margin-bottom: 5px; }
.cite-box {
  margin-top: 8px; padding: 12px 16px; background: var(--sky);
  border-radius: 8px; font-size: 13px; border: 1px solid var(--line);
}

/* ---------- sezioni prosa ---------- */
.prose-section { padding-block: 36px 6px; }
.prose-section h2 { color: var(--ink); font-weight: 700; font-size: 22px; margin: 0 0 12px; }
.prose-section .rule { height: 3px; width: 52px; background: var(--blue); border: 0; margin: 0 0 18px; }
.prose-section p { max-width: 76ch; margin: 0 0 12px; }
.prose-section ul { max-width: 76ch; margin: 0 0 12px; padding-left: 20px; }
.prose-section li { margin-bottom: 8px; font-size: 14.5px; }
.prose-section li b { color: var(--ink); font-weight: 600; }

/* ---------- footer ---------- */
footer.site {
  margin-top: 44px; border-top: 3px solid var(--blue);
  background: var(--card); padding-block: 24px 30px;
  font-size: 12.5px; color: var(--muted);
}
footer.site p { margin: 4px 0; max-width: 100ch; }

/* ---------- icone e bandiere ---------- */
.ic { width: 17px; height: 17px; flex: none; }
.stat .n { display: flex; align-items: center; gap: 8px; }
.stat .ic { width: 21px; height: 21px; color: var(--muted); }
.side-box h2 { display: flex; align-items: center; gap: 7px; }
.side-box h2 .ic { width: 15px; height: 15px; color: var(--blue); }
.lbl { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.court-btn .ic { width: 15px; height: 15px; color: var(--blue); }
.flag {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  vertical-align: -3px; box-shadow: 0 0 0 1px var(--line);
}
.tag.geo { display: inline-flex; align-items: center; gap: 5px; }
.tag.geo .flag { width: 13px; height: 13px; vertical-align: 0; }
.active-chip .flag { width: 14px; height: 14px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.fact .flag { margin-right: 6px; }
.search-wrap { position: relative; flex: 1 1 220px; min-width: 160px; display: flex; }
.search-wrap .ic {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.search-wrap input[type="search"] { flex: 1; width: 100%; padding-left: 33px; }

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  .case-card { transition: none; }
}
