/* ===========================================================================
   "Watch the film": the product film as a stage, after the apps band.

   The mechanic is measured off orionix.framer.website's reel section, which is
   the reference: a 16:9 frame at ~60% of the viewport, 32px corners; behind
   it, edge to edge, a line of display type in a grey a shade off the paper,
   sliding, as the invitation; and under the frame the same film mirrored and
   fading out, the way a screen reflects on a tabletop. The reference plays on
   its own; ours waits: the frame holds its poster until a click starts the
   film from the top and quiets the line, a second click pauses it.

   The film itself is ours (assets/media/agentidoo-film.mp4, 33 s, silent), so
   "sound on" is not a state here.
   =========================================================================== */

.reel {
    position: relative;
    z-index: 1;
    padding: 80px var(--gutter);
    /* white, like the apps band before it: the page's paper is a shade warmer
       and the two sections read as one field */
    background: #fff;
    overflow: hidden;
}

.reel__stage {
    position: relative;
    width: min(60vw, 1100px);
    margin: 0 auto;
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.reel__stage:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 12px;
    border-radius: 32px;
}

/* ---- the frame ----------------------------------------------------------- */

.reel__frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 32px;
    overflow: hidden;
    background: var(--paper-pure);
    /* the film's own paper is near white; a hairline keeps the frame legible
       against the page without a shadow, which the reflection would double */
    box-shadow: 0 0 0 1px var(--line-soft);
}

.reel__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    background: var(--paper);
}

/* ---- the invitation, edge to edge behind the card ------------------------ */
/* The reference sets it in a grey a shade off the page, 96px on a 1440 viewport,
   at the frame's vertical middle, and lets the card cover it: ground, not figure.
   reel.js keeps --reel-mid on the frame's centre. */

.reel__marquee {
    position: absolute;
    left: 0;
    right: 0;
    top: var(--reel-mid, 50%);
    z-index: 0;
    height: 1.12em;
    transform: translateY(-50%);
    overflow: hidden;
    pointer-events: none;
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 400;
    font-size: clamp(40px, 6.67vw, 112px);
    line-height: 1;
    letter-spacing: -0.03em;
    color: #BDB8B0;
    white-space: nowrap;
    opacity: 1;
    transition: opacity .45s ease;
}

.reel__stage {
    position: relative;
    z-index: 1;
}

/* Four identical copies, moving exactly one copy: the loop lands on
   identical pixels, as in the apps band. */
.reel__track {
    display: inline-flex;
    width: max-content;
    animation: reel-slide var(--dur, 22s) linear infinite;
    will-change: transform;
}

.reel__copy {
    display: inline-block;
    padding-right: .5em;
}

/* Archivo's middle dot is a square at this size; the separator is drawn as a
   circle instead. */
.reel__copy::after {
    content: "";
    display: inline-block;
    width: .13em;
    height: .13em;
    margin-left: .5em;
    border-radius: 50%;
    background: currentColor;
    vertical-align: middle;
    position: relative;
    top: -.06em;
}

@keyframes reel-slide {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-25%, 0, 0); }
}

/* clicked: the ground goes quiet while the film runs */
.reel.is-focus .reel__marquee { opacity: .35; }

/* off screen the track rests: reel.js drops the flag */
.reel:not(.is-running) .reel__track { animation-play-state: paused; }

/* ---- the reflection ------------------------------------------------------- */

.reel__reflection {
    position: relative;
    height: 51%;                       /* of the frame's height, set in reel.js */
    margin-top: 0;
    overflow: hidden;
    pointer-events: none;
    /* No card under it and no rounded corner of its own: a tone in the shape
       of the frame drew a second outline below the real one, which read as a
       border rather than as a reflection. What is left is the mirrored film,
       carried by its own ink and gone by three quarters of its height. */
    opacity: .72;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .35) 45%, rgba(0, 0, 0, 0) 78%);
    mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .35) 45%, rgba(0, 0, 0, 0) 78%);
}

.reel__reflection .reel__video {
    top: 8px;
    height: auto;
    aspect-ratio: 16 / 9;
    background: none;
    transform: scaleY(-1);
    transform-origin: 50% 0;
    /* the mirrored copy is drawn from its own top edge downwards: its top
       row is the film's bottom row, which is what a reflection shows */
    translate: 0 100%;
    opacity: .75;
    filter: saturate(.9);
}

/* ---- the pointer's label -------------------------------------------------
   On the reference a 120px disc rides on the pointer over the reel and names
   the click. Here it follows with a little lag (reel.js), so it reads as an
   object being led, not a decal. Only where there is a pointer to follow. */

.reel__cursor {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    width: 120px;
    height: 120px;
    margin: -60px 0 0 -60px;
    pointer-events: none;
    will-change: transform;
    display: none;
}

.reel__cursor-disc {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(18, 16, 22, .84);
    color: #fff;
    text-align: center;
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: scale(.55);
    transition: opacity .22s ease, transform .32s cubic-bezier(.22, 1, .36, 1);
}

.reel__stage.has-cursor .reel__cursor-disc {
    opacity: 1;
    transform: none;
}

.reel__cursor-pause { display: none; }
.reel.is-focus .reel__cursor-play { display: none; }
.reel.is-focus .reel__cursor-pause { display: block; }

@media (hover: hover) and (pointer: fine) {
    .reel__cursor { display: block; }
    /* the disc is the pointer here; two arrows would be one too many */
    .reel__stage.has-cursor { cursor: none; }
}

/* A finger has no pointer to carry the label, so the same disc is parked in
   the middle of the frame and simply says what a tap will do. It leaves when
   the film starts. */
@media (hover: none), (pointer: coarse) {
    .reel__cursor {
        display: block;
        left: 50%;
        top: var(--frame-mid, 50%);
        width: 104px;
        height: 104px;
        margin: -52px 0 0 -52px;
        transition: opacity .25s ease, transform .3s cubic-bezier(.22, 1, .36, 1);
    }

    .reel__cursor-disc { opacity: 1; transform: none; }

    .reel.is-focus .reel__cursor { opacity: 0; transform: scale(0.85); }
}

/* ---- arrival ------------------------------------------------------------- */

.reel__stage {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s ease, transform .9s cubic-bezier(.22, 1, .36, 1);
}

.reel.is-revealed .reel__stage {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .reel__track { animation: none; }
    .reel__cursor-disc { transition-duration: .15s; }
    .reel__stage { transform: none; transition-duration: .2s; }
    .reel__marquee { transition: opacity .2s ease; }
}

/* ---- narrow screens ------------------------------------------------------ */

@media (max-width: 900px) {
    .reel { padding: 56px 24px 40px; }
    .reel__stage { width: 100%; }
    .reel__frame, .reel__stage:focus-visible { border-radius: 20px; }
    .reel__marquee {
        position: static;
        transform: none;
        margin: 0 -24px 22px;
        font-size: 40px;
        height: 1.1em;
    }
    .reel.is-focus .reel__marquee { opacity: 1; }
    .reel__reflection { height: 34%; opacity: .6; }
}
