/* ============================================================
   CCG PERFORMANCE FOUNDATIONS
   ------------------------------------------------------------
   Shared rendering containment and animation controls.
   Loaded by resources/js/ccg-performance.js.
============================================================ */

html.ccg-perf-enabled .games-accordion__section,
html.ccg-perf-enabled .ccg-publisher-results,
html.ccg-perf-enabled .ccg-developer-results,
html.ccg-perf-enabled [data-ccg-defer-render] {
    content-visibility: auto;
    contain-intrinsic-size: auto 720px;
}

html.ccg-perf-enabled .games-accordion__section {
    contain-intrinsic-size: auto 240px;
}

html.ccg-perf-enabled img[data-ccg-perf-normalized="true"] {
    max-width: 100%;
}

html.ccg-perf-paused .ccg-bg-starfield,
html.ccg-perf-paused .ccg-bg-grid,
html.ccg-perf-paused .ccg-bg-crt-overlay,
html.ccg-perf-paused .home-hero__scanlines,
html.ccg-perf-paused .home-hero__crt-overlay,
html.ccg-perf-paused .home-hero__bg,
html.ccg-perf-paused .home-hero__content::after,
html.ccg-perf-paused .home-hero__title,
html.ccg-perf-paused .home-hero__mode-pill,
html.ccg-perf-paused .home-random-cta,
html.ccg-perf-paused .home-featured-videos .home-video-card,
html.ccg-perf-paused .home-visitor-callout__beam,
html.ccg-perf-paused .home-visitor-callout__headline--interactive,
html.ccg-page-hidden .ccg-bg-starfield,
html.ccg-page-hidden .ccg-bg-grid,
html.ccg-page-hidden .ccg-bg-crt-overlay,
html.ccg-page-hidden .home-hero__scanlines,
html.ccg-page-hidden .home-hero__crt-overlay,
html.ccg-page-hidden .home-hero__bg,
html.ccg-page-hidden .home-hero__content::after,
html.ccg-page-hidden .home-hero__title,
html.ccg-page-hidden .home-hero__mode-pill,
html.ccg-page-hidden .home-random-cta,
html.ccg-page-hidden .home-featured-videos .home-video-card,
html.ccg-page-hidden .home-visitor-callout__beam,
html.ccg-page-hidden .home-visitor-callout__headline--interactive {
    animation-play-state: paused !important;
}

html.ccg-perf-save-data .ccg-bg-starfield,
html.ccg-perf-save-data .ccg-bg-grid,
html.ccg-perf-save-data .ccg-bg-crt-overlay,
html.ccg-perf-reduced-motion .ccg-bg-starfield,
html.ccg-perf-reduced-motion .ccg-bg-grid,
html.ccg-perf-reduced-motion .ccg-bg-crt-overlay {
    animation: none !important;
}

/* A narrowed or short browser window has much less compositing room than a
   wide desktop. Keep the Omega artwork, but stop continuous decorative work
   as soon as the viewport crosses into the compact layout. */
html.ccg-perf-compact .ccg-bg-starfield,
html.ccg-perf-compact .ccg-bg-grid,
html.ccg-perf-compact .ccg-bg-crt-overlay,
html.ccg-perf-compact .home-hero__bg,
html.ccg-perf-compact .home-hero__scanlines,
html.ccg-perf-compact .home-hero__crt-overlay,
html.ccg-perf-compact .home-hero__content::after,
html.ccg-perf-compact .home-hero__title,
html.ccg-perf-compact .home-hero__mode-pill,
html.ccg-perf-compact .home-random-cta,
html.ccg-perf-compact .home-featured-videos .home-video-card,
html.ccg-perf-compact .home-visitor-callout__beam,
html.ccg-perf-compact .home-visitor-callout__headline--interactive {
    animation: none !important;
    will-change: auto !important;
}

html.ccg-perf-compact .home-hero__content,
html.ccg-perf-compact .ccg-global-search__backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ============================================================
   SCROLL-STABILITY PASS
   ------------------------------------------------------------
   Ordinary chapters and page sections stay rendered before they enter the
   viewport. Deferred rendering is reserved for explicit archive/result
   surfaces so wheel and touch scrolling do not hitch at section boundaries.
============================================================ */

/* Keep the Omega look static rather than continuously recompositing hero and
   divider layers on compact/mobile viewports. */
html.ccg-perf-compact .ccg-omega-divider,
html.ccg-perf-compact .ccg-omega-core,
html.ccg-perf-compact .ccg-hero-overlay-starfield,
html.ccg-perf-compact .ccg-hero-overlay-crt,
html.ccg-perf-compact .ccg-hero-scanlines,
html.ccg-perf-compact .games-hero img,
html.ccg-perf-compact .game-hero__bg img,
html.ccg-perf-compact .ccg-genre-hero__img,
html.ccg-perf-compact .ccg-hero__backdrop img,
html.ccg-perf-compact .ccg-hero--collections::before,
html.ccg-perf-compact .ccg-hero--collections .ccg-hero-image {
    animation: none !important;
    will-change: auto !important;
}

/* Sticky/fixed glass effects and oversized shadows are among the most costly
   things to repaint while a mobile viewport moves. The mobile presentation
   keeps its borders/backgrounds, but drops those compositor-heavy effects. */
html.ccg-perf-compact :is(
    .ccg-header,
    .ccg-nav,
    .ccg-nav__more-menu,
    .ccg-hud-dock,
    .ccg-global-search__backdrop,
    .ccg-global-search__dialog
) {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html.ccg-perf-compact :is(
    .ccg-header,
    .ccg-global-search__dialog,
    .ccg-hud-dock
) {
    box-shadow: none !important;
}

/* The search results are their own scroll surface on phones. Use native touch
   momentum and avoid any smooth-scroll work inside that nested scroller. */
html.ccg-perf-compact .ccg-global-search__results {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: auto !important;
    touch-action: pan-y;
}

@media (max-width: 820px) {
    html.ccg-perf-enabled [data-ccg-defer-render] {
        contain-intrinsic-size: auto 560px;
    }
}

@media print {
    html.ccg-perf-enabled .ccg-main > .ccg-chapter,
    html.ccg-perf-enabled .ccg-main > section,
    html.ccg-perf-enabled .games-accordion__section,
    html.ccg-perf-enabled [data-ccg-defer-render] {
        content-visibility: visible;
        contain-intrinsic-size: none;
    }
}
