/*
 * jambo-hero-cards.css — the home hero below 992 px: a deck of poster cards.
 *
 * Loaded by components/partials/hero-cards.blade.php only, so it costs
 * nothing on any other page. Jambo's file (ADR-0001: vendor CSS is never
 * edited); plan docs/plans/mobile-hero-cards.md, ADR-0038.
 *
 * GEOMETRY, measured off Rio's mockup (2026-12-02, a 435 px-wide screen):
 *   front card   4:5, 83.4% of the width, 4.6% in from the left
 *   previous     scale .95, 8 px gap, the rest of the left inset showing
 *   stack        three cards behind on the right, 18 / 9 / 7 px showing,
 *                scales .95 / .90 / .85
 *   buttons      48 px circles, bottom right; pill and meta 12 px in
 *
 * HOW THE DECK MOVES. The track is a plain horizontal scroller with
 * mandatory snap, so a swipe is the browser's own 1:1 drag and momentum.
 * Each card's deck wrapper runs ONE keyframe set on the track's scroll timeline, over the
 * six card-steps from "four behind" to "two past". With every card one step
 * (S = card + gap) from the next, the six positions land on fixed keyframe
 * offsets whatever the screen size:
 *
 *     0%       16.67%   33.33%   50%      66.67%   83.33%   100%
 *     next 4   next 3   next 2   next 1   FRONT    prev 1   prev 2
 *
 * The translate values cancel the card's natural place in the row and put
 * it where the deck wants it. For a card k steps right, scaled s, whose
 * visible edge sits o px past the front card:
 *     translate = ((1 - s) / 2 - k) * 100%  +  (o - k * gap) px
 * (translate % is the card's own width, before scale; scale is about the
 * centre). The gap is 8 px, so the previous card only scales.
 *
 * Z-ORDER IS STATIC: card i gets z-index N - i in the markup. Every card
 * sits above the cards to its right, which is exactly the deck; the
 * previous card is above the front one but never overlaps it (8 px gap),
 * so nothing has to animate z-index on the main thread.
 *
 * Without scroll-driven animations (Chrome < 115, Safari < 26, Firefox
 * < 159) or with reduced motion, the same markup is a plain snapping row
 * with the next card peeking. Nothing is lost but the stack.
 */

.jambo-hero-cards {
    /* Raw values live here and nowhere else in this file. */
    --jhc-card-ratio: 1.25;                 /* 4:5 */
    --jhc-pad-top: 12px;
    --jhc-pad-bottom: 20px;
    /* What the screen spends on the page's own chrome below 992 px: the
       sticky header with its genre rail (103 px, measured at every phone
       and tablet size from 320 to 991) and the fixed bottom tab bar
       (jambo-header.css reserves 3.75rem + the safe area for it). */
    --jhc-chrome: calc(103px + var(--jhc-pad-top) + var(--jhc-pad-bottom) + 3.75rem + env(safe-area-inset-bottom, 0px));
    --jhc-hmax: min(62vh, calc(100vh - var(--jhc-chrome))); /* card height cap, see below */
    --jhc-gap: 8px;
    --jhc-stack: 34px;                      /* how far the stack shows past the front card */
    --jhc-radius: var(--bs-border-radius-xl, 1em);
    --jhc-ink: var(--bs-white, #fff);
    --jhc-meta: rgba(255, 255, 255, 0.86);
    --jhc-gold: var(--bs-warning, #ffd81c);
    --jhc-glass: rgba(18, 18, 22, 0.55);
    --jhc-glass-edge: rgba(255, 255, 255, 0.18);
    --jhc-play-top: #ffffff;
    --jhc-play-bottom: #d7d9de;
    --jhc-play-ink: #0b0c0f;
    --jhc-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    --jhc-scrim: linear-gradient(180deg, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.45) 72%, rgba(0, 0, 0, 0.82) 100%);

    /* Width: the mockup's 83.4% on a phone, but never taller than 62% of the
       screen (tablets), nor than what the header and the tab bar leave
       (landscape phones: at 844x390 the tab bar covered the play button). */
    --jhc-w: min(83.4vw, calc(var(--jhc-hmax) / var(--jhc-card-ratio)));
    --jhc-s: calc(var(--jhc-w) + var(--jhc-gap));

    /* Left inset: the mockup's 4.6% on a phone; on a wide screen the deck
       (card + stack) is centred instead. % = the section's own width. */
    --jhc-l: max(4.6%, 12px, calc((100% - var(--jhc-w) - var(--jhc-stack)) / 2));

    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding-block: var(--jhc-pad-top) var(--jhc-pad-bottom);
    transition: opacity 0.45s ease;
}

@supports (height: 1svh) {
    .jambo-hero-cards {
        --jhc-hmax: min(62svh, calc(100svh - var(--jhc-chrome)));
    }
}

/* Whole pixels. At 83.4vw a card is 325.25 px, so six cards are 1999.5 px:
   the loop's jump (one set's width) moved the deck half a pixel and the
   posters visibly re-sampled (measured: 6.7% of the hero changed across a
   jump). Integer card, gap and inset make every snap point and every jump
   land on a pixel. In @supports, because a fallback line before a var()
   line does nothing (screen skill 6g). */
@supports (width: round(down, 10.5px, 1px)) {
    .jambo-hero-cards {
        --jhc-w: round(down, min(83.4vw, calc(var(--jhc-hmax) / var(--jhc-card-ratio))), 1px);
        --jhc-l: round(max(4.6%, 12px, calc((100% - var(--jhc-w) - var(--jhc-stack)) / 2)), 1px);
    }
}

/* ------------------------------------------------------------------ */
/* Ambient: the front card's poster, blurred, behind the deck          */
/* ------------------------------------------------------------------ */

.jhc-ambient {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.jhc-ambient__layer {
    position: absolute;
    inset: -15%;
    background-position: center;
    background-size: cover;
    filter: blur(48px) saturate(1.25);
    opacity: 0;
    transition: opacity 0.7s ease;
}

.jhc-ambient__layer.is-on {
    opacity: 0.5;
}

/* Fade the glow into the page at both edges, so the section has no seam. */
.jhc-ambient::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, var(--bs-body-bg, #000) 0%, transparent 22%, transparent 70%, var(--bs-body-bg, #000) 100%);
}

/* ------------------------------------------------------------------ */
/* The track                                                           */
/* ------------------------------------------------------------------ */

.jhc-track {
    position: relative;                     /* offsetParent for the cards */
    display: flex;
    gap: var(--jhc-gap);
    margin: 0;
    padding: 0;
    padding-inline-start: var(--jhc-l);
    /* room for the last card to reach the front */
    padding-inline-end: calc(100% - var(--jhc-l) - var(--jhc-w));
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline-start: var(--jhc-l);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-timeline: --jhc-deck inline;
    outline: none;
}

.jhc-track::-webkit-scrollbar {
    display: none;
}

.jhc-card {
    position: relative;
    flex: 0 0 var(--jhc-w);
    width: var(--jhc-w);
    aspect-ratio: 1 / var(--jhc-card-ratio);
    scroll-snap-align: start;
    scroll-snap-stop: always;               /* one card per swipe, like a deck */
    list-style: none;
}

/* The deck transform lives here, not on .jhc-card: a snap area is the
   card's TRANSFORMED box, so a card that moved itself would move its own
   snap point and every snap would land off by the deck's offset (measured:
   0 / 333 / 666 snapped to 16 / 337 / 499 before this split). */
.jhc-card__deck {
    width: 100%;
    height: 100%;
}

.jhc-card__body {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: var(--jhc-radius);
    background: var(--bs-gray-900, #111);
    box-shadow: var(--jhc-shadow);
    transition: scale 0.18s ease;
}

/* Respond on press-down, on the poster only (not when a button is pressed). */
.jhc-card__body:has(> .jhc-card__link:active) {
    scale: 0.98;
}

.jhc-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Scrim under the meta line. A pseudo-element, never the image's parent's
   background (Frontend Overrides trap 5). */
.jhc-card__body::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--jhc-scrim);
    pointer-events: none;
}

/* The deck's dimming of the cards behind. */
.jhc-card__body::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000;
    opacity: 0;
    pointer-events: none;
}

.jhc-card__link {
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
}

.jhc-card__link:focus-visible {
    outline: 2px solid var(--bs-primary, #1a98ff);
    outline-offset: -4px;
}

/* ------------------------------------------------------------------ */
/* Pill, meta line, buttons                                            */
/* ------------------------------------------------------------------ */

.jhc-card__ui {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;                   /* the link underneath takes the press */
    transition: opacity 0.3s ease;
    container-type: inline-size;            /* the title's cqi is the card's width */
}

/* The title, above the meta line. The face is the desktop hero's title
   (measured on jambofilms.com, 2026-12-02: Roboto 800, letter-spacing
   0.0625em, the template's .texture-text stone fill, no text-transform), at a
   card's size: 6.5% of the card, 21 px on a 390 phone (its card lays out
   325 px wide; the front card is drawn slightly scaled), 18 px at the least
   and 24 px at the most (a tablet's card). Two lines, the
   template's .line-count-2; past 40 characters the partial adds
   .jambo-title-long and the title takes one size down. The selectors carry
   two classes because .texture-text sets its own size per breakpoint. */
.jhc-card__ui .jhc-title {
    position: absolute;
    left: 14px;
    right: 76px;                            /* clear of the button column, as the meta */
    bottom: 40px;                           /* the meta's 16 px + 20 px line + 4 px */
    margin: 0;
    font-family: var(--bs-heading-font-family, Roboto, sans-serif);
    font-size: clamp(1.125rem, 6.5cqi, 1.5rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: 0.0625em;
    text-wrap: balance;
}

.jhc-card__ui .jhc-title.jambo-title-long {
    font-size: clamp(1rem, 5.5cqi, 1.3125rem);
}

/* A landscape phone's card is 148 to 190 px wide, which leaves the title
   under 100 px beside the buttons: "Insidi… / Out o…" (measured at 844 x 390).
   There the poster names itself and the meta line stays. */
@container (width < 200px) {
    .jhc-card__ui .jhc-title {
        display: none;
    }
}

.jhc-pill {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 8px;
    background: var(--jhc-glass);
    border: 1px solid var(--jhc-glass-edge);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--jhc-ink);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.jhc-pill i {
    color: var(--jhc-gold);
    font-size: 16px;
}

.jhc-meta {
    position: absolute;
    left: 14px;
    right: 76px;                            /* clear of the button column */
    bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--jhc-meta);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    /* One line, as drawn. On a narrow card an item that does not fit wraps
       to a second line and out of sight, so it drops whole, never cut mid-word,
       and in reverse order of importance: genres before the VJ, the VJ
       before the year (measured: two lines at 320 and 360, four at 844x390). */
    max-height: 20px;
    overflow: hidden;
}

.jhc-meta li {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* A drawn dot, not a "•" a screen reader would read out. */
.jhc-meta li + li::before {
    content: "";
    width: 4px;
    height: 4px;
    margin-inline: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

.jhc-actions {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.jhc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: scale 0.16s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.jhc-btn:active {
    scale: 0.92;
}

.jhc-btn:focus-visible {
    outline: 2px solid var(--bs-primary, #1a98ff);
    outline-offset: 2px;
}

.jhc-btn--glass {
    color: var(--jhc-ink);
    background: var(--jhc-glass);
    border: 1px solid var(--jhc-glass-edge);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.jhc-btn--glass:hover,
.jhc-btn--glass:focus-visible {
    color: var(--jhc-ink);
}

.jhc-btn--play {
    color: var(--jhc-play-ink);
    background: linear-gradient(180deg, var(--jhc-play-top), var(--jhc-play-bottom));
    border: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.jhc-btn--play:hover,
.jhc-btn--play:focus-visible {
    color: var(--jhc-play-ink);
}

.jhc-btn--play i {
    margin-inline-start: 2px;               /* optical centre of a triangle */
}

/* Once the script runs, only the front card's controls take presses and
   tab stops (it moves tabindex too); a tap on a card behind brings it
   forward instead of opening it. Without the script, every card works. */
[data-jhc-ready] .jhc-card:not(.is-active) .jhc-actions {
    pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* The deck: scroll-driven, compositor-only                            */
/* ------------------------------------------------------------------ */

@keyframes jhc-deck {
    0%      { translate: calc(-392.5% + 2px) 0;  scale: 0.85; opacity: 0; }
    16.667% { translate: calc(-292.5% + 10px) 0; scale: 0.85; opacity: 1; }
    33.333% { translate: calc(-195% + 11px) 0;   scale: 0.90; opacity: 1; }
    50%     { translate: calc(-97.5% + 10px) 0;  scale: 0.95; opacity: 1; }
    66.667% { translate: 0 0;                    scale: 1;    opacity: 1; }
    83.333% { translate: 2.5% 0;                 scale: 0.95; opacity: 1; }
    100%    { translate: 2.5% 0;                 scale: 0.95; opacity: 0; }
}

@keyframes jhc-dim {
    0%, 16.667% { opacity: 0.5; }
    33.333%     { opacity: 0.38; }
    50%         { opacity: 0.22; }
    66.667%     { opacity: 0; }
    83.333%, 100% { opacity: 0.3; }
}

/* The pill, meta and buttons belong to the front card only. */
@keyframes jhc-ui {
    0%, 58%  { opacity: 0; }
    66.667%  { opacity: 1; }
    75%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
    @supports ((animation-timeline: scroll()) and (animation-range: entry)) {
        .jhc-card__deck,
        .jhc-card__body::after,
        .jhc-card__ui {
            /* The range: from four steps before this card is in front to
               two steps after. Longhands only: the `animation` shorthand
               would reset the timeline and the range. */
            animation-timing-function: linear;
            animation-fill-mode: both;
            animation-duration: auto;
            animation-timeline: --jhc-deck;
            animation-range:
                calc((var(--i) - 4) * var(--jhc-s))
                calc((var(--i) + 2) * var(--jhc-s));
        }

        .jhc-card__deck {
            animation-name: jhc-deck;
        }

        .jhc-card__body::after {
            animation-name: jhc-dim;
        }

        .jhc-card__ui {
            animation-name: jhc-ui;
        }

        /* Scrolling the page past the hero: the deck settles back. */
        .jhc-stage {
            animation: jhc-recede linear both;
            animation-timeline: view();
            animation-range: exit 0% exit 100%;
        }
    }
}

@keyframes jhc-recede {
    to { scale: 0.94; opacity: 0.35; }
}

/* Without the deck (old browser, or reduced motion), the script marks the
   front card and the others' controls fade out. */
@supports not ((animation-timeline: scroll()) and (animation-range: entry)) {
    [data-jhc-ready] .jhc-card:not(.is-active) .jhc-card__ui {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-jhc-ready] .jhc-card:not(.is-active) .jhc-card__ui {
        opacity: 0;
    }

    .jambo-hero-cards,
    .jhc-ambient__layer,
    .jhc-card__body,
    .jhc-card__ui,
    .jhc-btn {
        transition: none;
    }
}

/* ------------------------------------------------------------------ */
/* Crossing 992 px (a tablet turned, a window resized): whichever hero */
/* appears fades in rather than snapping into place.                   */
/* ------------------------------------------------------------------ */

@starting-style {
    .jambo-hero-cards {
        opacity: 0;
    }
}

@media (min-width: 992px) {
    .iq-banner-thumb-slider {
        transition: opacity 0.45s ease;
    }

    @starting-style {
        .iq-banner-thumb-slider {
            opacity: 0;
        }
    }
}

@media (min-width: 768px) {
    .jhc-meta {
        font-size: 15px;
    }
}
