/* =========================================================
   Tokens
   ========================================================= */
:root {
  --ink: #0B2B2A;          /* near-black teal, brand-adjacent but not KMRL's mark */
  --teal: #00A99D;         /* signature accent, evokes KMRL teal without copying the logo */
  --teal-dim: #0B5E57;
  --paper: #F6F7F5;
  --line: rgba(11, 43, 42, 0.12);
  --warn-bg: #FFF4E5;
  --warn-text: #7A4B00;
  --shadow: 0 12px 32px rgba(11, 43, 42, 0.18);
  --radius: 14px;
  --font-display: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
}

#map { position: absolute; left: 0; right: 0; top: 60px; bottom: 72px; }

/* =========================================================
   Top bar — white, native app feel
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: white;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  color: var(--ink);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.topbar__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
}

.topbar__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 2.2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__icon-btn {
  background: rgba(11,43,42,0.07);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.topbar__icon-btn:hover { background: rgba(11,43,42,0.14); }

.topbar__icon-btn--spinning svg {
  animation: spin 0.6s linear;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.topbar__about {
  background: var(--ink);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  line-height: 1;
  flex-shrink: 0;
}
.topbar__about:hover { background: var(--teal-dim); }

/* =========================================================
   Status pill (floats above the bottom nav bar)
   ========================================================= */
.status-pill {
  position: fixed;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%);
  z-index: 1300;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 43, 42, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: white;
  padding: 7px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  font-size: 12px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  transition: opacity 0.2s ease;
}
.status-pill--hidden { display: none; }

.status-pill__dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #888;
}
.status-pill--active .status-pill__dot {
  background: var(--teal);
  animation: pulse 2.2s infinite;
}

.status-pill__text {
  font-weight: 600;
  font-size: 12px;
}

.status-pill__sub {
  font-size: 11px;
  opacity: 0.6;
}

.status-pill__action {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.status-pill__action:hover { background: rgba(255,255,255,0.25); }
.status-pill__action--stop {
  padding: 3px 8px;
  font-size: 12px;
}

/* =========================================================
   Overlay / Modal
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(11, 43, 42, 0.55);
  backdrop-filter: blur(2px);
}
.overlay--hidden { display: none; }

.modal {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  max-height: 88vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .overlay { align-items: center; }
  .modal { border-radius: var(--radius); }
}

.modal__title {
  margin: 0 0 10px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
}

.modal__body {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(11,43,42,0.85);
}

.modal__body--small { font-size: 13.5px; }

.modal__subhead {
  font-size: 14px;
  font-weight: 700;
  margin: 18px 0 6px;
}

.modal__points {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal__points li {
  font-size: 14px;
  padding-left: 22px;
  position: relative;
  color: rgba(11,43,42,0.8);
}
.modal__points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--teal);
  font-weight: 700;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.modal__fine-print {
  margin: 14px 0 0;
  font-size: 12px;
  color: rgba(11,43,42,0.55);
  line-height: 1.5;
}
.modal__fine-print a { color: var(--teal-dim); text-decoration: underline; }

.callout {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 4px;
}
.callout--warning {
  background: var(--warn-bg);
  color: var(--warn-text);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--teal);
  color: white;
}
.btn--primary:hover { background: var(--teal-dim); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: rgba(11,43,42,0.04); }

/* =========================================================
   Leaflet marker tweaks (train icon styling lives inline in map.js,
   since each marker's transform/flip is computed per-train)
   ========================================================= */

/* =========================================================
   Bottom navigation bar
   ========================================================= */
.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  background: white;
  border-top: none;
  box-shadow: none;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0)) 8px;
  height: 72px;
  gap: 4px;
}

.bottombar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  background: transparent;
  border: none;
  border-radius: 14px;
  color: #A0AABA;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}

.bottombar__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.15s ease;
}

/* ── Active state: pill card + top indicator line ── */
.bottombar__item--active {
  color: #2196F3;
}

.bottombar__item--active .bottombar__icon {
  background: #E8F4FE;
  width: 52px;
  height: 42px;
  border-radius: 12px;
}

/* Blue top indicator line on active icon card */
.bottombar__item--active .bottombar__icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 3px;
  background: #2196F3;
  border-radius: 0 0 3px 3px;
}

/* Tint SVG icon blue when active */
.bottombar__item--active .bottombar__icon svg {
  stroke: #2196F3;
}

/* Grey inactive SVG */
.bottombar__item:not(.bottombar__item--active) .bottombar__icon svg {
  stroke: #A0AABA;
}


/* =========================================================
   Stations slide-up panel
   ========================================================= */
.panel {
  position: fixed;
  left: 0; right: 0;
  top: 60px;
  bottom: 72px;
  z-index: 1400;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  transition: transform 0.22s ease;
}

.panel--hidden {
  transform: translateY(100%);
  pointer-events: none;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.panel__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.panel__close {
  background: rgba(11,43,42,0.06);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}

.panel__search {
  padding: 10px 12px;
  background: #f8f9f9;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.panel__search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px 11px 38px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2300A99D' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
  color: var(--ink);
  -webkit-appearance: none;
}
.panel__search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,169,157,0.12);
}
.panel__search-input::placeholder {
  color: rgba(11,43,42,0.35);
  font-size: 13.5px;
}

.panel__body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px; /* clears the bottom nav bar */
}


/* =========================================================
   Ticket booking screen (native, no iframe)
   ========================================================= */
.ticket-screen {
  background: #F3F5F4;
  padding-bottom: 90px;
}

.ticket-hero {
  text-align: center;
  padding: 32px 16px 20px;
}

.ticket-hero__icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
}

.ticket-hero__sub {
  font-size: 13px;
  color: rgba(11,43,42,0.45);
  margin: 0;
  font-weight: 500;
}

.ticket-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}

.ticket-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border-radius: 16px;
  padding: 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.ticket-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ticket-card--primary {
  background: var(--ink);
  color: white;
  box-shadow: 0 4px 14px rgba(11,43,42,0.25);
}
.ticket-card--primary .ticket-card__desc {
  color: rgba(255,255,255,0.65);
}
.ticket-card--primary .ticket-card__arrow {
  color: rgba(255,255,255,0.5);
}

.ticket-card__emoji {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.ticket-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ticket-card__title {
  font-size: 15px;
  font-weight: 700;
}

.ticket-card__desc {
  font-size: 12.5px;
  color: rgba(11,43,42,0.5);
}

.ticket-card__arrow {
  font-size: 22px;
  color: rgba(11,43,42,0.25);
  line-height: 1;
}

.ticket-disclaimer {
  margin: 20px 16px 0;
  font-size: 12px;
  color: rgba(11,43,42,0.4);
  text-align: center;
  line-height: 1.6;
}


.station-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: white;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.station-row:active { background: rgba(0,169,157,0.07); }

.station-row__num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(0,169,157,0.12);
  color: var(--teal-dim);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-row__names {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.station-row__name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.station-row__name-ml {
  font-size: 12px;
  color: rgba(11,43,42,0.5);
}

.station-row__chevron {
  color: rgba(11,43,42,0.3);
  font-size: 18px;
}

/* =========================================================
   Leaflet attribution — tiny and unobtrusive
   ========================================================= */
.leaflet-control-attribution {
  font-size: 9px !important;
  padding: 1px 5px !important;
  background: rgba(255,255,255,0.6) !important;
  backdrop-filter: blur(2px);
  border-radius: 4px 4px 0 0 !important;
  color: rgba(0,0,0,0.45) !important;
  line-height: 1.4 !important;
}
.leaflet-control-attribution a {
  color: rgba(0,0,0,0.5) !important;
}

/* =========================================================
   Next Train Card
   ========================================================= */
.next-train-card {
  position: fixed;
  top: 68px;
  left: 12px;
  right: 12px;
  z-index: 1200;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  padding: 10px 14px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.next-train-card--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.next-train-card__station {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(11,43,42,0.5);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
}
.next-train-card__station-dot {
  color: var(--teal);
  font-size: 8px;
}

.next-train-card__rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.next-train-card__no-service {
  font-size: 13px;
  color: rgba(11,43,42,0.4);
}

.next-train-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.next-train-row__dir {
  flex: 1;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-train-row__time {
  font-size: 12px;
  color: rgba(11,43,42,0.45);
  flex-shrink: 0;
}

.next-train-row__countdown {
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-dim);
  min-width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.next-train-row__countdown--urgent {
  color: #DC2626;
}
.next-train-row--urgent .next-train-row__dir {
  color: #DC2626;
}

/* =========================================================
   Last Train Warning Banner
   ========================================================= */
.last-train-banner {
  position: fixed;
  top: 68px;
  left: 12px;
  right: 12px;
  z-index: 1201;
  background: #7C2D12;
  color: white;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 16px rgba(124,45,18,0.35);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.last-train-banner--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.last-train-banner__icon {
  font-size: 16px;
  flex-shrink: 0;
}

.last-train-banner__text {
  flex: 1;
  font-size: 12px;
  line-height: 1.5;
}
.last-train-banner__text strong {
  font-weight: 700;
}

.last-train-banner__dismiss {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.last-train-banner__dismiss:hover {
  background: rgba(255,255,255,0.25);
}

/* Push next train card below the last train banner when both visible */
.next-train-card--below-banner {
  top: 126px;
}

