/* =========================================================================
   Mobile bottom navigation: every style for the bar lives here.
   A floating frosted pill of icons, shown below 1024px (Tailwind lg),
   where the desktop header nav is hidden.
   Partial: resources/views/yalla-gt/layout/mobile_bottom_nav.blade.php
   ========================================================================= */

:root {
    --mbn-h: 64px;                                   /* pill height */
    --mbn-gap: 16px;                                 /* space around the pill */
    --mbn-radius: 999px;
    --mbn-bg: rgba(255, 255, 255, .72);
    --mbn-border: rgba(255, 255, 255, .6);
    --mbn-outline: rgba(15, 23, 42, .06);
    --mbn-shadow: 0 10px 30px -8px rgba(15, 23, 42, .25), 0 2px 8px -2px rgba(15, 23, 42, .08);
    --mbn-text: #64748b;
    --mbn-active: var(--g, #1db954);
    --mbn-primary-bg: var(--g, #1db954);
    --mbn-primary-text: #fff;
    --mbn-speed: .3s;
    /* space the page keeps free under its content */
    --mbn-space: calc(var(--mbn-h) + var(--mbn-gap) * 2 + env(safe-area-inset-bottom));
}

.mbn {
    display: none;
}

@media (max-width: 1023.98px) {
    .mbn {
        display: block;
        position: fixed;
        left: var(--mbn-gap);
        right: var(--mbn-gap);
        bottom: calc(var(--mbn-gap) + env(safe-area-inset-bottom));
        z-index: 50;                                 /* under toasts (60), drawer (70) and modals */
        max-width: 420px;
        margin: 0 auto;
        border-radius: var(--mbn-radius);
        background: var(--mbn-bg);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border: 1px solid var(--mbn-border);
        box-shadow: var(--mbn-shadow), 0 0 0 1px var(--mbn-outline);
        transform: translateY(0);
        transition: transform var(--mbn-speed) cubic-bezier(.2, .8, .2, 1), opacity var(--mbn-speed);
        will-change: transform;
    }

    /* slides fully off screen, past its own gap and the safe area */
    .mbn.is-hidden {
        transform: translateY(calc(100% + var(--mbn-gap) + env(safe-area-inset-bottom) + 8px));
        opacity: 0;
    }

    .mbn-list {
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        height: var(--mbn-h);
        margin: 0;
        padding: 0 6px;
        list-style: none;
    }

    .mbn-list > li {
        display: flex;
        justify-content: center;
        flex: 1;
    }

    .mbn-item {
        display: grid;
        place-items: center;
        width: 48px;
        height: 48px;
        border-radius: 999px;
        color: var(--mbn-text);
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: color .15s;
    }

    .mbn-icon {
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        border-radius: 999px;
        font-size: 19px;
        transition: background-color .15s, transform .15s, box-shadow .15s;
    }

    .mbn-item:active .mbn-icon {
        transform: scale(.9);
    }

    .mbn-item.is-active {
        color: var(--mbn-active);
    }

    .mbn-item.is-active .mbn-icon {
        background: color-mix(in srgb, var(--mbn-active) 14%, transparent);
    }

    /* Sell +: slightly bigger highlighted circle */
    .mbn-item--primary,
    .mbn-item--primary.is-active {
        width: 56px;
        height: 56px;
        color: var(--mbn-primary-text);
    }

    .mbn-item--primary .mbn-icon,
    .mbn-item--primary.is-active .mbn-icon {
        width: 52px;
        height: 52px;
        font-size: 21px;
        background: var(--mbn-primary-bg);
        box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--mbn-primary-bg) 75%, transparent);
    }

    .mbn-item--primary.is-active .mbn-icon {
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--mbn-primary-bg) 22%, transparent),
            0 6px 16px -6px color-mix(in srgb, var(--mbn-primary-bg) 75%, transparent);
    }

    .mbn-item:focus-visible {
        outline: none;
    }

    .mbn-item:focus-visible .mbn-icon {
        outline: 2px solid var(--mbn-active);
        outline-offset: 2px;
    }

    /* Room under the page so the pill never covers content */
    body.has-bottom-nav {
        padding-bottom: var(--mbn-space);
    }

    /* Toasts sit above the pill */
    body.has-bottom-nav #toastContainer {
        bottom: calc(var(--mbn-space) + 4px);
    }

    /* Pages with their own fixed bottom bar (Edit Listing Save/Cancel, Advanced Search actions):
       the nav is not shown there, so the bars never overlap */
    body.has-fixed-actions .mbn {
        display: none;
    }

    body.has-fixed-actions.has-bottom-nav {
        padding-bottom: 0;
    }

    body.has-fixed-actions.has-bottom-nav #toastContainer {
        bottom: 1rem;
    }
}

/* Browsers without backdrop blur get a more solid pill so icons stay readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root {
        --mbn-bg: rgba(255, 255, 255, .96);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mbn,
    .mbn-icon {
        transition: none;
    }
}
