/*
 * Erkatoy: персонажи и отклик на карте «Qishki sarguzasht» (сессия 32, 29.11.2026; поручение b1 по слову владельца
 * «скучно, мало анимации»). Фон оживляет ea (erkatoy-live.*, префикс ek-), здесь — снеговик, подарки, узлы дней,
 * праздник пройденного дня и прохожие по краю. Префикс ec-.
 *
 * ПРАВИЛА:
 *  • двигаются только transform-свойства и opacity. У их спрайтов своё transform: translate(-50%, -100%) с позиции,
 *    поэтому здесь — отдельные свойства translate / rotate / scale: они складываются с transform, а не заменяют его;
 *  • скрытая вкладка — html[data-hidden] (ставит их app.js) — всё моё на паузе;
 *  • «меньше движения» / data-motion="off" — класс .ec-still: ничего не движется само; слабое устройство — .wm-lite
 *    (их решение) — без мелочи (искры, глаза, прохожие).
 */

/* ── пауза ── */
html[data-hidden] .ec-a, html[data-hidden] .ec-a *,
html[data-hidden] .ec-on [class*="wm-sp-gift-"] > canvas, html[data-hidden] .ec-on .wm-mound-art, html[data-hidden] .ec-on .wm-badge { animation-play-state: paused !important; }

/* ── снеговик: слои поверх их спрайта ── */
.wm-sp-snowman.ec-split > canvas.px-canvas { visibility: hidden; }
.ec-man { position: absolute; inset: 0; transform-origin: 50% 100%; }
.ec-man > canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.ec-man .ec-head { z-index: 1; transform-origin: var(--ox, 50%) var(--oy, 60%); transition: rotate 0.45s ease-in-out, translate 0.45s ease-in-out; }
.ec-man .ec-body { z-index: 2; }
.ec-man .ec-arm { z-index: 3; transform-origin: var(--ox) var(--oy); }
.ec-man.ec-look-l .ec-head { rotate: -5deg; translate: -1.5% 0; }
.ec-man.ec-look-r .ec-head { rotate: 5deg; translate: 1.5% 0; }
.ec-man.ec-wave .ec-arm-r { animation: ec-wave-r 0.42s ease-in-out 4 alternate; }
.ec-man.ec-wave-l .ec-arm-l { animation: ec-wave-l 0.42s ease-in-out 4 alternate; }
@keyframes ec-wave-r { from { rotate: 0deg; } to { rotate: -28deg; } }
@keyframes ec-wave-l { from { rotate: 0deg; } to { rotate: 28deg; } }
/* глаза: «открытые» поверх нарисованных дуг, моргают */
.ec-eyes { position: absolute; inset: 0; z-index: 4; opacity: 0; transition: opacity 0.18s; pointer-events: none; }
.ec-man.ec-open .ec-eyes { opacity: 1; }
.ec-eye { position: absolute; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9); }
.ec-eye::after { content: ''; position: absolute; left: 22%; top: 18%; width: 56%; height: 64%; border-radius: 50%; background: #222c3a; translate: var(--px, 0) 0; transition: translate 0.4s; }
.ec-man.ec-blink .ec-eye { animation: ec-blink 0.2s ease-in-out 1; }
@keyframes ec-blink { 50% { scale: 1 0.1; } }
/* нажатие: прыжок с разворотом и сердечки */
/* кнопка — в своём слое над доской (.wm-board z 5); слой сам касаний не берёт */
.ec-hits { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.ec-hit { position: absolute; background: none; border: 0; padding: 0; cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent; border-radius: 40%; }
.ec-hit:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }
.ec-man.ec-jump { animation: ec-jump 0.9s cubic-bezier(.3, .7, .4, 1) 1; }
@keyframes ec-jump {
  0% { translate: 0 0; scale: 1 1; rotate: 0deg; }
  15% { translate: 0 0; scale: 1.12 0.86; }
  45% { translate: 0 -22%; scale: 0.94 1.08; rotate: -8deg; }
  70% { translate: 0 0; scale: 1.1 0.9; rotate: 4deg; }
  85% { scale: 0.97 1.03; rotate: 0deg; }
  100% { translate: 0 0; scale: 1 1; rotate: 0deg; }
}
.ec-heart { position: absolute; left: 50%; top: 20%; width: 26%; aspect-ratio: 1; z-index: 6; pointer-events: none; animation: ec-heart 1.1s ease-out forwards; }
@keyframes ec-heart { 0% { opacity: 0; translate: -50% 0; scale: 0.4; } 20% { opacity: 1; scale: 1; } 100% { opacity: 0; translate: calc(-50% + var(--dx)) -150%; scale: 0.9; rotate: var(--rot); } }

/* ── подарки: прыгают по очереди и поблёскивают ── */
.wm-sp[class*="wm-sp-gift-"].ec-gift > canvas { transform-origin: 50% 100%; animation: ec-gift 4.8s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes ec-gift {
  0%, 70%, 100% { translate: 0 0; scale: 1 1; }
  76% { translate: 0 0; scale: 1.08 0.9; }
  83% { translate: 0 -16%; scale: 0.95 1.06; }
  90% { translate: 0 0; scale: 1.06 0.94; }
  95% { scale: 1 1; }
}
.ec-glint { position: absolute; width: 22%; aspect-ratio: 1; pointer-events: none; opacity: 0; animation: ec-glint 3.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes ec-glint { 0%, 60%, 100% { opacity: 0; scale: 0.3; rotate: 0deg; } 72% { opacity: 1; scale: 1; rotate: 45deg; } 84% { opacity: 0; scale: 0.5; rotate: 90deg; } }

/* ── узлы дней ── */
.wm-mound .wm-mound-art { transition: translate 0.22s cubic-bezier(.3, .7, .4, 1); }
.wm-mound.ec-press .wm-mound-art { translate: 0 -7%; }
/* сегодня (ещё не открыт): дышит сильнее и искрит */
.wm-mound.is-eligible:not(.is-opened):not(.is-cracking) .wm-mound-art { animation: ec-breathe 2.2s ease-in-out infinite; }
@keyframes ec-breathe { 0%, 100% { scale: 1; } 50% { scale: 1.07; } }
.ec-sparks { position: absolute; inset: -18% -14%; pointer-events: none; z-index: 2; }
.ec-spark { position: absolute; width: 16%; aspect-ratio: 1; opacity: 0; animation: ec-spark 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes ec-spark { 0%, 55%, 100% { opacity: 0; scale: 0.2; } 68% { opacity: 1; scale: 1; rotate: 30deg; } 80% { opacity: 0; scale: 0.6; rotate: 70deg; } }
/* закрытый: замочек иногда вздрагивает; по нажатию — «не открывается» */
.wm-mound.is-locked .wm-badge { display: inline-block; transform-origin: 50% 20%; animation: ec-lock 7s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes ec-lock { 0%, 88%, 100% { rotate: 0deg; } 90% { rotate: -14deg; } 92% { rotate: 12deg; } 94% { rotate: -8deg; } 96% { rotate: 4deg; } }
.wm-mound.ec-nope .wm-mound-art { animation: ec-nope 0.42s ease-in-out 1; }
.wm-mound.ec-nope .wm-badge { animation: ec-lock-hard 0.42s ease-in-out 1; }
@keyframes ec-nope { 20% { translate: -5% 0; } 40% { translate: 5% 0; } 60% { translate: -3% 0; } 80% { translate: 2% 0; } }
@keyframes ec-lock-hard { 25% { rotate: -22deg; scale: 1.2; } 50% { rotate: 18deg; scale: 1.2; } 75% { rotate: -10deg; } }

/* ── праздник пройденного дня ── */
.ec-party { position: absolute; left: 50%; top: 40%; width: 0; height: 0; pointer-events: none; z-index: 6; }
.ec-bit { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 2px; opacity: 0; animation: ec-bit 1.25s cubic-bezier(.2, .7, .3, 1) forwards; animation-delay: var(--d, 0s); }
.ec-bit.ec-flake { width: 12px; height: 12px; left: -6px; top: -6px; border-radius: 0; background: none; }
@keyframes ec-bit {
  0% { opacity: 0; translate: 0 0; rotate: 0deg; scale: 0.4; }
  12% { opacity: 1; scale: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; translate: var(--dx) var(--dy); rotate: var(--rot); scale: 0.8; }
}

/* ── прохожие по краю ── */
.ec-walk { position: absolute; left: 0; right: 0; bottom: 1.5%; height: 9%; z-index: 4; pointer-events: none; overflow: hidden; }
.ec-walker { position: absolute; bottom: 0; height: 100%; aspect-ratio: 1.4; left: 0; animation: ec-cross var(--t, 9s) linear 1 forwards; }
.ec-walker.ec-rtl { scale: -1 1; animation-name: ec-cross-rtl; }
@keyframes ec-cross { from { translate: -120% 0; } to { translate: calc(var(--w) + 20%) 0; } }
@keyframes ec-cross-rtl { from { translate: calc(var(--w) + 20%) 0; } to { translate: -120% 0; } }
.ec-walker svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.ec-walker .ec-step-a { animation: ec-step 0.36s steps(1) infinite; }
.ec-walker .ec-step-b { animation: ec-step 0.36s steps(1) infinite reverse; }
@keyframes ec-step { 0% { opacity: 1; } 50% { opacity: 0; } }
.ec-walker.ec-hop svg { animation: ec-hop 0.5s ease-in-out infinite; }
@keyframes ec-hop { 0%, 100% { translate: 0 0; } 50% { translate: 0 -22%; } }

/* ── тишина: «меньше движения» и data-motion="off" ── */
.ec-still .ec-a, .ec-still .ec-a *, .ec-still .wm-mound .wm-mound-art, .ec-still .wm-mound .wm-badge,
.ec-still [class*="wm-sp-gift-"] > canvas { animation: none !important; transition: none !important; }
.ec-still .ec-sparks, .ec-still .ec-glint, .ec-still .ec-walk, .ec-still .ec-eyes { display: none; }
/* слабое устройство (их .wm-lite): без искр, глаз и прохожих */
.wm-lite .ec-sparks, .wm-lite .ec-glint, .wm-lite .ec-walk, .wm-lite .ec-eyes { display: none; }
