/**
 * NGOMA STREAM - Adaptive Performance & Loading Stylesheet
 * Handles adaptive device tiers, network-aware optimizations,
 * zero-CLS skeleton shimmers, and non-blocking sync animations.
 */

/* 1. Zero-CLS Skeleton Shimmer & Image Loading */
.skeleton-shimmer {
    position: relative;
    overflow: hidden;
    background: #141722;
}

.skeleton-shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.04) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: skeletonShimmer 1.8s infinite ease-in-out;
    pointer-events: none;
}

@keyframes skeletonShimmer {
    100% {
        transform: translateX(100%);
    }
}

.fade-in-img {
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity;
}

.fade-in-img.loaded {
    opacity: 1;
}

/* 2. Network-Aware & Data-Saver Adaptations */
html[data-network-speed="slow"] .catalog-card:hover,
html[data-data-saver="active"] .catalog-card:hover {
    transform: translateY(-3px) scale(1.01) !important;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5) !important;
}

html[data-network-speed="slow"] .hero-bg,
html[data-data-saver="active"] .hero-bg {
    filter: none !important;
}

/* 3. Low-Tier Device Hardware Adaptations */
html[data-device-tier="low"] .heavy-blur-only {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

html[data-device-tier="low"] .netflix-nav,
html[data-device-tier="low"] .mobile-bottom-nav,
html[data-device-tier="low"] .watch-top-bar {
    background: rgba(14, 16, 24, 0.98) !important;
}

html[data-device-tier="low"] .home-hero::before,
html[data-device-tier="low"] .details-hero::before {
    background: rgba(8, 9, 12, 0.85) !important;
}

/* 4. Infinite Scroll Sentinel & Loader */
.infinite-scroll-sentinel {
    width: 100%;
    height: 60px;
    margin: 30px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    font-size: 14px;
    font-weight: 500;
}

.infinite-scroll-spinner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E2E8F0;
}

.infinite-scroll-spinner i {
    color: var(--brand-red, #E50914);
}

.infinite-scroll-end {
    text-align: center;
    padding: 25px 0;
    color: #64748B;
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* 5. Smooth In-Place Content Sync Pop-In */
@keyframes contentItemPopIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.sync-item-fresh {
    animation: contentItemPopIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
}

.sync-item-fresh::after {
    content: 'NOUVEAU';
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #FF2D55 0%, #E50914 100%);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 900;
    padding: 3px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.6);
    z-index: 5;
    pointer-events: none;
}

/* 6. Subtle Discrete Sync Notification Badge */
.sync-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(70, 211, 105, 0.15);
    border: 1px solid rgba(70, 211, 105, 0.3);
    border-radius: 20px;
    font-size: 11px;
    color: #46D369;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sync-live-pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #46D369;
    animation: syncDotPulse 2s infinite ease-in-out;
}

@keyframes syncDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

/* =========================================================================
   7. ULTRANAV TOP PROGRESS BAR (Instant <5ms Visual Feedback)
   ========================================================================= */
.ultra-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #ff7edb 0%, #fe4450 50%, #36f9f6 100%);
    box-shadow: 0 0 10px rgba(254, 68, 80, 0.8), 0 0 4px rgba(54, 249, 246, 0.9);
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: width 0.18s ease, opacity 0.2s ease;
    will-change: width, opacity;
}

.ultra-progress-bar.is-active {
    opacity: 1;
}

/* =========================================================================
   8. ULTRANAV NAVIGATION SMOOTHNESS
   ========================================================================= */
.netflix-main {
    animation: fadeInPage 0.2s ease-out;
}

@keyframes fadeInPage {
    from { opacity: 0.88; }
    to { opacity: 1; }
}

/* =========================================================================
   9. MOBILE & WEB TOUCH RESPONSIVENESS (300ms Delay Elimination)
   ========================================================================= */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

a, button, input, select, textarea,
.catalog-card, .media-card, .top10-item,
.mobile-nav-item, .nav-link, .btn, .card-btn-circle,
[role="button"], [onclick] {
    touch-action: manipulation;
}

/* Native App Tactile Feedback on Tap / Press */
.mobile-nav-item:active,
.btn:active,
.card-btn-circle:active,
.pills-filter-bar button:active {
    transform: scale(0.94) !important;
    transition: transform 0.08s cubic-bezier(0.2, 0.8, 0.4, 1) !important;
}

.catalog-card:active,
.media-card:active {
    transform: scale(0.98) !important;
    transition: transform 0.08s cubic-bezier(0.2, 0.8, 0.4, 1) !important;
}

/* =========================================================================
   10. 60/120 FPS HARDWARE ACCELERATED SCROLLING & GPU COMPOSITING
   ========================================================================= */
html {
    scroll-behavior: smooth;
}

.media-carousel,
.pills-filter-bar,
.mobile-bottom-nav-items,
.horizontal-scroll-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
}

/* Offscreen Section Rendering Optimization (Huge FPS boost on long pages) */
@supports (content-visibility: auto) {
    .media-section:nth-child(n+4) {
        content-visibility: auto;
        contain-intrinsic-size: 1px 320px;
    }
}

