/* ============================================================================
   Lynn Data Dive — Maps page styles
   Layered on top of the global maxwellhowegis.com style.css
   ============================================================================ */

:root {
    --lehs-navy: #0A1F44;
    --lehs-gold: #FFB81C;
    --panel-bg: rgba(255, 255, 255, 0.96);
    --panel-border: rgba(10, 31, 68, 0.08);
    --panel-shadow: 0 2px 16px rgba(10, 31, 68, 0.12);
    --legend-bg: rgba(255, 255, 255, 0.95);
    --nav-height: 64px;
    --panel-width: 320px;
}

/* The maps page is full-bleed below the site nav */
body.maps-page {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fafafa;
    font-family: 'Inter', sans-serif;
}

.maps-main {
    position: relative;
    height: calc(100vh - var(--nav-height));
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ============================================================================
   Map container — fills the entire viewport below nav
   ============================================================================ */
.map-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* MapLibre attribution: tuck into bottom-left, away from legend */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.85);
    font-size: 10px;
}
.maplibregl-ctrl-bottom-right {
    bottom: 110px !important;  /* lift above legend */
    right: 12px !important;
}
.maplibregl-ctrl-bottom-left {
    left: calc(var(--panel-width) + 16px);
}
@media (max-width: 768px) {
    .maplibregl-ctrl-bottom-left { left: 12px; }
}

/* ============================================================================
   Control panel (left side) — collapsible
   ============================================================================ */
.control-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    width: var(--panel-width);
    max-height: calc(100vh - var(--nav-height) - 24px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: var(--panel-shadow);
    z-index: 10;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.25s ease;
}
.control-panel.collapsed {
    transform: translateX(calc(-1 * var(--panel-width) - 24px));
}
.control-panel.collapsed .panel-toggle {
    transform: translateX(calc(var(--panel-width) + 12px));
}

.panel-toggle {
    position: absolute;
    top: 16px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    transition: transform 0.25s ease, background 0.15s;
}
.panel-toggle:hover { background: rgba(10, 31, 68, 0.06); }
.panel-toggle span {
    display: block;
    width: 14px;
    height: 2px;
    background: var(--lehs-navy);
    margin: 3px auto;
}

.panel-section {
    padding: 16px 18px;
    border-bottom: 1px solid var(--panel-border);
}
.panel-section:last-child {
    border-bottom: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.panel-header .section-label {
    color: var(--lehs-navy);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.65;
}
.back-link {
    font-size: 11px;
    color: var(--lehs-navy);
    text-decoration: none;
    opacity: 0.7;
}
.back-link:hover { opacity: 1; text-decoration: underline; }

.panel-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--lehs-navy);
    margin: 4px 0 8px;
    letter-spacing: -0.3px;
}
.panel-desc {
    font-size: 13px;
    color: #455A64;
    line-height: 1.5;
    margin: 0;
}

.panel-h2 {
    font-size: 11px;
    font-weight: 600;
    color: var(--lehs-navy);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 0 0 10px;
}

/* Quick view buttons */
.view-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.view-btn {
    flex: 1 1 auto;
    min-width: 70px;
    padding: 7px 10px;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    background: white;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--lehs-navy);
}
.view-btn:hover {
    background: rgba(255, 184, 28, 0.1);
    border-color: var(--lehs-gold);
}
.view-btn.active {
    background: var(--lehs-navy);
    color: white;
    border-color: var(--lehs-navy);
}

/* Layer rows */
.layer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--lehs-navy);
}
.layer-row input[type="checkbox"] {
    accent-color: var(--lehs-navy);
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}
.layer-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}
.swatch-schools         { background: var(--lehs-gold); border-radius: 50%; }
.swatch-gateway         { background: rgba(156, 39, 176, 0.25); border: 2px solid #6a1b9a; }
.swatch-muni-outline    { background: transparent; border: 1.5px solid #78909c; }
.swatch-academic-outline{ background: transparent; border: 1.8px solid #1a3a6b; }
.swatch-voctech-overlay { background: rgba(106, 27, 154, 0.15); border: 1.5px dashed #6a1b9a; }
.swatch-charter-overlay { background: rgba(0, 137, 123, 0.15); border: 1.3px dotted #00695C; }
.swatch-ma-schools      { background: #1976D2; border-radius: 50%; }
.swatch-lynn            { background: rgba(255, 184, 28, 0.3); border: 2px solid var(--lehs-navy); }

/* Form labels for select inputs */
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--lehs-navy);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Radio group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}
.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--lehs-navy);
    cursor: pointer;
    padding: 2px 0;
}
.radio-group input[type="radio"] {
    accent-color: var(--lehs-navy);
    width: 13px;
    height: 13px;
    margin: 0;
}

/* Year slider + play button */
.year-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.year-play {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--lehs-navy);
    color: var(--lehs-gold);
    border: none;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.year-play:hover  { background: #1a3a6b; transform: scale(1.05); }
.year-play.playing{ background: var(--lehs-gold); color: var(--lehs-navy); }
.year-slider {
    flex: 1;
    accent-color: var(--lehs-navy);
}
.year-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--lehs-navy);
    min-width: 40px;
    text-align: right;
}
.year-note {
    margin-top: 6px;
    font-size: 10px;
    font-style: italic;
    color: #90A4AE;
    line-height: 1.4;
}

/* Metric summary below choropleth section */
.metric-summary {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(10, 31, 68, 0.04);
    border-radius: 6px;
    font-size: 11px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}
.summary-row strong { color: var(--lehs-navy); }
.summary-row span:first-child { color: #607D8B; }

/* Classed legend rows */
.legend-class {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    font-size: 11px;
}
.legend-class-swatch {
    width: 22px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.legend-class-range { color: var(--lehs-navy); }

.legend-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--panel-border);
    font-size: 10px;
    color: #607D8B;
}

/* "No data" swatch in legend meta */
.legend-null {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-null-swatch {
    display: inline-block;
    width: 18px;
    height: 12px;
    background: #f0eee8;
    border: 1px solid #c0b8aa;
    border-radius: 2px;
    flex-shrink: 0;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(180, 168, 140, 0.45) 3px,
        rgba(180, 168, 140, 0.45) 4px
    );
}
.legend-null strong { color: var(--lehs-navy); }

/* Mini histogram in the legend */
.hist {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 32px;
    margin-bottom: 8px;
    padding: 2px 0;
    border-bottom: 1px solid var(--panel-border);
}
.hist-bar {
    flex: 1;
    min-height: 2px;
    border-radius: 1px 1px 0 0;
    opacity: 0.95;
}

/* Bivariate (3×3) legend grid */
.bivar-wrap {
    display: grid;
    grid-template-columns: 14px 1fr;
    grid-template-rows: 1fr 14px;
    grid-template-areas: "ylab grid" ". xlab";
    gap: 4px;
    max-width: 200px;
    margin: 4px 0 8px;
}
.bivar-ylabel {
    grid-area: ylab;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 10px;
    color: var(--lehs-navy);
    text-align: center;
    line-height: 14px;
    letter-spacing: 0.02em;
}
.bivar-xlabel {
    grid-area: xlab;
    font-size: 10px;
    color: var(--lehs-navy);
    text-align: center;
    letter-spacing: 0.02em;
}
.bivar-grid {
    grid-area: grid;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 84px;
    height: 84px;
    gap: 1px;
    border: 1px solid #ddd;
}
.bivar-cell {
    display: block;
    width: 100%;
    height: 100%;
}
.bivar-cuts {
    font-size: 10.5px;
    color: var(--lehs-navy);
    line-height: 1.4;
    margin-top: 6px;
}
.bivar-cuts b { font-weight: 600; }

/* ============================================================================
   Help button + modal (controls hint)
   ============================================================================ */
.help-button {
    position: absolute;
    bottom: 28px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--lehs-navy);
    color: var(--lehs-gold);
    border: none;
    box-shadow: 0 3px 12px rgba(10, 31, 68, 0.35);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 20px;
    z-index: 40;
    transition: transform 0.15s, box-shadow 0.15s;
}
.help-button:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 18px rgba(10, 31, 68, 0.45);
}

.help-modal {
    position: absolute;
    inset: 0;
    background: rgba(10, 31, 68, 0.55);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.help-modal.open { display: flex; }

.help-modal-inner {
    position: relative;
    max-width: 460px;
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 28px 32px 24px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    font-family: 'Inter', sans-serif;
    color: var(--lehs-navy);
}
.help-modal-inner h2 {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 600;
}
.help-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: #607D8B;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}
.help-modal-close:hover { color: var(--lehs-navy); }

.help-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 14px;
    margin-top: 4px;
    font-size: 13px;
}
.help-section strong {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #607D8B;
}
.help-section .help-row { margin-bottom: 6px; }

.help-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.help-key {
    display: inline-block;
    min-width: 130px;
    padding: 4px 10px;
    background: #F0F4F8;
    border: 1px solid #d0d8e0;
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--lehs-navy);
    text-align: center;
    box-shadow: 0 1px 0 #d0d8e0;
}
.help-footer {
    margin-top: 18px;
    text-align: right;
}
.help-got-it {
    padding: 8px 22px;
    background: var(--lehs-navy);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.help-got-it:hover { background: #1a3a6b; }

/* PNG export button */
.export-png-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 9px 14px;
    background: white;
    color: var(--lehs-navy);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.export-png-btn:hover {
    background: var(--lehs-navy);
    color: white;
    border-color: var(--lehs-navy);
}

/* ============================================================================
   Map container
   ============================================================================ */
.maps-wrap {
    position: absolute;
    inset: 0;
}

.export-csv-btn {
    width: 100%;
    padding: 9px 12px;
    background: var(--lehs-navy);
    color: var(--lehs-gold);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.export-csv-btn:hover { background: #1a3a6b; }
.export-csv-btn:active { transform: translateY(1px); }

/* Hover tooltip floating over the map */
.map-tooltip {
    position: absolute;
    display: none;
    pointer-events: none;
    background: var(--lehs-navy);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    z-index: 50;
    max-width: 280px;
}
.tooltip-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}
.tooltip-value {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
}
.tooltip-value strong { color: var(--lehs-gold); font-weight: 600; }

/* ============================================================================
   Right side feature-detail panel (sticky on click)
   ============================================================================ */
.feature-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 360px;
    max-height: calc(100vh - var(--nav-height) - 24px);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: var(--panel-shadow);
    z-index: 8;
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}
.feature-panel.open {
    display: flex;
}

.feature-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--panel-border);
    background: var(--lehs-navy);
    color: white;
    border-radius: 10px 10px 0 0;
}
.feature-panel-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.feature-panel-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    opacity: 0.8;
}
.feature-panel-close:hover { opacity: 1; }

.feature-panel-body {
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1;
}
.feature-panel-tag {
    display: inline-block;
    padding: 3px 9px;
    background: rgba(255, 184, 28, 0.18);
    color: var(--lehs-navy);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
    text-transform: uppercase;
}
.feature-panel-section {
    padding: 10px 0;
    border-top: 1px solid var(--panel-border);
}
.feature-panel-section:first-child { border-top: none; }
.feature-panel-section h3 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--lehs-navy);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.85;
}
.feature-panel-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12px;
}
.feature-panel-row .label { color: #607D8B; }
.feature-panel-row .value { color: var(--lehs-navy); font-weight: 500; }
.feature-panel-row .value.highlight {
    background: rgba(255, 184, 28, 0.25);
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .feature-panel {
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 45vh;
    }
}

.layer-name { flex: 1; }

/* Toggle rows (visual mode) */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--lehs-navy);
}
.toggle-row input[type="checkbox"] {
    accent-color: var(--lehs-navy);
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

/* Variable selectors */
.select-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    background: white;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--lehs-navy);
    cursor: pointer;
}
.select-input:focus {
    outline: none;
    border-color: var(--lehs-navy);
}

/* Footer attribution */
.panel-footer { padding-top: 10px; }
.attribution {
    font-size: 10px;
    color: #607D8B;
    line-height: 1.6;
}
.attribution strong { color: var(--lehs-navy); }
.attribution a { color: var(--lehs-navy); }

/* ============================================================================
   Legend (bottom-right floating)
   ============================================================================ */
.legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    min-width: 200px;
    max-width: 280px;
    padding: 12px 14px;
    background: var(--legend-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    z-index: 5;
    font-size: 12px;
    color: var(--lehs-navy);
    backdrop-filter: blur(8px);
}
.legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 13px;
}
.legend-stops {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.legend-bar {
    display: flex;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.legend-bar-stop {
    flex: 1;
}
.legend-axis {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #607D8B;
}

/* ============================================================================
   Loading overlay
   ============================================================================ */
.map-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    padding: 24px 36px;
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    text-align: center;
    color: var(--lehs-navy);
    z-index: 100;
    font-size: 13px;
}
.map-loading.hidden { display: none; }
.map-loading-spinner {
    width: 32px; height: 32px;
    margin: 0 auto 12px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--lehs-navy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   Popup styling — overrides MapLibre's defaults
   ============================================================================ */
.maplibregl-popup-content {
    padding: 14px 18px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    box-shadow: var(--panel-shadow);
    max-width: 320px;
}
.popup-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--lehs-navy);
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--panel-border);
}
.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 12px;
}
.popup-row .label { color: #607D8B; }
.popup-row .value { color: var(--lehs-navy); font-weight: 500; }

/* ============================================================================
   Floating toggle button — visible at all sizes, lives OUTSIDE the panel
   so closing the panel doesn't hide its own toggle. On desktop it sits
   inside the panel; on mobile we move it to a floating position so the
   user can re-open the closed panel.
   ============================================================================ */
.panel-fab {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--lehs-navy);
    color: var(--lehs-gold);
    border: none;
    box-shadow: 0 3px 12px rgba(10, 31, 68, 0.35);
    cursor: pointer;
    z-index: 20;
    display: none;          /* desktop hides it; mobile reveals via media query */
    align-items: center;
    justify-content: center;
    padding: 0;
}
.panel-fab:hover { background: #1a3a6b; }
.panel-fab svg {
    width: 22px; height: 22px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}

/* ============================================================================
   Mobile responsiveness — < 768px
   ============================================================================ */
@media (max-width: 768px) {
    /* Show the floating toggle button, always tappable */
    .panel-fab { display: inline-flex; }

    /* Hide the inline panel-toggle on mobile (use the FAB instead) */
    .control-panel .panel-toggle { display: none; }

    /* Control panel becomes a slide-in drawer covering most of the screen */
    .control-panel {
        top: 0;
        left: 0;
        width: 88vw;
        max-width: 360px;
        height: calc(100vh - var(--nav-height));
        max-height: calc(100vh - var(--nav-height));
        border-radius: 0 12px 12px 0;
        z-index: 30;
        transform: translateX(-100%);    /* hidden by default on mobile */
        transition: transform 0.28s ease;
    }
    .control-panel.open {
        transform: translateX(0);
    }
    /* The legacy .collapsed class still works (treats as closed) */
    .control-panel.collapsed { transform: translateX(-100%); }

    /* Backdrop while drawer is open — tap to close */
    .panel-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(10, 31, 68, 0.35);
        z-index: 25;
        display: none;
    }
    .panel-backdrop.open { display: block; }

    /* Quick view buttons stay 2 per row on narrow screens */
    .view-btn { min-width: 0; flex: 1 1 calc(50% - 6px); }

    /* Bigger touch targets for radios + checkboxes */
    .radio-group label,
    .layer-row,
    .toggle-row {
        padding: 8px 0;
        font-size: 13px;
    }
    .radio-group input[type="radio"],
    .layer-row input[type="checkbox"],
    .toggle-row input[type="checkbox"] {
        width: 18px; height: 18px;
    }
    .select-input {
        padding: 10px 12px;
        font-size: 14px;        /* 16px+ avoids iOS auto-zoom */
        min-height: 44px;
    }

    /* Year play button bigger + slider thumb */
    .year-play { width: 38px; height: 38px; font-size: 14px; }
    .year-slider { height: 28px; }
    .year-slider::-webkit-slider-thumb { width: 22px; height: 22px; }

    /* Feature detail = bottom sheet */
    .feature-panel {
        top: auto;
        right: 0; left: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        max-height: 60vh;
        border-radius: 14px 14px 0 0;
        transform: translateY(110%);
        transition: transform 0.28s ease;
        display: flex;
    }
    .feature-panel.open {
        transform: translateY(0);
    }

    /* Help button — move out from behind the FAB */
    .help-button {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    .help-modal-inner {
        padding: 22px 18px 18px;
        font-size: 14px;
    }
    .help-key { min-width: 110px; font-size: 11px; }

    /* Legend trimmed for small screens */
    .legend {
        bottom: 12px;
        left: 12px;
        right: 12px;
        max-width: none;
        font-size: 11px;
        padding: 10px 12px;
    }
    .hist { height: 26px; }

    /* MapLibre controls — make bigger for fingers */
    .maplibregl-ctrl-group button {
        width: 38px !important;
        height: 38px !important;
    }
    .maplibregl-ctrl-bottom-left {
        left: 12px !important;
        bottom: 78px !important;   /* lift above the bottom legend */
    }
    .maplibregl-ctrl-bottom-right {
        right: 12px !important;
        bottom: 78px !important;
    }

    /* Bigger, more discoverable FAB on mobile + soft pulse on first paint
       so the user notices the affordance. */
    .panel-fab {
        width: 52px;
        height: 52px;
        box-shadow: 0 6px 18px rgba(10, 31, 68, 0.45);
        animation: fab-pulse 1.6s ease-out 0.4s 2;
    }
    @keyframes fab-pulse {
        0%   { box-shadow: 0 6px 18px rgba(10, 31, 68, 0.45),
                            0 0 0 0 rgba(255, 184, 28, 0.55); }
        70%  { box-shadow: 0 6px 18px rgba(10, 31, 68, 0.45),
                            0 0 0 14px rgba(255, 184, 28, 0); }
        100% { box-shadow: 0 6px 18px rgba(10, 31, 68, 0.45),
                            0 0 0 0 rgba(255, 184, 28, 0); }
    }
}

@media (max-width: 480px) {
    /* Even tighter for phones */
    .panel-title { font-size: 18px; }
    .help-modal-inner h2 { font-size: 17px; }
    .legend { font-size: 10px; }
    .view-btn { font-size: 10px; padding: 9px 8px; }
}
