/* 手機底部導覽列 — 只在手機出現,桌機完全不顯示,兩套版面互不干擾 */

.mobile-tabbar { display: none; }

@media (max-width: 768px) {
    .mobile-tabbar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 90;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        background: rgba(16, 19, 22, 0.96);
        backdrop-filter: blur(14px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        /* 避開 iPhone 底部的 Home Indicator */
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
    }

    .mobile-tab {
        position: relative;
        min-height: 56px;
        padding: 8px 2px 7px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #8a949c;
        text-decoration: none;
        font-size: 10px;
        font-weight: 800;
        transition: color .18s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab svg { width: 22px; height: 22px; display: block; }
    .mobile-tab span { line-height: 1; }

    .mobile-tab:active { color: #4ade80; }
    .mobile-tab.is-active { color: #4ade80; }

    /* 目前所在分頁的頂部指示線 */
    .mobile-tab.is-active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 26px;
        height: 2px;
        border-radius: 0 0 3px 3px;
        background: #4ade80;
    }

    .mobile-tab-badge {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: 4px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 900;
        line-height: 1;
    }
    .mobile-tab-badge[hidden] { display: none; }

    /* 內容底部留空間,不要被導覽列蓋住 */
    body.has-mobile-tabbar {
        padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-tabbar .legal-footer,
    body.has-mobile-tabbar .footer {
        margin-bottom: 6px;
    }

    /* ---- 底部已有導覽列時,把頂部重複的入口收起來 ----
       首頁原本的 nav 有「前往商店 / 訂單 / 購物車」,底部 tabbar 也有同樣入口,
       手機上兩套並存會擠爆而且重複。頂部只保留 logo、錨點連結與頭像。 */
    body.has-mobile-tabbar .nav-shop-cta,
    body.has-mobile-tabbar .nav-orders-cta,
    body.has-mobile-tabbar .nav-cart-link {
        display: none;
    }

    /* 商店頁:返回鍵由底部「首頁」取代 */
    body.has-mobile-tabbar .shop-actions > a[href="/"],
    body.has-mobile-tabbar .back-link[href="/"] {
        display: none;
    }

    /* 返回鍵收起來後,訂單頁 logo 就不用再避開它 */
    body.has-mobile-tabbar .orders-top {
        place-items: center;
    }

    /* 商店頁餘額:手機上不換行、字級縮小,避免被擠成直排 */
    body.has-mobile-tabbar .shop-balance {
        gap: 5px;
        flex-shrink: 1;
        min-width: 0;
    }
    body.has-mobile-tabbar .shop-balance-item {
        padding: 4px 8px;
        font-size: 10px;
        white-space: nowrap;
        line-height: 1.2;
    }
    body.has-mobile-tabbar .shop-nav {
        gap: 8px;
    }
    body.has-mobile-tabbar .shop-actions {
        gap: 7px;
        flex-wrap: nowrap;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-tab { transition: none; }
}
