:root {
  --bg: #0d1218;
  --panel: rgba(14, 19, 26, 0.82);
  --border: rgba(255, 255, 255, 0.14);
  --text: #eef1f5;
  --muted: #9aa4b2;
  --c-early: #4da3ff;
  --c-on_time: #3ddc84;
  --c-late: #ffb02e;
  --c-very_late: #ff4d4f;
  --c-unknown: #8a93a0;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------- start page ---------- */
body.home {
  min-height: 100%;
  background: linear-gradient(160deg, #101822 0%, #070a0e 70%);
}
.bg-video {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: -2;
}
.scrim {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(6, 9, 13, 0.45) 0%, rgba(6, 9, 13, 0.72) 100%);
}
.hero {
  min-height: 100vh; padding: 32px 24px 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.eyebrow {
  margin: 0 0 12px; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.hero h1 {
  margin: 0; font-size: clamp(40px, 8vw, 88px); font-weight: 500; line-height: 1.05;
  letter-spacing: -0.02em;
}
.lead {
  max-width: 560px; margin: 20px 0 0; font-size: clamp(16px, 2vw, 19px);
  color: rgba(255, 255, 255, 0.8);
}
.actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 40px; }
.btn {
  display: inline-block; padding: 14px 32px; border-radius: 999px; text-decoration: none;
  font-size: 16px; font-weight: 500; color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background 0.15s, transform 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.18); transform: translateY(-1px); }
.btn-primary { background: #fff; color: #0a0e13; border-color: #fff; }
.btn-primary:hover { background: #dfe5ec; }
.site-foot {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 24px;
  text-align: center; font-size: 12px; color: rgba(255, 255, 255, 0.6);
}

/* ---------- plain content page (analytics placeholder) ---------- */
body.page { min-height: 100%; }
.page-wrap { max-width: 720px; margin: 0 auto; padding: 48px 24px; }
.page-wrap h1 { font-size: 36px; font-weight: 500; margin: 24px 0 12px; }
.page-wrap p, .page-wrap li { color: var(--muted); }
.back { font-size: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }

/* ---------- live map ---------- */
body.live { overflow: hidden; }
#map { position: fixed; inset: 0; }
.panel {
  position: fixed; top: 16px; left: 16px; z-index: 5; width: 264px;
  max-height: calc(100vh - 32px); overflow: auto;
  padding: 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
/* collapsible live-map controls */

.controls-panel {
  transition:
    transform 0.22s ease,
    background-color 0.22s ease,
    border-color 0.22s ease;
  will-change: transform;
}

.controls-panel > :not(.panel-toggle) {
  transition: opacity 0.12s ease;
}

.panel-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;

  width: 36px;
  height: 36px;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--border);
  border-radius: 9px;

  background: rgba(255, 255, 255, 0.06);
  color: var(--text);

  font: inherit;
  font-size: 27px;
  line-height: 1;

  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.panel-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

/*
  Move almost the entire panel beyond the left edge.
  28px are deliberately left so the toggle button remains visible.
*/
body.controls-collapsed .controls-panel {
  transform: translateX(calc(-100% + 28px));

  background: transparent;
  border-color: transparent;

  -webkit-backdrop-filter: none;
  backdrop-filter: none;

  overflow: hidden;
  pointer-events: none;
}

body.controls-collapsed .controls-panel > :not(.panel-toggle) {
  opacity: 0;
  pointer-events: none;
}

body.controls-collapsed .panel-toggle {
  pointer-events: auto;
  background: var(--panel);
  border-color: var(--border);
}

.panel h1 { margin: 6px 0 4px; font-size: 20px; font-weight: 500; }
.panel h2 {
  margin: 18px 0 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.status-line { margin: 0; font-size: 13px; color: var(--muted); }
.status-line.warn { color: var(--c-late); }
.status-line.error { color: var(--c-very_late); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
}
.chip .count { color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.legend .text { flex: 1; min-width: 0; }
.legend .name, .legend .hint { display: block; }
.legend .hint { color: var(--muted); font-size: 12px; line-height: 1.3; }
.legend .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.fatal {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; background: var(--bg); color: var(--text);
}

/* detail panel */
.panel.detail {
  left: auto; right: 16px; width: 320px; padding-top: 14px;
}
.detail-close {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 40px; height: 40px;            /* comfortable tap target on a phone */
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0;
}
.detail-close:hover { color: var(--text); }
.detail-head { display: flex; align-items: flex-start; gap: 10px; padding-right: 38px; }
.detail-dest { min-width: 0; }
.detail-dest strong { display: block; font-weight: 500; font-size: 15px; }
.detail-route { display: block; color: var(--muted); font-size: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 14px 0 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }
.h2-note { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.panel-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

.stops { list-style: none; margin: 0; padding: 0 0 0 2px; }
.stop { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; font-size: 13px; position: relative; }
.stop::before {                       /* the line joining the stop dots */
  content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 1px;
  background: var(--border);
}
.stop:first-child::before { top: 50%; }
.stop:last-child::before { bottom: 50%; }
.stop-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; position: relative;
  background: var(--bg); border: 1.5px solid var(--muted);
}
.stop.done { color: var(--muted); }
.stop.done .stop-dot { background: var(--muted); border-color: var(--muted); }
.stop.next .stop-dot { background: var(--text); border-color: var(--text); }
.stop.next { font-weight: 500; }
.stop-name { flex: 1; min-width: 0; }
.stop-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.service-summary { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.siblings { list-style: none; margin: 0; padding: 0; }
.sibling {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  padding: 6px 8px; margin: 2px 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
}
.sibling:hover { background: rgba(255, 255, 255, 0.1); }
.sib-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sib-next { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sib-delay { color: var(--muted); font-size: 12px; }

/* vehicle tooltip */
.veh-popup .maplibregl-popup-content {
  padding: 10px 12px; border-radius: 10px; font-family: var(--font); font-size: 13px;
  background: rgba(14, 19, 26, 0.94); color: var(--text); border: 1px solid var(--border);
  box-shadow: none; pointer-events: none;
}
.veh-popup .maplibregl-popup-tip { display: none; }
.veh-tip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.line-badge {
  min-width: 28px; padding: 1px 8px; border-radius: 6px; text-align: center;
  font-weight: 500; color: #0a0e13;
}
.veh-tip-mode { color: var(--muted); }
.veh-tip-row { display: flex; justify-content: space-between; gap: 18px; }
.veh-tip-row span:first-child { color: var(--muted); }
.maplibregl-ctrl-attrib { background: rgba(14, 19, 26, 0.7) !important; color: var(--muted) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

@media (max-width: 640px) {
  .panel { width: calc(100vw - 32px); max-height: 40vh; }
  .panel.detail { left: 16px; right: 16px; width: auto; top: auto; bottom: 16px; max-height: 58vh; }
  /* with the details open there is no room for both, so the controls hide */
  body.detail-open .panel:not(.detail) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn,
  .controls-panel,
  .controls-panel > :not(.panel-toggle) {
    transition: none;
  }

  .btn:hover {
    transform: none;
  }
}