/*
 * GO Transit Mobile — Overrides
 * Extends style.css with GO-specific branding & colors.
 * Mirrors mobile.css structure but for GO Transit.
 */

/* ==========================================================================
   Z-INDEX STACK (map < Ko-fi < full-screen UI — alerts/nav/sheets on top)
   Ko-fi is injected on body; map pan layer uses transform (stacking context).
   Without this, some browsers paint the map above the donation overlay.
   ========================================================================== */
#map-viewport {
    z-index: 1 !important;
    isolation: isolate;
}

.ui-layer {
    z-index: 2000 !important;
    isolation: isolate;
}

/* Ko-fi classic button — above map, under .ui-layer (see transit-kofi.css). */
body.go-app #transit-kofi-button-host,
body.go-desktop #transit-kofi-button-host {
    z-index: 1500 !important;
}

/* ==========================================================================
   GO MAP — Tracks & station labels (dark mode default)
   ========================================================================== */
/* Pan = translate on wrapper; zoom = scale on SVG — keeps Draggable and pinch in sync (esp. iOS). */
#map-pan-layer {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    line-height: 0;
}

#map-viewport #map-pan-layer,
#map-viewport #map-root {
    transform-origin: 0 0 !important;
}

#map-root .track {
    stroke-linecap: round;
    stroke-linejoin: round;
}
#map-root .station-label {
    pointer-events: none;
    user-select: none;
    paint-order: stroke;
    stroke: rgba(0,0,0,0.8);
    stroke-width: 2px;
}
#map-root .go-station-marker {
    cursor: default;
}

.go-accessibility-icon {
    pointer-events: none;
    /* #map-root uses geometricPrecision; nested path + small scale can fragment on some engines */
    shape-rendering: auto;
}

.go-accessibility-icon path {
    stroke: none;
}

.go-line-route-label {
    pointer-events: none;
}

.go-line-route-label-text {
    fill: #ffffff;
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 1px;
}

body.light-mode .go-line-route-label-text {
    fill: #ffffff;
    stroke: rgba(0, 0, 0, 0.25);
}

/* Capsule (special interchange) — blue only when accessible */
.go-capsule {
    fill: #1a1d23;
    stroke: #ffffff;
}

.go-capsule-accessible {
    fill: #528CCB;
}

/* Slot circles inside capsules */
.go-slot-circle {
    fill: #ffffff;
}

/* Standard interchange */
.go-interchange {
    fill: #ffffff;
    stroke: #1a1d23;
}

/* Normal station dot (stroke set inline per-line color) */
.go-station-dot {
    fill: #ffffff;
}

/* Station labels */
.go-label {
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 3px;
    paint-order: stroke fill;
    pointer-events: none;
    user-select: none;
}

/* ==========================================================================
   GO MAP — Alert overlays (proportional to 16px line width)
   ========================================================================== */
#map-root .alert-base {
    fill: none;
    stroke-width: 22px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}
#map-root .alert-base.flow-forward,
#map-root .alert-base.flow-reverse {
    stroke-width: 22px;
    stroke-dasharray: 20, 45;
}
#map-root .shuttle-outline {
    fill: none;
    stroke-width: 32px;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#map-root .shuttle-outline.flow-forward,
#map-root .shuttle-outline.flow-reverse {
    stroke-width: 30px;
    stroke-dasharray: 20, 45;
}

.svg-alert-pulse {
    pointer-events: none;
    transform-origin: center;
    transform-box: fill-box;
}
.svg-alert-pulse.yellow {
    animation: go-pulse-yellow 2s infinite;
    fill: #ff9f1c;
}
.svg-alert-pulse.red {
    animation: go-pulse-red 2s infinite;
    fill: #ef4444;
}
@keyframes go-pulse-red {
    0%   { r: 10; opacity: 0.55; stroke-width: 0; }
    50%  { opacity: 0.28; }
    100% { r: 22; opacity: 0; stroke-width: 0; }
}
@keyframes go-pulse-yellow {
    0%   { r: 10; opacity: 0.55; stroke-width: 0; }
    50%  { opacity: 0.28; }
    100% { r: 22; opacity: 0; stroke-width: 0; }
}

/* ==========================================================================
   GO LINE FILTER BUTTONS (in sheet header)
   ========================================================================== */

.go-filter-lw {
    background: #98002E;
    color: white;
}

.go-filter-le {
    background: #ED1B24;
    color: white;
}

.go-filter-br {
    background: #005C8A;
    color: white;
}

.go-filter-ki {
    background: #00853F;
    color: white;
}

.go-filter-st {
    background: #7A5030;
    color: white;
}

.go-filter-rh {
    background: #00A4E4;
    color: white;
}

.go-filter-mi {
    background: #F58220;
    color: white;
}

.go-filter-up {
    background: #40bfd9;
    color: white;
}


/* ==========================================================================
   GO LINE BADGE (wider pill for 2-char line IDs like "LW", "LE")
   ========================================================================== */

.go-badge {
    width: auto !important;
    min-width: 28px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    color: white;
    letter-spacing: 0.5px;
}


/* ==========================================================================
   ACTIVE NAV ACCENT COLOR — GO green instead of TTC yellow
   ========================================================================== */

.nav-item.active i {
    color: #3B7D2F;
}

/* Status indicator live state — GO green */
.status-indicator.live .status-text {
    color: #3B7D2F;
}

.status-indicator.live {
    border-color: rgba(59, 125, 47, 0.3);
}

.live-dot {
    background: #3B7D2F;
}

@keyframes livePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(59, 125, 47, 0.6);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(59, 125, 47, 0);
    }
}


/* ==========================================================================
   EMPTY STATE CARDS (shown when no alerts)
   ========================================================================== */

.empty-alert-card {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-alert-card i {
    font-size: 40px;
    color: #3B7D2F;
    opacity: 0.4;
    margin-bottom: 16px;
    display: block;
}

.empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.empty-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}


/* ==========================================================================
   ALERT CARD OVERRIDES (GO specific)
   ========================================================================== */

/* Stack cards with gap so light-mode / long bodies never visually merge */
#alerts-list.sheet-content,
#upcoming-list.sheet-content {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 3.5vw, 20px);
}

#alerts-list.sheet-content .alert-card,
#upcoming-list.sheet-content .alert-card {
    margin-bottom: 0;
}

.go-alert-card.suspension {
    border-left-color: var(--alert-color);
}

.go-alert-card.delay {
    border-left-color: var(--delay-color);
}

.go-alert-card.upcoming {
    border-left-color: #009ADE;
}

.alert-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}


/* ==========================================================================
   DISCLAIMER ACCENT — GO green instead of TTC yellow
   ========================================================================== */

.disclaimer-banner strong {
    color: #3B7D2F !important;
}


/* ==========================================================================
   INFO POPUP — GO green accents
   ========================================================================== */

.walkthrough-list li::before {
    color: #3B7D2F;
}

.info-popup-footer {
    color: #3B7D2F;
}


/* ==========================================================================
   SPINNER COLOR — GO green
   ========================================================================== */

.status-spinner {
    border-top-color: #3B7D2F;
}


/* ==========================================================================
   LIGHT MODE OVERRIDES
   ========================================================================== */

body.light-mode .nav-item.active i {
    color: #2D6122;
}

body.light-mode .status-indicator.live .status-text {
    color: #2D6122;
}

body.light-mode .info-popup-footer {
    color: #2D6122;
}

/* Light mode map elements */
body.light-mode .go-capsule {
    fill: #ffffff;
    stroke: #1a1d23;
}

body.light-mode .go-capsule-accessible {
    fill: #4A7BA7;
    stroke: #ffffff;
}

body.light-mode .go-slot-circle {
    fill: #1a1d23;
}

body.light-mode .go-interchange {
    fill: #ffffff;
    stroke: #1a1d23;
}

body.light-mode .go-station-dot {
    fill: #ffffff;
}

body.light-mode .go-label {
    fill: #1f2937;
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 4px;
}

body.light-mode #map-root .station-label {
    fill: #1f2937;
    stroke: rgba(255, 255, 255, 0.6);
}

/* High contrast map overrides */
body.high-contrast .go-capsule {
    fill: #000000;
    stroke: #ffffff;
    stroke-width: 5;
}

body.high-contrast .go-capsule-accessible {
    fill: #0066cc;
    stroke: #ffffff;
    stroke-width: 5;
}

body.high-contrast .go-label {
    stroke-width: 4px;
}

body.high-contrast .svg-alert-pulse.red {
    fill: #ff00ff;
}

body.high-contrast .svg-alert-pulse.yellow {
    fill: #00e5ff;
}

/* ==========================================================================
   GO Settings Row
   ========================================================================== */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-top: 8px;
}

.go-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================================
   BATTERY SAVER MODE (moderate)
   ========================================================================== */
body.battery-saver #vanta-bg {
    display: none;
}

body.battery-saver .flow-forward,
body.battery-saver .flow-reverse,
body.battery-saver .shuttle-outline.flow-forward,
body.battery-saver .shuttle-outline.flow-reverse {
    animation-duration: 2s !important;
}

body.battery-saver .pulse-solid,
body.battery-saver .svg-alert-pulse.red,
body.battery-saver .svg-alert-pulse.yellow,
body.battery-saver .live-dot {
    animation-duration: 4s !important;
}

body.battery-saver .status-spinner {
    animation-duration: 1.6s !important;
}

/* ==========================================================================
   GO MAP ALERT DETAIL (tap segment / station pulse) — floating card like arrivals
   ========================================================================== */
#alert-overlay-card.alert-overlay-card {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: max(72px, calc(72px + env(safe-area-inset-bottom, 0px)));
    width: auto;
    max-width: min(560px, calc(100vw - 16px));
    margin-left: auto;
    margin-right: auto;
    max-height: min(50vh, calc(100vh - 120px));
    max-height: min(50vh, calc(100dvh - 120px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: clamp(10px, 3vw, 14px) clamp(10px, 3.5vw, 16px);
    box-sizing: border-box;
    z-index: 2005;
    border-radius: clamp(10px, 2.5vw, 14px);
    border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.12));
    background: var(--surface-glass, rgba(26, 28, 32, 0.92));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
    gap: clamp(8px, 2vw, 12px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) rgba(255, 255, 255, 0.06);
}

body.go-desktop #alert-overlay-card.alert-overlay-card {
    bottom: max(20px, calc(12px + env(safe-area-inset-bottom, 0px)));
    max-height: min(55vh, calc(100dvh - 40px));
}

#alert-overlay-card.alert-overlay-card::-webkit-scrollbar {
    width: 5px;
}

#alert-overlay-card.alert-overlay-card::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    margin: 6px 0;
}

#alert-overlay-card.alert-overlay-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 100px;
}

body.light-mode #alert-overlay-card.alert-overlay-card {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.06);
}

body.light-mode #alert-overlay-card.alert-overlay-card::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.06);
}

body.light-mode #alert-overlay-card.alert-overlay-card::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   GO ARRIVALS SNACKBAR — route rows + time chips (responsive / all screen sizes)
   ========================================================================== */
#arrivals-snackbar.go-arrivals-snackbar.alert-overlay-card {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: max(72px, calc(72px + env(safe-area-inset-bottom, 0px)));
    width: auto;
    max-width: min(560px, calc(100vw - 16px));
    margin-left: auto;
    margin-right: auto;
    max-height: min(62vh, calc(100vh - 120px));
    max-height: min(62vh, calc(100dvh - 120px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    gap: clamp(6px, 2vw, 10px);
    padding: clamp(10px, 3vw, 14px) clamp(10px, 3.5vw, 16px);
    box-sizing: border-box;
}

.go-arrivals-snackbar__section {
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 1.5vw, 8px);
    width: 100%;
    min-width: 0;
}

.go-arrivals-snackbar__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.go-arrivals-snackbar__station {
    font-size: clamp(13px, 3.8vw, 17px);
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

body.light-mode .go-arrivals-snackbar__station {
    color: #111;
}

/* Loading / empty / error lines inside snackbar */
.go-arrivals-snackbar__placeholder {
    font-size: clamp(11px, 3.2vw, 14px);
    line-height: 1.4;
    color: var(--text-muted, #a0a0a0);
    padding: clamp(4px, 1vw, 8px) 0;
}

body.light-mode .go-arrivals-snackbar__placeholder {
    color: #666;
}

.go-arrivals-snackbar__header .close-btn {
    flex-shrink: 0;
    margin-left: 0;
}

.go-arrivals-snackbar__content {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 2vw, 10px);
    margin-top: clamp(2px, 1vw, 6px);
    width: 100%;
    min-width: 0;
}

#snackbar-arrivals-content.go-arrivals-list {
    gap: clamp(8px, 2.5vw, 12px) !important;
}

.go-arrival-row {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2.2vw, 12px);
    padding: clamp(10px, 2.8vw, 14px) clamp(10px, 3.2vw, 16px);
    border-radius: clamp(10px, 2.5vw, 14px);
    background: var(--surface-glass, rgba(26, 28, 32, 0.75));
    border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.12));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

body.light-mode .go-arrival-row {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.go-arrival-row__head {
    display: flex;
    align-items: flex-start;
    gap: clamp(8px, 2vw, 12px);
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
}

.go-arrival-line-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(26px, 8vw, 32px);
    min-height: clamp(20px, 5.5vw, 24px);
    height: auto;
    padding: clamp(2px, 0.6vw, 4px) clamp(6px, 2vw, 10px);
    border-radius: 6px;
    font-size: clamp(10px, 2.8vw, 12px);
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.go-arrival-direction {
    font-weight: 600;
    font-size: clamp(11px, 3.2vw, 14px);
    line-height: 1.35;
    color: var(--text-main, #e8eaed);
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

body.light-mode .go-arrival-direction {
    color: #1a1a1a;
}

.go-arrival-times {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.75rem), 1fr));
    gap: clamp(6px, 2vw, 12px);
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

/* Very narrow: single column of full-width chips */
@media (max-width: 280px) {
    .go-arrival-times {
        grid-template-columns: 1fr;
    }
}

.go-arrival-time-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: clamp(8px, 2.2vw, 12px) clamp(8px, 2.8vw, 16px);
    border-radius: clamp(10px, 2.2vw, 14px);
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

body.light-mode .go-arrival-time-chip {
    background: #f0f2f5;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.go-arrival-time-chip--due {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

body.light-mode .go-arrival-time-chip--due {
    background: #fee2e2;
    border-color: #ef4444;
}

/* Active service alert: delay / reduced speed on this line & segment */
.go-arrival-time-chip--delay {
    border-color: rgba(245, 158, 11, 0.85);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

body.light-mode .go-arrival-time-chip--delay {
    border-color: #d97706;
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.2);
}

.go-arrival-time-chip--due.go-arrival-time-chip--delay {
    border-color: #ef4444;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.go-arrival-time-chip__delay-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: clamp(4px, 1.2vw, 8px);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: clamp(9px, 2.5vw, 11px);
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #fef3c7;
    background: rgba(245, 158, 11, 0.35);
    border: 1px solid rgba(251, 191, 36, 0.5);
}

.go-arrival-time-chip__delay-pill i {
    font-size: 0.95em;
    opacity: 0.95;
}

body.light-mode .go-arrival-time-chip__delay-pill {
    color: #78350f;
    background: rgba(251, 191, 36, 0.45);
    border-color: rgba(217, 119, 6, 0.45);
}

.go-arrival-time-chip__eta {
    font-size: clamp(14px, 4.2vw, 18px);
    font-weight: 800;
    line-height: 1.15;
    color: #fff;
    letter-spacing: -0.02em;
    text-align: center;
    max-width: 100%;
    overflow-wrap: break-word;
}

body.light-mode .go-arrival-time-chip__eta {
    color: #111;
}

.go-arrival-time-chip--due .go-arrival-time-chip__eta {
    color: #fecaca;
}

body.light-mode .go-arrival-time-chip--due .go-arrival-time-chip__eta {
    color: #b91c1c;
}

.go-arrival-time-chip__clock {
    margin-top: clamp(2px, 0.8vw, 6px);
    font-size: clamp(9px, 2.6vw, 12px);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

body.light-mode .go-arrival-time-chip__clock {
    color: rgba(0, 0, 0, 0.55);
}

.go-arrival-time-chip--due .go-arrival-time-chip__clock {
    color: rgba(254, 202, 202, 0.9);
}

body.light-mode .go-arrival-time-chip--due .go-arrival-time-chip__clock {
    color: #7f1d1d;
}