/* ============================================================
   kg-motion-slots.css — BAAL'S VAULT motion module (Animations &
   Effects lane). Implements hidden_files/motion-slots-SPEC.md
   against Slots design #443/#444. The Slots lane links this sheet
   and drives the classes from its spin/door clock; it does not
   fork the keyframes. Motion properties ONLY (transform/opacity);
   all cabinet art, colors and layout live in slots.css.

   CONTRACT VARIABLES (Slots sets these in slots.css / inline):
   --kslot-cell     px height of one symbol cell (settle overshoot)
   --kslot-anticip  ms of the current anticipation window, computed
                    by slots.js as min(900 + 150*opened, 1500) and
                    ALSO written to a data attribute for Audio.

   Every idle loop's 0% frame is the NEUTRAL pose (spec §6h): under
   reduced motion the frozen first frame must look composed, never
   caught mid-gesture. All assignments live inside the
   no-preference block; the reduce block kills animations AND
   transitions (the in-game data-motion="reduced" gate is slots.js's
   side: it simply never adds these classes / sets final states).
   ============================================================ */

/* ================= REELS ================= */
/* settle overshoot: applied to a WRAPPER around the strip (the strip's
   own transform is slots.js's dealt position and is never animated by
   CSS — the resting transform must equal dealtStop * cellHeight
   exactly, spec §6b). The wrapper overshoots +2 cells in the direction
   of travel and springs back to 0. */
@keyframes kslot-reel-settle {
  0% { transform: translateY(0); }
  35% { transform: translateY(calc(var(--tile, 64px) * 2)); }
  100% { transform: translateY(0); }
}
.kslot-settle-wrap { animation: kslot-reel-settle 120ms cubic-bezier(.34, 1.4, .4, 1) 1; }
/* motion smear (the design's "blur at speed", re-techniqued — NO filter:
   two ghost copies of the strip at ±7px, low opacity, run phase only) */
.kslot-smear i { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.kslot-smear i:nth-child(1) { transform: translateY(-7px); }
.kslot-smear i:nth-child(2) { transform: translateY(7px); }
.kslot-smear-on i:nth-child(1) { opacity: .3; }
.kslot-smear-on i:nth-child(2) { opacity: .18; }
/* relic flip (Nov 4 2026): a landed card turns over to show its
   relic. rotateY on the IMG only (never the tile — tile geometry is
   the board's shared law); slots.js swaps the image at the midpoint. */
@keyframes kslot-relic-flip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}
.tile .kslot-relic-flip { animation: kslot-relic-flip 340ms ease-in-out 1; }
/* reduced settle: slots.js swaps the window content, this fades it in */
@keyframes kslot-fade-swap { from { opacity: 0; } to { opacity: 1; } }
.kslot-fade-swap { animation: kslot-fade-swap 150ms ease-out 1; }

/* ================= CABINET LIFE ================= */
@keyframes kslot-hearth { from { opacity: .55; } to { opacity: .8; } }
.kslot-hearth { animation: kslot-hearth 4.8s ease-in-out infinite alternate; }
@keyframes kslot-raven-look {
  0%, 25% { transform: rotate(0deg); } 40% { transform: rotate(-6deg); }
  55%, 78% { transform: rotate(0deg); } 88% { transform: rotate(5deg); } 100% { transform: rotate(0deg); }
}
.kslot-raven-look { animation: kslot-raven-look 9s ease-in-out infinite; }
@keyframes kslot-letter-pop {
  /* NO scale: a scaled tile corrupts the board's shared geometry and
     any live measurement of it (owner visual bug, Nov 4 2026). The pop
     is light, not size. */
  0% { filter: brightness(1); } 40% { filter: brightness(1.7); } 100% { filter: brightness(1); }
}
.kslot-letter-pop { animation: kslot-letter-pop 260ms cubic-bezier(.34, 1.35, .4, 1) 1; }
@keyframes kslot-glow-pulse { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }
.kslot-vault-pulse::before { animation: kslot-glow-pulse 700ms ease-out 1; }
@keyframes kslot-cell-win {
  /* NO scale (see letter-pop): the win pulse is light + shadow only,
     so a celebrating board keeps exact grid geometry. */
  0% { filter: brightness(1); } 45% { filter: brightness(1.45); } 100% { filter: brightness(1); }
}
.kslot-cell-win { animation: kslot-cell-win 380ms cubic-bezier(.22, 1, .36, 1) 2; }
/* cabinet shade for the bonus cut (transition-driven state) */
.kslot-shade { opacity: 0; transition: opacity 400ms ease; pointer-events: none; }
.kslot-shaded .kslot-shade { opacity: .55; }

/* ================= BAAL (layered 2D, bonus room) ================= */
@keyframes kslot-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.kslot-breathe { animation: kslot-breathe 4.2s ease-in-out infinite; }
@keyframes kslot-raven-head-a {
  0%, 60% { transform: rotate(0deg); } 72% { transform: rotate(-9deg); } 84%, 100% { transform: rotate(0deg); }
}
.kslot-raven-head-a { animation: kslot-raven-head-a 7s ease-in-out infinite; }
@keyframes kslot-raven-head-b {
  0%, 45% { transform: rotate(0deg); } 58% { transform: rotate(7deg); } 70%, 100% { transform: rotate(0deg); }
}
.kslot-raven-head-b { animation: kslot-raven-head-b 11s ease-in-out infinite; }
@keyframes kslot-sway { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(1.2deg); } }
.kslot-sway { animation: kslot-sway 5s ease-in-out infinite; }
@keyframes kslot-head-tilt {
  0%, 70% { transform: rotate(0deg); } 82% { transform: rotate(3deg); } 94%, 100% { transform: rotate(0deg); }
}
.kslot-head-tilt { animation: kslot-head-tilt 13s ease-in-out infinite; }
@keyframes kslot-nod { 0%, 100% { transform: rotateX(0deg); } 45% { transform: rotateX(6deg); } }
.kslot-nod { animation: kslot-nod 300ms ease-in-out 1; }
@keyframes kslot-bow {
  0%, 100% { transform: rotateX(0deg) translateY(0); } 50% { transform: rotateX(4deg) translateY(3px); }
}
.kslot-bow { animation: kslot-bow 600ms ease-in-out 1; }
/* the pointing arm: six column states (transition-driven, spec §4).
   Slots sets data-col="0..5" on the arm layer for the picked door. */
.kslot-arm { transition: transform 380ms cubic-bezier(.22, 1, .36, 1); }
.kslot-arm[data-col="0"] { transform: rotate(-38deg) translateX(-6px); }
.kslot-arm[data-col="1"] { transform: rotate(-24deg) translateX(-3px); }
.kslot-arm[data-col="2"] { transform: rotate(-12deg) translateX(-1px); }
.kslot-arm[data-col="3"] { transform: rotate(4deg) translateX(1px); }
.kslot-arm[data-col="4"] { transform: rotate(20deg) translateX(3px); }
.kslot-arm[data-col="5"] { transform: rotate(36deg) translateX(6px); }

/* ================= DOORS ================= */
@keyframes kslot-flame {
  0%, 100% { transform: scaleY(1) skewX(0deg); } 30% { transform: scaleY(.94) skewX(-2deg); } 65% { transform: scaleY(1.06) skewX(2deg); }
}
.kslot-flame { animation: kslot-flame 1.9s ease-in-out infinite; transform-origin: 50% 100%; }
/* flames lean toward the picked door during anticipation (wrapper states;
   the lean holds for the whole window via the transition duration) */
.kslot-flames { transition: transform var(--kslot-anticip, 900ms) cubic-bezier(.4, 0, .2, 1); }
.kslot-flames-lean-l { transform: skewX(-6deg); }
.kslot-flames-lean-r { transform: skewX(6deg); }
/* the swing: hinge rotation, light arrives DURING (light layer below) */
.kslot-door { transform-origin: 0% 50%; }
@keyframes kslot-door-swing { from { transform: rotateY(0deg); } to { transform: rotateY(-102deg); } }
.kslot-door-open { animation: kslot-door-swing 450ms cubic-bezier(.4, 0, .2, 1) both; }
/* light states behind the door — slots.css paints gold/red/white-gold;
   this layer only governs arrival. .on is added 120ms into the swing. */
.kslot-light { opacity: 0; transition: opacity 300ms ease-out; }
.kslot-light.on { opacity: 1; }
.kslot-light-vault { transition-duration: 700ms; } /* the VAULT bloom is slower */
/* door lock dimming at pick (other doors) */
.kslot-door-glow { transition: opacity 120ms ease; }
.kslot-locked .kslot-door-glow { opacity: 0; }
/* picked-door highlight */
.kslot-picked { animation: kslot-letter-pop 260ms cubic-bezier(.34, 1.35, .4, 1) 1; }
/* LAST CALL: the bell + the sigh of the unopened doors */
@keyframes kslot-bell {
  0% { transform: rotate(0deg); } 20% { transform: rotate(18deg); } 45% { transform: rotate(-13deg); }
  65% { transform: rotate(8deg); } 82% { transform: rotate(-4deg); } 100% { transform: rotate(0deg); }
}
.kslot-bell { animation: kslot-bell 900ms ease-in-out 1; transform-origin: 50% 0%; }
@keyframes kslot-sigh { from { opacity: .25; transform: translateY(0); } to { opacity: 0; transform: translateY(2px); } }
.kslot-sigh { animation: kslot-sigh 500ms ease-out both; }
/* the Tab tally: dim during anticipation, pop on chit arrival */
.kslot-tab { transition: opacity 300ms ease; }
.kslot-tab-dim { opacity: .45; }
.kslot-tab-pop { animation: kslot-letter-pop 260ms cubic-bezier(.34, 1.35, .4, 1) 1; }

/* Batch #837 — free-spin celebration + win counter, Door Room vault flare.
   Same discipline as the rest of this sheet: JS gates the cabinet/room
   classes on the reduced flag; the media block below stills the rest. */
.fs-award.kslot-fs-on { animation: kslot-fs-award 2.15s ease-out both; }
@keyframes kslot-fs-award {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(.8); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}
.kslot-fs-flare { animation: kslot-fs-flare-k 1.9s ease-out; }
@keyframes kslot-fs-flare-k {
  0%, 100% { opacity: 0; } 25% { opacity: 1; } 60% { opacity: .45; }
}
.kslot-fs-pop { animation: kslot-fs-pop-k 450ms ease-out; }
@keyframes kslot-fs-pop-k {
  0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); }
}
.vault-flare.kslot-vault-flare { animation: kslot-vault-flare-k 1.6s ease-out; }
@keyframes kslot-vault-flare-k {
  0%, 100% { opacity: 0; } 30% { opacity: .9; }
}

/* ================================================================
   ASSIGNMENTS that must never run under reduced motion are already
   class-gated by slots.js; this block additionally neutralizes the
   CSS-driven loops/transitions for media-query users.
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .kslot-settle-wrap, .kslot-fade-swap, .kslot-hearth, .kslot-raven-look,
  .kslot-letter-pop, .kslot-vault-pulse::before, .kslot-cell-win,
  .kslot-breathe, .kslot-raven-head-a, .kslot-raven-head-b, .kslot-sway,
  .kslot-head-tilt, .kslot-nod, .kslot-bow, .kslot-flame, .kslot-fs-on,
  .kslot-fs-flare, .kslot-fs-pop, .kslot-vault-flare,
  .kslot-door-open, .kslot-picked, .kslot-bell, .kslot-sigh, .kslot-tab-pop {
    animation: none !important;
  }
  .kslot-shade, .kslot-arm, .kslot-flames, .kslot-light, .kslot-door-glow, .kslot-tab {
    transition: none !important;
  }
  .kslot-smear i { opacity: 0 !important; }
}
