/* Homepage back-office stage for the RCM animation (rcm-stage.js).
 *
 * The animation sits straight on the section: no panel, edge or shadow. The
 * concept runs in its light theme and paints no background, so the white
 * section (and its faint coral glow) is the animation's background.
 *
 * It starts as a compact strip: a window onto the slice of the frame that
 * holds the signed-visit card, with Submit and the caption under it. When the
 * strip is in view, Submit presses itself, the window opens to the full frame
 * (pushing the rest of the section down) and the film plays to "Paid". A quiet
 * Pause / Play / Replay pill sits in the corner while it runs. Without script,
 * or with reduced motion, the window is the full frame from the start. */

@property --rcm-fade {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
}

.rcm-stage {
    position: relative;
    max-width: 1140px;
    margin: -8px auto 56px;
    container-type: inline-size;
}

.rcm-stage:focus {
    outline: none;
}

.rcm-stage.rcm-unavailable {
    display: none;
}

/* ------------------------------------------------------------------ window
 * Lengths are in the stage's cqw, so they track its width.
 *   --rcm-open-h     the frame's height (the concept's .ha root)
 *   --rcm-band-top   where the closed strip starts in the frame (above the card)
 *   --rcm-start-top  where Submit sits in the frame
 *   --rcm-band-tail  Submit, caption and a margin below --rcm-start-top
 * Wide layouts are 16:9 maps. On narrow stages each concept moves its frame to
 * the top and shows a decision feed below it, so the root grows to fit that
 * concept's feed. Keyed by data-rcm-anim; a new concept adds its own rules. */
.rcm-window {
    --rcm-open-h: 56.25cqw;
    --rcm-band-top: 16.5cqw;
    --rcm-start-top: calc(34.4cqw + 34px);
    --rcm-band-tail: 120px;
    --rcm-fade-max: 28px;
    position: relative;
}

/* rcm-tree and rcm-fusion: feed under 640 px in a 25:23 box. */
@container (max-width: 639px) {
    .rcm-stage[data-rcm-anim="rcm-tree"] .rcm-window,
    .rcm-stage[data-rcm-anim="rcm-fusion"] .rcm-window {
        --rcm-open-h: 92cqw;
        --rcm-band-top: 6cqw;
        --rcm-start-top: calc(28.125cqw + clamp(84px, 23cqw, 112px));
        --rcm-band-tail: 112px;
        --rcm-fade-max: 20px;
    }
}

/* rcm-bloom: feed under 800 px, sized in em of its clamped feed font. */
@container (max-width: 799px) {
    .rcm-stage[data-rcm-anim="rcm-bloom"] .rcm-window {
        --rcm-open-h: calc(56.25cqw + clamp(12.5px, 3.8cqw, 16px) * 9.4);
        --rcm-band-top: 6cqw;
        --rcm-start-top: calc(28.125cqw + clamp(84px, 23cqw, 112px));
        --rcm-band-tail: 112px;
        --rcm-fade-max: 20px;
    }
}

/* Closed: the strip, softened top and bottom so the cut never shows. */
.rcm-window {
    --rcm-fade: var(--rcm-fade-max);
    height: calc(var(--rcm-start-top) - var(--rcm-band-top) + var(--rcm-band-tail));
    overflow: hidden;
    overflow: clip;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--rcm-fade), #000 calc(100% - var(--rcm-fade)), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 var(--rcm-fade), #000 calc(100% - var(--rcm-fade)), transparent);
}

.rcm-screen {
    position: relative;
    container-type: inline-size;
    transform: translateY(calc(-1 * var(--rcm-band-top)));
}

/* Open: the window grows to the frame while the frame slides into place, so
 * the card glides down into the opening. Transitions live on the open state
 * only, so arming never animates. */
.rcm-stage.is-open .rcm-window {
    --rcm-fade: 0px;
    height: var(--rcm-open-h);
    transition: height 1s cubic-bezier(0.65, 0, 0.35, 1), --rcm-fade 1s cubic-bezier(0.65, 0, 0.35, 1);
}

.rcm-stage.is-open .rcm-screen {
    transform: none;
    transition: transform 1s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Once open, drop the clip and mask so nothing composites through them. */
.rcm-stage.is-opened .rcm-window {
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
}

/* Back to the start after "Paid": the window closes to the strip as it opened. */
.rcm-stage.is-closing .rcm-window {
    transition: height 1s cubic-bezier(0.65, 0, 0.35, 1), --rcm-fade 1s cubic-bezier(0.65, 0, 0.35, 1);
}

.rcm-stage.is-closing .rcm-screen {
    transition: transform 1s cubic-bezier(0.65, 0, 0.35, 1);
}

.ha.rcm-ha {
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    height: var(--rcm-open-h);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The frame fades out on "Paid" before the scene is set back on its card. */
.rcm-stage.is-fading .ha.rcm-ha {
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Phones: the section keeps 40 px side padding, so the transparent stage
 * borrows most of it for a larger frame. */
@media (max-width: 600px) {
    .rcm-stage {
        margin-left: -28px;
        margin-right: -28px;
    }
}

/* ------------------------------------------------------------------ start controls */
.rcm-start {
    position: absolute;
    left: 0;
    right: 0;
    top: var(--rcm-start-top);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    text-align: center;
    transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1), transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}

@container (max-width: 799px) {
    .rcm-start {
        gap: 12px;
    }
}

.rcm-stage.is-running .rcm-start {
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.15s, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.15s, visibility 0s linear 0.5s;
}

.rcm-submit {
    appearance: none;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px 15px 34px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #4CB5AE 0%, #3A9A94 100%);
    color: #FFFFFF;
    font: 600 1.02rem/1 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(76, 181, 174, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.rcm-submit svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* A slow invitation ring while the strip waits to be seen. */
.rcm-submit::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(76, 181, 174, 0.45);
    animation: rcm-invite 2.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
    pointer-events: none;
}

@keyframes rcm-invite {
    0% { box-shadow: 0 0 0 0 rgba(76, 181, 174, 0.42); }
    70%, 100% { box-shadow: 0 0 0 16px rgba(76, 181, 174, 0); }
}

.rcm-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(76, 181, 174, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.rcm-submit:hover svg {
    transform: translateX(3px);
}

.rcm-submit:active {
    transform: translateY(0) scale(0.96);
    box-shadow: 0 3px 10px rgba(76, 181, 174, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.rcm-submit:focus-visible {
    outline: 3px solid #1A2B3C;
    outline-offset: 4px;
}

/* The press, whether a click or the strip submitting itself. */
.rcm-stage.is-pressed .rcm-submit {
    animation: rcm-press-key 0.32s cubic-bezier(0.4, 0, 0.2, 1) 1 both;
}

.rcm-stage.is-pressed .rcm-submit::after {
    animation: rcm-press 0.6s cubic-bezier(0.22, 1, 0.36, 1) 1 both;
}

@keyframes rcm-press-key {
    0% { transform: none; }
    40% { transform: scale(0.94); box-shadow: 0 3px 10px rgba(76, 181, 174, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
    100% { transform: none; }
}

@keyframes rcm-press {
    0% { box-shadow: 0 0 0 0 rgba(76, 181, 174, 0.55); }
    100% { box-shadow: 0 0 0 26px rgba(76, 181, 174, 0); }
}

.rcm-caption {
    margin: 0;
    color: var(--text-gray, #5A6B7D);
    font-size: 0.98rem;
    line-height: 1.5;
}

/* ------------------------------------------------------------------ pause / play / replay */
.rcm-ctl {
    appearance: none;
    position: absolute;
    right: 1.4cqw;
    bottom: 1.6cqw;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 15px 9px 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: inset 0 0 0 1px var(--border, #E8ECF1);
    color: var(--text-gray, #5A6B7D);
    font: 600 0.84rem/1 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease, box-shadow 0.2s ease, visibility 0s linear 0.5s;
}

.rcm-ctl svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rcm-stage.is-paused .rcm-ctl svg path {
    fill: currentColor;
}

/* Quiet while the film plays; fully there when it rests on "Paid". */
.rcm-stage.is-running .rcm-ctl {
    opacity: 0.6;
    visibility: visible;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 1s, color 0.2s ease, box-shadow 0.2s ease, visibility 0s linear 0s;
}

.rcm-stage.is-paused .rcm-ctl,
.rcm-stage.is-done .rcm-ctl,
.rcm-stage .rcm-ctl:hover,
.rcm-stage .rcm-ctl:focus-visible {
    opacity: 1;
}

.rcm-stage.is-done .rcm-ctl {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.9s, color 0.2s ease, box-shadow 0.2s ease, visibility 0s linear 0s;
}

.rcm-ctl:hover {
    color: #127C74;
    box-shadow: inset 0 0 0 1px rgba(76, 181, 174, 0.55);
}

.rcm-ctl:focus-visible {
    outline: 3px solid #1A2B3C;
    outline-offset: 3px;
}

@container (max-width: 799px) {
    .rcm-ctl {
        right: 12px;
        bottom: 12px;
    }
}

/* ------------------------------------------------------------------ no script */
.rcm-still {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Without script, or with reduced motion, there is nothing to open: the
 * window is the full frame from the start (the script then shows "Paid"). */
@media (scripting: none), (prefers-reduced-motion: reduce) {
    .rcm-window {
        height: var(--rcm-open-h);
        overflow: visible;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .rcm-screen {
        transform: none;
    }

    .rcm-start,
    .rcm-ctl {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rcm-submit::after {
        animation: none;
    }

    .rcm-window,
    .rcm-screen,
    .rcm-start,
    .rcm-ctl {
        transition: none;
    }
}
