/* - - - FLOATING PILL NAVBAR - - - */
.floating-nav {
    position: fixed;
    bottom: 25px;
    bottom: calc(25px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    padding: 10px 15px;
    border-radius: 50px;
    z-index: 100000;

    /* Scrollable Logic */
    width: auto;
    max-width: 320px;
    overflow-x: auto;
    white-space: nowrap;
    -ms-overflow-style: none;
    /* IE/Edge */
    scrollbar-width: none;
    /* Firefox */

    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    /* Animation State: SHOW */
    opacity: 1;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;

    /* Responsive Width */
    width: auto;
    max-width: 90%;
}

/* Match .floating-nav style */
/* Match .floating-nav style */
.floating-popup {
    position: fixed;
    /* Same position as floating-nav */
    bottom: 25px !important;
    bottom: calc(25px + env(safe-area-inset-bottom)) !important;
    left: 50%;
    transform: translateX(-50%) scale(0.9);

    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    padding: 10px 15px;
    /* Synced with nav */
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 100001;
    /* Higher than nav */
    width: auto;
    max-width: 90%;
    white-space: nowrap;

    /* Animation */
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.floating-popup.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
    bottom: 25px !important;
    /* Ensure it stays put */
    bottom: calc(25px + env(safe-area-inset-bottom)) !important;
}

/* State when Nav is replaced by Music Control */
.floating-nav.nav-hidden-morph {
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
    pointer-events: none;
}

.floating-nav::-webkit-scrollbar {
    display: none;
}

/* Scroll Hide Class */
.floating-nav.hidden {
    transform: translateX(-50%) translateY(120%);
    opacity: 0;
    pointer-events: none;
}

/* Hide nav initially on cover or if needed */
body.landing-page:not(.open) .floating-nav {
    transform: translateX(-50%) translateY(200%);
    opacity: 0;
}

/* Nav Items */
.nav-item {
    color: var(--text-color, #333);
    font-size: 1.2rem;
    position: relative;
    padding: 8px 15px;
    display: flex;
    flex-direction: row !important;
    /* Force side-by-side */
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    border-radius: 50px !important;
    /* Force pill shape */
    flex-shrink: 0;
    text-decoration: none;
}

.nav-item .nav-label {
    display: none;
    margin-left: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--primary-color, #5D5C61);
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.nav-item.active {
    color: white;
    background: var(--primary-color, #5D5C61);
    box-shadow: 0 4px 10px rgba(93, 92, 97, 0.3);
    padding-right: 20px;
}

.nav-item.active .nav-label {
    display: inline-block;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .floating-nav {
        bottom: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        width: 80% !important;
        max-width: 80% !important;
        justify-content: flex-start;
        /* Allow scrolling */
        padding: 8px 10px;

        /* Force Scroll */
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;

        /* Hide Scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .floating-nav.nav-centered {
        justify-content: center;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 1rem;
    }

    /* Music Popup Mobile Match */
    .floating-popup {
        width: 80% !important;
        max-width: 80% !important;
        padding: 8px 10px;
        justify-content: space-between;
    }
}

/* Desktop Optimization */
#music-control {
    color: var(--primary-color);
}

#music-control.playing i {
    animation: spin 3s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@media (min-width: 769px) {
    .floating-nav {
        max-width: 90%;
        /* Prevent cut-off */
        width: auto;
        gap: 0.5rem;
        padding: 10px 20px 15px 20px;
        /* Extra bottom padding for scrollbar */
        overflow-x: auto;
        /* Allow Scroll */
        justify-content: flex-start;
        /* Ensure items start from left if scrolling needed */

        /* Reset Firefox/IE explicit hide */
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
        -ms-overflow-style: auto;
    }

    .nav-item {
        margin: 0;
    }

    /* Custom Scrollbar for Desktop - HIDDEN (Drag to Scroll enabled) */
    .floating-nav::-webkit-scrollbar {
        display: none;
        /* Hide again */
    }

    .floating-nav {
        /* Reset Firefox/IE explicit hide */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .floating-nav::-webkit-scrollbar-track {
        background: transparent;
        margin: 0 15px;
        /* Indent */
    }

    .floating-nav::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 10px;
    }

    .floating-nav::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.4);
    }
}