/* Shambamap responsive mobile map and bottom navigation */

/* Keep the mobile controls hidden on desktop even if the partial has no utility class. */
.sm-mobile-tabs,
.sm-mobile-backdrop,
.sm-bottom-sheet {
    display: none;
}

@media (max-width: 991.98px) {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    :root {
        --sm-tab-bar-height: 68px;
        --sm-safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    html,
    body {
        width: 100%;
        min-height: 100%;
        margin: 0;
        overflow-x: hidden;
    }

    body {
        padding-bottom: calc(var(--sm-tab-bar-height) + var(--sm-safe-bottom));
    }

    main.py-5 {
        padding-top: .5rem !important;
        padding-bottom: calc(var(--sm-tab-bar-height) + 1rem + var(--sm-safe-bottom)) !important;
    }

    main .container-xxl {
        width: 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .home-hero.grid-2col {
        display: block !important;
        width: 100%;
        min-width: 0;
    }

    section.hero-left {
        width: 100%;
        min-width: 0;
        height: calc(100dvh - var(--sm-tab-bar-height) - var(--sm-safe-bottom)) !important;
        min-height: 420px;
    }

    #map {
        width: 100% !important;
        height: calc(100dvh - var(--sm-tab-bar-height) - var(--sm-safe-bottom)) !important;
        min-height: 420px;
    }

    #searchPanel,
    .open-btn,
    .hero-right,
    section.mt-3,
    section.mt-5 {
        display: none !important;
    }

    .ol-popup {
        width: min(86vw, 360px);
        max-width: 86vw;
        min-width: 0;
        left: -43vw;
    }

    .sm-mobile-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 3000;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
        width: 100%;
        max-width: 100vw;
        min-height: calc(var(--sm-tab-bar-height) + var(--sm-safe-bottom));
        margin: 0;
        padding: 4px max(4px, env(safe-area-inset-right, 0px)) var(--sm-safe-bottom) max(4px, env(safe-area-inset-left, 0px));
        overflow: hidden;
        background: #fff;
        border-top: 1px solid #ddd;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, .12);
    }

    .sm-mobile-tab {
        width: 100%;
        min-width: 0;
        min-height: 60px;
        margin: 0;
        padding: 5px 2px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: #222;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        overflow: hidden;
        font-size: clamp(.62rem, 2.8vw, .78rem);
        line-height: 1.1;
        text-align: center;
        white-space: normal;
        overflow-wrap: anywhere;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .sm-mobile-tab i,
    .sm-mobile-tab svg {
        flex: 0 0 auto;
        font-size: clamp(1.05rem, 5vw, 1.3rem);
        line-height: 1;
    }

    .sm-mobile-tab span {
        display: block;
        width: 100%;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sm-mobile-tab:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: -2px;
    }

    .sm-mobile-backdrop {
        position: fixed;
        inset: 0;
        z-index: 3050;
        display: block;
        background: rgba(0, 0, 0, .35);
    }

    .sm-bottom-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 3100;
        display: block;
        width: 100%;
        max-width: 100vw;
        max-height: 82dvh;
        margin: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #fff;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
        padding: .65rem max(1rem, env(safe-area-inset-right, 0px)) calc(1rem + var(--sm-safe-bottom)) max(1rem, env(safe-area-inset-left, 0px));
        transform: translate3d(0, 110%, 0);
        transition: transform .22s ease;
    }

    .sm-bottom-sheet.open {
        transform: translate3d(0, 0, 0);
    }

    .sm-small-sheet {
        max-height: 45dvh;
    }

    .sm-sheet-handle {
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: #d1d1d1;
        margin: 0 auto .65rem;
    }

    .sm-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        margin-bottom: .75rem;
    }

    .sm-sheet-header > * {
        min-width: 0;
    }

    #mobilePlotResults .list-group-item {
        cursor: pointer;
    }
}

/* Very narrow phones: preserve four equal buttons without horizontal overflow. */
@media (max-width: 359.98px) {
    :root {
        --sm-tab-bar-height: 62px;
    }

    .sm-mobile-tab {
        min-height: 54px;
        padding-inline: 1px;
        font-size: .58rem;
    }

    .sm-mobile-tab i,
    .sm-mobile-tab svg {
        font-size: 1rem;
    }
}

/* Landscape phones need a shallower navigation bar and map. */
@media (max-width: 991.98px) and (orientation: landscape) and (max-height: 500px) {
    :root {
        --sm-tab-bar-height: 54px;
    }

    .sm-mobile-tab {
        min-height: 48px;
        flex-direction: row;
        gap: 5px;
        font-size: .68rem;
    }

    .sm-mobile-tab i,
    .sm-mobile-tab svg {
        font-size: 1rem;
    }

    section.hero-left,
    #map {
        min-height: 280px;
    }
}
