/* Când a ajuns modernitatea la tine? — semantic tokens, dual theme. */

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-raised: #fcfaf4;
  --bg-sunken: #e8e2d3;
  --fg: #1a1916;
  --fg-soft: #45403a;
  --fg-faint: #524c43;
  --line: rgba(26, 25, 22, 0.16);
  --line-strong: rgba(26, 25, 22, 0.4);
  --shadow: rgba(26, 25, 22, 0.12);
  --accent: #23587f;
  --accent-soft: #dbe6ef;
  --accent-ink: #173d59;
  --on-accent: #ffffff;
  --link: #1b4c72;
  --focus: #23587f;
  /* utilities */
  --w: #2f6f9e;      /* apă */
  --w-soft: #b9d3e6;
  --s: #7a5230;      /* canalizare */
  --s-soft: #d9c3ab;
  --g: #c8781e;      /* gaze */
  --g-soft: #f0d3a8;
  --h: #a53b2c;      /* termoficare */
  --h-soft: #e8b6ac;
  --both: #1f6b62;   /* apă și canalizare */
  --only: #d98a3a;   /* apă fără canalizare */
  --new: #e6c229;    /* apare în anul curent */
  /* completion-year bins */
  --t0: #2b3f5c; --t1: #3e6b8f; --t2: #5a95a8; --t3: #8fbfa8; --t4: #d5d9a3;
  --w-ink: #1d4a70; --s-ink: #5a3a1f; --g-ink: #7c4608; --h-ink: #8a2e21;
  --nodata: #e9e4d8;
  --map-line: rgba(26, 25, 22, 0.10);
  --county-line: rgba(26, 25, 22, 0.55);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --container: 70ch;
  --wide: 1180px;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161a; --bg-raised: #1c1f25; --bg-sunken: #0d0f12;
    --fg: #eeeae1; --fg-soft: #cbc5b9; --fg-faint: #b7afa0;
    --line: rgba(238, 234, 225, 0.16); --line-strong: rgba(238, 234, 225, 0.42); --shadow: rgba(0, 0, 0, 0.55);
    --accent: #7fb3dc; --accent-soft: #1d2f3f; --accent-ink: #a9cfeb; --on-accent: #0b1a26; --link: #98c2e4; --focus: #98c2e4;
    --w: #6fb0dd; --w-soft: #24455e; --s: #c9976a; --s-soft: #4a3625; --g: #f0a54a; --g-soft: #4e3a1c; --h: #e57a68; --h-soft: #4d2620;
    --both: #4fb3a6; --only: #e69a4a; --new: #f2d95c;
    --t0: #9fb7d6; --t1: #6f9fc4; --t2: #4f8ea3; --t3: #3d7a6a; --t4: #6b7a3c;
    --w-ink: #8fc3ea; --s-ink: #d8ab80; --g-ink: #f5b76a; --h-ink: #ee9585;
    --w-ink: #8fc3ea; --s-ink: #d8ab80; --g-ink: #f5b76a; --h-ink: #ee9585;
  --nodata: #23262c; --map-line: rgba(238, 234, 225, 0.10); --county-line: rgba(238, 234, 225, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a; --bg-raised: #1c1f25; --bg-sunken: #0d0f12;
  --fg: #eeeae1; --fg-soft: #cbc5b9; --fg-faint: #b7afa0;
  --line: rgba(238, 234, 225, 0.16); --line-strong: rgba(238, 234, 225, 0.42); --shadow: rgba(0, 0, 0, 0.55);
  --accent: #7fb3dc; --accent-soft: #1d2f3f; --accent-ink: #a9cfeb; --on-accent: #0b1a26; --link: #98c2e4; --focus: #98c2e4;
  --w: #6fb0dd; --w-soft: #24455e; --s: #c9976a; --s-soft: #4a3625; --g: #f0a54a; --g-soft: #4e3a1c; --h: #e57a68; --h-soft: #4d2620;
  --both: #4fb3a6; --only: #e69a4a; --new: #f2d95c;
  --t0: #9fb7d6; --t1: #6f9fc4; --t2: #4f8ea3; --t3: #3d7a6a; --t4: #6b7a3c;
  --w-ink: #8fc3ea; --s-ink: #d8ab80; --g-ink: #f5b76a; --h-ink: #ee9585;
  --nodata: #23262c; --map-line: rgba(238, 234, 225, 0.10); --county-line: rgba(238, 234, 225, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6; text-rendering: optimizeLegibility; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 3px; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
strong { font-weight: 650; }
.visually-hidden, .sr-live { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }
.wide { width: min(100% - 2.5rem, var(--wide)); margin-inline: auto; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line); font-family: var(--sans); font-size: 0.9rem; }
.brand { color: var(--fg); text-decoration: none; font-weight: 600; }
.topbar-tools { display: flex; align-items: center; gap: 0.75rem; }
.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.lang-switch a { padding: 0.25rem 0.7rem; text-decoration: none; color: var(--fg-soft); }
.lang-switch a[aria-current] { background: var(--fg); color: var(--bg); }
.theme-toggle { border: 1px solid var(--line-strong); background: var(--bg-raised); border-radius: 999px; padding: 0.3rem 0.8rem; cursor: pointer; font-size: 0.85rem; }

.hero { padding: clamp(2rem, 6vw, 4.5rem) 0 1.5rem; }
.kicker { font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-faint); margin: 0 0 0.6rem; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); line-height: 1.05; margin: 0 0 1rem; letter-spacing: -0.01em; font-weight: 600; }
.deck { font-size: clamp(1.15rem, 2.2vw, 1.4rem); line-height: 1.45; color: var(--fg-soft); margin: 0 0 1.25rem; }
.deck strong { color: var(--fg); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); line-height: 1.15; margin: 0 0 0.75rem; font-weight: 600; }
h3 { font-size: 1.15rem; margin: 0 0 0.5rem; font-weight: 650; }
section { padding: clamp(2rem, 5vw, 3.5rem) 0; }
section + section { border-top: 1px solid var(--line); }
.lede { font-size: 1.15rem; color: var(--fg-soft); }
.small { font-size: 0.9rem; color: var(--fg-faint); }
p { margin: 0 0 1rem; }
.maxw { max-width: 70ch; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 1.5rem 0 0; font-family: var(--sans); }
.stat { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: clamp(1.15rem, 2.2vw, 1.9rem); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.stat span { display: block; font-size: 0.86rem; color: var(--fg-soft); margin-top: 0.35rem; line-height: 1.4; }

/* explorer */
.explorer { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .explorer { grid-template-columns: 1fr; } }
.map-panel { position: relative; }
.map-tools { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; margin-bottom: 0.75rem; font-family: var(--sans); font-size: 0.9rem; }
.search { position: relative; flex: 1 1 240px; }
.search input { width: 100%; padding: 0.65rem 0.9rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-raised); color: var(--fg); font: inherit; font-size: 1rem; }
.search input::placeholder { color: var(--fg-faint); }
.search-list { position: absolute; z-index: 5; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 0.25rem; list-style: none; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 10px 30px var(--shadow); max-height: 320px; overflow: auto; }
.search-list li { padding: 0.5rem 0.7rem; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 0.75rem; }
.search-list li[aria-selected="true"], .search-list li:hover { background: var(--accent-soft); }
.search-list .meta { color: var(--fg-faint); font-size: 0.85rem; white-space: nowrap; }
.modes { display: flex; flex-wrap: wrap; gap: 0.35rem; font-family: var(--sans); font-size: 0.86rem; margin-bottom: 0.6rem; }
.modes button { border: 1px solid var(--line-strong); background: var(--bg-raised); border-radius: 999px; padding: 0.32rem 0.75rem; cursor: pointer; color: var(--fg-soft); display: inline-flex; align-items: center; gap: 0.4rem; }
.modes button i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--nodata); }
.modes button[data-mode="w"] i { background: var(--w); } .modes button[data-mode="s"] i { background: var(--s); } .modes button[data-mode="g"] i { background: var(--g); } .modes button[data-mode="h"] i { background: var(--h); }
.modes button[data-mode="wns"] i { background: var(--only); } .modes button[data-mode="tri"] i { background: var(--t1); }
.modes button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.yearrow { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; font-family: var(--sans); font-size: 0.9rem; margin-bottom: 0.6rem; }
.yearrow input[type="range"] { flex: 1 1 200px; accent-color: var(--accent); min-width: 160px; }
.yearrow output { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2ch; font-size: 1.05rem; }
.play { border: 1px solid var(--line-strong); background: var(--bg-raised); border-radius: 999px; padding: 0.35rem 0.85rem; cursor: pointer; }

.map-frame { position: relative; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.map-frame svg { display: block; width: 100%; height: auto; }
.map-frame .status { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--sans); color: var(--fg-soft); background: var(--bg-raised); text-align: center; padding: 1rem; }
.u { fill: var(--nodata); stroke: var(--map-line); stroke-width: 0.25; transition: fill 0.35s ease; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .u { transition: none; } }
.u.on-w { fill: var(--w); } .u.on-s { fill: var(--s); } .u.on-g { fill: var(--g); } .u.on-h { fill: var(--h); }
.u.new { fill: var(--new); }
.u.both { fill: var(--both); } .u.only { fill: var(--only); }
.u.t0 { fill: var(--t0); } .u.t1 { fill: var(--t1); } .u.t2 { fill: var(--t2); } .u.t3 { fill: var(--t3); } .u.t4 { fill: var(--t4); }
.u:hover, .u.hover { stroke: var(--fg); stroke-width: 1.2; }
.u.sel { stroke: var(--fg); stroke-width: 1.8; }
.counties path { fill: none; stroke: var(--county-line); stroke-width: 0.7; pointer-events: none; }
.map-zoom { position: absolute; right: 0.6rem; top: 0.6rem; display: flex; flex-direction: column; gap: 0.3rem; }
.map-zoom button { width: 2.2rem; height: 2.2rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg-raised); cursor: pointer; font-family: var(--sans); font-size: 1.1rem; }
.map-tip { position: absolute; pointer-events: none; z-index: 4; background: var(--fg); color: var(--bg); font-family: var(--sans); font-size: 0.85rem; padding: 0.35rem 0.6rem; border-radius: 7px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.map-year { position: absolute; left: 0.9rem; bottom: 0.6rem; font-family: var(--sans); font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 700; color: var(--fg-faint); letter-spacing: -0.02em; pointer-events: none; }
.map-count { position: absolute; right: 0.9rem; bottom: 0.7rem; font-family: var(--sans); font-size: 0.85rem; color: var(--fg-soft); text-align: right; pointer-events: none; max-width: 55%; background: var(--bg-raised); padding: 0.15rem 0.4rem; border-radius: 6px; }
@media (max-width: 640px) { .map-count { position: static; display: block; max-width: none; text-align: left; padding: 0.4rem 0 0; background: none; } .map-year { font-size: 1.3rem; } }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; margin-top: 0.7rem; font-family: var(--sans); font-size: 0.82rem; color: var(--fg-soft); }
.legend .sw { display: inline-block; width: 22px; height: 12px; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; margin-right: 0.3rem; }
.sw.on-w { background: var(--w); } .sw.on-s { background: var(--s); } .sw.on-g { background: var(--g); } .sw.on-h { background: var(--h); } .sw.new { background: var(--new); }
.sw.both { background: var(--both); } .sw.only { background: var(--only); } .sw.nodata { background: var(--nodata); }
.sw.t0 { background: var(--t0); } .sw.t1 { background: var(--t1); } .sw.t2 { background: var(--t2); } .sw.t3 { background: var(--t3); } .sw.t4 { background: var(--t4); }

/* card */
.card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; position: sticky; top: 0.75rem; }
@media (max-width: 900px) { .card { position: static; } }
.card .kicker { margin-bottom: 0.25rem; }
.card h3 { font-size: 1.5rem; line-height: 1.15; margin: 0; }
.card .where { font-family: var(--sans); font-size: 0.9rem; color: var(--fg-faint); margin: 0.15rem 0 0.9rem; }
.card .claim { font-size: 1.08rem; line-height: 1.45; margin: 0 0 0.9rem; }
.chrono { list-style: none; margin: 0 0 0.9rem; padding: 0; font-family: var(--sans); }
.chrono li { padding: 0.55rem 0; border-top: 1px solid var(--line); }
.chrono .row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; font-size: 0.9rem; }
.chrono .row b { display: inline-flex; align-items: center; gap: 0.4rem; }
.chrono .row b i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chrono .w .row b i { background: var(--w); } .chrono .s .row b i { background: var(--s); } .chrono .g .row b i { background: var(--g); } .chrono .h .row b i { background: var(--h); }
.chrono .row .yr { font-variant-numeric: tabular-nums; color: var(--fg-soft); text-align: right; }
.strip { display: grid; grid-template-columns: repeat(36, 1fr); gap: 1px; margin: 0.35rem 0 0.2rem; }
.strip i { display: block; height: 9px; border-radius: 1px; background: var(--bg-sunken); }
.strip.w i.on { background: var(--w); } .strip.s i.on { background: var(--s); } .strip.g i.on { background: var(--g); } .strip.h i.on { background: var(--h); }
.strip i.cur { outline: 2px solid var(--fg); outline-offset: -1px; }
.strip-axis { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--fg-faint); font-family: var(--sans); }
.chrono .det { font-size: 0.82rem; color: var(--fg-faint); margin: 0.2rem 0 0; }
.spark { width: 100%; height: auto; display: block; margin-top: 0.3rem; }
.spark .ln { fill: none; stroke-width: 2; } .spark .ln.w { stroke: var(--w); } .spark .ln.s { stroke: var(--s); } .spark .ln.g { stroke: var(--g); } .spark .ln.h { stroke: var(--h); }
.spark text { font-family: var(--sans); font-size: 10px; fill: var(--fg-faint); }
.spark .grid { stroke: var(--line); }
.card .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; font-family: var(--sans); font-size: 0.85rem; margin-top: 0.5rem; }
.btn { border: 1px solid var(--line-strong); background: var(--bg-raised); border-radius: 999px; padding: 0.35rem 0.85rem; cursor: pointer; font-family: var(--sans); font-size: 0.88rem; color: var(--fg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.card .empty { color: var(--fg-soft); }
.caveat { font-family: var(--sans); font-size: 0.8rem; color: var(--fg-faint); border-left: 3px solid var(--line-strong); padding-left: 0.6rem; margin: 0.5rem 0 0; line-height: 1.45; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; font: inherit; }

/* charts */
figure.chart { margin: 1.5rem 0; }
figure.chart figcaption { font-family: var(--sans); font-size: 0.85rem; color: var(--fg-faint); margin-top: 0.5rem; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg text { font-family: var(--sans); font-size: 12px; fill: var(--fg-faint); }
.chart-svg .lbl { fill: var(--fg-soft); font-size: 12.5px; font-weight: 600; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .grid.ref { stroke: var(--line-strong); stroke-dasharray: 3 3; }
.chart-svg .mark { stroke: var(--fg); stroke-width: 1.3; stroke-dasharray: 4 3; }
.chart-svg .mark-lbl { fill: var(--fg); font-weight: 600; }
.chart-svg .axis-t { fill: var(--fg-faint); font-size: 11.5px; }
.chart-svg .ln { fill: none; stroke-width: 2.6; stroke-linejoin: round; }
.chart-svg .ln.w { stroke: var(--w); } .chart-svg .lbl.w { fill: var(--w-ink); }
.chart-svg .ln.s { stroke: var(--s); } .chart-svg .lbl.s { fill: var(--s-ink); }
.chart-svg .ln.g { stroke: var(--g); } .chart-svg .lbl.g { fill: var(--g-ink); }
.chart-svg .ln.h { stroke: var(--h); } .chart-svg .lbl.h { fill: var(--h-ink); }
.chart-svg rect.w { fill: var(--w); } .chart-svg rect.s { fill: var(--s); } .chart-svg rect.g { fill: var(--g); }
.chart-svg rect.same { fill: var(--both); } .chart-svg rect.pre { fill: var(--t0); }
.chart-svg .area.both { fill: var(--both); opacity: 0.85; } .chart-svg .area.wns { fill: var(--only); opacity: 0.9; }
.chart-svg .area.h { fill: var(--h); opacity: 0.8; }
.chart-svg .rank .nm, .chart-svg text.nm { fill: var(--fg-soft); font-size: 12px; }
.chart-svg rect.peak { fill: var(--h-soft); } .chart-svg rect.now { fill: var(--h); }
.chart-svg .pct { font-size: 11.5px; fill: var(--fg-soft); }
.chart-svg .legend-g text { font-size: 11.5px; }

figure.photo { margin: 1.75rem 0; }
figure.photo img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }
figure.photo figcaption { font-family: var(--sans); font-size: 0.85rem; color: var(--fg-faint); margin-top: 0.5rem; line-height: 1.45; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.rank { list-style: none; margin: 0; padding: 0; font-family: var(--sans); font-size: 0.92rem; }
.rank li { display: grid; grid-template-columns: 1.6rem 1fr auto; gap: 0.5rem; align-items: baseline; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.rank li .n { color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.rank li .where { display: block; color: var(--fg-faint); font-size: 0.8rem; }
.rank li b { font-variant-numeric: tabular-nums; font-size: 1.02rem; white-space: nowrap; }
.rank li small { color: var(--fg-faint); font-size: 0.78rem; display: block; text-align: right; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.9rem; }
th, td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--fg-faint); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.03em; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.callout { background: var(--bg-raised); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.25rem 0; }
.callout p:last-child { margin-bottom: 0; }
.method p, .method li { font-size: 0.98rem; }
.method ul { padding-left: 1.2rem; }
footer { border-top: 1px solid var(--line); padding: 2rem 0 3rem; font-family: var(--sans); font-size: 0.88rem; color: var(--fg-soft); }
footer p { margin: 0 0 0.5rem; }
.back-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 10; }
@media (min-width: 901px) { .back-top { display: none; } }
