/* vodostaj.org: a full-screen map with a floating top bar and a panel:
   on the left on computers, a bottom sheet on phones (as parkiraj.click). */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 20px; height: 20px; flex: none; }
a { color: var(--brand); }

/* ── map ───────────────────────────────────────────────────── */

.map { position: fixed; inset: 0; z-index: 0; background: var(--surface-2); }
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-tile-pane { filter: saturate(0.3) contrast(0.88) brightness(1.04); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(0.85) contrast(0.82) saturate(0.35); }
}
.leaflet-control-attribution { background: var(--glass) !important; color: var(--ink-3); font-size: 11px; border-radius: 8px 0 0 0; }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-bar.leaflet-control, .map-btn { border: 1px solid var(--line) !important; border-radius: 14px; box-shadow: var(--shadow-float); overflow: hidden; }
.leaflet-bar a, .leaflet-bar a:hover, .leaflet-touch .leaflet-bar a {
  width: 42px; height: 42px; line-height: 40px; background: var(--surface); color: var(--ink); border-bottom-color: var(--line); font-size: 20px;
}
.map-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; background: var(--surface); color: var(--brand); }

.legend {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; box-shadow: var(--shadow-1);
  font-size: 12px; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { width: 16px; height: 5px; border-radius: 3px; background: var(--fill); }

/* station markers */
.mdot { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--fill); border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.22); }
.mdot.t-grey { background: var(--surface); border-color: var(--t-grey); }
.pin { position: relative; display: block; width: 28px; height: 36px; filter: drop-shadow(0 3px 3px rgb(0 0 0 / 0.3)); }
.pin svg { width: 28px; height: 36px; display: block; }
.pin svg .body { fill: var(--fill); stroke: #fff; stroke-width: 2; }
.pin svg .wave { fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; }
.pin.t-yellow svg .wave { stroke: #2b2300; }
.plabel {
  position: absolute; left: 25px; top: 3px; white-space: nowrap;
  background: var(--surface); color: var(--ink); border: 2px solid var(--fill);
  border-radius: 999px; padding: 1px 8px; font-weight: 700; font-size: 12px; line-height: 1.5;
  box-shadow: var(--shadow-1);
}
.me-dot { display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(11 114 133 / 0.18); }

/* map popups */
.station-popup .leaflet-popup-content-wrapper { background: var(--surface); color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-float); padding: 0; overflow: hidden; }
.station-popup .leaflet-popup-tip { background: var(--surface); }
.station-popup .leaflet-popup-content { margin: 0; width: 250px !important; }
.station-popup a.leaflet-popup-close-button { color: var(--ink-3); top: 8px; right: 8px; }
.pp { border-top: 5px solid var(--fill); padding: 12px 14px 14px; }
.pp-title { font-size: 17px; font-weight: 750; padding-right: 16px; line-height: 1.2; }
.pp-sub { color: var(--ink-2); font-size: 12px; margin: 2px 0 8px; }
.pp-value { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pp-value .big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.pp-line { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.pp svg { width: 100%; height: 46px; display: block; margin: 8px 0 2px; }
.pp .btn { width: 100%; margin-top: 10px; }

/* ── top bar ───────────────────────────────────────────────── */

.topbar {
  position: fixed; z-index: 30;
  top: calc(var(--safe-top) + var(--gap)); left: var(--gap);
  width: var(--panel-w); height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 10px;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-float);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; min-width: 0; }
.mark { width: 30px; height: 30px; flex: none; }
.wordmark { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; font-stretch: 92%; }
.wordmark b { color: var(--brand); font-weight: 800; }
.updated { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.updated::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--t-blue); }
.updated.is-old::before { background: var(--t-yellow); }
.pill { height: 34px; padding: 0 11px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 13px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2) center / cover no-repeat;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--brand); padding: 0;
}
.avatar.signed { background-color: var(--brand); color: var(--brand-ink); border-color: transparent; }

/* ── the panel: left column (desktop), bottom sheet (phone) ── */

.sheet {
  position: fixed; z-index: 20;
  top: calc(var(--safe-top) + var(--gap) * 2 + var(--topbar-h)); left: var(--gap); bottom: var(--gap);
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-float);
  overflow: hidden;
}
.sheet-grab { display: none; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 18px; scrollbar-width: thin; }

.search { position: relative; display: flex; align-items: center; gap: 8px; margin: 12px 14px 8px; padding: 0 6px 0 12px; height: 46px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font-size: 15px; height: 100%; }
.search input::placeholder { color: var(--ink-3); }
.locate { width: 36px; height: 36px; border-radius: 11px; border: 0; background: var(--surface); color: var(--brand); display: grid; place-items: center; box-shadow: var(--shadow-1); }
.locate.on { background: var(--brand); color: var(--brand-ink); }
.locate.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.results {
  position: absolute; z-index: 5; left: -1px; right: -1px; top: 50px; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-float); max-height: 60vh; overflow-y: auto;
}
.results li button { width: 100%; display: flex; align-items: baseline; gap: 8px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 10px; color: var(--ink); }
.results li button:hover, .results li button:focus-visible { background: var(--surface-2); }
.results .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); padding: 6px 10px 2px; }
.results small { margin-left: auto; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.results .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--fill); flex: none; align-self: center; }

/* phones: the panel is a sheet the map shows above */
@media (max-width: 760px) {
  .topbar { left: var(--gap); right: var(--gap); width: auto; }
  .updated { display: none; }
  .brand { margin-right: auto; }
  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: var(--sheet-h, 52vh); max-height: calc(100vh - var(--topbar-h) - var(--safe-top) - 24px);
    border-radius: 24px 24px 0 0; border-bottom: 0;
    box-shadow: 0 -12px 32px -14px rgb(0 0 0 / 0.35);
    transition: height 0.4s var(--ease);
  }
  body.dragging .sheet { transition: none; }
  .sheet-grab { display: block; flex: none; height: 22px; cursor: grab; touch-action: none; position: relative; }
  .sheet-handle { position: absolute; left: 50%; top: 9px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--surface-3); }
  .search { margin-top: 2px; }
  .leaflet-bottom.leaflet-right { bottom: calc(var(--sheet-h, 52vh) - 6px); transition: bottom 0.4s var(--ease); }
  /* the status card explains the colours; fingers zoom */
  .legend, .leaflet-control-zoom { display: none; }
}

/* ── panel content ─────────────────────────────────────────── */

.h-eyebrow { font-size: 11px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 18px 2px 8px; display: flex; align-items: center; gap: 8px; }
.h-eyebrow a, .h-eyebrow button { margin-left: auto; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 650; color: var(--brand); background: none; border: 0; padding: 0; text-decoration: none; }
.h1 { font-size: 26px; line-height: 1.1; font-weight: 800; letter-spacing: -0.025em; margin: 6px 0 2px; }
.sub { color: var(--ink-2); font-size: 14px; }
.note { font-size: 13px; color: var(--ink-2); margin: 8px 0; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--brand); padding: 6px 0; font-weight: 700; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 14px; border: 0;
  background: var(--brand); color: var(--brand-ink); font-weight: 750; font-size: 15px; text-decoration: none;
}
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 11px; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--fill); color: #fff; white-space: nowrap; }
.t-yellow .badge, .badge.t-yellow { color: #2b2300; }
.t-grey .badge, .badge.t-grey { background: var(--surface-3); color: var(--ink-2); }

/* state colours, by class: --fill for shapes, --text for text, --soft for tints */
.t-blue { --fill: var(--t-blue); --text: var(--t-blue-ink); --soft: var(--t-blue-soft); }
.t-yellow { --fill: var(--t-yellow); --text: var(--t-yellow-ink); --soft: var(--t-yellow-soft); }
.t-red { --fill: var(--t-red); --text: var(--t-red-ink); --soft: var(--t-red-soft); }
.t-grey { --fill: var(--t-grey); --text: var(--t-grey-ink); --soft: var(--t-grey-soft); }
.up { color: var(--t-red-ink); }
.down { color: var(--t-blue-ink); }

/* the status card on top of the home view */
.hero { margin-top: 6px; padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); border-left: 5px solid var(--fill); }
.hero .eyebrow { font-size: 11px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-top: 6px; }
.hero .big small { font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.hero .what { font-weight: 700; margin-top: 4px; }
.bar { display: flex; gap: 3px; height: 8px; margin: 12px 0 6px; }
.bar i { border-radius: 4px; background: var(--fill); min-width: 4px; }
.counts { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.counts span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fill); margin-right: 5px; }
.hero .btn { margin-top: 12px; width: 100%; }

/* raised stations, compact */
.alerts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface); }
.alerts li + li { border-top: 1px solid var(--line); }
.alerts button { width: 100%; display: grid; grid-template-columns: 4px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px 10px 0; border: 0; background: none; text-align: left; color: var(--ink); }
.alerts button::before { content: ""; align-self: stretch; background: var(--fill); border-radius: 0 3px 3px 0; }
.alerts b { display: block; font-size: 14px; }
.alerts small { display: block; color: var(--ink-2); font-size: 12px; }
.alerts .v { text-align: right; font-weight: 750; font-size: 14px; }
.alerts .v small { color: var(--text); font-weight: 650; }

/* river cards */
.rivers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rcard {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 148px;
  padding: 14px 12px 10px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-1); text-align: left; color: var(--ink); overflow: hidden;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.rcard::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--fill); }
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }
.rcard .name { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.rcard .into { font-size: 12px; color: var(--ink-3); }
.rcard .state { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 4px; }
.rcard .meta { font-size: 12px; color: var(--ink-2); margin-top: auto; }
.rcard svg { width: 100%; height: 30px; display: block; margin-top: 6px; }
.rcard.dim { opacity: 0.72; }

/* river view */
.river-head { border-left: 5px solid var(--fill); padding-left: 12px; margin-top: 4px; }
.report { margin: 12px 0; padding: 14px; border-radius: 18px; background: var(--soft); border: 1px solid var(--line); font-size: 14px; }
.report p { margin: 6px 0; }
.report a { color: var(--text); font-weight: 700; }
.report .btn { width: 100%; margin-top: 8px; }
.group { margin-top: 14px; }
.group summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 8px 2px; font-weight: 750; font-size: 16px; border-bottom: 2px solid var(--line); }
.group summary::-webkit-details-marker { display: none; }
.group summary::after { content: "▾"; margin-left: 4px; color: var(--ink-3); font-size: 12px; transition: transform 0.2s; }
.group:not([open]) summary::after { transform: rotate(-90deg); }
.group summary .into { font-weight: 500; font-size: 12px; color: var(--ink-3); }
.group summary .cnt { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.group summary .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--fill); }

/* station rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 10px 1fr auto 60px; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--surface-2); }
.row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fill); }
.row .dot.t-grey { background: transparent; border: 2px solid var(--t-grey); }
.row b { display: block; font-size: 14px; }
.row small { display: block; font-size: 12px; color: var(--ink-2); }
.row .rel { color: var(--text); font-weight: 650; }
.row .v { text-align: right; font-weight: 750; font-size: 14px; }
.row .v small { font-weight: 500; }
.row svg { width: 60px; height: 24px; }

/* station view */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 8px; }
.fact { background: var(--surface-2); border-radius: 16px; padding: 10px 12px; }
.fact .label { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.fact .big { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.fact .big small { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.chart { width: 100%; height: 200px; display: block; margin: 8px 0 4px; }
.chart text { fill: var(--ink-3); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.2; }
.chart .area { fill: var(--brand-soft); }
.chart .thr { stroke-dasharray: 5 4; stroke-width: 1.6; }
.thresholds { list-style: none; padding: 0; margin: 8px 0; }
.thresholds li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.thresholds .num { margin-left: auto; font-weight: 700; }
.table-wrap { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; }
.readings { width: 100%; border-collapse: collapse; font-size: 13px; }
.readings th { position: sticky; top: 0; background: var(--surface-2); text-align: right; font-weight: 700; color: var(--ink-2); padding: 7px 9px; }
.readings th:first-child, .readings td:first-child { text-align: left; }
.readings td { text-align: right; padding: 5px 9px; border-top: 1px solid var(--line); }

.card { margin-top: 14px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.card h2 { font-size: 16px; margin: 0 0 6px; }
.card label { display: block; font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; }
.card select, .card input:not([type="checkbox"]) { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.card .btn { margin-top: 12px; width: 100%; }
.card.dev { border-style: dashed; }
.card.dev .btn { width: auto; margin-right: 6px; }
.signin { display: grid; gap: 10px; justify-items: start; }
.who { display: flex; align-items: center; gap: 12px; }
.who .avatar { width: 44px; height: 44px; font-size: 16px; }
.danger { color: var(--t-red-ink); background: none; border: 0; padding: 0; font-weight: 650; text-decoration: underline; }
.credit, .sources { font-size: 12px; color: var(--ink-3); margin-top: 16px; line-height: 1.6; }
.credit a, .sources a { color: inherit; }
.empty { text-align: center; color: var(--ink-2); padding: 30px 10px; }
