/* riders.ee — palette and controls follow obelone.com, in blue */

:root,
:root[data-theme="light"] {
  --page: #F7FAFC;
  --surface: #FFFFFF;
  --soft: #F4F8FB;
  --sky: #EEF8FF;
  --active: #DFF1FF;
  --border: #D8E6F0;
  --text: #102033;
  --text-soft: #40576B;
  --muted: #6C8AA0;
  --accent: #337AB7;
  --accent-strong: #286090;
  --accent-light: #7DB8F1;
  --danger: #C0392B;
  --shadow: 0 1px 2px rgba(16, 32, 51, .05);
  --shadow-pop: 0 12px 32px rgba(157, 180, 200, .35);
  --wind-0: #B5D4F4;
  --wind-1: #85B7EB;
  --wind-2: #378ADD;
  --wind-3: #185FA5;
  --offline: #B8C7D3;
  --grid: #EEF3F7;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --page: #0B1622;
  --surface: #122131;
  --soft: #172A3D;
  --sky: #15304A;
  --active: #1B3E60;
  --border: #23394E;
  --text: #E4EEF7;
  --text-soft: #B5C8D8;
  --muted: #86A2B8;
  --accent: #5AA2E0;
  --accent-strong: #8CC2F2;
  --accent-light: #3D7FBF;
  --danger: #F08A7E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45);
  --wind-0: #7FAFDB;
  --wind-1: #4F95D6;
  --wind-2: #2F7BD0;
  --wind-3: #8CC2F2;
  --offline: #4A5F72;
  --grid: #1C2F42;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--text);
  font: 400 15px/1.5 Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ico--sm { width: 14px; height: 14px; }

/* ---------- Header (sticky) ---------- */

.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar__inner {
  max-width: 1320px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 8px;
}

.brand { display: flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand__name span { color: var(--accent); }

.nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.tools { display: flex; align-items: center; gap: 8px; }

/* Pill: nav links and segmented options (obelone header style) */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: transparent; color: var(--text);
  border-radius: 9999px; padding: 6px 10px;
  font: 500 13px/1.4 inherit; font-family: inherit; white-space: nowrap;
  cursor: pointer; list-style: none; transition: background .15s, color .15s;
}
.pill::-webkit-details-marker { display: none; }
.pill:hover { background: var(--soft); }
.pill.is-on, .dd[open] > .pill { background: var(--active); color: var(--accent-strong); }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--soft); border: 1px solid var(--border); border-radius: 9999px;
}
.seg .pill { padding: 5px 11px; }
.seg .pill:hover { background: var(--surface); }
.seg .pill.is-on { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }

/* Soft button: obelone "RU" / secondary actions */
.btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9999px;
  background: var(--soft); border: 1px solid var(--border); color: var(--text);
  font: 700 13px/1 inherit; font-family: inherit; cursor: pointer; list-style: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-soft::-webkit-details-marker { display: none; }
.btn-soft:hover { background: var(--active); border-color: var(--accent-light); text-decoration: none; }

/* Theme switch: system / light / dark with a sliding thumb (obelone header style) */
.theme {
  position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 2px;
  background: var(--soft); border: 1px solid var(--border); border-radius: 9999px;
}
.theme__thumb {
  position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 9999px;
  background: var(--surface); box-shadow: var(--shadow), 0 0 0 1px var(--border);
  transform: translateX(calc(var(--i, 0) * 30px));
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), background-color .3s;
}
.theme button {
  position: relative; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 9999px;
  display: grid; place-items: center; background: none; color: var(--muted); cursor: pointer;
  transition: color .15s;
}
.theme button:hover, .theme button[aria-checked="true"] { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .theme__thumb { transition: none; } }
.theme__thumb { view-transition-name: theme-thumb; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; animation-timing-function: ease; }
::view-transition-group(theme-thumb) { animation-duration: .3s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }

.link-btn {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 4px; border-radius: 8px;
}
.link-btn:hover { color: var(--accent); }
.link-btn.is-busy .ico { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Dropdowns built on <details> */
.dd { position: relative; }
.dd__panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 10;
  min-width: 240px; max-width: min(360px, 90vw); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-pop); padding: 6px;
}
.dd--right .dd__panel { left: auto; right: 0; min-width: 170px; }
.dd__panel a, .dd__panel button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: 10px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.dd__panel a:hover, .dd__panel button:hover { background: var(--sky); text-decoration: none; }
.dd__panel .is-on { background: var(--active); color: var(--accent-strong); font-weight: 500; }
.dd__panel .ico { color: var(--muted); }
.dd__empty { padding: 8px 10px; font-size: 13px; color: var(--muted); }

/* ---------- Layout ---------- */

.page { max-width: 1320px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow);
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }

.map-card { position: relative; overflow: hidden; isolation: isolate; }
.map { height: clamp(420px, calc(100vh - 140px), 760px); background: var(--sky); }

.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); border-radius: 9999px;
  font-size: 11px; color: var(--muted);
}
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

.list-card { display: flex; flex-direction: column; max-height: clamp(420px, calc(100vh - 140px), 760px); overflow: hidden; }
.list-card__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}
.list-card__head .link-btn { text-transform: none; letter-spacing: 0; }
.list { overflow: auto; }
.row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: 0; border-bottom: 1px solid var(--border); background: none;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.row:hover { background: var(--sky); }
.row.is-on { background: var(--active); }
.row__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__val { font-weight: 500; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.row__val small { color: var(--muted); font-weight: 400; }
.row.is-off .row__val { color: var(--muted); font-weight: 400; font-size: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.banner {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger); font-size: 14px;
}

/* ---------- Station card ---------- */

.station { margin-top: 16px; padding: 16px 18px; scroll-margin-top: 80px; }
.station__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.station__icon {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: var(--active); color: var(--accent-strong);
}
.station__icon .ico { width: 22px; height: 22px; fill: currentColor; stroke: none; transition: transform .3s; }
.station__title { flex: 1; min-width: 160px; }
.station__title h1 { margin: 0; font-size: 19px; font-weight: 500; }
.station__title p { margin: 0; font-size: 13px; color: var(--muted); }
.station__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 14px 0; }
.metric { background: var(--soft); border-radius: 14px; padding: 9px 12px; }
button.metric { border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background .15s, box-shadow .15s; }
button.metric:hover { background: var(--active); }
button.metric.is-on { background: var(--active); box-shadow: inset 0 0 0 2px var(--accent); }
button.metric:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.metric__label, .metric__value { display: block; }
.metric__label { font-size: 12px; color: var(--muted); }
.metric__value { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.metric__value small { font-size: 12px; font-weight: 400; color: var(--muted); }

.chart { position: relative; height: 240px; }

.footer { padding: 18px 4px 6px; font-size: 12px; color: var(--muted); }

/* ---------- Map markers ---------- */

.leaflet-container { font: inherit; background: var(--sky); cursor: default; }
.leaflet-tile-pane { filter: saturate(.55) brightness(1.04); }
[data-theme="dark"] .leaflet-tile-pane { filter: grayscale(1) invert(1) sepia(.35) hue-rotate(170deg) saturate(1.6) brightness(.82) contrast(.9); }
.leaflet-control-attribution { font-size: 10px; }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(18, 33, 49, .8); color: var(--muted); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--accent-strong); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--soft); }
.leaflet-touch .leaflet-bar { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

.mk { position: relative; width: 0; height: 0; cursor: pointer; }
.mk__dot {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid var(--surface); opacity: .92;
}
.mk__arrow { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.mk__arrow svg { position: absolute; left: -7px; width: 14px; height: 12px; }
.mk__label {
  position: absolute; top: 0; transform: translateY(-50%);
  padding: 1px 7px; border-radius: 9999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11px; line-height: 16px; color: var(--text-soft); font-variant-numeric: tabular-nums;
}
.mk--strong .mk__label { color: var(--accent-strong); font-weight: 700; }
.mk--off .mk__label { color: var(--muted); }
.mk.is-on .mk__dot { border-color: var(--text); }
.mk.is-on .mk__label { border-color: var(--accent); }
.leaflet-marker-icon.is-on { z-index: 900 !important; }

/* Forecast spots: diamond pin, no live data */
.spot { position: relative; width: 0; height: 0; cursor: pointer; }
.spot__pin, .row__pin {
  width: 11px; height: 11px; flex: none;
  background: var(--surface); border: 2px solid var(--accent);
  transform: rotate(45deg); border-radius: 2px;
}
.spot__pin { position: absolute; left: -6px; top: -6px; }
/* Spots sit close together (Limassol); the name shows on hover and in the popup. */
.spot__label { left: 11px; color: var(--accent-strong); display: none; }
.spot:hover .spot__label { display: block; }
.leaflet-marker-icon:hover { z-index: 950 !important; }

.list__section {
  padding: 10px 14px 6px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}
.row--spot .row__val small { color: var(--accent); }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
.leaflet-popup-content-wrapper { border-radius: 14px; border: 1px solid var(--border); }
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; }
.spot-pop { display: flex; flex-direction: column; gap: 4px; }
.spot-pop a { font-weight: 500; }

/* ---------- Mobile ---------- */

@media (max-width: 980px) {
  .topbar__inner { flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .tools { margin-left: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  /* Static map: match the wide shape of Estonia and Cyprus instead of a tall box. */
  .map { height: auto; aspect-ratio: 4 / 3; min-height: 280px; }
  .list-card { max-height: 360px; }
  .dd__panel { position: fixed; top: auto; left: 16px; right: 16px; max-width: none; }
}

@media (max-width: 560px) {
  .page { padding: 10px; }
  .topbar__inner { padding: 8px 10px; gap: 6px; }
  .brand { margin-right: 0; }
  .brand__name { display: none; }
  .tools { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .seg .pill { padding: 5px 7px; font-size: 12px; }
  .btn-soft { padding: 0 10px; }
  .nav .pill { padding: 6px 8px; }
  .station { padding: 14px; }
  .station__actions { width: 100%; }
}
