/* ── Dublin Transit Live Map — cyberpunk / synthwave HUD ──────────────────── */
:root {
  --bg: #05070d;
  --panel: rgba(8, 12, 22, 0.82);
  --panel-edge: rgba(0, 229, 255, 0.22);
  --bus: #ffe600;          /* Dublin Bus yellow */
  --bus-glow: rgba(255, 230, 0, 0.85);
  --dart: #00e5ff;         /* DART / rail cyan */
  --dart-glow: rgba(0, 229, 255, 0.85);
  --rail: #7c5cff;         /* wider rail (purple) */
  --ink: #cfe3ff;
  --ink-dim: #6f86ad;
  --grid: rgba(0, 229, 255, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", Menlo, monospace;
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: var(--bg); z-index: 0; }

/* The bus/train canvas overlay sits above tiles, below the HUD. */
#vehicle-canvas {
  position: absolute; inset: 0; z-index: 400; pointer-events: none;
}

/* faint scanline + grid texture over everything for the synthwave feel */
.fx-overlay {
  position: absolute; inset: 0; z-index: 450; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,0.18) 3px 4px);
  mix-blend-mode: overlay; opacity: 0.5;
}

/* ── HUD panel ─────────────────────────────────────────────────────────────*/
/* Top toolbar — Portfolio / Map / Flows nav (shared look with the flows page). */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 900;
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
  background: rgba(8, 12, 22, 0.86); border-bottom: 1px solid var(--panel-edge);
  backdrop-filter: blur(10px);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.topbar .tb-home { font-size: 12px; letter-spacing: 0.5px; color: var(--ink); text-decoration: none;
  padding: 7px 10px; border-radius: 8px; }
.topbar .tb-home:hover { color: var(--bus); }
.topbar .tb-links { display: flex; gap: 3px; }
.topbar .tb-links a { font-size: 12px; letter-spacing: 0.5px; color: var(--ink-dim); text-decoration: none;
  padding: 7px 13px; border-radius: 8px; transition: all 0.15s; white-space: nowrap; }
.topbar .tb-links a:hover { color: var(--ink); }
.topbar .tb-links a.active { color: #06121c; background: var(--bus); font-weight: 700; }
.leaflet-top { top: 44px; }   /* push zoom/attribution below the toolbar */
@media (max-width: 560px) {
  .topbar .tb-full { display: none; }   /* "built by bobby" → "bobby" */
  .topbar .tb-links a { padding: 6px 11px; }
}

.hud {
  position: absolute; top: 58px; left: 16px; z-index: 500;
  width: 304px; max-height: calc(100% - 74px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  backdrop-filter: blur(9px);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 18px 50px rgba(0,0,0,0.55);
}

.hud h1 {
  margin: 0; font-size: 15px; letter-spacing: 2.5px; font-weight: 700;
  color: #fff; text-transform: uppercase;
}
.hud h1 .accent { color: var(--bus); }
.hud .subtitle { margin: 3px 0 0; font-size: 10px; letter-spacing: 1.5px; color: var(--ink-dim); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  padding: 9px 10px; background: rgba(255,255,255,0.015);
}
.stat .label { font-size: 9px; letter-spacing: 1.4px; color: var(--ink-dim); text-transform: uppercase; }
.stat .value { font-size: 21px; font-weight: 700; line-height: 1.1; margin-top: 3px; }
.stat .value.bus { color: var(--bus); }
.stat .value.dart { color: var(--dart); }

.section-label { font-size: 9px; letter-spacing: 1.5px; color: var(--ink-dim); text-transform: uppercase; }

.toggles { display: flex; gap: 8px; }
.toggle {
  flex: 1; cursor: pointer; user-select: none; text-align: center;
  padding: 7px 6px; border-radius: 7px; font-size: 11px; letter-spacing: 0.5px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.02);
  color: var(--ink-dim); transition: all 0.15s ease;
}
.toggle.on.bus { color: #1a1400; background: var(--bus); border-color: var(--bus); font-weight: 700; }
.toggle.on.dart { color: #001316; background: var(--dart); border-color: var(--dart); font-weight: 700; }
.toggle.on.luas { color: #fff; background: #7d2e68; border-color: #7d2e68; font-weight: 700; }
.toggle { padding: 7px 4px; font-size: 10px; }

/* ── Grouped filters (Public Transport / Footfall / Traffic) ───────────────── */
.filter-groups { display: flex; flex-direction: column; gap: 8px; }
.fgroup { display: flex; flex-direction: column; gap: 6px; }
.grp-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 8px 10px; border-radius: 8px; font-size: 11px; letter-spacing: 1px; font-weight: 700;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.025);
  color: var(--ink-dim); transition: all 0.15s ease;
}
.grp-head .grp-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ink-dim); transition: all 0.15s ease;
}
.grp-head .grp-count { margin-left: auto; font-size: 9px; font-weight: 400; opacity: 0.8; letter-spacing: 0.5px; }
.grp-head.on { color: #fff; }
/* each group lights its accent when active */
.grp-head.transport.on { border-color: var(--bus); box-shadow: inset 0 0 0 1px rgba(255,230,0,0.25); }
.grp-head.transport.on .grp-dot { background: var(--bus); box-shadow: 0 0 8px var(--bus); }
/* sub-toggles indent under the transport group; dim when the group is off */
.subtoggles { display: flex; gap: 8px; padding-left: 4px; transition: opacity 0.15s ease; }
.fgroup.muted .subtoggles, .fgroup.muted .bus-tools { opacity: 0.35; pointer-events: none; }

/* bus curation tools: frequency segments + labels toggle */
.bus-tools { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.seg-mini-group { display: flex; gap: 4px; flex: 1; }
.seg-mini { flex: 1; text-align: center; cursor: pointer; user-select: none;
  padding: 5px 3px; border-radius: 6px; font-size: 8.5px; letter-spacing: 0.6px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.02);
  color: var(--ink-dim); transition: all 0.15s ease; }
.seg-mini.on { color: #001316; background: var(--dart); border-color: var(--dart); font-weight: 700; }
.label-toggle { cursor: pointer; user-select: none; white-space: nowrap;
  padding: 5px 8px; border-radius: 6px; font-size: 8.5px; letter-spacing: 0.6px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.02);
  color: var(--ink-dim); transition: all 0.15s ease; }
.label-toggle.on { color: #1a1400; background: var(--bus); border-color: var(--bus); font-weight: 700; }

select {
  width: 100%; padding: 8px 10px; border-radius: 7px;
  background: rgba(0,0,0,0.45); color: var(--ink);
  border: 1px solid rgba(0,229,255,0.25); font-family: inherit; font-size: 12px;
  outline: none; cursor: pointer;
}
select:focus { border-color: var(--dart); }

.status-row { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--ink-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-dim); }
.dot.live { background: #2dff9e; animation: pulse 2s infinite; }
.dot.stale { background: #ff5d5d; }
.dot.mock { background: var(--bus); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.countdown { color: var(--ink); }
.refresh-bar { height: 3px; border-radius: 2px; background: rgba(255,255,255,0.08); overflow: hidden; }
.refresh-bar > i { display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--dart), var(--bus)); transform-origin: left;
  transition: transform 0.5s linear; }

.banner {
  font-size: 10px; line-height: 1.5; color: #ffd27a;
  border: 1px solid rgba(255,210,122,0.25); border-radius: 7px;
  padding: 8px 10px; background: rgba(255,210,122,0.05);
}
.banner.hidden { display: none; }

/* ── Vehicle info popup (custom, not Leaflet's) ───────────────────────────── */
.info-card {
  position: absolute; z-index: 600; left: 16px; bottom: 16px; width: 304px;
  padding: 14px 16px; border-radius: 11px; background: var(--panel);
  border: 1px solid var(--panel-edge); backdrop-filter: blur(9px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.55); display: none;
}
.info-card.show { display: block; }
.info-card .badge {
  display: inline-block; font-weight: 700; font-size: 16px; padding: 3px 11px;
  border-radius: 6px; color: #1a1400; background: var(--bus);
}
.info-card .badge.dart { color: #001316; background: var(--dart); }
.info-card .headsign { font-size: 12px; color: var(--ink); margin: 9px 0 11px; }
.info-card table { width: 100%; border-collapse: collapse; font-size: 11px; }
.info-card td { padding: 2px 0; }
.info-card td.k { color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; font-size: 9px; }
.info-card td.v { text-align: right; color: var(--ink); }
.info-card .close { position: absolute; top: 10px; right: 12px; cursor: pointer; color: var(--ink-dim); font-size: 14px; }

.legend { position: absolute; right: 16px; top: 58px; z-index: 500; display: flex; flex-wrap: wrap;
  gap: 8px 14px; max-width: 340px; justify-content: flex-end;
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 9px; font-size: 12px; letter-spacing: 0.6px; backdrop-filter: blur(9px); }
.legend span { display: flex; align-items: center; gap: 6px; color: var(--ink-dim); }
/* legend glyphs mirror the map shapes: bus = square, DART/rail = circle, Luas = pill */
.legend i { display: inline-block; border: 1px solid rgba(12,18,30,0.85); }
.dot-bus  { width: 9px; height: 9px; background:#ffe600; }
.dot-dart { width: 9px; height: 9px; border-radius:50%; background:#b6d908; }
.dot-luas { width: 16px; height: 6px; border-radius:3px; background:#ED1C24; }
.dot-rail { width: 9px; height: 9px; border-radius:50%; background:#8aa0b4; }

/* ── LIVE / REPLAY switch ─────────────────────────────────────────────────── */
.mode-switch { display: flex; gap: 6px; padding: 4px; border-radius: 9px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.06); }
.seg { flex: 1; text-align: center; padding: 7px 4px; border-radius: 7px; font-size: 11px;
  letter-spacing: 0.6px; cursor: pointer; color: var(--ink-dim); transition: all 0.15s; }
.seg.on { color: #001316; background: var(--dart); font-weight: 700; }

.hidden { display: none !important; }

/* ── Replay transport ─────────────────────────────────────────────────────── */
#replay-clock { color: var(--bus); font-size: 13px; letter-spacing: 2px; }
input[type="range"] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--dart), var(--bus)); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; cursor: pointer; }
.transport { display: flex; align-items: center; gap: 8px; }
.t-btn { font-family: inherit; cursor: pointer; color: var(--ink); background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-edge); border-radius: 7px; padding: 6px 12px; font-size: 13px; }
.t-btn:hover { border-color: var(--dart); }
.t-btn.wide { flex: 1; }
.t-speed { width: auto; flex: 0 0 auto; padding: 6px 8px; }
.src-tag { margin-left: auto; font-size: 9px; letter-spacing: 1px; color: var(--ink-dim);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 5px; padding: 3px 7px; cursor: pointer; }

.hud-foot { display: flex; gap: 10px; align-items: center; padding-top: 2px; }
.more-toggle { margin: 0 auto 0 0; }
.advanced { display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid rgba(255,255,255,0.08); padding-top: 12px; margin-top: -4px; }
.advanced .adv-row { display: flex; gap: 10px; align-items: center; }
.foot-sel { flex: 1; padding: 6px 8px; font-size: 10px; letter-spacing: 0.5px; }
.link { font-size: 10px; letter-spacing: 1px; color: var(--ink-dim); cursor: pointer; white-space: nowrap; text-decoration: none; }
.link:hover { color: var(--dart); }

/* Hover destination blind — styled like the front-of-bus LED display. */
.dest-blind {
  position: absolute; z-index: 700; pointer-events: none;
  display: flex; gap: 8px; align-items: baseline;
  background: #0a0a0a; border: 1px solid #2a2a2a; border-radius: 5px;
  padding: 5px 10px; white-space: nowrap;
  transform: translate(-50%, -150%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.dest-blind.hidden { display: none; }
.dest-blind .db-route { color: #ffb000; font-weight: 800; font-size: 15px; letter-spacing: 1px;
  text-shadow: 0 0 7px rgba(255, 176, 0, 0.65); }
.dest-blind .db-dest { color: #ffc83a; font-size: 11px; letter-spacing: 0.4px;
  text-shadow: 0 0 5px rgba(255, 176, 0, 0.4); }

/* On light/detailed basemaps, drop the scanline texture (reads as dirt on light). */
body.light-map .fx-overlay { opacity: 0; }

/* Leaflet dark tweaks */
.leaflet-control-attribution { background: rgba(0,0,0,0.5) !important; color: var(--ink-dim) !important; }
.leaflet-control-attribution a { color: var(--dart) !important; }

/* ── Mobile: dock the HUD as a collapsible bottom sheet ─────────────────────── */
/* On phones the 304px side panel swallowed the whole screen. Instead the HUD
   becomes a full-width sheet at the bottom that starts collapsed to just its
   header (tap the title to expand), so the map is the hero. */
@media (max-width: 620px) {
  .hud {
    top: auto; bottom: 0; left: 0; right: 0; width: auto;
    max-height: 64vh; overflow-y: auto; gap: 12px;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    transition: transform 0.25s ease;
  }
  /* Collapsed → peek the title AND the Live/Time-lapse switch, so the value prop and
     the primary control are both visible without expanding (was just the 58px header). */
  .hud.collapsed { transform: translateY(calc(100% - 124px)); overflow: hidden; }
  .hud > div:first-child { cursor: pointer; position: relative; padding-right: 40px; }
  /* Big, bright expand/collapse chevron — the playback controls live under it, so it
     needs to be obvious on a phone (was a tiny dim 14px glyph that was easy to miss). */
  .hud > div:first-child::after {
    content: "▾"; position: absolute; right: 4px; top: 50%;
    transform: translateY(-50%); color: var(--accent); font-size: 30px; line-height: 1;
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(255,255,255,0.08); transition: transform 0.2s;
  }
  .hud.collapsed > div:first-child::after { transform: translateY(-50%) rotate(180deg); }

  /* Legend: compact, top-right, clear of the left zoom control; allow wrapping. */
  .legend {
    top: 50px; right: 8px; left: auto; max-width: 62vw;
    flex-wrap: wrap; justify-content: flex-end; gap: 7px 12px;
    font-size: 9px; padding: 6px 9px;
  }
}
.leaflet-bar a { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--panel-edge) !important; }
