/* Five original portraits, four walking beats, one quiet idle cycle.
   Movement across the map belongs to the merchant's outer world element.
   These transforms only articulate the character within that element. */
.merchant-sprite { overflow: visible; image-rendering: pixelated; }
.merchant-sprite .sprite-facing { transform-origin: 240px 690px; }
.merchant-sprite .sprite-torso { transform-origin: 240px 650px; animation: merchant-breathe 3.6s ease-in-out infinite; }
.merchant-sprite .sprite-foot { transform-origin: 240px 650px; }
.merchant-sprite .sprite-shadow { transform-origin: 240px 694px; }

/* The nearest merchant wrapper controls facing. Never flip the world position,
   name label, speech bubble, or trading controls with the artwork. */
[data-facing="left"] > .merchant-sprite .sprite-facing,
[data-facing="left"] > * > .merchant-sprite .sprite-facing,
.merchant-sprite[data-facing="left"] .sprite-facing { transform: translateX(480px) scaleX(-1); transform-origin: 0 0; }
[data-facing="right"] > .merchant-sprite .sprite-facing,
[data-facing="right"] > * > .merchant-sprite .sprite-facing,
.merchant-sprite[data-facing="right"] .sprite-facing { transform: none; }

.walking .merchant-sprite .sprite-torso,
.merchant-sprite.walking .sprite-torso { animation: merchant-walk-body .64s steps(1, end) infinite; }
.walking .merchant-sprite .sprite-foot-left,
.merchant-sprite.walking .sprite-foot-left { animation: merchant-step-left .64s steps(1, end) infinite; }
.walking .merchant-sprite .sprite-foot-right,
.merchant-sprite.walking .sprite-foot-right { animation: merchant-step-right .64s steps(1, end) infinite; }
.walking .merchant-sprite .sprite-shadow,
.merchant-sprite.walking .sprite-shadow { animation: merchant-walk-shadow .64s steps(1, end) infinite; }

@keyframes merchant-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes merchant-walk-body {
  0%, 50%, 100% { transform: translateY(-4px); }
  25%, 75% { transform: translateY(-10px); }
}
@keyframes merchant-step-left {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-12px, -20px); }
  50% { transform: translate(0, -2px); }
  75% { transform: translate(10px, 2px); }
}
@keyframes merchant-step-right {
  0%, 100% { transform: translate(0, -2px); }
  25% { transform: translate(-10px, 2px); }
  50% { transform: translate(0, 0); }
  75% { transform: translate(12px, -20px); }
}
@keyframes merchant-walk-shadow {
  0%, 50%, 100% { transform: scaleX(1); opacity: 1; }
  25%, 75% { transform: scaleX(.94); opacity: .9; }
}

.motion-paused .merchant-sprite *,
.merchant-sprite.motion-paused * { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .merchant-sprite * { animation: none !important; }
}
