/* RailSpotting shared tokens and base styles (public site and admin portal). */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #ebe8e2;
  --ink: #1d1f22;
  --ink-2: #4d525a;
  --ink-3: #737982;
  --line: #d8d4cc;
  --accent: #0d5c63;
  --accent-ink: #ffffff;
  --focus: #e0a100;
  --nearby: #c8102e;
  --activity: #d98a00;
  --quiet: #2f8f4e;
  --offline: #8a9099;
  --unmonitored: #b4b8be;
  --danger: #b3261e;
  --ok: #2f8f4e;
  --warn: #a86a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 6px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121416;
    --surface: #1b1e21;
    --surface-2: #24282c;
    --ink: #e9e7e3;
    --ink-2: #b4b2ad;
    --ink-3: #8c8a86;
    --line: #33383d;
    --accent: #4fb3bb;
    --accent-ink: #0b1416;
    --nearby: #ff4d5e;
    --activity: #ffb627;
    --quiet: #4cc274;
    --offline: #8a9099;
    --unmonitored: #5d636a;
    --danger: #ff6b61;
    --ok: #4cc274;
    --warn: #ffb627;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121416;
  --surface: #1b1e21;
  --surface-2: #24282c;
  --ink: #e9e7e3;
  --ink-2: #b4b2ad;
  --ink-3: #8c8a86;
  --line: #33383d;
  --accent: #4fb3bb;
  --accent-ink: #0b1416;
  --nearby: #ff4d5e;
  --activity: #ffb627;
  --quiet: #4cc274;
  --offline: #8a9099;
  --unmonitored: #5d636a;
  --danger: #ff6b61;
  --ok: #4cc274;
  --warn: #ffb627;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; letter-spacing: 0.01em; }
h3 { font-size: 0.95rem; }

.num, time, .mono { font-variant-numeric: tabular-nums; }
.mono, code { font-family: var(--mono); font-size: 0.92em; }

.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* Header bar: a dark strip like a station sign, in both themes. */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 52px;
  background: #16191c;
  color: #f1efe9;
  border-bottom: 4px solid var(--focus);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.95rem;
}
.brand img { width: 26px; height: 26px; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topnav a {
  color: #c9c6bf;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9rem;
}
.topnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.topnav a[aria-current="page"] { color: #16191c; background: var(--focus); }
.topbar .tools { display: flex; gap: 8px; align-items: center; }

/* Buttons and inputs */
button, .button {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--ink-3); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger, .button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.topbar button { background: transparent; color: #f1efe9; border-color: #4a4f55; }
.topbar button:hover { border-color: #c9c6bf; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  max-width: 100%;
}
textarea { min-height: 70px; width: 100%; }
label { font-weight: 600; font-size: 0.88rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: 1px;
}
.badge.ok { color: var(--ok); border-color: var(--ok); background: transparent; }
.badge.bad { color: var(--danger); border-color: var(--danger); background: transparent; }
.badge.warn { color: var(--warn); border-color: var(--warn); background: transparent; }
.badge.train { color: var(--nearby); border-color: var(--nearby); background: transparent; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: 0;
  margin-right: 6px;
  flex: none;
}
.dot.online { background: var(--ok); }
.dot.offline { background: transparent; border: 2px solid var(--offline); }
.dot.nearby { background: var(--nearby); }
.dot.recent { background: var(--nearby); }
@media (prefers-reduced-motion: no-preference) {
  .dot.nearby { animation: rs-blink 1.2s steps(2, jump-none) infinite; }
  @keyframes rs-blink { 0% { opacity: 1; } 100% { opacity: 0.2; } }
}
@media (prefers-reduced-motion: reduce) {
  .dot.nearby { box-shadow: 0 0 0 2px var(--ink); }
}
.dot.activity { background: var(--activity); }
.dot.quiet { background: var(--quiet); }
.dot.unmonitored { background: var(--unmonitored); }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 700; }
.table-wrap { overflow-x: auto; max-width: 100%; }

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--ok);
  color: var(--ok);
  background: var(--surface);
  margin-bottom: 14px;
}
.flash.error { border-color: var(--danger); color: var(--danger); }

.empty { color: var(--ink-3); font-style: italic; padding: 6px 0; }

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--nearby);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
}
.toast strong { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 180ms ease-out; }
  @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Search box with suggestions (public map and admin placement) */
.place-search { position: relative; }
.search-input { width: 100%; font-size: 0.95rem; }
.search-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 3000;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-list { list-style: none; margin: 0; padding: 4px; max-height: min(60vh, 420px); overflow-y: auto; }
.search-group { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 8px 2px; }
.search-item { display: flex; flex-direction: column; gap: 1px; padding: 7px 8px; border-radius: 4px; cursor: pointer; }
.search-item[aria-selected="true"], .search-item:hover { background: var(--surface-2); }
.search-name { font-weight: 600; }
.search-name mark { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--focus); text-decoration-thickness: 2px; }
.search-detail { font-size: 0.78rem; color: var(--ink-3); }
.search-status { font-size: 0.75rem; color: var(--ink-3); padding: 4px 12px 8px; }
.search-status:empty { display: none; }
