/* holavoda.hu — a Duna és a Tisza vízállása
   A színek szerepek szerint vannak definiálva, hogy a világos/sötét mód
   egyetlen helyen váltson. A vízállás-skála diverging: meleg = szokatlanul
   alacsony, hideg = szokatlanul magas, szürke = a szokásos sávban. */

:root {
  color-scheme: light;

  --surface-0: #f7f6f2;   /* oldal háttere */
  --surface-1: #fcfcfb;   /* panel / grafikon felülete */
  --surface-2: #efeee9;   /* kiemelt sáv, táblázat fejléc */
  --border:    #dedcd4;
  --border-strong: #c5c2b7;

  --text-primary:   #14140f;
  --text-secondary: #52514a;
  --text-muted:     #7d7b71;

  --land:  #f0efe9;       /* Magyarország területe */
  --land-neighbour: #f4f3ee;
  --water: #9ec5f4;       /* folyók, tavak */
  --water-strong: #2a78d6;

  /* diverging skála: 7 fokozat, alacsony -> magas */
  --lvl-1: #8c2020;  /* rekordközeli alacsony */
  --lvl-2: #c0392f;
  --lvl-3: #e08a6a;
  --lvl-4: #b0aea6;  /* szokásos sáv — semleges */
  --lvl-5: #6da7ec;
  --lvl-6: #256abf;
  --lvl-7: #0d366b;  /* rekordközeli magas */

  --grid: #e5e3db;
  --band-outer: #dfe9f6;  /* p05–p95 sokéves sáv */
  --band-inner: #c2d8f1;  /* p25–p75 sokéves sáv */

  --shadow: 0 1px 2px rgba(20,20,15,.06), 0 4px 16px rgba(20,20,15,.05);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface-0: #131312;
    --surface-1: #1c1c1a;
    --surface-2: #262623;
    --border:    #333330;
    --border-strong: #4a4a45;

    --text-primary:   #f4f3ee;
    --text-secondary: #c3c2b7;
    --text-muted:     #8f8e84;

    --land:  #242422;
    --land-neighbour: #1b1b19;
    --water: #2d4c72;
    --water-strong: #5598e7;

    --lvl-1: #f2856b;
    --lvl-2: #d4674d;
    --lvl-3: #a8563f;
    --lvl-4: #55544f;
    --lvl-5: #3e6f9e;
    --lvl-6: #3b8ae0;
    --lvl-7: #8cc0fa;

    --grid: #2e2e2b;
    --band-outer: #223046;
    --band-inner: #2c445f;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- fejléc ---------- */

.site-header { padding: 34px 0 22px; }
.site-header h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -.02em;
  font-weight: 640;
}
.tagline { margin: 8px 0 0; color: var(--text-secondary); max-width: 62ch; }

/* ---------- összefoglaló ---------- */

.summary { margin-bottom: 22px; }
.summary .lede {
  font-size: clamp(17px, 2.4vw, 21px);
  line-height: 1.45;
  margin: 0 0 18px;
  max-width: 72ch;
}
.summary .lede strong { font-weight: 640; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 10px;
}
.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.stat-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin: 0 0 5px;
}
.stat-value {
  font: 600 26px/1.1 var(--mono);
  letter-spacing: -.02em;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 12.5px; color: var(--text-secondary); margin: 5px 0 0; }

/* ---------- panelek ---------- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 22px;
}
.panel-head { margin-bottom: 16px; }
.panel-head h2 {
  margin: 0; font-size: 19px; font-weight: 620; letter-spacing: -.01em;
}
.panel-sub {
  margin: 6px 0 0; color: var(--text-secondary); font-size: 13.5px;
  max-width: 78ch;
}

/* ---------- térkép ---------- */

.map-holder { position: relative; }
#map { width: 100%; height: auto; display: block; touch-action: manipulation; }

.map-land { fill: var(--land); stroke: var(--border-strong); stroke-width: .9; }
.map-neighbour {
  fill: none; stroke: var(--border); stroke-width: .8;
  stroke-dasharray: 3 3;
}
.map-lake { fill: var(--water); opacity: .55; stroke: none; }
.map-river-minor {
  fill: none; stroke: var(--water); stroke-width: 1.1; opacity: .75;
  stroke-linejoin: round; stroke-linecap: round;
}
.map-river-main {
  fill: none; stroke: var(--water); stroke-width: 2.6;
  stroke-linejoin: round; stroke-linecap: round;
}
.map-river-label {
  fill: var(--water-strong); font-size: 11px; font-weight: 620;
  letter-spacing: .06em; text-transform: uppercase;
  paint-order: stroke; stroke: var(--surface-1); stroke-width: 3.5px;
  stroke-linejoin: round; pointer-events: none;
}

.station {
  stroke: var(--surface-1); stroke-width: 1.6;
  cursor: pointer; transition: r .12s ease;
}
.station:hover, .station:focus-visible { stroke: var(--text-primary); stroke-width: 2; }
.station.is-selected { stroke: var(--text-primary); stroke-width: 2.6; }

.station-label {
  fill: var(--text-secondary); font-size: 10.5px; font-weight: 500;
  paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px;
  stroke-linejoin: round; pointer-events: none;
}

/* ---------- jelmagyarázat ---------- */

.legend {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 20px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-secondary);
}
.legend > strong { flex: none; padding-top: 1px; }
/* egyenlő szélességű fokozatok: a felirat így nem tolja szét a skálát */
.legend-scale {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px; flex: 1 1 460px; max-width: 620px;
}
.legend-step { text-align: center; min-width: 0; }
.legend-swatch {
  height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.08);
}
.legend-caption {
  font-size: 10.5px; line-height: 1.25; color: var(--text-muted);
  margin-top: 4px; white-space: pre-line;
}
.legend > .muted { flex: 1 1 100%; font-size: 12px; }

@media (max-width: 720px) {
  .legend-scale { flex-basis: 100%; }
  .legend-caption { font-size: 9.5px; }
}

/* ---------- grafikonok ---------- */

.chart { margin-bottom: 20px; }
.chart:last-child { margin-bottom: 0; }
.chart-title {
  font-size: 14px; font-weight: 600; margin: 0 0 2px;
}
.chart-sub { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 8px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }

.axis text { fill: var(--text-muted); font-size: 11px; }
.axis line, .axis path { stroke: var(--grid); }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.zero-line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 3; }

.band-outer { fill: var(--band-outer); }
.band-inner { fill: var(--band-inner); }
.series-line {
  fill: none; stroke: var(--text-primary); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
.median-line {
  fill: none; stroke: var(--water-strong); stroke-width: 1.6;
  stroke-dasharray: 5 4; opacity: .85;
}
.record-line { stroke: var(--lvl-2); stroke-width: 1.4; stroke-dasharray: 2 3; }
.series-dot { stroke: var(--surface-1); stroke-width: 2; }

.crosshair { stroke: var(--border-strong); stroke-width: 1; pointer-events: none; }

.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px;
  font-size: 12px; color: var(--text-secondary);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 13px; height: 13px; border-radius: 3px; flex: none; }
.key-line { width: 15px; height: 0; border-top-width: 2px; border-top-style: solid; }

/* ---------- tooltip ---------- */

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 11px;
  box-shadow: var(--shadow);
  font-size: 12.5px; line-height: 1.45; min-width: 150px; max-width: 260px;
}
.tooltip .tt-name { font-weight: 620; margin-bottom: 3px; }
.tooltip .tt-row {
  display: flex; justify-content: space-between; gap: 14px;
  font-variant-numeric: tabular-nums;
}
.tooltip .tt-row span:first-child { color: var(--text-secondary); }
.tooltip .tt-row span:last-child { font-family: var(--mono); }
.tooltip .tt-note {
  margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ---------- táblázatok ---------- */

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td {
  text-align: right; padding: 7px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
th:first-child, td:first-child, th.left, td.left { text-align: left; }
thead th {
  position: sticky; top: 0; background: var(--surface-2);
  font-weight: 600; font-size: 12px; color: var(--text-secondary);
  cursor: pointer; user-select: none;
}
thead th[aria-sort="ascending"]::after  { content: " ▲"; font-size: 9px; }
thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-selected { background: var(--surface-2); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #fff;
}
.table-view { margin-top: 16px; }
.table-view summary {
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
  padding: 6px 0;
}

/* ---------- hosszmetszet ---------- */

.profile { margin-bottom: 22px; }
.profile:last-child { margin-bottom: 0; }

/* ---------- lábléc ---------- */

.site-footer {
  border-top: 1px solid var(--border); margin-top: 34px;
  padding: 22px 0 44px; font-size: 13px; color: var(--text-secondary);
}
.site-footer p { margin: 0 0 6px; max-width: 82ch; }
.site-footer a { color: inherit; }
.muted { color: var(--text-muted); }
.loading { color: var(--text-muted); }

@media (max-width: 640px) {
  .panel { padding: 15px; }
  .wrap { padding: 0 14px; }
  .station-label { display: none; }
}
