/* ==================== REACHABILITY PAGE (reachability.html) ====================
   Full-bleed Leaflet map + a left panel for starting location (search/click/drag) and a travel
   time slider. The reachable area itself is computed server-side (netlify/functions/
   reachability.js) and rendered here as a plain GeoJSON layer. Mirrors live.css's structural
   conventions (panel sizing, search-suggestions dropdown) for visual consistency across pages.
*/

body.reach-page, body.reach-page #app {
    height: 100%;
    width: 100%;
    margin: 0;
    overflow: hidden;
}

.reach-page .map-container {
    height: 100%;
    width: 100%;
    background: #0f1117;
}

.reach-page #reachMap {
    height: 100%;
    width: 100%;
}

/* ---------- Left panel ---------- */
.reach-page-sidebar {
    width: 300px;
}

.reach-page-sidebar .panel-content {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

/* ---------- Location search ---------- */
.reach-location-search {
    position: relative;
    display: flex;
    align-items: center;
}

.reach-search-icon {
    position: absolute;
    left: var(--space-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.reach-location-search .filter-input {
    padding-left: 34px;
}

.reach-search-suggestions {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: var(--z-dropdown);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.reach-search-suggestions.open {
    display: block;
}

.reach-search-suggestion {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.reach-search-suggestion:hover {
    background: var(--bg-tertiary);
}

.reach-search-suggestion i {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.reach-search-empty {
    padding: var(--space-sm) var(--space-md);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.reach-location-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.reach-location-hint i {
    flex-shrink: 0;
}

.reach-selected-location {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.reach-selected-location i {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.reach-selected-location span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Time slider -- the panel's one deliberately oversized moment: a departure-board-style
   numeral (Overpass, the same highway-signage face the nav brand uses), since this single value is
   what actually drives the whole map underneath it. ---------- */
.reach-time-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: var(--space-sm);
}

.reach-time-num {
    font-family: var(--font-display);
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--accent-primary);
}

.reach-time-unit {
    font-size: 0.95rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
}

.reach-time-slider {
    width: 100%;
    accent-color: var(--accent-primary);
    height: 28px;
    cursor: pointer;
}

.reach-time-slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: -4px;
}

/* ---------- Mode display (mobile drawer only -- non-interactive, transit is the only option) ---------- */
.reach-mode-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-sm) var(--space-md);
    background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
}

.reach-mode-display i {
    color: var(--accent-primary);
    font-size: 1.1rem;
}

/* ---------- View toggle (Combined / Walking only / Transit only) -- a vertical, icon-led list
   rather than a 3-way horizontal pill switch: at this panel's ~270px content width, three pills
   sharing one row left "Combined"/"Walking only"/"Transit only" cramped against each other with no
   breathing room (and wrapped mid-word on the mobile drawer's narrower card). Stacking them gives
   each option its own full-width row -- room for an icon, clearer tap target, no wrapping. ---------- */
.reach-view-toggle {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reach-view-toggle-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: var(--font-weight-medium);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.reach-view-toggle-option i {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.reach-view-toggle-option:hover:not(.active) {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.reach-view-toggle-option.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.reach-view-toggle-option.active i {
    color: #fff;
}

/* ---------- Legend ---------- */
.reach-legend {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.reach-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.reach-legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.reach-legend-swatch-pin {
    border-radius: 50%;
    background: var(--accent-primary);
    border: 1.5px solid #fff;
}

.reach-legend-swatch-transit {
    height: 6px;
    border-radius: 3px;
    align-self: center;
    /* Dark-theme pair by default (matches :root's dark-theme-default convention) -- mirrors
       REACH_TRANSIT_COLORS.dark in reachabilityController.js. */
    background: linear-gradient(to right, #e0aaff, #a05ad6);
}

[data-theme="light"] .reach-legend-swatch-transit {
    /* Mirrors REACH_TRANSIT_COLORS.light -- the dark pair above is too washed out against a light
       panel background to read as a gradient. */
    background: linear-gradient(to right, #b185db, #4a148c);
}

.reach-legend-swatch-walk {
    height: 6px;
    border-radius: 3px;
    align-self: center;
    /* Mirrors the walking isochrone's ramp (minutes-to-reach) -- see REACH_WALK_GRADIENT_STOPS in
       reachabilityController.js. */
    background: linear-gradient(to right, #5b8c5a, #9caf50, #d4a017, #c87f32, #b33f3f);
}

/* ---------- Floating legend (bottom-right, over the map -- desktop only; mirrors the Map page's
   own .legend-overlay card convention for consistency across the site) ---------- */
.reach-legend-overlay {
    position: absolute;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-fixed);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.reach-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reach-legend-row i {
    width: 14px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.reach-legend-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
}

.reach-legend-bar-transit {
    /* Dark-theme pair by default (matches :root's dark-theme-default convention) -- mirrors
       REACH_TRANSIT_COLORS.dark in reachabilityController.js. */
    background: linear-gradient(to right, #e0aaff, #a05ad6);
}

[data-theme="light"] .reach-legend-bar-transit {
    /* Mirrors REACH_TRANSIT_COLORS.light -- the dark pair above is too washed out against a light
       panel background to read as a gradient. */
    background: linear-gradient(to right, #b185db, #4a148c);
}

.reach-legend-bar-walk {
    /* Mirrors the walking isochrone's muted green -> olive -> goldenrod -> ochre -> brick-red ramp
       (minutes-to-reach) -- see REACH_WALK_GRADIENT_STOPS in reachabilityController.js, which in
       turn mirrors mapVisualizer.js's SEVERITY_GRADIENT_STOPS (same ramp used sitewide now). */
    background: linear-gradient(to right, #5b8c5a, #9caf50, #d4a017, #c87f32, #b33f3f);
}

.reach-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-left: 22px; /* aligns under the gradient bars, past the icon column */
}

body.mobile-active .reach-legend-overlay {
    display: none;
}

.reach-approximation-note {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.74rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.reach-info-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.74rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}

.reach-info-link:hover {
    text-decoration: underline;
}

/* ---------- "How is this calculated?" modal -- reuses components.css's shared .modal-* classes,
   this file just styles the body copy ---------- */
.reach-methodology-content {
    max-width: 560px;
}

.reach-methodology-content p {
    margin: 0 0 var(--space-md);
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.reach-methodology-content p:last-child {
    margin-bottom: 0;
}

.reach-methodology-content strong {
    color: var(--text-primary);
}

.reach-approximation-note i {
    color: var(--text-muted);
    margin-right: 4px;
}

/* ---------- Starting-location marker ---------- */
.reach-start-marker {
    background: none;
    border: none;
}

.reach-start-marker-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--accent-primary);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.85rem;
}

.reach-start-marker-dot i {
    transform: rotate(45deg);
}

/* ---------- Loading / empty-state overlays ---------- */
.reach-loading {
    position: absolute;
    top: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-fixed);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.reach-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: reach-spin 0.7s linear infinite;
}

@keyframes reach-spin {
    to { transform: rotate(360deg); }
}

.reach-empty-state {
    position: absolute;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-fixed);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100vw - 2 * var(--space-lg)));
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-warning);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.reach-empty-state i {
    color: var(--accent-warning);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .reach-page .leaflet-control-zoom {
        display: none;
    }
}

body.mobile-active .reach-page-sidebar {
    display: none;
}

/* ---------- Mobile hint row (js/reachabilityMobile.js) ---------- */
.reach-mobile-hint-row {
    height: auto;
    pointer-events: none;
}

.reach-mobile-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(var(--bg-secondary-rgb), 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg);
}

/* ---------- Persistent travel-time row, right under the tab row (js/reachabilityMobile.js) --
   moved out of the settings drawer so changing the single most common value on this page doesn't
   need an extra tap to open anything first. ---------- */
.reach-mobile-time-row {
    height: auto;
}

.reach-mobile-time-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    padding: 0 14px;
}

.reach-mobile-time-value {
    font-weight: var(--font-weight-semibold);
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 44px;
}

.reach-mobile-time-tile .reach-time-slider {
    flex: 1;
    height: 100%;
}

/* ---------- Bottom-right legend toggle + popover (js/reachabilityMobile.js) -- own classes
   (not js/mobile.js's shared .mobile-legend-toggle/.mobile-legend-panel) so a future change to the
   Map page's mobile legend can't accidentally move or restyle this one. Content mirrors
   #reachLegendOverlay (the desktop floating legend) exactly, via the same .reach-legend-bar-*
   classes, so the two can't drift out of sync. ---------- */
.reach-mobile-legend-toggle {
    position: absolute;
    bottom: 22px;
    right: 15px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-lg);
    -webkit-tap-highlight-color: transparent;
}

.reach-mobile-legend-toggle i {
    pointer-events: none;
}

.reach-mobile-legend-panel {
    position: absolute;
    bottom: 64px;
    right: 15px;
    width: min(220px, 60vw);
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
    z-index: var(--z-fixed);
}

.reach-mobile-legend-panel.visible {
    display: flex;
}

@supports (padding: max(0px)) {
    .reach-mobile-legend-toggle {
        bottom: max(22px, env(safe-area-inset-bottom));
        right: max(15px, env(safe-area-inset-right));
    }
    .reach-mobile-legend-panel {
        bottom: max(64px, env(safe-area-inset-bottom) + 42px);
        right: max(15px, env(safe-area-inset-right));
    }
}
