/* The Mystery forge (stage 3 of the animation plan): the Blender clip of the anvil and hammer, the possible skins in a golden halo, and the
   reveal of the drop in the target slot. anvil.js builds the layers, forge-mystery.js moves them with GSAP.
   Only transform, opacity and filter move; every light is its own layer. */

/* In Mystery the showcase stands on the stage until the drop is revealed */
.slot-mystery .target.stage-empty {
  display: none;
}

.dial-mystery .dial-wheel,
.dial-mystery .dial-arm,
.dial-mystery .dial-core {
  display: none;
}

/* One light only: in Mystery the anvil's own warm light replaces the dial's light layer */
.dial-mystery::before {
  display: none;
}

/* The forge stands in the dial's place and is bigger than it, so the hammer and sparks have room */
.forge-anvil {
  --anvil-shift-x: 0.76%; /* the anvil's waist sits 5.5 px of 720 left of the clip's centre */
  --anvil-shift-y: -5%; /* the clip leaves room above the anvil for the swing; this lifts the anvil to the dial's middle */
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  /* Sized so the anvil (63% of the clip's width) stays clear of the side panels even with the camera moved in */
  width: 140%;
  height: 140%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.dial-mystery .forge-anvil {
  display: block;
}

/* While it works the forge is above the side panels, so its embers can fly over the target slot */
.dial.anvil-working {
  z-index: 3;
}

/* The camera moves in less in Mystery: the forge is already bigger than the wheel */
.dial-mystery {
  --dial-push: 1.05;
}

.anvil-rig,
.anvil-body,
.anvil-fx,
.anvil-embers {
  position: absolute;
  inset: 0;
}

.anvil-body {
  transform: translate(var(--anvil-shift-x), var(--anvil-shift-y));
}

.anvil-image {
  display: block;
  width: 100%;
  height: 100%;
}

/* A warm pool of light behind and under the anvil: the stage's only light */
.anvil-light {
  position: absolute;
  inset: 22% 10% 6%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 120, 40, 0.38), rgba(255, 90, 20, 0.12) 55%, transparent 78%);
  opacity: 0.55;
}

.forge-anvil.is-idle .anvil-light {
  animation: anvil-breathe 4s ease-in-out infinite;
}

@keyframes anvil-breathe {
  50% { opacity: 0.75; }
}

/* A few embers drift up from the anvil while it waits */
.anvil-ember {
  position: absolute;
  bottom: 52%;
  left: calc(34% + var(--i) * 6%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffb347;
  box-shadow: 0 0 6px 1px rgba(255, 140, 40, 0.8);
  opacity: 0;
}

.forge-anvil.is-idle .anvil-ember {
  animation: ember-rise calc(3.2s + var(--i) * 0.45s) ease-out calc(var(--i) * -0.9s) infinite;
}

@keyframes ember-rise {
  0% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(calc((var(--i) - 2.5) * 6px), -150px); }
}

.anvil-working .anvil-ember {
  animation: none;
}

/* The glow on the anvil's face, where the hammer strikes (each blow lights it) */
.anvil-reflect {
  position: absolute;
  top: 37%;
  left: 22%;
  width: 52%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 150, 60, 0.5), rgba(255, 100, 30, 0.18) 55%, transparent);
  opacity: 0;
  pointer-events: none;
}

/* The target slot while it waits: the possible skins take turns over the same warm shimmer */
.slot-mystery .showcase-face::before {
  width: 240px;
  background: radial-gradient(closest-side, rgba(255, 190, 110, 0.4), rgba(255, 110, 30, 0.2) 50%, transparent 78%);
  animation: heat-shimmer 2.6s ease-in-out infinite;
}

@keyframes heat-shimmer {
  0%, 100% { opacity: 0.75; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

/* While the forge works the possible skins keep taking turns in the slot, inside a golden halo that pulses */
.slot-forging .showcase-face::before {
  width: 260px;
  background: radial-gradient(closest-side, rgba(255, 232, 160, 0.75), rgba(255, 196, 80, 0.4) 45%, rgba(255, 150, 40, 0.12) 65%, transparent 80%);
  animation: halo-pulse 0.9s ease-in-out infinite;
}

.slot-forging .showcase-face .target-image {
  filter: drop-shadow(0 0 10px rgba(255, 214, 120, 0.7)) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
}

@keyframes halo-pulse {
  0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.12); }
}

.anvil-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffd27a;
  box-shadow: 0 0 6px 1px rgba(255, 140, 40, 0.9);
  pointer-events: none;
}

.anvil-spark-small {
  width: 3px;
  height: 3px;
}

.anvil-ring {
  position: absolute;
  width: 180px;
  height: 180px;
  border: 2px solid rgba(255, 190, 110, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 140, 40, 0.6), inset 0 0 10px rgba(255, 140, 40, 0.4);
  pointer-events: none;
}

/* After .anvil-ring, so its paler edge wins */
.anvil-ring-gather {
  border-color: rgba(255, 214, 140, 0.6);
}

.anvil-flash {
  position: absolute;
  inset: 5% 10% 25%;
  border-radius: 50%;
  background: radial-gradient(closest-side, #fff8ec, rgba(255, 220, 160, 0.8) 25%, rgba(255, 120, 40, 0.3) 55%, transparent 75%);
  opacity: 0;
  pointer-events: none;
}

/* Skip: in the middle under the forge while it works, gone the moment the card opens */
.forge-skip {
  position: absolute;
  bottom: -18px;
  left: 50%;
  z-index: 7;
  min-height: 32px;
  padding: 0 18px;
  font-size: var(--text-sm);
  transform: translateX(-50%);
}

.forge-skip:active:not(:disabled) {
  transform: translateX(-50%) scale(0.97);
}

/* The stake is pulled towards the anvil, which is to the right of it */
.slot-feeding .stake-tile {
  animation: stake-feed 0.9s ease-in forwards;
}

.slot-fed .stake-tile {
  visibility: hidden;
}

@keyframes stake-feed {
  0% { transform: translateX(0) scale(1); opacity: 1; }
  100% { transform: translateX(260px) scale(0.3); opacity: 0; }
}

/* The result: the multiplier on a small plate under the anvil */
.dial-mystery .dial-core {
  top: auto;
  bottom: -16px;
  z-index: 2;
  width: 124px;
  height: 58px;
  border-radius: var(--radius);
  transform: translateX(-50%);
}

.dial-revealed .dial-core {
  display: flex;
  animation: plate-in 0.3s ease-out;
}

.dial-revealed .dial-value {
  color: var(--gold);
}

@keyframes plate-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

/* The reveal in the target slot: the name and price come first, then the skin rises over ember rays.
   The slot's light is its ::after layer (forge-dial.css), so only opacity changes. */
.forge.is-focused .slot-reveal {
  opacity: 1;
  filter: none;
}

.slot-reveal {
  overflow: hidden;
  border-color: var(--ember);
}

.slot-reveal::after {
  animation: slot-flash 2.6s ease-out;
}

.slot-reveal-rare {
  --slot-flash-edge: var(--gold);
  --slot-flash-shadow: 0 0 70px 14px rgba(255, 224, 138, 0.7);
  border-color: var(--gold);
}

.slot-reveal-low {
  --slot-flash-edge: var(--steel);
  --slot-flash-shadow: 0 0 30px 4px rgba(163, 156, 151, 0.35);
  border-color: var(--steel);
}

.slot-reveal .target {
  position: relative;
  z-index: 0;
}

.slot-reveal .target-name,
.slot-reveal .skin-price {
  position: relative;
  text-shadow: 0 1px 4px #000, 0 0 10px #000;
  animation: reveal-text 0.35s ease-out both;
}

.slot-reveal .skin-price {
  animation-delay: 0.08s;
}

.slot-reveal .target-image {
  position: relative;
  animation: reveal-rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) 0.4s both;
}

.reveal-rays {
  position: absolute;
  top: calc(var(--stage-pad) + var(--stage-image) / 2);
  left: 50%;
  z-index: -1;
  width: 240px;
  height: 240px;
  margin: -120px 0 0 -120px;
  background: repeating-conic-gradient(color-mix(in srgb, var(--rarity, #ff963c) 45%, transparent) 0 12deg, transparent 12deg 30deg);
  border-radius: 50%;
  -webkit-mask: radial-gradient(closest-side, #000 25%, transparent);
  mask: radial-gradient(closest-side, #000 25%, transparent);
  animation: rays-in 0.6s ease-out 0.3s both, rays-turn 9s linear infinite;
  pointer-events: none;
}

.slot-reveal-rare .reveal-rays {
  background: repeating-conic-gradient(rgba(255, 224, 138, 0.8) 0 14deg, transparent 14deg 28deg);
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  animation-duration: 0.6s, 5s;
}

.slot-reveal-low .reveal-rays {
  background: repeating-conic-gradient(rgba(163, 156, 151, 0.22) 0 12deg, transparent 12deg 30deg);
}

@keyframes reveal-text {
  from { opacity: 0; transform: translateY(6px); }
}

@keyframes reveal-rise {
  from { opacity: 0; transform: translateY(34px) scale(0.85); }
}

@keyframes rays-in {
  from { opacity: 0; transform: scale(0.5); }
}

@keyframes rays-turn {
  to { transform: rotate(360deg); }
}
