/**
 * Premium Home Page Sections
 * Ultra-modern, unique design for content sections
 * Mobile-First Responsive
 * 
 * @package StreamBox
 */

/* ===============================================
   BASE STYLES (MOBILE-FIRST)
   Starting with smallest screens
   =============================================== */

/* Wrapper */
.content-rows-wrapper {
    position: relative;
    z-index: 2;
    background: transparent;
    padding: 0;
    margin-top: -40px;
    padding-top: 40px;
}

/* Individual Section - Clean, no boxes */
.content-row {
    margin-bottom: 1rem;
    position: relative;
    padding: 0;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    animation: contentFadeIn 0.6s ease-out backwards;
}

.content-row::before {
    display: none;
}

/* ===============================================
   SECTION HEADERS - MOBILE BASE
   =============================================== */

.content-row__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0 12px;
}

.content-row__title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

/* Content Type Icon - Mobile */
.content-type-icon {
    font-size: 16px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: all 0.3s ease;
}

/* Section Title - Mobile */
.content-row__title {
    font-size: 14px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-row__title::after {
    display: none; /* Hidden on mobile */
}

/* Trending Badge - Mobile */
.trending-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.4rem;
    background: linear-gradient(135deg, #E91EFF 0%, #9D4EFF 100%);
    border-radius: 100px;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 
        0 0 12px rgba(233, 30, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

.trending-badge svg {
    width: 10px;
    height: 10px;
    animation: flicker 1.5s ease-in-out infinite;
}

/* Count Badge - Hidden on mobile */
.content-row__count {
    display: none;
}

/* See All Link - Mobile */
.content-row__see-all {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.content-row__see-all svg {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
}

/* ===============================================
   CAROUSEL - MOBILE BASE (Touch Optimized)
   =============================================== */

.content-carousel {
    position: relative;
    padding: 0;
}

.carousel-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    position: relative;
    margin: 0;
    padding: 0 12px;
    border-radius: 0;
}

.carousel-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.carousel-track {
    display: flex;
    gap: 8px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 4px 0;
}

.carousel-item {
    flex: 0 0 105px;
    min-width: 105px;
    max-width: 120px;
    scroll-snap-align: start;
    transition: transform 0.3s ease;
}

/* Trending Item with Rank Badge - Mobile */
.trending-item {
    position: relative;
}

.trending-rank {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #E91EFF 0%, #9D4EFF 100%);
    border-radius: 8px;
    border: 2px solid rgba(11, 11, 30, 0.9);
    z-index: 10;
    box-shadow: 
        0 2px 8px rgba(233, 30, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: rotate(-8deg);
}

/* Navigation Buttons - Hidden on mobile (use touch scroll) */
.carousel-nav {
    display: none;
}

/* ===============================================
   ANIMATIONS
   =============================================== */

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 
            0 0 12px rgba(233, 30, 255, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 
            0 0 20px rgba(233, 30, 255, 0.5),
            0 2px 12px rgba(0, 0, 0, 0.4);
    }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation delays */
.content-row:nth-child(1) { animation-delay: 0.1s; }
.content-row:nth-child(2) { animation-delay: 0.2s; }
.content-row:nth-child(3) { animation-delay: 0.3s; }
.content-row:nth-child(4) { animation-delay: 0.4s; }

/* ===============================================
   SMALL PHONES (480px+)
   =============================================== */

@media (min-width: 480px) {
    .content-row {
        margin-bottom: 1.25rem;
    }
    
    .content-row__header {
        margin-bottom: 0.75rem;
    }
    
    .content-type-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 18px;
    }
    
    .content-row__title {
        font-size: 16px;
    }
    
    .trending-badge {
        font-size: 10px;
        padding: 0.25rem 0.5rem;
    }
    
    .carousel-track {
        gap: 10px;
    }
    
    .carousel-item {
        flex: 0 0 120px;
        min-width: 120px;
        max-width: 140px;
    }
    
    .trending-rank {
        width: 36px;
        height: 36px;
        font-size: 18px;
        top: -8px;
        left: -8px;
    }
}

/* ===============================================
   LARGE PHONES (576px+)
   =============================================== */

@media (min-width: 576px) {
    .content-rows-wrapper {
        margin-top: -60px;
        padding-top: 60px;
    }
    
    .content-row {
        margin-bottom: 1.5rem;
    }
    
    .content-row__header {
        padding: 0 16px;
        margin-bottom: 0.875rem;
    }
    
    .content-row__title-group {
        gap: 0.625rem;
    }
    
    .content-type-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 22px;
        border-radius: 10px;
    }
    
    .content-row__title {
        font-size: 20px;
    }
    
    .trending-badge {
        font-size: 11px;
        padding: 0.35rem 0.7rem;
        gap: 0.35rem;
    }
    
    .trending-badge svg {
        width: 12px;
        height: 12px;
    }
    
    .content-row__see-all {
        padding: 0.5rem 1rem;
        font-size: 13px;
    }
    
    .carousel-container {
        padding: 0 16px;
    }
    
    .carousel-track {
        gap: 12px;
    }
    
    .carousel-item {
        flex: 0 0 130px;
        min-width: 130px;
        max-width: 150px;
    }
    
    .trending-rank {
        width: 40px;
        height: 40px;
        font-size: 20px;
        border-radius: 10px;
    }
}

/* ===============================================
   TABLETS (768px+)
   =============================================== */

@media (min-width: 768px) {
    .content-rows-wrapper {
        margin-top: -80px;
        padding-top: 0;
    }
    
    .content-row {
        margin-bottom: 2rem;
    }
    
    .content-row__header {
        flex-wrap: nowrap;
        gap: 0.75rem;
        padding: 0 1.5rem;
        margin-bottom: 1rem;
    }
    
    .content-row__title-group {
        gap: 0.75rem;
    }
    
    .content-type-icon {
        width: 48px;
        height: 48px;
        min-width: 48px;
        font-size: 26px;
        border-radius: 12px;
    }
    
    .content-row__title {
        font-size: 26px;
        letter-spacing: -0.4px;
    }
    
    .content-row__title::after {
        content: '';
        display: block;
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 40px;
        height: 2px;
        background: linear-gradient(90deg, #7B2FFF 0%, transparent 100%);
        border-radius: 2px;
    }
    
    /* Show count badge on tablets */
    .content-row__count {
        display: inline-block;
        font-size: 13px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.5);
        padding: 0.25rem 0.625rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 100px;
        border: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .trending-badge {
        font-size: 12px;
        padding: 0.4rem 0.9rem;
        gap: 0.4rem;
    }
    
    .content-row__see-all {
        padding: 0.625rem 1.25rem;
        font-size: 14px;
    }
    
    .content-row__see-all svg {
        width: 16px;
        height: 16px;
    }
    
    /* Carousel with nav buttons on tablet */
    .content-carousel {
        padding: 0 1.5rem;
    }
    
    .carousel-container {
        overflow: hidden; /* Switch to JS navigation */
        margin: 0 50px;
        padding: 0;
    }
    
    .carousel-track {
        gap: 14px;
        padding: 4px;
    }
    
    .carousel-item {
        flex: 0 0 calc((100% - 56px) / 4);
        min-width: 150px;
        max-width: 180px;
    }
    
    /* Show navigation buttons */
    .carousel-nav {
        display: flex;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        background: rgba(11, 11, 30, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        color: #fff;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 
            0 4px 16px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.05);
        opacity: 0;
    }
    
    .content-carousel:hover .carousel-nav {
        opacity: 1;
    }
    
    .carousel-nav--prev {
        left: 0;
    }
    
    .carousel-nav--next {
        right: 0;
    }
    
    .trending-rank {
        width: 44px;
        height: 44px;
        font-size: 22px;
        top: -10px;
        left: -10px;
        border-radius: 10px;
        border-width: 3px;
    }
    
    /* Hover effects for non-touch */
    .content-row:hover .content-type-icon {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.2);
        transform: scale(1.05) rotate(5deg);
    }
    
    .carousel-item:hover {
        transform: scale(1.05);
        z-index: 5;
    }
    
    .carousel-nav:hover {
        background: rgba(123, 47, 255, 0.9);
        border-color: rgba(123, 47, 255, 0.5);
        transform: translateY(-50%) scale(1.1);
        box-shadow: 
            0 8px 24px rgba(123, 47, 255, 0.4),
            0 0 0 1px rgba(123, 47, 255, 0.3);
    }
    
    .carousel-nav:active {
        transform: translateY(-50%) scale(0.95);
    }
}

/* ===============================================
   SMALL DESKTOP (992px+)
   =============================================== */

@media (min-width: 992px) {
    .content-rows-wrapper {
        margin-top: -100px;
    }
    
    .content-row {
        margin-bottom: 2.25rem;
    }
    
    .content-row__header {
        padding: 0 2rem;
        margin-bottom: 1.125rem;
    }
    
    .content-row__title-group {
        gap: 0.875rem;
    }
    
    .content-type-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
        font-size: 28px;
        border-radius: 14px;
    }
    
    .content-row__title {
        font-size: 30px;
    }
    
    .content-row__title::after {
        width: 50px;
        height: 3px;
    }
    
    .content-row__count {
        font-size: 14px;
        padding: 0.3rem 0.75rem;
    }
    
    .trending-badge {
        font-size: 13px;
        padding: 0.5rem 1rem;
    }
    
    .content-row__see-all {
        padding: 0.75rem 1.5rem;
        font-size: 15px;
    }
    
    /* See All shine effect */
    .content-row__see-all::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
        transition: left 0.6s ease;
    }
    
    .content-row__see-all:hover::before {
        left: 100%;
    }
    
    .content-row__see-all:hover {
        background: rgba(123, 47, 255, 0.2);
        border-color: rgba(123, 47, 255, 0.3);
        transform: translateX(4px);
        box-shadow: 0 4px 20px rgba(123, 47, 255, 0.2);
    }
    
    .content-row__see-all:hover svg {
        transform: translateX(4px);
    }
    
    /* Carousel */
    .content-carousel {
        padding: 0 2rem;
    }
    
    .carousel-container {
        margin: 0 56px;
    }
    
    .carousel-track {
        gap: 16px;
    }
    
    .carousel-item {
        flex: 0 0 calc((100% - 64px) / 5);
        min-width: 160px;
        max-width: 200px;
    }
    
    .carousel-nav {
        width: 44px;
        height: 44px;
    }
    
    .trending-rank {
        width: 48px;
        height: 48px;
        font-size: 24px;
        top: -10px;
        left: -10px;
    }
}

/* ===============================================
   DESKTOP (1200px+)
   =============================================== */

@media (min-width: 1200px) {
    .content-rows-wrapper {
        margin-top: -120px;
    }
    
    .content-row {
        margin-bottom: 2.5rem;
    }
    
    .content-row__header {
        margin-bottom: 1.25rem;
    }
    
    .content-row__title-group {
        gap: 1rem;
    }
    
    .content-type-icon {
        width: 56px;
        height: 56px;
        min-width: 56px;
        font-size: 32px;
        border-radius: 16px;
    }
    
    .content-row__title {
        font-size: 34px;
        letter-spacing: -0.5px;
    }
    
    .content-row__title::after {
        width: 60px;
    }
    
    .content-row__count {
        font-size: 15px;
        padding: 0.375rem 0.875rem;
    }
    
    .trending-badge {
        font-size: 15px;
        padding: 0.6rem 1.2rem;
        gap: 0.5rem;
        box-shadow: 
            0 0 20px rgba(233, 30, 255, 0.3),
            0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .content-row__see-all {
        padding: 0.85rem 1.75rem;
        font-size: 16px;
    }
    
    /* Carousel */
    .carousel-container {
        margin: 0 60px;
    }
    
    .carousel-track {
        gap: 20px;
    }
    
    .carousel-item {
        flex: 0 0 calc((100% - 100px) / 6);
        min-width: 180px;
        max-width: 220px;
    }
    
    .carousel-nav {
        width: 48px;
        height: 48px;
        box-shadow: 
            0 8px 24px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.05);
    }
    
    .trending-rank {
        width: 52px;
        height: 52px;
        font-size: 28px;
        top: -12px;
        left: -12px;
        border-radius: 12px;
        box-shadow: 
            0 4px 12px rgba(233, 30, 255, 0.4),
            0 0 0 1px rgba(255, 255, 255, 0.1);
    }
}

/* ===============================================
   LARGE DESKTOP (1400px+)
   =============================================== */

@media (min-width: 1400px) {
    .carousel-item {
        flex: 0 0 calc((100% - 100px) / 6);
        min-width: 190px;
        max-width: 230px;
    }
}

/* ===============================================
   ULTRA WIDE (1920px+)
   =============================================== */

@media (min-width: 1920px) {
    .carousel-item {
        flex: 0 0 calc((100% - 120px) / 7);
        min-width: 200px;
        max-width: 240px;
    }
}

/* ===============================================
   SPECIAL EFFECTS
   =============================================== */

/* Glassmorphic Backdrop Effect */
.content-row::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 120%;
    background: radial-gradient(
        ellipse at center,
        rgba(123, 47, 255, 0.05) 0%,
        transparent 70%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

@media (min-width: 768px) {
    .content-row:hover::after {
        opacity: 1;
    }
}

/* Loading State */
.skeleton-wrapper {
    opacity: 0.6;
    pointer-events: none;
}

/* Smooth Transition for Track */
.carousel-track {
    will-change: transform;
}

/* ===============================================
   ACCESSIBILITY & REDUCED MOTION
   =============================================== */

@media (prefers-reduced-motion: reduce) {
    .carousel-track {
        transition: none;
    }
    
    .content-row {
        animation: none;
    }
    
    .trending-badge,
    .carousel-nav,
    .content-type-icon,
    .carousel-item {
        animation: none;
        transition: none;
    }
}

/* ===============================================
   MOBILE PERFORMANCE - SMOOTH SCROLLING
   Disable expensive effects for lag-free experience
   =============================================== */

@media (max-width: 991.98px) {
    /* Disable ALL infinite animations on mobile - causes lag */
    .trending-badge,
    .content-type-icon,
    .pulse-glow,
    [class*="pulse"],
    [class*="glow"] {
        animation: none !important;
    }
    
    /* Disable fade-in animations - load content instantly */
    .content-row {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    /* Remove all backdrop-filter blur - very expensive on mobile */
    .content-type-icon,
    .trending-badge,
    .carousel-nav,
    .content-row__see-all {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Simplify backgrounds */
    .content-type-icon {
        background: rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Disable hover transforms on mobile */
    .carousel-item:hover,
    .content-row:hover .content-type-icon,
    .content-row__see-all:hover {
        transform: none !important;
    }
    
    /* Optimize carousel scrolling */
    .carousel-track,
    .carousel-container {
        scroll-behavior: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Disable box-shadow animations */
    .trending-badge {
        box-shadow: none !important;
    }
    
    /* Use simpler transitions */
    .carousel-item,
    .content-card,
    .poster-card {
        transition: opacity 0.15s ease !important;
    }
}

/* ============================================
   Hero Image Quality Fixes
   ============================================ */

/* Ensure hero backdrop renders at highest quality */
.hero-cinematic,
.hero-slide,
.hero,
.hero-cinematic-carousel .hero-slide {
    /* Force high-quality image rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    
    /* Prevent browser from applying blur/smoothing during scale */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    
    /* Enable hardware acceleration without quality loss */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    
    /* Ensure background image is crisp */
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

/* High-DPI/Retina display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-cinematic,
    .hero-slide {
        /* Use better interpolation on retina */
        image-rendering: auto;
    }
}

/* Prevent quality loss from transform animations */
.hero-cinematic::before,
.hero-slide::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    background-size: inherit;
    background-position: inherit;
    z-index: -1;
}

/* Fix for background-image quality on Safari */
@supports (-webkit-backdrop-filter: none) {
    .hero-cinematic,
    .hero-slide {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .carousel-nav {
        display: none !important;
    }
    
    .carousel-container {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    .carousel-item {
        scroll-snap-align: start;
    }
    
    /* Disable hover effects on touch */
    .carousel-item:hover {
        transform: none;
    }
    
    .content-row:hover .content-type-icon {
        transform: none;
    }
    
    /* Active state for touch */
    .carousel-item:active {
        transform: scale(0.98);
    }
    
    .content-row__see-all:active {
        background: rgba(123, 47, 255, 0.3);
    }
}