/* =========================================================
   Персонажи-игрушки: раскраска и анимации
   ========================================================= */

.ch{
  --ink:#171024;
  display:block;width:100%;height:100%;overflow:visible;
}
.ch *{transform-box:fill-box}

/* ---------- заливки ---------- */
.ch-shape{fill:var(--c);stroke:var(--ink);stroke-width:4;stroke-linejoin:round}
.ch-shape2{fill:var(--cd);stroke:var(--ink);stroke-width:4;stroke-linejoin:round}
.ch-hi{fill:#fff;opacity:.26;stroke:none}
.ch-limb{fill:var(--cd);stroke:var(--ink);stroke-width:4}
.ch-acc{fill:var(--cl);stroke:var(--ink);stroke-width:4}
.ch-stroke{fill:none;stroke:var(--ink);stroke-width:4;stroke-linecap:round}
.ch-spot{fill:#fff;opacity:.85;stroke:none}
.ch-white{fill:#fff;stroke:var(--ink);stroke-width:3.4}
.ch-pupil{fill:var(--ink)}
.ch-glint{fill:#fff;opacity:.95}
.ch-lid{fill:none;stroke:var(--ink);stroke-width:3.4;stroke-linecap:round}
.ch-mouth{fill:none;stroke:var(--ink);stroke-width:4.4;stroke-linecap:round;stroke-linejoin:round}
.ch-mouth.ch-fill{fill:var(--cdd);stroke:var(--ink);stroke-width:4}
.ch-shadow{fill:#000;opacity:.26}
.ch-ghost{fill:#fff;opacity:.86;stroke:var(--c);stroke-width:4;stroke-linejoin:round}
.ch-ghost-eye{fill:var(--cdd);opacity:.9}
.ch-shadow--ghost{opacity:.14}

/* ---------- базовая оснастка ---------- */
.ch-rig{transform-origin:50% 100%}
.ch-arm-l{transform-origin:right center}
.ch-arm-r{transform-origin:left center}
.ch-leg-l,.ch-leg-r{transform-origin:center top}
.ch-eyes{transform-origin:center}
.ch-face{transform-origin:center}
.ch-body{transform-origin:center bottom}

/* ---------- покой ---------- */
@keyframes ch-bob{
  0%,100%{transform:translateY(0) scale(1,1)}
  50%{transform:translateY(-3px) scale(.985,1.025)}
}
@keyframes ch-armL{0%,100%{transform:rotate(0deg)}50%{transform:rotate(-13deg)}}
@keyframes ch-armR{0%,100%{transform:rotate(0deg)}50%{transform:rotate(13deg)}}
@keyframes ch-blink{0%,91%,100%{transform:scaleY(1)}94.5%{transform:scaleY(.06)}}
@keyframes ch-facefloat{0%,100%{transform:translate(0,var(--fy,0px))}50%{transform:translate(0,calc(var(--fy,0px) + 1.2px))}}

.ch--idle .ch-rig{animation:ch-bob var(--bob,1.9s) ease-in-out infinite}
.ch--idle .ch-arm-l{animation:ch-armL calc(var(--bob,1.9s) * 1.4) ease-in-out infinite}
.ch--idle .ch-arm-r{animation:ch-armR calc(var(--bob,1.9s) * 1.4) ease-in-out infinite}
.ch .ch-eyes{animation:ch-blink var(--blink,4s) linear infinite}

/* ---------- радость ---------- */
@keyframes ch-jump{
  0%{transform:translateY(0) scale(1,1)}
  22%{transform:translateY(0) scale(1.12,.86)}
  48%{transform:translateY(-16px) scale(.92,1.12)}
  74%{transform:translateY(0) scale(1.08,.92)}
  100%{transform:translateY(0) scale(1,1)}
}
@keyframes ch-cheerL{0%,100%{transform:rotate(-140deg)}50%{transform:rotate(-170deg)}}
@keyframes ch-cheerR{0%,100%{transform:rotate(140deg)}50%{transform:rotate(170deg)}}
.ch--happy .ch-rig{animation:ch-jump .78s cubic-bezier(.3,1.2,.5,1) infinite}
.ch--happy .ch-arm-l{animation:ch-cheerL .39s ease-in-out infinite}
.ch--happy .ch-arm-r{animation:ch-cheerR .39s ease-in-out infinite}

/* ---------- уныние ---------- */
@keyframes ch-sag{0%,100%{transform:translateY(2px) scale(1.02,.97)}50%{transform:translateY(4px) scale(1.03,.95)}}
.ch--sad .ch-rig{animation:ch-sag 2.6s ease-in-out infinite}
.ch--sad .ch-arm-l{transform:rotate(24deg)}
.ch--sad .ch-arm-r{transform:rotate(-24deg)}
.ch--sad .ch-mouth{transform:translateY(6px) rotate(180deg);transform-origin:center}

/* ---------- испуг ---------- */
@keyframes ch-shiver{
  0%{transform:translate(-1.2px,0) rotate(-1.2deg)}
  50%{transform:translate(1.2px,-1px) rotate(1.2deg)}
  100%{transform:translate(-1.2px,0) rotate(-1.2deg)}
}
.ch--scared .ch-rig{animation:ch-shiver .11s linear infinite}
.ch--scared .ch-eyes{transform:scale(1.12)}

/* ---------- смерть ---------- */
@keyframes ch-die{
  0%{transform:translateY(0) rotate(0deg);opacity:1}
  14%{transform:translateY(-8px) rotate(-4deg);opacity:1}
  30%{transform:translateY(0) rotate(6deg)}
  55%{transform:translateY(4px) rotate(52deg)}
  78%{transform:translateY(10px) rotate(84deg)}
  100%{transform:translateY(10px) rotate(78deg);opacity:.9}
}
.ch--dead{filter:grayscale(.9) brightness(.95) drop-shadow(0 0 12px rgba(255,60,90,.35))}
.ch--dead .ch-rig{animation:ch-die 1.15s cubic-bezier(.4,.1,.6,1) forwards}
.ch--dead .ch-eyes{animation:none}
.ch--dead .ch-white{fill:#ddd}
.ch--dead .ch-shadow{opacity:.1}

/* крестики вместо глаз у мёртвых */
.ch--dead .ch-pupil{display:none}
.ch--dead .ch-white{stroke-dasharray:0}

/* ---------- призрак ---------- */
@keyframes ch-float{
  0%,100%{transform:translateY(0) rotate(-1.5deg)}
  50%{transform:translateY(-7px) rotate(1.5deg)}
}
.ch--ghost .ch-rig{animation:ch-float 3s ease-in-out infinite}
.ch--ghost{opacity:.92}

/* ---------- появление ---------- */
@keyframes ch-pop{
  0%{transform:scale(.2) translateY(14px);opacity:0}
  60%{transform:scale(1.14) translateY(-4px);opacity:1}
  100%{transform:scale(1) translateY(0);opacity:1}
}
.ch--pop{animation:ch-pop .46s cubic-bezier(.2,1.5,.4,1) backwards}

/* ---------- «победитель» ---------- */
@keyframes ch-dance{
  0%{transform:rotate(-7deg) translateY(0)}
  25%{transform:rotate(0deg) translateY(-9px)}
  50%{transform:rotate(7deg) translateY(0)}
  75%{transform:rotate(0deg) translateY(-9px)}
  100%{transform:rotate(-7deg) translateY(0)}
}
.ch--win .ch-rig{animation:ch-dance .9s ease-in-out infinite}
.ch--win .ch-arm-l{animation:ch-cheerL .45s ease-in-out infinite}
.ch--win .ch-arm-r{animation:ch-cheerR .45s ease-in-out infinite}

/* ---------- думает ---------- */
@keyframes ch-think{0%,100%{transform:rotate(-4deg)}50%{transform:rotate(4deg)}}
.ch--think .ch-rig{animation:ch-think 2.4s ease-in-out infinite}

@media (prefers-reduced-motion: reduce){
  .ch *,.ch{animation:none !important}
}

/* крестики-глаза появляются только у мёртвых */
.ch-x{display:none}
.ch-x path{stroke:var(--ink);stroke-width:5;stroke-linecap:round;fill:none}
.ch--dead .ch-x{display:block}
.ch--dead .ch-white,.ch--dead .ch-glint,.ch--dead .ch-lid{display:none}

/* язык у пончика */
.ch-tongue{fill:#ff6b8a;stroke:var(--ink);stroke-width:4}
