/* ============================================
   Chinese Master - Mobile Bottom Tab Bar
   iOS-style translucent bar + center Learn FAB
   Active at: max-width 844px
   ============================================ */

/* --- Desktop: hidden --- */
@media (min-width: 845px) {
    #mobile-tabbar,
    .mobile-topbar {
        display: none !important;
    }
}

/* --- Phone (≤844px) --- */
@media (max-width: 844px) {

    /* --- Tab Bar Container --- */
    #mobile-tabbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        padding: 0 4px;
        padding-bottom: env(safe-area-inset-bottom, 6px);
        background: rgba(12, 19, 34, 0.85);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid rgba(148, 163, 184, 0.08);
        z-index: 300;
        align-items: stretch;
        justify-content: space-around;
        box-sizing: border-box;
        -webkit-user-select: none;
        user-select: none;
    }

    /* --- Individual Tab --- */
    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 48px;
        min-height: 48px;
        padding: 4px 6px 2px;
        color: var(--text-muted);
        cursor: pointer;
        transition: color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        background: none;
        border: none;
        font-family: var(--font-en);
        position: relative;
    }

    .mobile-tab:focus-visible {
        outline: 2px solid var(--color-secondary);
        outline-offset: -2px;
        border-radius: 12px;
    }

    .mobile-tab:active {
        transform: scale(0.92);
    }

    .mobile-tab-icon {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-tab-icon svg {
        width: 22px;
        height: 22px;
        transition: stroke 0.2s ease, fill 0.2s ease;
    }

    .mobile-tab-label {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.01em;
        line-height: 1.1;
        transition: color 0.2s ease;
    }

    /* --- Active Tab --- */
    .mobile-tab.active {
        color: var(--color-primary);
    }

    .mobile-tab.active .mobile-tab-label {
        font-weight: 700;
    }

    /* Active indicator pill under icon */
    .mobile-tab.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--color-primary);
        border-radius: 0 0 3px 3px;
    }

    /* --- Center FAB (Learn / Grammar) --- */
    .mobile-fab {
        position: absolute;
        top: -22px;
        left: 50%;
        transform: translateX(-50%);
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #ff6b6b 0%, #ef4444 100%);
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 301;
        box-shadow: 0 6px 20px rgba(255, 107, 107, 0.45);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .mobile-fab:focus-visible {
        outline: 3px solid var(--color-secondary);
        outline-offset: 3px;
        box-shadow: 0 6px 20px rgba(255, 107, 107, 0.45), 0 0 0 4px rgba(241, 196, 15, 0.3);
    }

    .mobile-fab:active {
        transform: translateX(-50%) scale(0.9);
        box-shadow: 0 3px 10px rgba(255, 107, 107, 0.5);
    }

    .mobile-fab svg {
        width: 26px;
        height: 26px;
        stroke: #fff;
        fill: none;
    }

    /* --- FAB ripple / pulsing glow on idle --- */
    .mobile-fab.pulse {
        animation: fabPulse 2.5s ease-in-out infinite;
    }

    @keyframes fabPulse {
        0%, 100% { box-shadow: 0 6px 20px rgba(255, 107, 107, 0.45); }
        50%      { box-shadow: 0 6px 28px rgba(255, 107, 107, 0.65); }
    }

    /* --- Badges (on tabs or FAB) --- */
    .mobile-tab-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 16px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        background: var(--color-danger);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .mobile-tab-badge:empty {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-fab.pulse {
        animation: none;
    }
}
