/* ============================================================
   Canadian Commute Explorer — UI styles
   ============================================================ */

:root {
    --accent-transit: #ff894d;
    --accent-transit-soft: #ffe6d6;
    --accent-auto: #4d86cc;
    --accent-auto-soft: #dceafa;
    --ink: #1f2933;
    --ink-soft: #5a6672;
    --ink-faint: #8a95a1;
    --card-radius: 16px;
    --page-bg: #f4f6f9;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.12);
}

body {
    background: var(--page-bg);
}

/* ---- Root container: centers content & caps width on large screens ---- */
.app-root-container {
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1rem, 2.5vw, 2.25rem) clamp(1.5rem, 5vw, 3.5rem) 3rem;
    display: flex;
    flex-direction: column;
    gap: clamp(0.7rem, 1.4vw, 1.1rem);
}

/* ---- Title / intro banner ---- */
.app-header {
    background: linear-gradient(120deg, #ffffff 0%, #fbfcfe 100%);
    border: 1px solid #e8ecf1;
    border-radius: var(--card-radius);
    padding: clamp(1.1rem, 2.2vw, 1.6rem) clamp(1.25rem, 2.5vw, 1.9rem);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-auto), var(--accent-transit));
}

.app-title-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.app-title-icon {
    color: var(--accent-auto);
    flex-shrink: 0;
}

.app-title {
    margin: 0;
    font-size: clamp(1.35rem, 2.6vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.1;
}

.app-subtitle {
    margin: 0.35rem 0 0 0;
    font-size: clamp(0.82rem, 1.4vw, 0.95rem);
    color: var(--ink-soft);
    line-height: 1.45;
}

/* let the text block take the full width beside the icon */
.app-title-row > div:last-child {
    flex: 1;
}

/* ---- Controls card ---- */
.controls-card {
    padding: clamp(1rem, 2vw, 1.35rem) clamp(1.1rem, 2.2vw, 1.5rem);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

/* ---- Key-stats section header ---- */
.key-stats-header-container {
    padding: 0;
}

.key-stats-card-header {
    font-size: clamp(1rem, 1.9vw, 1.25rem);
    font-weight: 750;
    letter-spacing: -0.01em;
    color: var(--ink);
    padding-left: 0.9rem;
    border-left: 4px solid var(--accent-transit);
    line-height: 1.25;
}

/* ============================================================
   KPI cards
   ============================================================ */
.transit-mode-header-cell {
    /* keep the Grid gutter's horizontal padding so cards have x-axis gaps */
    margin-bottom: 0;
}

.transit-mode-header-inner.kpi-card {
    border-radius: var(--card-radius);
    padding: 1.05rem 1.15rem 1.1rem;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    background: #ffffff;
    border: 1px solid #e8ecf1;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
    overflow: hidden;
    filter: none; /* override legacy drop-shadow */
}

.transit-mode-header-inner.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.kpi-transit::before { background: var(--accent-transit); }
.kpi-auto::before    { background: var(--accent-auto); }

.transit-mode-header-inner.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* Pill badge */
.kpi-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    width: fit-content;
}

.kpi-transit .kpi-pill { background: var(--accent-transit-soft); color: #c4521d; }
.kpi-auto .kpi-pill    { background: var(--accent-auto-soft);    color: #2c5a96; }

.kpi-pill-icon { flex-shrink: 0; }
.kpi-pill-label { white-space: nowrap; }

/* Headline number */
.kpi-value {
    margin: 0;
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.kpi-transit .kpi-value { color: var(--accent-transit); }
.kpi-auto .kpi-value    { color: var(--accent-auto); }

/* Supporting copy */
.kpi-sub {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--ink-faint);
    line-height: 1.35;
    margin: 0;
}

/* ============================================================
   Map + legend
   ============================================================ */
.dash-leaflet-main-map {
    filter: none;
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.dash-leaflet-map-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.1rem;
    background: #ffffff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    padding: 0.7rem 1rem;
    box-shadow: var(--shadow-sm);
}

.map-legend-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink);
}

.map-legend-scale {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 180px;
}

.map-legend-swatches {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.map-legend-swatch {
    flex: 1;
}

.map-legend-labels {
    display: flex;
    justify-content: space-between;
}

.map-legend-end {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--ink-faint);
}

.map-legend-hint {
    font-size: 0.72rem;
    color: var(--ink-soft);
    font-style: italic;
    margin-left: auto;
}

/* ============================================================
   Census-tract hover tooltip
   ============================================================ */
.leaflet-tooltip.ct-tooltip {
    background: #ffffff;
    border: 1px solid #e3e8ee;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.7rem 0.85rem;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.leaflet-tooltip.ct-tooltip::before {
    border-top-color: #ffffff;
}

.ct-tt-title {
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: -0.01em;
    margin-bottom: 0.1rem;
}

.ct-tt-sub {
    font-size: 0.7rem;
    color: var(--ink-faint);
    margin-bottom: 0.5rem;
}

.ct-tt-sub b { color: var(--ink); }

.ct-tt-rows {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.ct-tt-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.74rem;
}

.ct-tt-label {
    display: flex;
    align-items: center;
    color: var(--ink-soft);
}

.ct-tt-icon {
    display: inline-block;
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.ct-tt-val {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ct-tt-pct {
    color: var(--ink-faint);
    font-weight: 500;
}

/* ============================================================
   Responsive tuning
   ============================================================ */
@media (max-width: 640px) {
    .app-title-row {
        align-items: flex-start;
    }
    .map-legend-hint {
        margin-left: 0;
        flex-basis: 100%;
    }
    .dash-leaflet-main-map {
        height: 52vh !important;
    }
}
