/* =========================
   BASE
   ========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;

    font-family:
        Inter,
        Arial,
        sans-serif;

    background: #eef1f4;
    color: #1f2328;
}


/* =========================
   PAGE LAYOUT
   ========================= */

main {
    width: min(1400px, calc(100% - 2rem));

    margin: 0 auto;
    padding: 2rem 0 4rem;
}


/* =========================
   DASHBOARD HEADER
   ========================= */

.dashboard-header {
    display: flex;

    justify-content: space-between;
    align-items: flex-end;

    gap: 2rem;

    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;

    border-bottom: 1px solid #d8dde3;
}

.dashboard-header h1 {
    margin: 0;

    font-size: 2rem;
    letter-spacing: -0.03em;
}

.dashboard-header p {
    margin: 0.4rem 0 0;

    color: #68707a;

    font-size: 0.95rem;
}

#train-count {
    padding: 0.5rem 0.75rem;

    background: white;

    border: 1px solid #d8dde3;
    border-radius: 6px;

    color: #4f5863;

    font-size: 0.85rem;
    font-weight: 600;

    white-space: nowrap;
}

.live-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;

    gap: 0.25rem;
}

#last-updated {
    color: #8a929b;

    font-size: 0.7rem;
}

/* =========================
   DASHBOARD LAYOUT
   ========================= */

.dashboard-layout {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        300px;

    gap: 1.25rem;

    align-items: start;
}


/* =========================
   MAP PANEL
   ========================= */

.map-panel {
    padding: 0.75rem;

    background: white;

    border: 1px solid #d8dde3;
    border-radius: 8px;

    box-shadow:
        0 4px 18px
        rgba(0, 0, 0, 0.05);
}

/* =========================
   MAP HEADER
   ========================= */

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 0.65rem;
}

.map-header h2 {
    margin: 0;

    color: #222;

    font-size: 0.95rem;
    font-weight: 700;
}

/* =========================
   LINE FILTER
   ========================= */

.line-filter {
    display: flex;
    flex-wrap: wrap;

    gap: 0.4rem;

    margin-bottom: 0.75rem;
}

.line-filter-btn {
    padding: 0.4rem 0.65rem;

    background: white;

    border: 1px solid #d8dde3;
    border-radius: 5px;

    color: #68707a;

    font-size: 0.72rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.12s ease,
        color 0.12s ease,
        border-color 0.12s ease;
}

.line-filter-btn:hover {
    background: #f4f6f8;

    color: #222;
}

.line-filter-btn.active {
    background: #222;

    border-color: #222;

    color: white;
}

/* =========================
   INFO PANEL
   ========================= */

.info-panel {
    display: flex;
    flex-direction: column;

    gap: 1rem;

    position: sticky;
    top: 1rem;
}

.info-card {
    padding: 1rem;

    background: white;

    border: 1px solid #d8dde3;
    border-radius: 8px;

    box-shadow:
        0 3px 12px
        rgba(0, 0, 0, 0.04);
}

.info-card h2 {
    margin: 0 0 0.75rem;

    font-size: 0.9rem;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.05em;

    color: #3f4750;
}

.info-card p {
    margin: 0;

    color: #68707a;

    font-size: 0.88rem;
    line-height: 1.5;
}

/* =========================
   WEATHER
   ========================= */

.weather-main {
    display: flex;
    align-items: center;

    gap: 0.85rem;

    margin-bottom: 1rem;
}

.weather-temperature {
    font-size: 2.2rem;
    font-weight: 700;

    line-height: 1;
}

.weather-condition {
    font-size: 0.9rem;
    font-weight: 700;

    color: #333;
}

.weather-feels {
    margin-top: 0.2rem;

    color: #8a929b;

    font-size: 0.72rem;
}

.weather-details {
    padding-top: 0.75rem;

    border-top:
        1px solid #e2e6ea;
}

.weather-detail {
    display: flex;

    justify-content: space-between;

    gap: 1rem;

    padding: 0.25rem 0;

    font-size: 0.75rem;
}

.weather-detail span {
    color: #8a929b;
}

.weather-detail strong {
    color: #333;

    font-weight: 700;
}

.weather-error {
    color: #68707a;

    font-size: 0.85rem;
}

.weather-source {
    margin-top: 0.75rem;

    color: #999;

    font-size: 0.6rem;
}

.weather-source a {
    color: inherit;
}

/* =========================
   SYSTEM OVERVIEW
   ========================= */

.system-total {
    display: flex;
    align-items: baseline;

    gap: 0.35rem;

    margin-bottom: 1rem;
}

.system-total-number {
    font-size: 1.8rem;
    font-weight: 700;

    line-height: 1;

    color: #222;
}

.system-total-label {
    color: #8a929b;

    font-size: 0.75rem;
}

.system-lines {
    padding: 0.75rem 0;

    border-top: 1px solid #e2e6ea;
    border-bottom: 1px solid #e2e6ea;
}

.system-line-row {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 1rem;

    padding: 0.4rem 0.35rem;

    border-radius: 4px;

    font-size: 0.78rem;

    cursor: pointer;

    transition:
        background 0.12s ease;
}

.system-line-row:hover {
    background: #f4f6f8;
}

.system-line-row.active {
    background: #eef1f4;
}

.system-line-name {
    display: flex;
    align-items: center;

    gap: 0.45rem;

    color: #4f5863;
}

.system-line-dot {
    width: 8px;
    height: 8px;

    flex-shrink: 0;

    border-radius: 50%;
}

.system-line-row strong {
    color: #222;

    font-size: 0.78rem;
}

.system-status {
    display: flex;
    flex-direction: column;

    gap: 0.35rem;

    margin-top: 0.75rem;

    color: #68707a;

    font-size: 0.7rem;
}

.system-status > div {
    display: flex;
    align-items: center;

    gap: 0.4rem;
}

.status-indicator {
    width: 6px;
    height: 6px;

    flex-shrink: 0;

    border-radius: 50%;
}

.status-indicator.normal {
    background: #137333;
}

.status-indicator.delayed {
    background: #c5221f;
}

/* =========================
   STATION DETAILS
   ========================= */

.selected-station-name {
    margin-bottom: 0.75rem;

    font-size: 1.15rem;
    font-weight: 700;

    color: #222;
}

.selected-station-lines {
    display: flex;
    flex-wrap: wrap;

    gap: 0.4rem;

    margin-bottom: 1rem;
}

.station-line-badge {
    display: inline-flex;
    align-items: center;

    padding: 0.3rem 0.5rem;

    background:
        color-mix(
            in srgb,
            var(--line-color) 12%,
            white
        );

    border-left:
        4px solid
        var(--line-color);

    border-radius: 4px;

    font-size: 0.75rem;
    font-weight: 700;
}

.station-arrivals {
    padding-top: 0.75rem;

    border-top:
        1px solid #e2e6ea;
}

.arrival-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 1rem;

    padding: 0.65rem 0;

    border-bottom:
        1px solid #eef1f4;
}

.arrival-row:last-child {
    border-bottom: 0;
}

.arrival-destination {
    font-size: 0.85rem;
    font-weight: 700;
}

.arrival-run {
    display: block;

    margin-top: 0.15rem;

    color: #8a929b;

    font-size: 0.65rem;
    font-weight: 500;
}

.arrival-eta {
    flex-shrink: 0;

    font-size: 0.8rem;
    font-weight: 700;
}

.arrival-eta.delayed {
    color: #c5221f;
}

.arrival-empty,
.arrival-error {
    color: #68707a;

    font-size: 0.85rem;
}

.arrival-group {
    padding: 0.8rem 0;

    border-bottom: 1px solid #e2e6ea;
}

.arrival-group:first-child {
    padding-top: 0;
}

.arrival-group:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.arrival-group-title {
    margin-bottom: 0.35rem;

    color: #68707a;

    font-size: 0.7rem;
    font-weight: 700;

    letter-spacing: 0.05em;
    text-transform: uppercase;
}


/* =========================
   TRANSIT MAP
   ========================= */

#train-list {
    position: relative;

    width: 100%;
    height: 1400px;

    margin-top: 0;

    background: #f8fafb;

    border: 1px solid #e2e6ea;
    border-radius: 5px;

    overflow: hidden;
}

/* =========================
   MAP BACKGROUND
   ========================= */

.map-background-svg {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    pointer-events: none;

    z-index: 0;
}

.map-grid-line.minor {
    stroke: #dfe4e8;
    stroke-width: 1;
    opacity: 0.12;
}

.map-grid-line.major {
    stroke: #cfd6dc;
    stroke-width: 1;
    opacity: 0.3;
}

.lake-michigan {
    fill: #e5f1f7;
    opacity: 0.9;
}

.lake-shoreline {
    fill: none;
    stroke: #b8d0dc;
    stroke-width: 2;
    opacity: 0.8;
}

.lake-label {
    fill: #9cafba;

    font-size: 0.7rem;
    font-weight: 600;

    letter-spacing: 0.08em;

    text-transform: uppercase;
}


/* =========================
   ROUTES
   ========================= */

.route-svg {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    pointer-events: none;
    z-index: 1;
}

.route-line {
    fill: none;

    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* =========================
   STATIONS
   ========================= */

.map-station {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -50%);
    padding: 5px;
    cursor: pointer;
}

.station-dot {
    width: 8px;
    height: 8px;

    background: white;

    border: 2px solid #333;
    border-radius: 50%;
}

.selected-station .station-dot {
    box-shadow:
        0 0 0 3px
        rgba(0, 0, 0, 0.12);
}

/* =========================
   STATION TOOLTIP
   ========================= */

.station-name {
    position: absolute;

    left: 50%;
    bottom: 16px;

    padding: 0.3rem 0.45rem;

    background: white;

    border: 1px solid #ddd;
    border-radius: 4px;

    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);

    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;

    white-space: nowrap;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transform: translateX(-50%);

    transition:
        opacity 0.12s ease,
        visibility 0.12s ease;

    z-index: 30;
}

.map-station:hover .station-name {
    opacity: 1;
    visibility: visible;
}

/* =========================
   DOWNTOWN STATIONS OVERRIDES
   ========================= */

.downtown-station .station-name {
    padding: 0.25rem 0.4rem;
}

.downtown-station.label-right .station-name,
.downtown-station.label-top .station-name,
.downtown-station.label-diagonal .station-name {
    left: 50%;
    top: auto;
    bottom: 16px;

    text-align: center;

    transform: translateX(-50%) rotate(0deg);

    transform-origin: center;
}

/* =========================
   LOOP STATIONS OVERRIDES
   ========================= */

.loop-station {
    z-index: 10;
}

.loop-station::before {
    content: "";

    position: absolute;

    left: 50%;
    top: 50%;

    width: 14px;
    height: 14px;

    background: transparent;

    border-radius: 50%;

    pointer-events: auto;

    transform: translate(-50%, -50%);
}

.loop-station .station-dot {
    position: relative;
    width: 6px;
    height: 6px;
    z-index: 2;
}

.loop-station.transfer-station .station-dot {
    width: 7px;
    height: 7px;
    border-width: 2px;
}

/* =============================
   DOWNTOWN HOVER PRIORITY
   ============================= */

/*
 * Keep Red/Blue downtown stations above
 * the enlarged Loop hover targets.
 */
.downtown-station:not(.loop-station) {
    z-index: 12;
}

.priority-loop-station {
    z-index: 14;
}

/* =========================
   LIVE TRAINS
   ========================= */

.train-marker {
    position: absolute;

    z-index: 20;

    transform: translate(-50%, -50%);

    cursor: pointer;
}

.train-marker:hover {
    z-index: 100;
}

.train-direction {
    font-size: 0.9rem;
    line-height: 1;

    transform-origin: center;

    filter:
        drop-shadow(
            0 1px 1px
            rgba(0, 0, 0, 0.35)
        );
}


/* =========================
   TRAIN TOOLTIPS
   ========================= */

.train-tooltip {
    position: absolute;

    top: 50%;

    width: 210px;

    padding: 0.8rem;

    background: white;

    border: 1px solid #d8dde3;
    border-left: 4px solid var(--train-color);

    border-radius: 7px;

    box-shadow:
        0 6px 18px
        rgba(0, 0, 0, 0.14);

    color: #444;

    opacity: 0;
    visibility: hidden;

    pointer-events: auto;

    transform: translateY(-50%);

    transition:
        opacity 0.12s ease,
        visibility 0.12s ease;

    z-index: 30;
}

.train-marker.tooltip-right .train-tooltip {
    left: calc(100% + 10px);
    right: auto;
}

.train-marker.tooltip-left .train-tooltip {
    right: calc(100% + 10px);
    left: auto;
}

.train-marker.tooltip-below .train-tooltip {
    top: calc(100% + 10px);
    bottom: auto;

    transform: none;
}

.train-marker.tooltip-above .train-tooltip {
    top: auto;
    bottom: calc(100% + 10px);

    transform: none;
}

.train-tooltip-header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 0.75rem;

    margin-bottom: 0.6rem;
}

.train-line {
    font-size: 0.72rem;
    font-weight: 800;

    letter-spacing: 0.04em;
    text-transform: uppercase;

    color: var(--train-color);
}

.train-run {
    color: #8a929b;

    font-size: 0.65rem;
    font-weight: 600;
}

.train-tooltip-destination {
    margin-bottom: 0.7rem;

    font-size: 0.95rem;
    font-weight: 700;

    color: #222;
}

.train-tooltip-row {
    display: flex;

    justify-content: space-between;

    gap: 1rem;

    padding: 0.3rem 0;

    font-size: 0.75rem;
}

.train-tooltip-row span {
    color: #8a929b;
}

.train-tooltip-row strong {
    color: #333;

    font-weight: 700;
}

.train-marker:hover .train-tooltip {
    opacity: 1;
    visibility: visible;
}

.tooltip-status {
    margin-top: 0.25rem;

    font-weight: 700;
}

.tooltip-status.delayed {
    color: #c5221f;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 900px) {
    .dashboard-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .live-status {
        align-items: flex-start;
    }

    .info-panel {
        position: static;

        display: grid;

        grid-template-columns:
            repeat(
                auto-fit,
                minmax(220px, 1fr)
            );
    }
}

@media (max-width: 600px) {
    main {
        width: calc(100% - 1rem);
    }

    .map-panel {
        padding: 0.5rem;
    }
}