/* The winter surprise on the battlefield (src/battle/snowman.rs): a snowman pops up on the enemy half,
   throws a snowball at your tank and slides off on a sled. Unlayered and scoped to .battle-scope, like
   battle.css. The timeline, from the moment it mounts:
     0    – 0.5 s  rises out of the snow
     0.6  – 1.1 s  winds up the throwing arm; the ball leaves the hand at 1.1 s
     1.1  – 2.0 s  the ball flies in an arc (bigger at the top: it comes up towards the camera)
     2.0  – 2.7 s  it bursts on your tank: a white puff and seven chunks
     2.5  s        he turns, the sled appears; 2.6 – 4.1 s he slides off the right edge
   Positions come in as custom properties, in % of the stage: --sx/--sy his feet, --hx/--hy his hand,
   --tx/--ty your tank, --ex/--ey where he slides to. */

/* No z-index: it comes after the tanks and before the shots in the markup, so it stands on the field
   and never covers a damage number. */
.battle-scope .snowman-fx { position: absolute; inset: 0; pointer-events: none; }

/* The snowman: 5cqw wide (keep in sync with BODY_W in snowman.rs), feet on the spot. */
.battle-scope .sm-body { position: absolute; left: var(--sx); top: var(--sy); width: 5cqw; aspect-ratio: 60 / 80; transform: translate(-50%, -85%);
  animation: sm-slide 1.5s cubic-bezier(.45, 0, .7, .4) 2.6s forwards; }
.battle-scope .sm-pop { width: 100%; height: 100%; transform-origin: 50% 95%; animation: sm-rise .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.battle-scope .sm-flip { width: 100%; height: 100%; animation: sm-turn 4.1s step-end both; }
.battle-scope .sm-art { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 .15cqw .25cqw rgba(0, 0, 0, .35)); }

@keyframes sm-rise {
  from { transform: scale(.15, 0); opacity: 0; }
  60% { transform: scale(1.06, 1.1); opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}
/* At 2.5 s he turns to face the way he leaves. */
@keyframes sm-turn { 0% { transform: none; } 61%, 100% { transform: scaleX(-1); } }
@keyframes sm-slide {
  from { left: var(--sx); top: var(--sy); }
  to { left: var(--ex); top: var(--ey); }
}

/* The throwing arm swings back from the shoulder, then over: the ball leaves at 1.1 s. */
.battle-scope .sm-arm { transform-box: view-box; transform-origin: 20px 36px; animation: sm-arm 1.6s ease-in-out both; }
@keyframes sm-arm {
  0%, 38% { transform: rotate(0); }
  62% { transform: rotate(48deg); }
  70% { transform: rotate(-52deg); }
  86% { transform: rotate(-18deg); }
  100% { transform: rotate(0); }
}
.battle-scope .sm-held { animation: sm-held 4.1s step-end both; }
@keyframes sm-held { 0% { opacity: 1; } 27%, 100% { opacity: 0; } }
/* The sled appears as he turns. */
.battle-scope .sm-sled { opacity: 0; animation: sm-sled 4.1s step-end both; }
@keyframes sm-sled { 0% { opacity: 0; } 61%, 100% { opacity: 1; } }

/* Delayed parts use `forwards`, not `both`: `both` would show their first keyframe (visible) while
   they wait, putting the ball in his hand and the puff on your tank from the start. */
/* The snowball's flight: the path moves straight from the hand to your tank; the ball on it rises and
   falls (the arc) and its shadow stays on the ground, smaller while the ball is high. */
.battle-scope .sm-path { position: absolute; left: var(--hx); top: var(--hy); width: 0; height: 0; opacity: 0;
  animation: sm-fly .9s linear 1.1s forwards; }
@keyframes sm-fly {
  from { left: var(--hx); top: var(--hy); opacity: 1; }
  99% { opacity: 1; }
  to { left: var(--tx); top: var(--ty); opacity: 0; }
}
.battle-scope .sm-ball { position: absolute; width: 1.1cqw; height: 1.1cqw; margin: -.55cqw 0 0 -.55cqw; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e9f0f6 55%, #aebccb); box-shadow: 0 0 .5cqw rgba(255, 255, 255, .55);
  animation: sm-arc .9s 1.1s both; }
@keyframes sm-arc {
  from { transform: translateY(0) scale(1); animation-timing-function: cubic-bezier(.3, .6, .5, 1); }
  50% { transform: translateY(-6cqw) scale(1.55); animation-timing-function: cubic-bezier(.5, 0, .7, .4); }
  to { transform: translateY(0) scale(1); }
}
.battle-scope .sm-shadow { position: absolute; width: 1.2cqw; height: .5cqw; margin: -.25cqw 0 0 -.6cqw; border-radius: 50%; background: rgba(8, 14, 24, .4);
  animation: sm-shade .9s ease-in-out 1.1s both; }
@keyframes sm-shade { from, to { transform: scale(1); opacity: .9; } 50% { transform: scale(.5); opacity: .45; } }

/* The splash on your tank: a white puff and chunks of snow flying off. Not orange, so it never reads
   as a hit. */
.battle-scope .sm-splat { position: absolute; left: var(--tx); top: var(--ty); width: 0; height: 0; }
.battle-scope .sm-splat b { position: absolute; width: 4.4cqw; height: 4.4cqw; margin: -2.2cqw 0 0 -2.2cqw; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 22%, rgba(240, 246, 252, .9) 38%, rgba(220, 232, 244, .45) 58%, rgba(220, 232, 244, 0) 72%);
  opacity: 0; animation: sm-puff .7s cubic-bezier(.2, .8, .3, 1) 2s forwards; }
@keyframes sm-puff {
  from { transform: scale(.2); opacity: 1; }
  45% { opacity: .95; }
  to { transform: scale(1.5); opacity: 0; }
}
.battle-scope .sm-splat i { position: absolute; width: .55cqw; height: .55cqw; margin: -.275cqw 0 0 -.275cqw; border-radius: 50%; background: #f4f8fb;
  box-shadow: 0 0 .25cqw rgba(255, 255, 255, .7); opacity: 0; animation: sm-chunk .65s cubic-bezier(.15, .7, .35, 1) 2s forwards; }
@keyframes sm-chunk {
  from { transform: rotate(var(--a)) translateX(.3cqw) scale(1.1); opacity: 1; }
  70% { opacity: .9; }
  to { transform: rotate(var(--a)) translateX(var(--d)) scale(.4); opacity: 0; }
}

/* The scene is never scheduled with reduced motion or at the lowest effects tier; this is the belt
   to those braces. */
@media (prefers-reduced-motion: reduce) { .battle-scope .snowman-fx { display: none; } }
.battle-scope .battle-root.fx-2 .snowman-fx { display: none; }
