/* Mobile map workspace: keep the map primary, controls available as bottom sheets. */
.mobile-sheet-handle {
    display: none;
}

.sheet-scrollable-body {
    min-height: 0;
}

@media (max-width: 720px) {
    html:has(.maps-page),
    body:has(.maps-page) {
        height: 100%;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .maps-page {
        height: calc(100dvh - 60px - env(safe-area-inset-top, 0px));
        min-height: 520px;
        background: #e9f0eb;
    }

    .maps-bluebar {
        min-height: 54px;
        flex-wrap: nowrap;
        align-items: stretch;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding: 6px 8px;
        gap: 6px;
        border-bottom: 1px solid #d5e2da;
        background: rgba(248, 247, 241, .98);
        box-shadow: 0 5px 18px rgba(13, 70, 49, .09);
    }

    .maps-bluebar::-webkit-scrollbar {
        display: none;
    }

    .maps-bluebar-btn {
        flex: 0 0 auto;
        min-width: 132px;
        min-height: 46px;
        padding: 0 12px;
        border: 1px solid #d8e5dd;
        border-radius: 13px;
        background: #fff;
        color: #4c6b5e;
        font-size: .75rem;
        white-space: nowrap;
        scroll-snap-align: center;
        border-bottom-width: 1px;
    }

    .maps-bluebar-btn:hover {
        background: #eef7f1;
        color: #15553e;
    }

    .maps-bluebar-btn.is-active {
        border-color: #176c4f;
        background: #176c4f;
        color: #fff;
        box-shadow: 0 5px 14px rgba(23, 108, 79, .18);
    }

    .maps-stage,
    .maps-panel,
    #map-full,
    #map-gps,
    #map-breeding {
        min-height: 0;
    }

    .map-sidebar-overlay,
    .maps-fly-overlay,
    .breeding-atlas-toolbar {
        position: absolute;
        top: auto;
        right: 10px;
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        left: 10px;
        transform: none;
        width: auto;
        min-width: 0;
        min-height: 0;
        max-height: min(58dvh, 500px);
        padding: 0;
        gap: 0;
        overflow: hidden;
        border-radius: 18px;
        border: 1px solid #cfe0d6;
        background: rgba(252, 251, 246, .98);
        box-shadow: 0 12px 38px rgba(8, 38, 28, .2);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
        transition: max-height .24s ease, box-shadow .24s ease;
        z-index: 1001;
    }

    .map-sidebar-overlay.is-collapsed,
    .maps-fly-overlay.is-collapsed,
    .breeding-atlas-toolbar.is-collapsed {
        max-height: 62px;
        overflow: hidden;
        box-shadow: 0 8px 24px rgba(8, 38, 28, .16);
    }

    .mobile-sheet-handle {
        display: flex;
        flex: 0 0 62px;
        position: relative;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        min-height: 62px;
        padding: 13px 14px 10px;
        cursor: pointer;
        touch-action: manipulation;
        user-select: none;
        outline: none;
    }

    .mobile-sheet-handle:focus-visible {
        box-shadow: inset 0 0 0 3px rgba(16, 185, 129, .35);
    }

    .sheet-pill-indicator {
        position: absolute;
        top: 6px;
        left: 50%;
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: #9fbfaf;
        transform: translateX(-50%);
    }

    .sheet-header-content {
        display: flex;
        position: relative;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        color: #0f5039;
    }

    .sheet-title-text {
        max-width: calc(100% - 116px);
        text-align: center;
    }

    .sheet-action-hint {
        position: absolute;
        right: 0;
    }

    .sheet-title-text {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font: 800 .88rem/1.2 Outfit, sans-serif;
    }

    .sheet-title-text i {
        margin-right: 5px;
    }

    .sheet-action-hint {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        gap: 5px;
        font: 750 .72rem/1.2 Inter, sans-serif;
        color: #547064;
    }

    .sheet-chevron {
        transition: transform .2s ease;
    }

    .mobile-sheet-handle[aria-expanded="true"] .sheet-chevron {
        transform: rotate(180deg);
    }

    .sheet-scrollable-body {
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        max-height: calc(min(58dvh, 500px) - 62px);
        padding: 2px 16px 18px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .is-collapsed > .sheet-scrollable-body {
        display: none;
    }

    .sheet-scrollable-body > h2 {
        margin-top: 3px;
    }

    .maps-fly-overlay.has-selected-species.is-season-filter-mode {
        max-height: 178px;
    }

    .maps-fly-overlay.has-selected-species.is-season-filter-mode .sheet-scrollable-body {
        max-height: 116px;
        padding: 0 12px 10px;
        overflow-y: hidden;
    }

    .maps-fly-overlay.has-selected-species.is-season-filter-mode .sheet-scrollable-body > h2,
    .maps-fly-overlay.has-selected-species.is-season-filter-mode .maps-fly-kicker {
        display: none;
    }

    .maps-fly-overlay.has-selected-species.is-season-filter-mode .maps-species-search-wrap {
        flex: 0 0 42px;
        margin: 0 0 6px !important;
    }

    .maps-species-search-submit {
        min-width: 64px;
        min-height: 38px;
    }

    .maps-hub-search-results {
        max-height: min(230px, 31dvh);
    }

    .maps-season-bar {
        margin-bottom: 4px;
    }

    .maps-season-btn {
        min-height: 48px;
        border-radius: 11px;
    }

    .maps-fly-overlay.has-selected-species.is-season-filter-mode #gps-route-caption {
        display: none;
    }

    .breeding-atlas-toolbar .sheet-scrollable-body {
        gap: 10px;
    }

    .breeding-country-control,
    #breeding-country-select {
        width: 100%;
        max-width: none;
    }

    .breeding-atlas-legend {
        margin-left: 0;
    }

    .leaflet-top.leaflet-left {
        margin-top: 4px;
    }

    .leaflet-control-zoom a {
        display: grid !important;
        place-items: center;
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        color: #15553e !important;
        background: rgba(255, 255, 255, .96) !important;
    }

    .leaflet-control-zoom {
        overflow: hidden;
        border: 1px solid #cfe0d6 !important;
        border-radius: 13px !important;
        box-shadow: 0 7px 20px rgba(16, 59, 38, .14) !important;
    }

    .maps-hub-filter input,
    .maps-species-search-wrap input,
    .wetland-filter-grid input,
    .wetland-filter-grid select,
    #breeding-country-select {
        box-sizing: border-box;
        min-height: 46px;
        border-color: #c9dbd1 !important;
        border-radius: 12px !important;
        background: #fff !important;
        font-size: 16px !important;
    }

    .maps-hub-toggle .btn-toggle,
    .maps-hub-list-tabs .sidebar-tab,
    #btn-toggle-all-time,
    .maps-site-btn,
    .wetland-actions a,
    .wetland-actions button {
        min-height: 44px;
    }

    .wetland-detail-panel {
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        left: 10px;
        width: auto;
        height: min(62dvh, 540px);
    }
}

@media (max-width: 430px) {
    .maps-bluebar-btn {
        min-width: 122px;
    }

    .sheet-action-hint {
        font-size: .68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-sidebar-overlay,
    .maps-fly-overlay,
    .breeding-atlas-toolbar,
    .sheet-chevron {
        transition: none;
    }
}
