/* ==========================================
   HOMEPAGE REELS RAIL

   Portrait 9:16 clips on a single horizontal slider (the swiper-horizontal
   pattern). Each autoplays muted on loop and can be individually unmuted.

   The rail NEVER reflows into a static grid — every breakpoint is the same
   horizontal slider, only the number of reels in view changes:
   - phone   : ~1 reel plus a peek of the next
   - tablet  : ~2.5 reels
   - desktop : ~3.5 reels

   The 9:16 box is enforced at every width, so nothing shifts while loading.
   ========================================== */

.home-reels {
    --reel-radius: clamp(0.9rem, 1.6vw, 1.4rem);
    --reel-gap: clamp(0.6rem, 1.4vw, 1.15rem);

    box-sizing: border-box;
    width: min(100% - 2rem, 1520px);
    margin: clamp(2rem, 5vw, 3.5rem) auto;
}

/* ---------- Heading ---------- */
.home-reels-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: clamp(0.9rem, 2vw, 1.5rem);
}

.home-reels-eyebrow {
    margin: 0;
    color: #a91f25;
    font-size: clamp(0.68rem, 0.64rem + 0.2vw, 0.78rem);
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.home-reels-heading h2 {
    margin: 0.2rem 0 0;
    font-size: clamp(1.35rem, 1rem + 1.6vw, 2.25rem);
    line-height: 1.15;
}

.home-reels-hint {
    /* Always visible: the rail is a slider at every breakpoint. */
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 650;
}

.home-reels-hint svg {
    width: 1rem;
    height: 1rem;
}

/* ---------- Track ---------- */
.home-reels-track {
    display: grid;
    /* Mobile: one reel plus a sliver of the next, so swipe is discoverable. */
    grid-auto-flow: column;
    grid-auto-columns: min(78%, 20rem);
    gap: var(--reel-gap);
    padding-bottom: 0.35rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.home-reels-track::-webkit-scrollbar {
    display: none;
}

/* ---------- Reel card ---------- */
.reel-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    scroll-snap-align: start;
}

.reel-media {
    position: relative;
    width: 100%;
    /* The 9:16 portrait frame, fixed at every breakpoint => no layout shift. */
    aspect-ratio: 9 / 16;
    overflow: hidden;
    border-radius: var(--reel-radius);
    background: #0b0d10;
    box-shadow: 0 12px 32px rgba(15, 18, 25, 0.18);
}

.reel-video,
.reel-poster,
.reel-embed {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: cover;
}

.reel-poster-fallback {
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.9);
    background: linear-gradient(160deg, #1f2937 0%, #0b0d10 100%);
    font-family: var(--font-heading, "Inter", Arial, sans-serif);
    font-size: 3rem;
    font-weight: 800;
}

/* Gradient so the caption stays legible over any frame. */
.reel-scrim {
    position: absolute;
    inset: auto 0 0;
    height: 62%;
    background: linear-gradient(
        to top,
        rgba(6, 8, 12, 0.88) 0%,
        rgba(6, 8, 12, 0.55) 42%,
        rgba(6, 8, 12, 0) 100%
    );
    pointer-events: none;
}

/* ---------- Sound toggle ---------- */
.reel-audio {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    z-index: 3;
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(10, 12, 16, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
    transition:
        background 160ms ease,
        transform 160ms ease;
}

.reel-audio svg {
    width: 1.05rem;
    height: 1.05rem;
}

.reel-audio:hover {
    background: rgba(10, 12, 16, 0.78);
    transform: scale(1.06);
}

.reel-audio:focus-visible,
.reel-embed-play:focus-visible,
.reel-cta:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---------- Caption ---------- */
.reel-caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: clamp(0.7rem, 1.6vw, 1rem);
    color: #fff;
    pointer-events: none;
}

.reel-eyebrow {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.62rem;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.reel-title {
    margin: 0;
    font-family: var(--font-heading, "Inter", Arial, sans-serif);
    font-size: clamp(0.82rem, 0.76rem + 0.4vw, 1.02rem);
    font-weight: 750;
    line-height: 1.25;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.reel-sub {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: clamp(0.68rem, 0.64rem + 0.2vw, 0.8rem);
    line-height: 1.45;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* ---------- Embed play button ---------- */
.reel-embed-play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    display: grid;
    width: clamp(2.75rem, 6vw, 3.5rem);
    height: clamp(2.75rem, 6vw, 3.5rem);
    place-items: center;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(29, 54, 134, 0.92);
    cursor: pointer;
    transition: transform 200ms ease;
}

.reel-embed-play svg {
    width: 40%;
    height: 40%;
    margin-left: 5%;
}

/* ---------- Video play overlay (when paused or blocked by browser) ---------- */
.reel-play-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: background 200ms ease;
}

.reel-play-overlay:hover {
    background: rgba(0, 0, 0, 0.4);
}

.reel-play-icon {
    display: grid;
    place-items: center;
    width: clamp(2.75rem, 5.5vw, 3.5rem);
    height: clamp(2.75rem, 5.5vw, 3.5rem);
    border-radius: 50%;
    background: rgba(29, 54, 134, 0.92);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: transform 200ms ease;
}

.reel-play-overlay:hover .reel-play-icon {
    transform: scale(1.1);
}

.reel-play-icon svg {
    width: 42%;
    height: 42%;
    margin-left: 6%;
}

.reel-embed-play:hover {
    transform: translate(-50%, -50%) scale(1.07);
}

/* ---------- CTA under the reel ---------- */
.reel-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 2.5rem;
    margin-top: 0.55rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(15, 18, 25, 0.1);
    border-radius: 999px;
    color: #15181d;
    background: #fff;
    font-size: clamp(0.74rem, 0.7rem + 0.2vw, 0.84rem);
    font-weight: 700;
    text-decoration: none;
    transition:
        background 160ms ease,
        color 160ms ease,
        border-color 160ms ease;
}

.reel-cta svg {
    width: 0.75rem;
    height: 0.75rem;
    transition: transform 160ms ease;
}

.reel-cta:hover {
    border-color: #1d3686;
    color: #fff;
    background: #1d3686;
}

.reel-cta:hover svg {
    transform: translate(2px, -2px);
}

/* ==========================================
   TABLET (>= 640px)

   The rail stays a HORIZONTAL slider at every width (matching the
   swiper-horizontal pattern), rather than reflowing into a static grid.
   Each breakpoint just changes how much of a reel you see.
   ========================================== */
@media (min-width: 640px) {
    .home-reels {
        width: min(100% - 2.5rem, 1520px);
    }

    .home-reels-track {
        grid-auto-columns: min(38%, 17rem);
    }
}

/* ==========================================
   TABLET / DESKTOP TABLET (641px to 1024px)
   Single column: one reel fills the row and the rail scrolls
   left/right to reveal the next one.
   ========================================== */
@media (min-width: 641px) and (max-width: 1024px) {
    .home-reels-track {
        grid-auto-columns: 100%;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    .reel-card {
        scroll-snap-align: start;
    }
}

/* ==========================================
   DESKTOP (>= 1025px)
   Three and a bit reels in view, so it reads as a slider, not a grid.
   ========================================== */
@media (min-width: 1025px) {
    .home-reels-track {
        grid-auto-columns: min(23.5%, 19rem);
    }

    .reel-cta {
        justify-content: flex-start;
        border-radius: 0.75rem;
    }
}

/* Wide desktops: cap the reel width so they do not become enormous. */
@media (min-width: 1600px) {
    .home-reels-track {
        grid-auto-columns: min(20%, 21rem);
    }
}

/* ==========================================
   SMALL PHONES (<= 400px)
   Widen the peek so reels are not tiny.
   ========================================== */
@media (max-width: 400px) {
    .home-reels {
        width: min(100% - 1.25rem, 1520px);
    }

    .home-reels-track {
        grid-auto-columns: min(84%, 18rem);
    }

    .reel-audio {
        width: 2rem;
        height: 2rem;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .reel-audio,
    .reel-embed-play,
    .reel-cta,
    .reel-cta svg {
        transition: none;
    }

    .reel-embed-play:hover {
        transform: translate(-50%, -50%);
    }

    /* No autoplaying loops: show the poster frame only. */
    .reel-video {
        opacity: 0;
    }
}
