/* Mobile Categories Navigation Styles */
.mobile-categories-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    margin-bottom: 15px;
    position: relative;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-behavior: smooth; /* Smooth scrolling for better UX */
    /* Add physics-based scrolling for iOS */
    -webkit-overflow-scrolling: touch;
    /* Prevent text selection during swipe */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 480px) {
    .mobile-categories-container {
        padding: 8px 0;
        margin-bottom: 12px;
    }
}

.mobile-categories-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Style the mobile genre navigation */
@media (max-width: 768px) {
    .genre-navigation {
        padding: 0.5rem !important;
        margin: 10px 0 !important;
        width: 100%;
        overflow-x: auto;
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: var(--background-color);
        margin-top: 0 !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .genre-list {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding-bottom: 5px;
        width: auto;
        min-width: max-content;
        /* Add snap scrolling for better mobile experience */
        scroll-snap-type: x mandatory;
        /* Add extra padding for better thumb scrolling experience */
        padding-left: 4px;
        padding-right: 4px;
    }
    
    @media (max-width: 480px) {
        .genre-list {
            gap: 5px !important; /* Reduced from 6px for more compact layout */
            padding-bottom: 3px;
            justify-content: flex-start !important; /* Ensure proper alignment */
        }
    }

    .genre-pill {
        flex-shrink: 0;
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        border: none !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
        white-space: nowrap;
        transition: transform 0.2s ease, background-color 0.2s ease !important;
        -webkit-tap-highlight-color: transparent; /* Remove default mobile tap highlight */
        /* Improve touch target size */
        min-height: 36px;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        /* Add snap scrolling */
        scroll-snap-align: start;
        /* Limit maximum width on small screens */
        max-width: 140px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* Special sizing for mobile portrait */
    @media (max-width: 480px) {
        .genre-pill {
            max-width: 100px !important; /* Reduced from 110px to have more pills in view */
            padding: 6px 8px !important;
            font-size: 0.7rem !important;
            /* Fix shadow rendering on mobile */
            box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
            width: auto !important; /* Allow buttons to size based on content */
            flex-basis: auto !important; /* Auto flex basis */
        }
    }
    
    /* Add touch feedback animation */
    .genre-pill:active {
        transform: scale(0.95) !important;
    }

    .genre-count {
        padding: 2px 6px !important;
        font-size: 0.7rem !important;
    }
    
    @media (max-width: 480px) {
        .genre-count {
            padding: 1px 4px !important;
            font-size: 0.65rem !important;
            margin-left: 3px !important;
            /* Match the reduced shadow effect */
            box-shadow: none !important;
        }
    }
    
    /* Make mobile scrolling indicator */
    .mobile-categories-container::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(var(--card-background-rgb), 0.95));
        pointer-events: none;
        opacity: 0.8;
    }
    
    @media (max-width: 480px) {
        .mobile-categories-container::after {
            width: 20px;
        }
    }
    
    /* Add left gradient for scroll indication when not at start */
    .mobile-categories-container.scrolled-right::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 30px;
        background: linear-gradient(to left, transparent, rgba(var(--card-background-rgb), 0.95));
        pointer-events: none;
        opacity: 0.8;
    }
    
    @media (max-width: 480px) {
        .mobile-categories-container.scrolled-right::before {
            width: 20px;
        }
    }
}

/* Active state for category selection */
.genre-pill.active {
    background: var(--primary-color) !important;
    color: white !important;
}

/* Enhanced Mobile Navigation Controls */
.mobile-nav-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-nav-control span {
    font-size: 18px;
    line-height: 1;
}

.left-nav {
    left: 5px;
}

.right-nav {
    right: 5px;
}

.mobile-nav-control.visible {
    opacity: 0.8;
    pointer-events: auto;
}

.mobile-nav-control:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.mobile-nav-control:active {
    transform: translateY(-50%) scale(0.95);
}

/* Hide gradients when no scrolling needed */
.mobile-categories-container.no-scroll-needed::after,
.mobile-categories-container.no-scroll-needed::before {
    display: none;
}

/* Touch feedback styles */
.mobile-categories-container.touching {
    cursor: grabbing;
}

/* Hide navigation controls on smaller screens where they cause issues */
@media (max-width: 480px) {
    .mobile-nav-control {
        display: none;
    }
}
