/* Final responsive layer for the active Nightflixs Blade UI. */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

html {
    overflow-y: auto;
    scroll-behavior: smooth;
}

body.reference-theme {
    min-height: 100vh;
    overflow-y: visible;
    overscroll-behavior-y: auto;
}

body.reference-theme .nf-header-inner {
    width: min(1180px, calc(100% - 32px));
    min-width: 0;
}

/* Keep active header controls on the Nightflixs red/black theme. */
body.reference-theme .nf-search button:hover,
body.reference-theme .nf-search button:focus-visible,
body.reference-theme .nf-icon-link:hover,
body.reference-theme .nf-icon-link:focus-visible {
    color: #fff !important;
    background: #520000 !important;
    border-radius: 9px;
}

body.reference-theme .nf-search button:hover svg,
body.reference-theme .nf-search button:focus-visible svg,
body.reference-theme .nf-icon-link:hover svg,
body.reference-theme .nf-icon-link:focus-visible svg {
    stroke: #fff !important;
}

body.reference-theme .page-wrap {
    width: min(1500px, calc(100% - 48px));
    max-width: 1500px;
    margin-inline: auto;
}

/* The homepage uses normal-hero-carousel as its single source of truth.
   Hide the retired stacked/carousel shell if it is present in an older
   cached Blade view so production cannot render two sliders. */
body.reference-theme.home-page .hero-carousel-frame,
body.reference-theme.home-page .hero-shell {
    display: none !important;
}

body.reference-theme.home-page .normal-hero-carousel {
    position: relative !important;
    z-index: 1;
    margin-top: clamp(28px, 3vw, 46px) !important;
}

body.reference-theme .grid-list {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: clamp(10px, 1.15vw, 18px);
}

body.reference-theme .poster-card,
body.reference-theme .poster-card-wrap {
    min-width: 0;
    max-width: 100%;
}

body.reference-theme .poster-card-image {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
}

body.reference-theme .poster-card-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.reference-theme .poster-row-shell {
    position: relative;
    min-width: 0;
}

body.reference-theme .poster-row {
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    cursor: grab;
    user-select: none;
}

body.reference-theme .poster-row.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto !important;
}

body.reference-theme .poster-row.is-dragging a,
body.reference-theme .poster-row.is-dragging button {
    pointer-events: none;
}

body.reference-theme .poster-row:focus-visible {
    outline: 2px solid #b20710;
    outline-offset: 3px;
}

body.reference-theme .row-arrow {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    padding: 0 0 3px;
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 50%;
    color: #fff;
    background: rgba(82, 0, 0, .9);
    box-shadow: 0 5px 18px rgba(0, 0, 0, .5);
    font-size: 31px;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
}

body.reference-theme .row-arrow:hover,
body.reference-theme .row-arrow:focus-visible {
    background: #b20710;
}

body.reference-theme .row-arrow-prev { left: -14px; }
body.reference-theme .row-arrow-next { right: -14px; }

@media (max-width: 1399px) {
    body.reference-theme .grid-list { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
}

@media (max-width: 1099px) {
    body.reference-theme .page-wrap { width: min(960px, calc(100% - 32px)); }
    body.reference-theme .grid-list { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
}

@media (max-width: 899px) {
    body.reference-theme .page-wrap { width: calc(100% - 28px); margin-top: 20px; }
    body.reference-theme .grid-list {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 12px 10px;
    }
    body.reference-theme .section-head h1 { font-size: clamp(25px, 4vw, 34px); }
}

@media (max-width: 760px) {
    body.reference-theme .nf-header {
        position: sticky !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
    }

    body.reference-theme .nf-header-inner {
        width: 50%;
        min-height: 58px;
        gap: 8px;
    }

    body.reference-theme .nf-brand { min-width: 0; }
    body.reference-theme .nf-brand img { width: clamp(100px, 30vw, 132px); max-width: 100%; }
    body.reference-theme .nf-desktop-links { display: none; }

    body.reference-theme .nf-mobile-links {
        display: flex !important;
        width: 100%;
        min-height: 36px;
        align-items: center;
        justify-content: flex-start;
        gap: 2%;
        border-top: 1px solid rgba(149, 6, 14, .26);
        background: #070707;
        align-content: center;
    }

    body.reference-theme .nf-mobile-links a {
        padding: 8px 4px 9px;
        color: rgba(255, 255, 255, .76);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

    body.reference-theme .nf-mobile-links a.is-active { color: #fff; border-bottom: 2px solid #b20710; }
    body.reference-theme .nf-header-actions { gap: 2px; }
    body.reference-theme .nf-icon-link,
    body.reference-theme .nf-search,
    body.reference-theme .nf-search button { width: 36px; height: 36px; }

    body.reference-theme .nf-search.is-open {
        position: absolute;
        top: 9px;
        left: 10px;
        right: 10px;
        z-index: 10;
        width: auto;
        height: 40px;
        background: #111;
    }

    body.reference-theme .nf-search.is-open input {
        display: block;
        width: calc(100% - 40px);
        flex: 1;
    }

    body.reference-theme .row-arrow {
        width: 32px;
        height: 32px;
        font-size: 26px;
    }

    body.reference-theme .row-arrow-prev { left: -8px; }
    body.reference-theme .row-arrow-next { right: -8px; }
}

/* Legacy header fallback used by older production Blade caches. */
@media (max-width: 900px) {
    body.reference-theme:has(.topbar):not(:has(.nf-header)) {
        padding-top: 64px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar {
        position: fixed !important;
        inset: 0 0 auto 0 !important;
        z-index: 1000 !important;
        display: flex !important;
        height: 64px !important;
        min-height: 64px !important;
        flex-wrap: nowrap !important;
        align-content: center !important;
        gap: 6px !important;
        padding: 4px 10px !important;
        background: #070707 !important;
        border-bottom: 1px solid rgba(149, 6, 14, .55) !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .site-brand {
        width: auto !important;
        height: 54px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .site-brand img {
        width: clamp(100px, 25vw, 145px) !important;
        max-width: 100% !important;
        max-height: 46px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .main-nav {
        position: static !important;
        display: flex !important;
        width: auto !important;
        height: 54px !important;
        flex: 0 1 auto !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        overflow-x: auto !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .main-nav a {
        height: 32px !important;
        flex: 0 0 auto !important;
        padding: 0 10px !important;
        font-size: 12px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .actions {
        display: flex !important;
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 0 !important;
        gap: 5px !important;
        margin: 0 !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .actions .top-search,
    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .actions .plan-btn,
    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .actions .user-notification-bell {
        display: inline-flex !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .login-btn,
    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .actions a[href*="login"] {
        min-height: 36px !important;
        height: 36px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    body.reference-theme:has(.topbar):not(:has(.nf-header)) {
        padding-top: 94px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar {
        height: 94px !important;
        min-height: 94px !important;
        flex-wrap: wrap !important;
        align-content: center !important;
        padding: 4px 8px 0 !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .main-nav {
        order: 3 !important;
        width: 100% !important;
        height: 32px !important;
        flex: 0 0 100% !important;
        gap: 4px !important;
        overflow-x: auto !important;
        justify-content: center !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .main-nav a {
        height: 30px !important;
        padding-inline: 9px !important;
        font-size: 11px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .site-brand {
        height: 50px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .site-brand img {
        width: clamp(92px, 27vw, 116px) !important;
        max-height: 42px !important;
    }

    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .plan-btn,
    body.reference-theme:has(.topbar):not(:has(.nf-header)) .topbar .user-notification-bell {
        display: none !important;
    }
}

/* Final narrow-screen guard for production/legacy .topbar markup. */
@media (max-width: 480px) {
    body.reference-theme:has(.topbar) {
        padding-top: 94px !important;
    }

    body.reference-theme:has(.topbar) .topbar {
        position: fixed !important;
        inset: 0 0 auto 0 !important;
        display: flex !important;
        width: 100% !important;
        height: 94px !important;
        min-height: 94px !important;
        flex-wrap: wrap !important;
        align-content: center !important;
        gap: 0 !important;
        padding: 4px 8px 0 !important;
    }

    body.reference-theme:has(.topbar) .topbar .site-brand {
        position: static !important;
        width: auto !important;
        height: 50px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        order: 1 !important;
    }

    body.reference-theme:has(.topbar) .topbar .site-brand img {
        width: clamp(92px, 27vw, 116px) !important;
        max-width: 100% !important;
        max-height: 42px !important;
    }

    body.reference-theme:has(.topbar) .topbar .actions {
        position: static !important;
        width: auto !important;
        height: 50px !important;
        flex: 0 0 auto !important;
        order: 2 !important;
        margin: 0 !important;
        gap: 5px !important;
    }

    body.reference-theme:has(.topbar) .topbar .main-nav {
        position: static !important;
        inset: auto !important;
        display: flex !important;
        width: 100% !important;
        height: 32px !important;
        flex: 0 0 100% !important;
        order: 3 !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        overflow-x: auto !important;
    }

    body.reference-theme:has(.topbar) .topbar .main-nav a {
        position: static !important;
        width: auto !important;
        height: 30px !important;
        flex: 0 0 auto !important;
        padding: 0 9px !important;
        font-size: 11px !important;
    }
}

@media (max-width: 599px) {
    body.reference-theme .page-wrap { width: calc(100% - 20px); margin-top: 16px; }
    body.reference-theme.home-page .normal-hero-carousel { margin-top: 20px !important; }
    body.reference-theme .grid-list {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px 7px;
    }

    body.reference-theme .poster-card-title {
        min-height: 34px;
        padding: 8px 5px;
        font-size: clamp(10px, 2.7vw, 13px) !important;
        text-align: center;
    }

    body.reference-theme .poster-card .premium-badge,
    body.reference-theme .poster-card .favorite-form { top: 5px; }
    body.reference-theme .poster-card .premium-badge { left: 5px; width: 25px; height: 25px; min-width: 25px; }
    body.reference-theme .poster-card .favorite-form { right: 5px; }
    body.reference-theme .poster-card .heart-btn { width: 25px; height: 25px; font-size: 15px; }
}

@media (max-width: 399px) {
    body.reference-theme .grid-list { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px 10px; }
    body.reference-theme .nf-brand img { width: 100px; }
    body.reference-theme .nf-mobile-links { gap: 22px; }
}

@media (max-width: 900px) {
    html body.reference-theme:not(.auth-only):not(.checkout-only) {
        padding-top: 0 !important;
    }
}

/* One vertical scroll owner: the document root. */
html {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body.reference-theme {
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    scrollbar-width: none;
}

body.reference-theme::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body.reference-theme main,
body.reference-theme .site-footer {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    body.reference-theme .poster-card,
    body.reference-theme .poster-card-image { transition: none !important; }
}
