/**
 * StreamVault - Genres Browse Styles
 * Modern card-based genre browsing with premium effects
 */

/* Base Styles */
.genre-header,
.genres-header {
    position: relative;
    background: linear-gradient(135deg, 
        rgba(var(--primary-rgb), 0.1) 0%,
        rgba(var(--secondary-rgb), 0.05) 50%,
        transparent 100%);
}

/* Animation Keyframes */
@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fade-in-up 0.6s ease-out forwards;
    opacity: 0;
}

/* Modern Card System */
.modern-card {
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-card:hover {
    transform: scale(1.05);
    z-index: 10;
}

.modern-card .main-card {
    background: linear-gradient(145deg, 
        rgba(15, 23, 42, 0.8) 0%, 
        rgba(30, 41, 59, 0.6) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.modern-card:hover .main-card {
    border-color: rgba(var(--primary-rgb), 0.5);
    box-shadow: 
        0 20px 40px -12px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(var(--primary-rgb), 0.2),
        0 0 30px rgba(var(--primary-rgb), 0.15);
}

/* Poster and Image Effects */
.poster-wrapper {
    overflow: hidden;
    border-radius: 1rem;
}

.poster-wrapper img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.modern-card:hover .poster-wrapper img {
    transform: scale(1.1);
}

/* Badge Styling */
.type-badge,
.rating-badge {
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.type-badge {
    background: rgba(var(--primary-rgb), 0.9);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.rating-badge {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.content-info {
    background: rgba(var(--secondary-rgb), 0.8);
    backdrop-filter: blur(5px);
}

/* Play Overlay */
.play-overlay {
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.play-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modern-card:hover .play-button {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* Genre Card Specific Styles */
.genre-card {
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Remove any overflow hidden that might clip popups */
    overflow: visible;
}

.genre-card:hover {
    transform: translateY(-8px);
    /* Don't set z-index here as it creates stacking context */
}

.genre-main-card {
    background: linear-gradient(145deg, 
        rgba(15, 23, 42, 0.9) 0%, 
        rgba(30, 41, 59, 0.7) 100%);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Remove overflow hidden to allow popups to escape */
    overflow: visible;
}

.genre-card:hover .genre-main-card {
    border-color: rgba(var(--primary-rgb), 0.6);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(var(--primary-rgb), 0.3),
        0 0 40px rgba(var(--primary-rgb), 0.2);
}

/* Sample Poster Grid */
.sample-poster {
    transition: transform 0.3s ease;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
}

.sample-poster-wrapper {
    position: relative;
}

.sample-poster-wrapper:hover .sample-poster {
    transform: scale(1.1);
    z-index: 30;
}

/* Individual Poster Hover Popups */
.poster-popup {
    pointer-events: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.5);
    background: rgba(17, 24, 39, 0.95);
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.5),
        0 10px 10px -5px rgba(0, 0, 0, 0.3);
    z-index: 999999;
    /* Default absolute positioning */
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-in-out;
}

.sample-poster-wrapper:hover .poster-popup {
    pointer-events: auto;
}

/* Remove the old horizontal positioning */
.sample-poster-wrapper:nth-child(5) .poster-popup,
.sample-poster-wrapper:nth-child(6) .poster-popup,
.sample-poster-wrapper:nth-child(1) .poster-popup,
.sample-poster-wrapper:nth-child(2) .poster-popup {
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
}

/* Popup arrows pointing down to the hovered card */
.poster-popup::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 6px 0 6px;
    border-color: rgba(17, 24, 39, 0.95) transparent transparent transparent;
}

/* Arrow pointing up when popup is below the card */
.poster-popup.popup-bottom::before {
    bottom: auto;
    top: -6px;
    border-width: 0 6px 6px 6px;
    border-color: transparent transparent rgba(17, 24, 39, 0.95) transparent;
}

/* Remove the old side arrows */
.sample-poster-wrapper:nth-child(5) .poster-popup::before,
.sample-poster-wrapper:nth-child(6) .poster-popup::before {
    bottom: -6px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-color: rgba(17, 24, 39, 0.95) transparent transparent transparent;
}

/* Arrow adjustments for horizontal positioning */
.poster-popup.popup-left::before {
    left: 20px;
    transform: none;
}

.poster-popup.popup-right::before {
    left: auto;
    right: 20px;
    transform: none;
}

/* Dynamic positioning classes for JavaScript adjustments */
.poster-popup.popup-left.popup-bottom::before,
.poster-popup.popup-right.popup-bottom::before {
    top: -6px;
    bottom: auto;
    border-width: 0 6px 6px 6px;
    border-color: transparent transparent rgba(17, 24, 39, 0.95) transparent;
}

/* Genre card hover - reduce transform to prevent z-index conflicts */
.genre-card:hover {
    transform: translateY(-2px);
}

/* Ensure mini poster hover works independently with higher z-index */
.sample-poster-wrapper .sample-poster:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    z-index: 30;
}

/* Prevent genre card click when hovering posters */
.sample-poster-wrapper {
    position: relative;
    z-index: 20;
}

/* Ensure popups appear above everything */
.sample-poster-wrapper:hover {
    z-index: 10000;
    position: relative;
}

/* Filter and Sort Controls */
.filter-controls {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modern-card {
        transform: none;
    }
    
    .modern-card:hover {
        transform: none;
    }
    
    .genre-card:hover {
        transform: translateY(-4px);
    }
    
    .modern-card .main-card {
        min-height: 280px;
    }
    
    .genre-main-card {
        padding: 1.25rem;
    }
    
    .sample-poster {
        aspect-ratio: 2/3;
        min-height: 60px;
    }
    
    /* Mobile popup adjustments */
    .poster-popup {
        width: 200px;
        font-size: 0.75rem;
    }
    
    .sample-poster-wrapper .sample-poster:hover {
        transform: scale(1.1);
    }
    
    /* Disable popups on very small screens */
    @media (max-width: 480px) {
        .poster-popup {
            display: none;
        }
        
        .sample-poster-wrapper .sample-poster {
            cursor: pointer;
        }
        
        .sample-poster-wrapper .sample-poster:hover {
            transform: scale(1.05);
        }
    }
}

@media (max-width: 640px) {
    .animate-fade-in-up {
        animation-delay: 0s !important;
    }
    
    #content-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    #genres-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .modern-card .main-card {
        min-height: 240px;
    }
    
    .genre-main-card {
        padding: 1rem;
    }
    
    .genre-main-card h3 {
        font-size: 1.5rem;
    }
    
    .sample-poster {
        min-height: 50px;
    }
}

/* Loading States */
.loading-card {
    background: linear-gradient(90deg, 
        rgba(55, 65, 81, 0.1) 25%, 
        rgba(75, 85, 99, 0.2) 50%, 
        rgba(55, 65, 81, 0.1) 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Pagination Styles */
.pagination-button {
    background: rgba(31, 41, 55, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.3);
    transition: all 0.2s ease;
}

.pagination-button:hover {
    background: rgba(55, 65, 81, 0.9);
    border-color: rgba(var(--primary-rgb), 0.4);
    transform: translateY(-1px);
}

.pagination-button.active {
    background: rgba(var(--primary-rgb), 0.9);
    border-color: rgba(var(--primary-rgb), 0.6);
    color: white;
}

/* Content Type Filter */
.content-type-filter {
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.3);
}

.content-type-filter a {
    transition: all 0.2s ease;
}

.content-type-filter a:hover {
    background: rgba(55, 65, 81, 0.8);
}

.content-type-filter a.active {
    background: rgba(var(--primary-rgb), 0.9);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

/* Sort Tags */
.sort-tag {
    background: rgba(31, 41, 55, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(75, 85, 99, 0.3);
    transition: all 0.2s ease;
}

.sort-tag:hover {
    background: rgba(55, 65, 81, 0.9);
    border-color: rgba(var(--primary-rgb), 0.4);
}

.sort-tag.active {
    background: rgba(var(--primary-rgb), 0.9);
    border-color: rgba(var(--primary-rgb), 0.6);
    color: white;
}

/* Empty State */
.empty-state {
    opacity: 0.8;
}

.empty-state svg {
    opacity: 0.6;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-fade-in-up {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* Focus States for Accessibility */
.modern-card:focus,
.genre-card:focus {
    outline: 2px solid rgba(var(--primary-rgb), 0.8);
    outline-offset: 4px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .modern-card .main-card,
    .genre-main-card {
        border-color: #ffffff;
        border-width: 2px;
    }
    
    .type-badge,
    .rating-badge,
    .content-info {
        border-color: #ffffff;
        border-width: 1px;
    }
}

/* Print Styles */
@media print {
    .play-overlay,
    .filter-controls,
    .pagination-button {
        display: none !important;
    }
    
    .modern-card,
    .genre-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
