/* Mobile bottom bar (nav.app-tabbar in Components/Layout/Navbar.razor), below 640px only.
   A rounded bar that floats above the page with a see-through blur, instead of filling the bottom edge.
   A grey pill sits behind the open item and slides to the new one when the page changes;
   the item's icon swaps to its white '-active' version at once.
   The pill is moved with --tab-index (0-4) set from Navbar.razor; it is hidden when no item is open.
   Display is set here (not with Tailwind's sm:hidden) so html.lp-typing in learning.css can still hide it. */

.app-tabbar {
    display: none;
}

@media (max-width: 639px) {
    .app-tabbar {
        display: block;
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        z-index: 50;
        max-width: 520px;
        margin: 0 auto;
        padding: 5px;
        border-radius: 999px;
        background: rgba(15, 15, 15, 0.62);
        -webkit-backdrop-filter: blur(18px) saturate(160%);
        backdrop-filter: blur(18px) saturate(160%);
        border: 1px solid rgba(255, 255, 255, 0.10);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    }

    .app-tabbar-inner {
        position: relative;
        display: flex;
        flex-direction: row;
    }

    .app-tabbar-pill {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 20%;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.18);
        transform: translateX(calc(var(--tab-index, 0) * 100%));
        transition: transform 0.32s cubic-bezier(0.3, 0.8, 0.3, 1), opacity 0.2s ease;
        pointer-events: none;
    }

    .app-tabbar-pill.is-hidden {
        opacity: 0;
    }

    .app-tabbar-item {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        min-height: 52px;
        padding: 5px 2px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: #fff;
        text-decoration: none;
        border-radius: 999px;
        -webkit-tap-highlight-color: transparent;
    }

    .app-tabbar-item:hover,
    .app-tabbar-item:focus,
    .app-tabbar-item.active {
        color: #fff;
    }

    .app-tabbar-item:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.7);
        outline-offset: -2px;
    }

    .app-tabbar-icon {
        position: relative;
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .app-tabbar-icon img {
        width: 28px;
        height: 28px;
    }

    .app-tabbar-icon img.is-logo {
        border-radius: 999px;
        object-fit: cover;
    }

    .app-tabbar-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.7rem;
        line-height: 1.1;
        font-weight: 500;
    }

    .app-tabbar-item.active .app-tabbar-label {
        font-weight: 600;
    }
}

/* Browsers without backdrop blur get a solid bar so the icons stay readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    @media (max-width: 639px) {
        .app-tabbar {
            background: rgba(15, 15, 15, 0.94);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-tabbar-pill {
        transition: none;
    }
}
