/*
 * Home video stage + Video Library body
 * -------------------------------------
 * Hero media stage and library section are normal document flow.
 * No GSAP pin / cover / content-hold — both scroll with the page.
 *
 * Desktop filters stay sticky under the nav while the feed scrolls.
 * Library title is in-flow (not sticky) so the section feels normal.
 *
 * Do not hide/remove #video-library-heading.
 */

.home-pin-track {
    position: relative;
    z-index: 1;
    height: auto;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

.home-pin-track .home-pin-sticky,
.home-pin-track [data-home-pin-sticky] {
    position: relative;
    top: auto;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    height: auto;
    padding-bottom: 0;
    overflow: visible;
}

.home-pin-track [data-home-pin-sticky] > .ame-hero-video-card,
.home-pin-track [data-home-pin-sticky] > .ame-hero-slide-indicator {
    flex-shrink: 0;
    width: 100%;
}

.ame-hero-section.home-hero-pin {
    position: relative;
    z-index: 1;
    background-color: #ffffff;
    overflow: visible;
}

/*
 * Library section — NO top border / NO lead padding above the title.
 * (video-library.css + stripe-payments-guides set padding-top: lead-gap;
 *  that left a ~16px gap so the title sat slightly below the nav when docked.)
 * Border lives on .home-library-top so it docks flush with the title.
 */
.home-library-reveal.video-library,
section.home-library-reveal,
.home-library-reveal.stripe-payments-library.video-library--landing {
    position: relative;
    z-index: 2;
    width: 100%;
    box-sizing: border-box;
    /*
     * Match hero canvas exactly. Stripe .theme--White / .Section set
     * --textColor: #425466 which tinted the whole library (looked like a
     * different “white” than the black-on-white hero above).
     */
    --backgroundColor: #ffffff;
    --textColor: hsl(var(--primary, 0 0% 4%));
    background-color: #ffffff !important;
    color: hsl(var(--primary, 0 0% 4%));
    box-shadow: none; /* desktop top-edge depth is set in min-width:768 below */
    border-top: none;
    margin-top: 0 !important;
    scroll-margin-top: var(--site-header-height, 64px);
    min-height: 50svh;
    overflow: visible !important;
    /* Kill landing lead-in above the title so chrome can sit flush under nav */
    --sectionPaddingTop: 0px !important;
}

.home-library-reveal.video-library--landing .Section__layout,
.home-library-reveal .Section__layout,
.home-library-reveal.stripe-payments-library .Section__layout {
    padding-top: 0 !important;
    overflow: visible !important;
}

.home-library-reveal .Section__masked,
.home-library-reveal .Section__background,
.home-library-reveal .Section__container,
.home-library-reveal .Section__layoutContainer,
.home-library-reveal .Section__layout {
    background-color: #ffffff !important;
    color: inherit;
    overflow: visible !important;
    transform: none !important;
    filter: none;
    contain: none;
    perspective: none;
}

/* Lead gap moves BELOW the title (filters/cards), not above it */
.home-library-dock {
    box-sizing: border-box;
    width: 100%;
    padding-top: var(--library-lead-gap, 16px);
    background-color: #ffffff !important;
    position: relative;
    z-index: 1;
}

/* Zero-height marker at the natural start of the library top */
.home-library-dock-sentinel,
[data-home-library-dock-sentinel] {
    display: block;
    width: 100%;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
}

/* Spacer kept for markup compat; always 0 — no fixed-dock jump */
.home-library-top-spacer,
[data-home-library-top-spacer] {
    display: block;
    width: 100%;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    pointer-events: none;
    flex-shrink: 0;
}

/*
 * Library top chrome = in-flow title band (scrolls with the section).
 */
.home-library-top,
[data-home-library-top] {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    top: auto;
    z-index: 2;
    background-color: #ffffff;
    border-top: none;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
    transform: none;
    will-change: auto;
    backface-visibility: visible;
}

#video-library.is-under-nav .home-library-top,
#video-library.is-under-nav [data-home-library-top] {
    border-top: none;
}

.home-library-heading,
#video-library-heading {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
    /*
     * Section title band — readable size, still shorter than a full hero.
     * ~10px + 36px line + 10px ≈ 56px (under 64px nav).
     */
    padding: 0.625rem 1rem;
    text-align: center;
    display: block !important;
    visibility: visible !important;
    /*
     * Do NOT force opacity/transform here — .xai-enter-lib needs them for
     * the page-open entrance (hero-entrance.js). Ready state settles them.
     */
    position: relative;
    z-index: 1;
    background-color: transparent;
    pointer-events: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
    max-height: none;
    height: auto;
    min-height: 0;
}

/* After entrance (or if entrance skipped): keep title fully visible */
#video-library.xai-library-ready .home-library-heading,
#video-library.xai-library-ready #video-library-heading,
#video-library:not(.xai-library-pending) .home-library-heading:not(.xai-enter-lib) {
    opacity: 1;
    transform: none;
}

@media screen and (min-width: 768px) {
    /*
     * Title stays in normal flow — no sticky glass band under the nav.
     */
    .home-library-top,
    [data-home-library-top] {
        position: relative;
        top: auto;
        background: #ffffff !important;
        background-color: #ffffff !important;
        box-shadow: none !important;
        isolation: auto;
    }

    .home-library-top::before,
    [data-home-library-top]::before {
        content: none !important;
        display: none !important;
    }

    #video-library.is-under-nav .home-library-top,
    #video-library.is-under-nav [data-home-library-top] {
        background: #ffffff !important;
    }

    .home-library-heading,
    #video-library-heading {
        padding: 1rem 1.5rem;
        position: relative;
        z-index: 1;
        background-color: #ffffff !important;
        background: #ffffff !important;
    }
}

/*
 * “Video Library” section title — base / mobile size (28px).
 * Desktop size restored below after this block.
 */
.home-library-heading__title {
    margin: 0;
    padding: 0;
    display: block !important;
    visibility: visible !important;
    /* Opacity is owned by the parent .xai-enter-lib entrance animation */
    font-family: "Universal Sans Display", -apple-system, Arial, sans-serif;
    font-size: 1.75rem; /* 28px — mobile */
    line-height: 2.125rem; /* 34px */
    font-weight: 500 !important;
    font-style: normal;
    font-synthesis: none;
    letter-spacing: -0.02em;
    text-transform: none;
    text-decoration: none;
    font-feature-settings: normal;
    font-variation-settings: normal;
    font-kerning: auto;
    color: hsl(var(--foreground, 0 0% 4%) / 1);
    text-align: center;
    overflow-wrap: break-word;
    text-wrap: balance;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizelegibility;
}

@media screen and (min-width: 768px) {
    /*
     * Desktop section title — restored display size (was reduced to 28px
     * for the sticky band; felt too small as a library header).
     */
    .home-library-heading__title {
        font-size: 2.5rem; /* 40px */
        line-height: 1.15; /* ~46px */
        letter-spacing: -0.025em;
    }
}

/*
 * Proof stats under “Video Library” title (moved from hero CTAs).
 * Same density as x.ai: flex wrap, text-xs labels, text-sm values.
 */
.home-library-proof {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem; /* gap-6 */
    /* Balanced gap under the title (matches title↔nav breathing room) */
    margin: 1rem 0 0;
    padding: 0;
    font-size: 0.75rem; /* text-xs */
    line-height: 1rem;
    color: inherit;
}

.home-library-proof__stat {
    display: block;
    min-width: 0;
    text-align: center;
}

.home-library-proof__value {
    margin: 0;
    padding: 0;
    border: 0;
    font-family: inherit;
    font-size: 0.875rem; /* text-sm */
    line-height: 1.25rem;
    font-weight: 500;
    font-synthesis: none;
    letter-spacing: normal;
    font-variant-numeric: tabular-nums;
    color: hsl(var(--primary, 0 0% 4%) / 0.7);
}

.home-library-proof__label {
    margin: 0.125rem 0 0; /* mt-0.5 */
    padding: 0;
    border: 0;
    font-family: inherit;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 400;
    font-synthesis: none;
    letter-spacing: normal;
    color: hsl(var(--primary, 0 0% 4%) / 0.3);
}

/*
 * Homepage sticky-zone is unused (mobile filter lives in title chrome).
 * Kill video-library.css sticky-track hacks (100vh+900px ::before).
 */
.home-library-reveal.video-library--landing .video-library-sticky-zone {
    position: relative !important;
    top: auto !important;
    z-index: 1;
    min-height: 0 !important;
    height: auto !important;
}

/* Mobile filter inside sticky chrome — docks with title under the nav */
.home-library-mobile-filter {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    padding: 0 0 0.5rem;
    background-color: #ffffff !important;
    overflow: visible;
}

.home-library-mobile-filter .sticky-filter-bar {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-sizing: border-box;
}

.home-library-mobile-filter .mobile-filter-pill {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    box-sizing: border-box;
}

@media (max-width: 767px) {
    /* Empty sticky-zone placeholder (filter moved into chrome) */
    .home-library-reveal.video-library--landing .video-library-sticky-zone {
        display: none !important;
    }

    /*
     * Mobile feed: title + filter scroll away with the page
     * (do NOT stick under the nav — that felt like a frozen panel).
     */
    .home-library-top,
    [data-home-library-top] {
        position: relative !important;
        top: auto !important;
        z-index: 2;
        background-color: #ffffff !important;
        box-shadow: none;
    }

    /* Always one horizontal row of three stats */
    .home-library-proof {
        display: flex;
        flex-wrap: nowrap !important;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.35rem;
        width: 100%;
        max-width: 100%;
        margin-top: 1rem;
        padding-inline: 0.25rem;
        box-sizing: border-box;
    }

    .home-library-proof__stat {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }

    .home-library-proof__value {
        font-size: clamp(1rem, 4.2vw, 1.2rem);
        line-height: 1.35rem;
        font-weight: 600;
        color: hsl(var(--primary, 0 0% 4%) / 0.85);
        white-space: nowrap;
    }

    .home-library-proof__label {
        margin-top: 0.2rem;
        font-size: clamp(0.6875rem, 2.9vw, 0.8125rem);
        line-height: 1.05rem;
        color: hsl(var(--primary, 0 0% 4%) / 0.45);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .home-library-heading,
    #video-library-heading {
        padding: 0.35rem 1rem 0.5rem !important;
    }

    .home-library-heading__title {
        font-size: 1.75rem !important; /* 28px */
        line-height: 2.125rem !important;
    }

    .home-library-mobile-filter {
        /* Full-bleed strip — pill spans nearly the whole screen */
        width: 100vw !important;
        max-width: 100vw !important;
        margin-inline: calc(50% - 50vw) !important;
        padding: 0 0.5rem 0.5rem !important; /* tiny edge inset only */
        box-sizing: border-box !important;
    }

    @supports (width: 100dvw) {
        .home-library-mobile-filter {
            width: 100dvw !important;
            max-width: 100dvw !important;
            margin-inline: calc(50% - 50dvw) !important;
        }
    }

    .home-library-mobile-filter .sticky-filter-bar,
    .home-library-mobile-filter .mobile-filter-pill {
        width: 100% !important;
        max-width: 100% !important;
    }

    .home-library-dock {
        padding-top: 0;
    }

    .home-library-reveal.video-library,
    section.home-library-reveal {
        box-shadow: none;
        min-height: 0;
        /* Sit closer under the mobile stats band */
        margin-top: 0.25rem !important;
    }
}

@media (min-width: 768px) {
    .home-library-mobile-filter {
        display: none !important;
    }
}

.home-library-reveal .video-card,
.home-library-reveal #videoDirectory,
.home-library-reveal .video-content,
.home-library-reveal .main-content-wrapper {
    z-index: 1;
    isolation: auto;
}

.home-library-reveal [data-home-library-cards],
.home-library-reveal .video-content {
    position: relative;
    min-height: 0;
}

@media (min-width: 768px) {
    .home-library-reveal .main-content-wrapper::before {
        content: none !important;
        display: none !important;
        min-height: 0 !important;
        height: 0 !important;
    }

    /*
     * Desktop: filter column sticky under nav only.
     * Title scrolls away with the section (normal page scroll).
     */
    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar {
        position: sticky !important;
        top: calc(
            var(--site-header-height, 64px)
            + var(--library-lead-gap, 16px)
        ) !important;
        z-index: 25;
        align-self: start;
        min-height: 0 !important;
        height: auto !important;
        max-height: calc(
            100vh
            - var(--site-header-height, 64px)
            - var(--library-lead-gap, 16px)
            - 1.5rem
        ) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        /* Keep buttons from shifting left when the scrollbar becomes visible */
        scrollbar-gutter: stable;
        --category-sidebar-min-height: 0px;
        overscroll-behavior: contain;
        /* Allow scrollbar hit-testing (general rule uses pointer-events: none) */
        pointer-events: auto !important;
        /* x.ai docs-style minimal scrollbar — faint always, stronger on hover */
        scrollbar-width: thin;
        scrollbar-color: hsl(0 0% 4% / 0.16) transparent;
    }

    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar:hover,
    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar:focus-within {
        scrollbar-color: hsl(0 0% 4% / 0.28) transparent;
    }

    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar::-webkit-scrollbar-thumb {
        background-color: hsl(0 0% 4% / 0.14);
        border-radius: 9999px;
        border: 1px solid transparent;
        background-clip: padding-box;
    }

    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar:hover::-webkit-scrollbar-thumb,
    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar:focus-within::-webkit-scrollbar-thumb {
        background-color: hsl(0 0% 4% / 0.26);
    }

    .home-library-reveal.video-library--landing #categoryFilters.category-sidebar .category-sidebar-inner {
        min-height: 0 !important;
        height: auto !important;
        padding-top: 0;
        padding-bottom: 1.5rem;
    }
}

body:has(.home-library-reveal) .site-footer {
    position: relative;
    z-index: 2;
    background-color: hsl(var(--background, 0 0% 100%));
}

@media (prefers-reduced-motion: reduce) {
    .home-library-reveal.video-library,
    section.home-library-reveal {
        box-shadow: none;
    }
}
