/* ═══════════════════════════════════════════
   ReveelStage — the 2.5D baseline
   A CSS 3D camera (`.reveel-stage` / `.reveel-stage-world`), a light sweep,
   a card flip, a hit flash and a camera shake. Classes and custom
   properties are written by public/templates/_shared/lib/stage-25d.js;
   every keyframe here is prefixed `reveel-`, the shared keyframe namespace
   across a template.
   ═══════════════════════════════════════════ */

/* ───── The camera's viewing box ───── */
.reveel-stage {
    position: relative;
    perspective: 900px;
    overflow: hidden;
}

/* ───── Everything the camera moves, together ─────
   Reads --cam-x/-y/-z/-roty (written by ReveelStage.camera) and --cam-ms
   (the duration of whatever change just landed on them). `transition` on
   `transform` is what actually animates a pose change -- `camera.to()`
   only ever sets target values, never runs its own rAF loop. */
.reveel-stage-world {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform var(--cam-ms, 300ms) ease-out;
    transform:
        translate3d(var(--cam-x, 0px), var(--cam-y, 0px), var(--cam-z, 0px))
        rotateY(var(--cam-roty, 0deg));
}

/* ───── Light sweep — a diagonal highlight crossing an element ───── */
.reveel-sweep {
    position: relative;
    overflow: hidden;
}

.reveel-sweep::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        75deg,
        transparent 40%,
        rgba(255, 255, 255, 0.55) 50%,
        transparent 60%
    );
    background-size: 250% 100%;
    background-position: 150% 0;
    animation: reveel-sweep-move var(--sweep-ms, 900ms) ease-out;
}

@keyframes reveel-sweep-move {
    from { background-position: 150% 0; }
    to { background-position: -50% 0; }
}

/* ───── Card flip ─────
   Toggled (not one-shot): .reveel-flip marks the "flipped" state, so the
   turn itself is just this element's transform animating between the two
   states rather than a class that removes itself. */
.reveel-flip {
    transform-style: preserve-3d;
    transition: transform 0.6s ease-in-out;
    transform: rotateY(180deg);
}

/* ───── Hit flash — a warm radial pulse over the stage ─────
   The spike's gradient and timing, verbatim. */
.reveel-flash {
    position: relative;
}

.reveel-flash::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        circle,
        rgba(255, 244, 214, 0.95) 0%,
        rgba(242, 196, 109, 0.45) 40%,
        transparent 75%
    );
    opacity: 0;
    animation: reveel-flash-opacity 0.9s ease-out;
}

@keyframes reveel-flash-opacity {
    0% { opacity: 0; }
    8% { opacity: 1; }
    100% { opacity: 0; }
}

/* ───── Camera shake — a brief impact jitter ─────
   The spike's easing and duration, verbatim: up to +-5px of translate3d
   jitter over 0.42s. */
.reveel-shake {
    animation: reveel-shake-jitter 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes reveel-shake-jitter {
    0% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-5px, 3px, 0); }
    40% { transform: translate3d(4px, -4px, 0); }
    60% { transform: translate3d(-3px, -2px, 0); }
    80% { transform: translate3d(5px, 2px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

/* ───── Reduced motion ─────
   ReveelStage.camera/shake already no-op in JS (nothing here to override
   for them). The sweep and flip are plain motion and are switched off
   entirely. The hit flash is different: every beat must still register
   somehow, so instead of turning it off it fades gently in place -- a
   longer, lower-peak version of the same overlay -- rather than bursting. */
@media (prefers-reduced-motion: reduce) {
    .reveel-sweep::after,
    .reveel-shake {
        animation: none;
    }

    .reveel-flip {
        transition: none;
    }

    .reveel-flash::after {
        animation: reveel-flash-opacity-reduced 1.2s ease-out;
    }
}

@keyframes reveel-flash-opacity-reduced {
    0% { opacity: 0; }
    20% { opacity: 0.35; }
    100% { opacity: 0; }
}
