/* What-if view — occupies the content-column when active. */
.content-column--whatif {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

.content-column[hidden],
.content-column--whatif[hidden] {
    display: none;
}

.whatif {
    padding: var(--space-md);
}

/* Reused action bar at the top of the What-if view */
.whatif__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    position: relative;
    z-index: 1;
}
.whatif__action-buttons {
    display: flex;
    gap: var(--space-sm);
}

/* Location selector (own state) */
.whatif-location {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.whatif-location__icon {
    display: inline-flex;
    align-items: center;
    color: var(--color-primary);
    padding: 0 2px;
}
.whatif-location__btn {
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #000;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.whatif-location__btn:hover { background: #f4f4f4; }
.whatif-location__btn.is-active {
    background: var(--color-primary);
    color: #000;
}

/* Caption below the maps */
.whatif__caption {
    text-align: center;
    font-weight: 700;
    background: var(--color-primary);
    color: #000;
    border-radius: 6px;
    padding: 10px;
    margin-top: var(--space-sm);
}
.whatif__caption:empty { display: none; }

/* Back to dashboard — inside the panel, below Generate */
.whatif-panel__back {
    display: block;
    width: 100%;
    margin-top: var(--space-sm);
    padding: 8px;
    background: none;
    border: 1px solid var(--color-primary);
    border-radius: 6px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
}
.whatif-panel__back:hover {
    background: var(--color-bg);
}

.whatif__placeholder {
    color: #888;
    text-align: center;
    padding: var(--space-xl);
}

/* Sidebar What-if active state */
.sidebar-item.is-active {
    background: var(--color-primary);
}
/* What-if varbar: 12 variables need horizontal scroll without clipping the
   first item. The trick: justify-content:center clips overflowing flex content,
   so instead we left-align and use auto margins on the end items — this centres
   the row while it fits, but when it overflows the auto margins collapse to 0
   and nothing is clipped (first item stays scroll-reachable). */
.content-column--whatif .whatif-varbar {
    justify-content: flex-start;
}
.content-column--whatif .whatif-varbar > .varbar__item:first-child {
    margin-left: auto;
}
.content-column--whatif .whatif-varbar > .varbar__item:last-child {
    margin-right: auto;
}

/* ===== What-if body: maps (left) + panel (right) ===== */
.whatif__body {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    align-items: stretch;   /* both columns share the same height */
}

.whatif__left {
    flex: 1;
    min-width: 0;
    min-height: 460px;      /* floor so Leaflet is never sized to 0 */
    display: flex;
    flex-direction: column;
}

/* Right column: action bar on top + selector panel below */
.whatif_right {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.whatif_right .whatif__actions {
    padding: 0;               /* the column already has spacing */
    background: transparent;
}
.whatif_right .whatif__action-buttons {
    display: flex;
    width: 100%;
    gap: var(--space-xs);
}
.whatif_right .whatif__action-buttons .action-btn {
    flex: 1;                  /* share the panel width equally */
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
    padding-left: 8px;
    padding-right: 8px;
}
.whatif_right .whatif__action-buttons .action-btn__label {
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.whatif_right .whatif-panel {
    width: 100%;              /* fill the column; width is set by the parent */
}

.whatif__maps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    min-width: 0;
    flex: 1;                /* grow to fill the (stretched) left column */
}
.whatif-map {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.whatif-map__title {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--color-primary);
    color: #000;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: var(--space-xs);
}

.whatif-map__canvas {
    width: 100%;
    flex: 1;                /* fill the map column exactly */
    min-height: 0;          /* do NOT push the column taller */
    background: #eef1f4;
    border-radius: 6px;
}

.whatif-map__legend {
    margin-top: var(--space-xs);
    font-size: 0.7rem;
    text-align: center;
    color: #555;
}
.whatif-map__legend:empty { display: none; }

.whatif-legend__bar {
    height: 12px;
    width: 100%;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.whatif-legend__ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 0.68rem;
    color: #444;
}
.whatif-legend__unit {
    margin-top: 2px;
    font-style: italic;
    color: #666;
}

/* ===== Scenario selector panel (right) ===== */
.whatif-panel {
    width: 340px;
    flex-shrink: 0;
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.whatif-panel__heading {
    text-align: center;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 8px;
    margin: 0 0 var(--space-md);
}

.whatif-panel__group {
    margin-bottom: var(--space-md);
}

.whatif-panel__label {
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: var(--space-xs);
}

.whatif-panel__options {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
    flex-wrap: wrap;
}

.whatif-opt {
    flex: 1;
    min-width: 90px;
    padding: 8px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 6px;
    background: transparent;
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.whatif-opt:hover {
    background: var(--color-bg);
}
.whatif-opt.is-active {
    background: var(--color-primary);
    color: #000;
}

.whatif-panel__generate {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: var(--space-sm);
    border: none;
    border-radius: 6px;
    background: #1d584b;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.whatif-panel__generate:hover {
    background: #164438;
}
/* ===== Winter "coming soon" modal ===== */
.whatif-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.whatif-modal[hidden] { display: none; }

.whatif-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.whatif-modal__dialog {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: var(--space-lg);
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.whatif-modal__title {
    margin: 0 0 var(--space-sm);
    font-size: 1.25rem;
    font-weight: 700;
}

.whatif-modal__text {
    margin: 0 0 var(--space-md);
    color: var(--color-text);
    line-height: 1.5;
}

.whatif-modal__ok {
    padding: 8px 24px;
    border: none;
    border-radius: 6px;
    background: var(--color-primary);
    color: #000;
    font-weight: 700;
    cursor: pointer;
}
.whatif-modal__ok:hover { filter: brightness(0.95); }
/* ===================== MOBILE (≤991.98px) ===================== */
@media (max-width: 991.98px) {
    /* Hide the action buttons (Subscribe/Share/Download) entirely on mobile. */
    .whatif__actions {
        display: none;
    }
    /* Panel first, maps after — user changes scenario without scrolling down. */
    .whatif__body {
        flex-direction: column;
    }
    .whatif-panel {
        width: 100%;
    }
    .whatif_right {
        width: 100%;
        order: 1;            /* selectors column on top */
    }
    .whatif__left {
        order: 2;            /* maps below */
        width: 100%;
    }

    /* Carousel: one map at a time. The grid becomes a single visible slide. */
    .whatif__maps {
        display: block;
        position: relative;
    }
    .whatif-map {
        display: none;
    }
    .whatif-map.is-current {
        display: block;
    }
    .whatif-map__canvas {
        flex: none;
        height: 400px;
    }

    /* Carousel nav (arrows + dots) */
    .whatif__left .whatif-carousel-nav.mobile-only {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: var(--space-md);
        margin-top: var(--space-sm);
    }
    .whatif-carousel-nav__arrow {
        width: 40px;
        height: 40px;
        border: 1px solid var(--color-border);
        border-radius: 50%;
        background: #fff;
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
        color: var(--color-text);
    }
    .whatif-carousel-nav__arrow:active {
        background: var(--color-primary);
    }
    .whatif-carousel-nav__dots {
        display: flex;
        gap: 8px;
    }
    .whatif-carousel-nav__dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: var(--color-border);
        transition: background 0.15s;
    }
    .whatif-carousel-nav__dot.is-active {
        background: var(--color-primary);
    }

    /* Back-to-top */
    .whatif-backtotop {
        display: block;
        width: 100%;
        margin-top: var(--space-md);
        padding: 10px;
        border: 1px solid var(--color-primary);
        border-radius: 6px;
        background: transparent;
        color: var(--color-primary);
        font-weight: 700;
        cursor: pointer;
    }
}
/* Region indicator at the top of the filter panel */
.whatif-panel__region {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
}
.whatif-panel__region .region-header__location {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.whatif-panel__region .region-header__season { font-size: 1.5rem; }
.whatif-panel__region .region-header__subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted, #666);
}
.whatif-panel__region .region-header__title {
    font-size: 1.1rem;
    font-weight: 700;
}