/* ============================================================
   CCG PUBLIC SCROLL AUTHORITY
   ------------------------------------------------------------
   Public pages use the document element as the single vertical
   scroll root. Body/page shells must not compete with it. Intentional
   overlays, drawers and search-result panels keep their own scrolling.
============================================================ */

html[data-ccg-page] {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: auto !important;
    scroll-behavior: auto !important;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.72) rgba(2, 6, 14, 0.94);
}

/* `clip` prevents horizontal escape without creating another scroll
   container. Chromium can otherwise pair overflow-x:hidden with an auto
   vertical overflow value, which makes wheel ownership less deterministic. */
@supports (overflow: clip) {
    html[data-ccg-page] {
        overflow-x: clip !important;
    }
}

html[data-ccg-page] > body.ccg-body:not(.ccg-body--locked):not(.ccg-body--nav-open) {
    position: static !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
    overflow-x: clip !important;
    overscroll-behavior-y: auto !important;
    scroll-behavior: auto !important;
}

@supports not (overflow: clip) {
    html[data-ccg-page] > body.ccg-body:not(.ccg-body--locked):not(.ccg-body--nav-open) {
        overflow-x: hidden !important;
    }
}

/* Public layout shells should never become a second wheel-scrolling surface. */
html[data-ccg-page] > body.ccg-body :where(
    .ccg-page,
    .ccg-main,
    main,
    .games-main,
    .ccg-discover
) {
    height: auto !important;
    min-height: 0;
    max-height: none !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
    scroll-behavior: auto !important;
}

/* Keep navigation viewport locks authoritative. The Easter Egg secret modal
   is a fixed viewport overlay and owns background input itself; changing the
   document scroll root here can clamp scrollY by a few pixels on short/mobile
   viewports when the scrollbar geometry changes. */
html[data-ccg-page]:has(> body.ccg-body.ccg-body--nav-open),
html[data-ccg-page]:has(> body.ccg-body.ccg-body--locked) {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

/* Keep actual nested UI scrollers native and isolated from the page. */
html[data-ccg-page] :where(
    .ccg-nav-drawer__panel,
    .ccg-global-search__results,
    .ccg-global-search__dialog,
    [role="dialog"] [data-ccg-scroll-region]
) {
    scroll-behavior: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   EMBEDDED MEDIA WHEEL PASS-THROUGH
   ------------------------------------------------------------
   Cross-origin video players sit in their own browsing context, so physical
   wheel input over them may never reach the page. The shared JS guard places
   a transparent parent-layer control over inline YouTube players on desktop.
   Native page scrolling remains available until the viewer deliberately
   activates the embedded controls; leaving the player re-arms the guard.
============================================================ */

html[data-ccg-page] .ccg-wheel-guard-host {
    position: relative;
}

html[data-ccg-page] .ccg-wheel-guard {
    position: absolute;
    z-index: 20;
    display: none;
    box-sizing: border-box !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: inherit;
    appearance: none;
    -webkit-appearance: none;
    background: transparent !important;
    color: inherit;
    cursor: pointer;
    touch-action: auto;
    transform: none !important;
    scale: 1 !important;
    animation: none !important;
    transition: none !important;
}

html[data-ccg-page] .ccg-wheel-guard[hidden],
html[data-ccg-page] .ccg-wheel-guard-host--active > .ccg-wheel-guard {
    display: none !important;
}

html[data-ccg-page] .ccg-wheel-guard__hint {
    position: absolute;
    right: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
    padding: 6px 9px;
    border: 1px solid rgba(var(--accent-rgb), 0.34);
    border-radius: 999px;
    background: rgba(2, 6, 14, 0.88);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;
    line-height: 1.2;
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 120ms ease, transform 120ms ease;
    pointer-events: none;
}

html[data-ccg-page] .ccg-wheel-guard:hover .ccg-wheel-guard__hint,
html[data-ccg-page] .ccg-wheel-guard:focus-visible .ccg-wheel-guard__hint {
    opacity: 1;
    transform: translateY(0);
}

html[data-ccg-page] .ccg-wheel-guard:focus-visible {
    outline: 2px solid rgba(var(--accent-rgb), 0.78);
    outline-offset: -3px;
}

@media (any-hover: hover) and (any-pointer: fine) {
    html[data-ccg-page] .ccg-wheel-guard:not([hidden]) {
        display: block;
    }
}

/* ============================================================
   SITE-WIDE WHEEL PERFORMANCE CONTRACT
   ------------------------------------------------------------
   Mouse-wheel scrolling remains fully native. Expensive background-position
   drift is removed from the fixed universe layer on public pages while its
   subtle opacity breathing remains. This avoids repainting a viewport-sized
   fixed image on every animation frame before the first wheel event arrives.
============================================================ */

html[data-ccg-page] .ccg-bg-starfield {
    animation: ccg-star-breathe 24s ease-in-out infinite !important;
    will-change: opacity !important;
}

html[data-ccg-page] .ccg-bg-starfield::after {
    animation: ccg-star-breathe-alt 30s ease-in-out infinite !important;
    will-change: opacity !important;
}

/* Editorial/video collections share the same card component. Do not promote
   every card into its own compositor layer: on long collection pages that turns
   normal wheel scrolling into unnecessary layer management. Off-screen cards
   may also skip rendering work until they approach the viewport. */
html[data-ccg-page="collection-single"]
> body[data-collection="Retro Specials"]
.ccg-game-card--retro-event,
html[data-ccg-page="collection-single"]
> body[data-collection="Retro Events"]
.ccg-game-card--retro-event,
html[data-ccg-page="collection-single"]
> body[data-collection="Amiga Demo Music"]
.ccg-game-card--retro-event {
    transform: none;
    will-change: auto;
    content-visibility: auto;
    contain-intrinsic-size: auto 340px;
}

/* Avoid invalidating the HTML root's descendants simply to pause a small
   fixed decorative universe, on any CCG page with that background. */
html[data-ccg-page] .ccg-bg.ccg-perf-paused .ccg-bg-starfield,
html[data-ccg-page] .ccg-bg.ccg-perf-paused .ccg-bg-starfield::after,
html[data-ccg-page] .ccg-bg.ccg-perf-paused .ccg-bg-particles__spark {
    animation-play-state: paused !important;
    will-change: auto !important;
}

/* During active document scrolling the shared `ccg-perf-paused` state pauses
   decorative motion and removes hover-transition churn across ALL public
   pages, including Browse by Genre, Collections, game pages, Home and hubs. */
html.ccg-perf-paused[data-ccg-page] .ccg-bg-starfield,
html.ccg-perf-paused[data-ccg-page] .ccg-bg-starfield::after,
html.ccg-perf-paused[data-ccg-page] .ccg-bg-particles__spark,
html.ccg-perf-paused[data-ccg-page] .ccg-pulse,
html.ccg-perf-paused[data-ccg-page] .ccg-fade-in,
html.ccg-perf-paused[data-ccg-page] .ccg-slide-up,
html.ccg-perf-paused[data-ccg-page] .ccg-anim-in {
    animation-play-state: paused !important;
    will-change: auto !important;
}

html.ccg-perf-paused[data-ccg-page] :where(
    .ccg-card,
    .ccg-game-card,
    .ccg-genre-card,
    .ccg-collection-card,
    .ccg-feature-card,
    .home-video-card,
    .home-highlight-card,
    .ccg-publisher-card,
    .video-library-card,
    .related-card
) {
    transition: none !important;
    will-change: auto !important;
}

html.ccg-perf-paused[data-ccg-page] :where(
    .ccg-card,
    .ccg-game-card,
    .ccg-genre-card,
    .ccg-collection-card,
    .ccg-feature-card,
    .home-video-card,
    .home-highlight-card,
    .ccg-publisher-card,
    .video-library-card,
    .related-card
):is(:hover, :focus-within) {
    transform: none !important;
    filter: none !important;
}

html.ccg-perf-paused[data-ccg-page] :where(
    .ccg-card,
    .ccg-game-card,
    .ccg-genre-card,
    .ccg-collection-card,
    .ccg-feature-card,
    .home-video-card,
    .home-highlight-card,
    .ccg-publisher-card,
    .video-library-card,
    .related-card
) img {
    transition: none !important;
    will-change: auto !important;
}

html.ccg-perf-paused[data-ccg-page] :where(
    .ccg-card,
    .ccg-game-card,
    .ccg-genre-card,
    .ccg-collection-card,
    .ccg-feature-card,
    .home-video-card,
    .home-highlight-card,
    .ccg-publisher-card,
    .video-library-card,
    .related-card
):is(:hover, :focus-within) img {
    transform: none !important;
    filter: none !important;
}

/* One restrained Omega scrollbar instead of a heavy inner/outer rail effect. */
html[data-ccg-page]::-webkit-scrollbar {
    width: 11px;
}

html[data-ccg-page]::-webkit-scrollbar-track {
    background: rgba(2, 6, 14, 0.94);
    border-left: 1px solid rgba(var(--accent-rgb), 0.14);
}

html[data-ccg-page]::-webkit-scrollbar-thumb {
    min-height: 54px;
    border: 2px solid rgba(2, 6, 14, 0.94);
    border-radius: 8px;
    background: linear-gradient(
        to bottom,
        rgba(var(--accent-rgb), 0.88),
        rgba(var(--accent-rgb), 0.48)
    );
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

html[data-ccg-page]::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--accent-rgb), 0.92);
}

@media (max-width: 820px) {
    html[data-ccg-page] {
        scrollbar-gutter: auto;
    }

    html[data-ccg-page]::-webkit-scrollbar {
        width: 8px;
    }
}
