/* Unde se termină asfaltul — semantic tokens, dual theme.
   Palette taken from the subject: asphalt, bitumen, crushed stone, earth. */

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-raised: #fbf9f4;
  --bg-sunken: #e6e0d4;
  --fg: #17161a;
  --fg-soft: #3b3934;
  --fg-faint: #4a4740;
  --line: rgba(23, 22, 26, 0.16);
  --line-strong: rgba(23, 22, 26, 0.42);
  --shadow: rgba(23, 22, 26, 0.12);
  --accent: #8a4a17;
  --link: #7c4213;
  --focus: #8a4a17;

  /* the four surface classes, hard to soft */
  --s-mod: #2b3036;
  --s-light: #6a7480;
  --s-gravel: #b3a184;
  --s-earth: #9a5f2a;

  /* choropleth: share of the local network without a surfacing, 6 steps */
  --c0: #eee7d8;
  --c1: #ddc9a6;
  --c2: #c9a877;
  --c3: #b3854e;
  --c4: #94612f;
  --c5: #6f4118;
  --nodata: #ded8cb;
  --map-line: rgba(23, 22, 26, 0.35);

  --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: 68ch;
  --wide: 1180px;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15161a;
    --bg-raised: #1e2026;
    --bg-sunken: #0e0f12;
    --fg: #efebe2;
    --fg-soft: #cdc7bb;
    --fg-faint: #bab3a5;
    --line: rgba(239, 235, 226, 0.17);
    --line-strong: rgba(239, 235, 226, 0.44);
    --shadow: rgba(0, 0, 0, 0.55);
    --accent: #e0a06a;
    --link: #e6ad7c;
    --focus: #e6ad7c;
    --s-mod: #aab5c0;
    --s-light: #79838f;
    --s-gravel: #c6b590;
    --s-earth: #d08a45;
    --c0: #2a2b2e;
    --c1: #4a412f;
    --c2: #6c5a38;
    --c3: #8f7440;
    --c4: #b58f4d;
    --c5: #dcae63;
    --nodata: #24262a;
    --map-line: rgba(239, 235, 226, 0.32);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15161a;
  --bg-raised: #1e2026;
  --bg-sunken: #0e0f12;
  --fg: #efebe2;
  --fg-soft: #cdc7bb;
  --fg-faint: #bab3a5;
  --line: rgba(239, 235, 226, 0.17);
  --line-strong: rgba(239, 235, 226, 0.44);
  --shadow: rgba(0, 0, 0, 0.55);
  --accent: #e0a06a;
  --link: #e6ad7c;
  --focus: #e6ad7c;
  --s-mod: #aab5c0;
  --s-light: #79838f;
  --s-gravel: #c6b590;
  --s-earth: #d08a45;
  --c0: #2a2b2e;
  --c1: #4a412f;
  --c2: #6c5a38;
  --c3: #8f7440;
  --c4: #b58f4d;
  --c5: #dcae63;
  --nodata: #24262a;
  --map-line: rgba(239, 235, 226, 0.32);
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.62;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: var(--container); margin: 0 auto; padding: 0 1.15rem; }
.wide { max-width: var(--wide); margin: 0 auto; padding: 0 1.15rem; }

a { color: var(--link); text-underline-offset: 0.16em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.18; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.5rem); margin: 0 0 0.6rem; }
h2 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); margin: 0 0 0.7rem; }
h3 { font-size: 1.2rem; margin: 1.6rem 0 0.4rem; }

p { margin: 0 0 1.05rem; }

.kicker {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 0.5rem;
}

.small { font-size: 0.86rem; color: var(--fg-faint); line-height: 1.55; }

/* ---------------------------------------------------------------- header */

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.6rem 1rem; max-width: var(--wide); margin: 0 auto; padding: 0.85rem 1.15rem;
}
.brand {
  font-family: var(--serif); font-size: 1.02rem; text-decoration: none;
  color: var(--fg-soft); white-space: nowrap;
}
.brand:hover { color: var(--fg); text-decoration: underline; }
.topbar-tools { display: flex; align-items: center; gap: 0.6rem; }

.lang-switch { display: flex; gap: 0.15rem; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch a {
  padding: 0.28rem 0.7rem; font-size: 0.8rem; letter-spacing: 0.06em;
  text-decoration: none; color: var(--fg-soft);
}
.lang-switch a[aria-current="page"] { background: var(--fg); color: var(--bg); }

.theme-toggle, .btn {
  font: inherit; font-size: 0.83rem; padding: 0.34rem 0.8rem; white-space: nowrap;
  background: var(--bg-raised); color: var(--fg-soft);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.theme-toggle:hover, .btn:hover { border-color: var(--line-strong); color: var(--fg); }

.hero { padding: 1.6rem 0 2.2rem; border-bottom: 1px solid var(--line); }
.deck { font-size: clamp(1.04rem, 2.1vw, 1.18rem); color: var(--fg-soft); }
.deck strong { color: var(--fg); }

.stat-row {
  display: grid; grid-template-columns: 1fr;
  gap: 0.85rem; margin-top: 1.5rem;
}
@media (min-width: 560px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem 0.9rem;
}
.stat b { display: block; font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; }
.stat span { display: block; font-size: 0.82rem; color: var(--fg-faint); margin-top: 0.3rem; }

/* ---------------------------------------------------------------- sections */

section { padding: 2.6rem 0; border-bottom: 1px solid var(--line); }
section.method { background: var(--bg-sunken); }
.lede { font-size: 1.06rem; color: var(--fg-soft); }

/* ------------------------------------------------------------ surface band */

.band-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem;
  margin: 1.2rem 0 0.9rem;
}
.year-control { display: flex; align-items: center; gap: 0.7rem; flex: 1 1 260px; }
.year-control label { font-size: 0.85rem; color: var(--fg-faint); white-space: nowrap; }
.year-control input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 140px; }
.year-now { font-family: var(--serif); font-size: 1.5rem; min-width: 3.4ch; }

.band { display: flex; width: 100%; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); }
/* An empty band or key means the series has not been drawn; collapse rather
   than leave a hollow box above the figures that carry the same numbers. */
.band:empty, .band-key:empty { display: none; }

.band-key { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin-top: 0.7rem; }
.band-key div { display: flex; align-items: baseline; gap: 0.4rem; font-size: 0.84rem; color: var(--fg-soft); }
.band-key i { width: 0.85rem; height: 0.85rem; border-radius: 3px; display: inline-block; border: 1px solid var(--line-strong); }
.band-key b { font-variant-numeric: tabular-nums; color: var(--fg); }

.two-bands { display: grid; gap: 1.3rem; margin-top: 1.4rem; }
@media (min-width: 780px) { .two-bands { grid-template-columns: 1fr 1fr; } }
.two-bands h3 { margin-top: 0; }
.two-bands .band { height: 54px; }

/* ---------------------------------------------------------------- classes */

.classes { display: grid; gap: 0.9rem; margin-top: 1.4rem; }
@media (min-width: 700px) { .classes { grid-template-columns: repeat(2, 1fr); } }
.class-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised); padding: 0.95rem 1rem;
  border-left: 6px solid var(--edge, var(--line-strong));
}
.class-card h3 { margin: 0 0 0.3rem; font-size: 1.06rem; }
.class-card p { margin: 0; font-size: 0.92rem; color: var(--fg-soft); }
.class-card .km { font-family: var(--serif); font-size: 1.25rem; color: var(--fg); display: block; margin-bottom: 0.25rem; }

/* ---------------------------------------------------------------- explorer */

.explorer { display: grid; gap: 1.2rem; margin-top: 1.2rem; }
@media (min-width: 900px) { .explorer { grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr); align-items: start; } }

.map-frame {
  position: relative; background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem;
}
.map-frame svg { display: block; width: 100%; height: auto; }
.map-frame path { stroke: var(--map-line); stroke-width: 0.6; cursor: pointer; }
.map-frame path:hover { stroke: var(--fg); stroke-width: 1.6; }
.map-frame path[aria-current="true"] { stroke: var(--fg); stroke-width: 2.2; }
.map-frame .status { padding: 2rem 1rem; text-align: center; color: var(--fg-faint); }

.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; margin-top: 0.6rem; font-size: 0.8rem; color: var(--fg-faint); }
.legend div { display: flex; align-items: center; gap: 0.35rem; }
.legend i { width: 1.1rem; height: 0.7rem; border-radius: 2px; display: inline-block; border: 1px solid var(--line); }

.card {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.05rem;
}
.card h3 { margin: 0 0 0.15rem; font-size: 1.3rem; }
.card .where { font-size: 0.84rem; color: var(--fg-faint); }
.card .big { font-family: var(--serif); font-size: 2.1rem; line-height: 1.1; margin: 0.7rem 0 0.1rem; }
.card .big-note { font-size: 0.84rem; color: var(--fg-faint); margin-bottom: 0.8rem; }
.card .band { height: 40px; }
.card table { width: 100%; border-collapse: collapse; margin-top: 0.8rem; font-size: 0.87rem; }
.card th, .card td { text-align: left; padding: 0.28rem 0; border-bottom: 1px solid var(--line); }
.card td:last-child, .card th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.card .spark { margin-top: 0.9rem; }
.card .spark svg { display: block; width: 100%; height: auto; }

/* ---------------------------------------------------------------- lists */

.rank { list-style: none; margin: 1.1rem 0 0; padding: 0; }
.rank li {
  display: grid; grid-template-columns: 1.9rem 1fr auto; gap: 0.6rem;
  align-items: baseline; padding: 0.42rem 0; border-bottom: 1px solid var(--line);
}
.rank .n { font-family: var(--serif); color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.rank button {
  font: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--link); text-align: left; text-decoration: underline; text-underline-offset: 0.16em;
}
.rank .where { display: block; font-size: 0.8rem; color: var(--fg-faint); text-decoration: none; }
.rank b { font-variant-numeric: tabular-nums; }
.rank .sub { display: block; font-size: 0.78rem; color: var(--fg-faint); font-weight: 400; }

/* ---------------------------------------------------------------- towns */

.town-tools { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.1rem 0 0.4rem; align-items: center; }
.town-tools input[type="search"] {
  font: inherit; font-size: 0.92rem; padding: 0.42rem 0.7rem; flex: 1 1 220px;
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 0.83rem; padding: 0.35rem 0.8rem; cursor: pointer;
  background: var(--bg-raised); color: var(--fg-soft); border: 0;
}
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.town-list { max-height: 30rem; overflow-y: auto; margin-top: 0.5rem; border-top: 1px solid var(--line); }
.town-row {
  display: grid; grid-template-columns: 1fr 5.2rem 4.6rem; gap: 0.5rem;
  align-items: center; padding: 0.4rem 0.1rem; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.town-row .nm b { font-weight: 600; }
.town-row .nm span { display: block; font-size: 0.78rem; color: var(--fg-faint); }
.town-row .barwrap { background: var(--bg-sunken); border-radius: 3px; height: 0.62rem; overflow: hidden; }
.town-row .barwrap i { display: block; height: 100%; background: var(--s-mod); }
.town-row .pc { text-align: right; font-variant-numeric: tabular-nums; }
.town-empty { padding: 1rem 0; color: var(--fg-faint); }

/* ---------------------------------------------------------------- figure */

figure { margin: 1.6rem 0; }
figure img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
figcaption { font-size: 0.84rem; color: var(--fg-faint); margin-top: 0.5rem; line-height: 1.5; }

.callout {
  border-left: 4px solid var(--accent); background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 0.9rem 1.05rem;
}
.callout p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- footer */

footer { padding: 2rem 0 3.4rem; color: var(--fg-faint); font-size: 0.87rem; }
footer p { margin: 0 0 0.4rem; }

.back-top {
  position: fixed; right: 1rem; bottom: 1rem; text-decoration: none;
  box-shadow: 0 2px 10px var(--shadow); background: var(--bg-raised);
  transition: opacity 180ms ease;
}
.back-top[data-near-top="true"] { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .back-top { transition: none; } }

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