/* ===== Reset / base ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #111;
  color: #e0e0e0;
  overflow: hidden;
}

/* ===== Map ===== */
#map {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  z-index: 1;
}

/* Leaflet panes / layers */
.leaflet-pane { z-index: 0; }

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(17, 17, 17, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 8px env(safe-area-inset-left);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* ===== Legend ===== */
.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.80rem;
  color: #bbb;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: #555;
}
.legend-solid.green      { background: #006633; }
.legend-dash.green-light { background: repeating-linear-gradient(90deg, #4c9a77 0 5px, transparent 5px 8px); }
.legend-solid.blue       { background: #1f6fb2; }
.legend-dash.blue-light  { background: repeating-linear-gradient(90deg, #7aa8d4 0 5px, transparent 5px 8px); }

/* mini bus-pin glyph in the legend */
.legend-pin {
  display: inline-block;
  width: 12px;
  height: 16px;
  background: #006633;
  border: 1.5px solid #fff;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
}
.legend-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #006633;
}

/* ===== Status / last-updated ===== */
.status-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-pill {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: #4a4a4a;
  min-width: 90px;
  text-align: center;
  line-height: 1.6;
}

.status-pill.live   { background: #2e7d32; }   /* green */
.status-pill.stale  { background: #c68a00; }   /* amber */
.status-pill.error  { background: #c62828; }   /* red */

.last-updated {
  font-size: 0.72rem;
  color: #888;
}

/* ===== Bus pin markers ===== */
.bus-pin {
  background: none;
  border: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  cursor: pointer;
}
.bus-pin svg { display: block; }

/* ===== Staleness — dim buses ===== */
body.stale .bus-pin {
  opacity: 0.35 !important;
}

/* ===== Popup extras ===== */
.route-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  vertical-align: middle;
  line-height: 1.5;
}

.stop-popup ul {
  margin: 4px 0 0;
  padding-left: 16px;
}
.stop-popup li {
  margin: 2px 0;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .header-inner { gap: 6px; }
  .title { font-size: 1rem; }
  .legend {
    flex-direction: row;
    gap: 8px;
    font-size: 0.74rem;
  }
  .legend-item { gap: 3px; }
  .legend-swatch { width: 14px; height: 3px; }
  .status-pill { font-size: 0.68rem; padding: 3px 8px; }
  .last-updated { font-size: 0.64rem; }
}
