/* Space Gate Nova+ — final header, catalog and details polish
   Loaded last to resolve legacy style collisions without removing existing features. */

:root {
    --nova-compact-header-h: 54px;
    --nova-glass-black: rgba(0, 0, 0, .76);
    --nova-glass-black-strong: rgba(0, 0, 0, .86);
    --nova-active-gradient: linear-gradient(100deg, #f04ad8 0%, #9b4dff 48%, #14d7ff 100%);
}

/* --------------------------------------------------------------------------
   1. Reactive application headers — transparent at the top, black glass after
      real document OR nested WebView scrolling.
   -------------------------------------------------------------------------- */
header.oscar-toolbar.nova-reactive-header,
header.oscar-toolbar.professional-home-toolbar,
.catalog-landing-toolbar.nova-reactive-header {
    height: calc(var(--nova-compact-header-h) + var(--safe-top, env(safe-area-inset-top, 0px))) !important;
    min-height: calc(var(--nova-compact-header-h) + var(--safe-top, env(safe-area-inset-top, 0px))) !important;
    padding-top: var(--safe-top, env(safe-area-inset-top, 0px)) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: blur(0) saturate(1) !important;
    -webkit-backdrop-filter: blur(0) saturate(1) !important;
    transition: background .24s cubic-bezier(.2,.78,.2,1),
                backdrop-filter .24s cubic-bezier(.2,.78,.2,1),
                box-shadow .24s cubic-bezier(.2,.78,.2,1) !important;
}

html.sg-header-scrolled header.oscar-toolbar.nova-reactive-header,
html.sg-header-scrolled header.oscar-toolbar.professional-home-toolbar,
html.sg-header-scrolled .catalog-landing-toolbar.nova-reactive-header {
    background: var(--nova-glass-black) !important;
    box-shadow: 0 12px 30px rgba(0,0,0,.30) !important;
    backdrop-filter: blur(18px) saturate(1.08) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.08) !important;
}

header.oscar-toolbar.professional-home-toolbar {
    padding-inline: clamp(14px, 3vw, 22px) !important;
}

.professional-home-toolbar .home-toolbar-shell {
    min-height: var(--nova-compact-header-h) !important;
}

/* Remove the old purple SPACE GATE NOVA+ eyebrow from section landing pages. */
.catalog-landing-title-copy > span,
.catalog-landing-toolbar span:not(.nova-refresh-desktop-icon) {
    display: none !important;
}

.catalog-landing-toolbar {
    padding-inline: clamp(14px, 3vw, 24px) !important;
}

.catalog-landing-toolbar h1 {
    font-size: clamp(1.08rem, 2.4vw, 1.42rem) !important;
    line-height: 1 !important;
}

.catalog-landing-toolbar-actions {
    gap: 7px !important;
}

.catalog-landing-toolbar-button {
    width: 35px !important;
    height: 35px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   2. All-content pages — compact fixed header with very small row spacing.
   -------------------------------------------------------------------------- */
.nova-catalog-fixed-header {
    background: transparent !important;
}

html.sg-header-scrolled .nova-catalog-fixed-header {
    background: var(--nova-glass-black-strong) !important;
}

.nova-catalog-brand,
.nova-catalog-menu,
.nova-catalog-heading-copy p {
    display: none !important;
}

.nova-catalog-back,
.nova-catalog-icon {
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.nova-catalog-search:focus-within,
.nova-catalog-controls-row.mobile-open .nova-catalog-search {
    border: 1px solid transparent !important;
    background:
        linear-gradient(#05070d, #05070d) padding-box,
        var(--nova-active-gradient) border-box !important;
    box-shadow: 0 0 0 1px rgba(155,77,255,.06), 0 8px 24px rgba(0,0,0,.22) !important;
}

@media (max-width: 1000px) {
    :root {
        --nova-catalog-header-h: calc(132px + var(--safe-top, 0px));
        --sg-catalog-fixed-h: var(--nova-catalog-header-h);
        --nova-catalog-control-h: 34px;
        --nova-catalog-chip-h: 32px;
    }

    .nova-catalog-page.mobile-search-open {
        --nova-catalog-header-h: calc(178px + var(--safe-top, 0px));
        --sg-catalog-fixed-h: var(--nova-catalog-header-h);
    }

    .nova-catalog-fixed-header {
        height: var(--nova-catalog-header-h) !important;
        min-height: var(--nova-catalog-header-h) !important;
        padding: var(--safe-top, 0px) 12px 3px !important;
        grid-template-rows: 50px 42px 34px !important;
        gap: 0 !important;
        align-content: start !important;
        overflow: hidden !important;
    }

    .nova-catalog-page.mobile-search-open .nova-catalog-fixed-header {
        grid-template-rows: 50px 88px 34px !important;
    }

    .nova-catalog-page {
        padding-top: calc(var(--nova-catalog-header-h) + 4px) !important;
    }

    .nova-catalog-hero-row {
        height: 50px !important;
        min-height: 50px !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        grid-template-areas: "heading actions" !important;
        gap: 8px !important;
        direction: rtl !important;
    }

    .nova-catalog-heading-group {
        grid-area: heading !important;
        min-width: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        direction: rtl !important;
    }

    .nova-catalog-heading-copy {
        min-width: 0 !important;
        justify-items: start !important;
        text-align: right !important;
    }

    .nova-catalog-heading-copy h1 {
        margin: 0 !important;
        font-size: clamp(1.28rem, 6vw, 1.72rem) !important;
        line-height: 1 !important;
        background: none !important;
        color: #fff !important;
        -webkit-text-fill-color: #fff !important;
    }

    .nova-catalog-back {
        display: grid !important;
        position: static !important;
        width: 33px !important;
        height: 33px !important;
        min-width: 33px !important;
        color: #fff !important;
    }

    .nova-catalog-actions {
        grid-area: actions !important;
        justify-self: end !important;
        gap: 3px !important;
        direction: ltr !important;
    }

    .nova-catalog-icon {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
    }

    .nova-catalog-controls-row {
        height: 42px !important;
        min-height: 42px !important;
        grid-template-rows: 42px !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    .nova-catalog-controls-row.mobile-open {
        height: 88px !important;
        min-height: 88px !important;
        grid-template-rows: 46px 40px !important;
        gap: 2px !important;
    }

    .nova-catalog-search {
        height: 43px !important;
        min-height: 43px !important;
        margin: 0 !important;
        border-radius: 8px !important;
    }

    .nova-catalog-filter-strip {
        height: 40px !important;
        min-height: 40px !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .nova-catalog-select-card,
    .nova-catalog-reset-filter {
        height: 34px !important;
        min-height: 34px !important;
        border-radius: 7px !important;
    }

    .nova-catalog-select-card {
        min-width: 84px !important;
        max-width: 126px !important;
        padding-inline: 7px !important;
        gap: 4px !important;
    }

    .nova-catalog-genre-row {
        height: 34px !important;
        min-height: 34px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .nova-catalog-fixed-header .nova-category-strip {
        height: 34px !important;
        min-height: 34px !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
        align-items: center !important;
    }

    .nova-catalog-fixed-header .nova-category-strip button,
    .nova-catalog-fixed-header .nova-category-strip .nova-category-chip {
        height: 32px !important;
        min-height: 32px !important;
        min-width: 56px !important;
        padding-inline: 12px !important;
        border-radius: 7px !important;
        font-size: .68rem !important;
    }
}

@media (max-width: 390px) {
    :root { --nova-catalog-header-h: calc(128px + var(--safe-top, 0px)); }
    .nova-catalog-page.mobile-search-open { --nova-catalog-header-h: calc(174px + var(--safe-top, 0px)); }
    .nova-catalog-fixed-header { padding-inline: 9px !important; }
    .nova-catalog-select-card { min-width: 78px !important; max-width: 112px !important; }
}

/* --------------------------------------------------------------------------
   3. Details page — remove the oversized dark toolbar and restore a cinematic
      Android hero with correctly distributed controls and content.
   -------------------------------------------------------------------------- */
.cinematic-details-page .nova-details-topbar,
.nova-channel-details .nova-details-topbar {
    position: fixed !important;
    z-index: 2147482500 !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(var(--nova-compact-header-h) + var(--safe-top, 0px)) !important;
    min-height: calc(var(--nova-compact-header-h) + var(--safe-top, 0px)) !important;
    padding: var(--safe-top, 0px) 16px 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: blur(0) !important;
    -webkit-backdrop-filter: blur(0) !important;
    pointer-events: none !important;
}

html.sg-header-scrolled .cinematic-details-page .nova-details-topbar,
html.sg-header-scrolled .nova-channel-details .nova-details-topbar {
    background: var(--nova-glass-black) !important;
    box-shadow: 0 12px 30px rgba(0,0,0,.28) !important;
    backdrop-filter: blur(18px) saturate(1.08) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.08) !important;
}

.cinematic-details-page .nova-details-topbar .nova-icon-btn,
.nova-channel-details .nova-details-topbar .nova-icon-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    pointer-events: auto !important;
}

.cinematic-details-page .nova-topbar-actions,
.nova-channel-details .nova-topbar-actions {
    gap: 8px !important;
    pointer-events: auto !important;
}

@media (max-width: 820px) {
    .cinematic-details-page {
        background: #000 !important;
    }

    .cinematic-details-hero {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: clamp(590px, 76dvh, 760px) !important;
        min-height: 590px !important;
        overflow: hidden !important;
        background: #000 !important;
    }

    .cinematic-details-backdrop {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        object-fit: cover !important;
        object-position: center top !important;
    }

    .cinematic-details-shade {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background:
            linear-gradient(180deg, rgba(0,0,0,.03) 0%, rgba(0,0,0,.04) 35%, rgba(0,0,0,.30) 56%, rgba(0,0,0,.88) 82%, #000 100%),
            linear-gradient(90deg, rgba(0,0,0,.16), transparent 48%, rgba(0,0,0,.12)) !important;
    }

    .cinematic-hero-copy {
        position: absolute !important;
        z-index: 2 !important;
        inset: 0 !important;
        width: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: calc(var(--nova-compact-header-h) + var(--safe-top, 0px) + 20px) 16px 22px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-end !important;
        text-align: center !important;
        background: transparent !important;
        box-sizing: border-box !important;
    }

    .cinematic-eyebrow,
    .cinematic-meta,
    .cinematic-ranking {
        justify-content: center !important;
    }

    .cinematic-title {
        width: min(100%, 680px) !important;
        margin: 7px auto 11px !important;
        font-size: clamp(2rem, 9vw, 3.05rem) !important;
        line-height: 1.04 !important;
        letter-spacing: -.025em !important;
        text-align: center !important;
        overflow-wrap: anywhere !important;
        text-wrap: balance !important;
    }

    .cinematic-meta {
        gap: 5px !important;
    }

    .cinematic-meta > *,
    .cinematic-age {
        min-height: 27px !important;
        padding-inline: 9px !important;
        font-size: .67rem !important;
    }

    .cinematic-ranking {
        margin-top: 8px !important;
        gap: 7px !important;
    }

    .cinematic-ranking span {
        min-height: 31px !important;
        padding-inline: 10px !important;
        border-radius: 7px !important;
        background: rgba(0,0,0,.58) !important;
        font-size: .66rem !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }

    .cinematic-actions {
        width: 100% !important;
        margin-top: 15px !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
        direction: rtl !important;
    }

    .cinematic-watch-button {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        height: 54px !important;
        min-height: 54px !important;
        border-radius: 12px !important;
        font-size: 1rem !important;
    }

    .cinematic-secondary-action {
        min-height: 49px !important;
        padding: 0 12px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        border: 1px solid rgba(255,255,255,.18) !important;
        border-radius: 11px !important;
        background: rgba(0,0,0,.42) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }

    .cinematic-secondary-action span {
        font-size: .76rem !important;
    }

    .cinematic-details-content {
        position: relative !important;
        z-index: 3 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 15px 24px !important;
        background: #000 !important;
        box-sizing: border-box !important;
    }

    .cinematic-tabs {
        margin-top: 0 !important;
    }
}

@media (max-width: 390px) {
    .cinematic-details-hero {
        height: clamp(550px, 73dvh, 690px) !important;
        min-height: 550px !important;
    }

    .cinematic-title {
        font-size: clamp(1.78rem, 8.4vw, 2.45rem) !important;
    }
}

/* --------------------------------------------------------------------------
   4. Refined Windows refresh action.
   -------------------------------------------------------------------------- */
.nova-refresh-desktop {
    width: 36px !important;
    height: 36px !important;
    color: rgba(255,255,255,.92) !important;
}

.nova-refresh-desktop:hover {
    color: #fff !important;
    filter: drop-shadow(0 0 9px rgba(71,175,255,.72)) drop-shadow(0 0 5px rgba(205,73,255,.48));
}

.nova-refresh-desktop-icon {
    border-radius: 50%;
}

.is-refreshing .nova-refresh-desktop-icon {
    color: #7ad9ff !important;
}

@media (prefers-reduced-motion: reduce) {
    header.oscar-toolbar.nova-reactive-header,
    .catalog-landing-toolbar.nova-reactive-header,
    .nova-catalog-fixed-header,
    .cinematic-details-page .nova-details-topbar {
        transition: none !important;
    }
}
