/* Original silhouettes and colours stay intact; only rigid source pixels move (2026-10-23 overhaul).
 * Layers: .cm-visual (swap dip / settle / line beats, Web Animations) > .cm-pose (aligned placement)
 * > .cm-sway (slow sway) > .cm-breath (breathing) > img. Transforms only; no filters on moving layers.
 * The white rim is baked into the images (uniform on every side). */

/* == [home] == */
/* ホーム cast (.hm-person.cm-title, built in 42-home; size and place in 47-home.css): the stage's idle breathing,
 * phase-shifted per character. Paused with the rest of the cast when the view is hidden or covered. */
.hm-person.cm-title { filter: none; }
.cm-title[data-person="teacher"] { --cm-phase: -1.7s; --cm-phase2: -3.9s; }
.cm-title[data-person="girl"] { --cm-phase: -3.1s; --cm-phase2: -1.2s; }
[data-motion="full"] .cm-title .cm-breath { animation: cm-breathe 3.8s ease-in-out var(--cm-phase,0s) infinite; }
[data-motion="full"] .cm-title .cm-sway { animation: cm-sway 6.4s ease-in-out var(--cm-phase2,0s) infinite; }
[data-motion="full"] .cm-title .cm-arm { animation: cm-arm-gesture 5.2s ease-in-out var(--cm-phase,0s) infinite; }

/* == [story] == */
.adv-cast, .adv-cast *, .cp-cast, .cp-cast * { pointer-events: none!important; }
.cm-visual { position: relative; display: block; width: 100%; height: 100%; transform-origin: 50% 100%; }
.cp-person__visual { width: 100%; height: 100%; }
/* One scale per character (--cm-u = px per original pixel); the eye midpoint stays on one point (x exact,
 * y via a foot offset of at most 4 % of the figure). --cm-shift: sideways step planned for the whole cast
 * (the children make room for the teacher's bust on wide stages). */
.cm-visual > .cm-pose.cm-pose, .cm-pose { position: absolute; display: block; top: auto; right: auto; pointer-events: none; max-width: none; max-height: none; object-fit: fill; filter: none; animation: none;
  left: calc(50% + var(--pl) * var(--cm-u, 0px) + var(--cm-shift, 0px)); bottom: calc(var(--pb) * var(--cm-u, 0px) - var(--cm-drop, 0px));
  width: calc(var(--pw) * var(--cm-u, 0px)); height: calc(var(--ph) * var(--cm-u, 0px)); }
.cm-pose.cm-fill { left: 0; bottom: 0; width: 100%; height: 100%; }
.cm-sway, .cm-breath { position: absolute; inset: 0; display: block; transform-origin: var(--fx, 50%) var(--fy, 99%); }
.cm-pose .cm-breath > img, .adv-person .cm-pose .cm-breath > img, .cp-person .cm-pose .cm-breath > img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: fill; filter: none; }
[data-motion="full"] .cp-person .cm-visual > .cp-pose { animation: none; }
/* Contact shadow on the ground (static; it stays down while the body hops). */
.adv-person::after, .cp-person::after { content: ''; position: absolute; z-index: -1; left: calc(var(--cm-feet, 50%) + var(--cm-shift, 0px)); bottom: calc(var(--cm-foot-y, 0px) - 5px); width: var(--cm-foot-w, 46%); height: 13px; border-radius: 50%; transform: translateX(-50%); background: radial-gradient(closest-side, #173b3633, #173b3600); pointer-events: none; }
/* Teacher bust (先生1/2): behind the children, waist hidden under the dialogue box. */
.adv-cast > .adv-person.cm-teacher-bust, .cp-cast > .cp-person.cm-teacher-bust { z-index: 0; }
.adv-person.cm-teacher-bust::after, .cp-person.cm-teacher-bust::after { display: none; }
.adv-stage > .adv-dialogue, .cp-stage > .cp-dialogue { z-index: 5; }
.cp-stage > .cp-dialogue { position: relative; }
.adv-person[data-person="girl"], .cp-person[data-person="girl"] { --cm-phase: -2.3s; --cm-phase2: -4.4s; }
.adv-person[data-person="teacher"], .cp-person[data-person="teacher"] { --cm-phase: -1.1s; --cm-phase2: -2.6s; }
/* Idle: breathing (scale from the feet) and a slow sway (rotation about the feet): feet stay planted.
 * Breathing peaks at 1.014 so that with the line hop's 1.035 the figure stays within 6 % (see JS). */
@keyframes cm-breathe { 0%,100% { transform: scale(1,1); } 46% { transform: scale(1.006,1.014); } }
@keyframes cm-breathe-soft { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.004,1.01); } }
@keyframes cm-sway { 0%,100% { transform: rotate(-.6deg); } 50% { transform: rotate(.6deg); } }
@keyframes cm-sway-soft { 0%,100% { transform: rotate(-.32deg); } 50% { transform: rotate(.32deg); } }
@keyframes cm-arm-gesture {
  0%,10%,100% { transform: rotate(0deg); }
  35% { transform: rotate(var(--cm-arm-min,0deg)); }
  72% { transform: rotate(var(--cm-arm-max,0deg)); }
}
@keyframes cm-arm-listen {
  0%,20%,100% { transform: rotate(0deg); }
  52% { transform: rotate(calc(var(--cm-arm-min,0deg) * .45)); }
  76% { transform: rotate(calc(var(--cm-arm-max,0deg) * .45)); }
}
[data-motion="full"] .is-speaking .cm-breath { animation: cm-breathe 3.8s ease-in-out var(--cm-phase,0s) infinite; }
[data-motion="full"] .is-speaking .cm-sway { animation: cm-sway 6.4s ease-in-out var(--cm-phase2,0s) infinite; }
[data-motion="full"] .is-listening .cm-breath { animation: cm-breathe-soft 4.6s ease-in-out var(--cm-phase,0s) infinite; }
[data-motion="full"] .is-listening .cm-sway { animation: cm-sway-soft 7.6s ease-in-out var(--cm-phase2,0s) infinite; }
[data-motion="full"] .is-speaking .cm-arm { animation: cm-arm-gesture 5.2s ease-in-out var(--cm-phase,0s) infinite; }
[data-motion="full"] .is-listening .cm-arm { animation: cm-arm-listen 7.4s ease-in-out -1.2s infinite; }
.cm-is-paused .cm-sway, .cm-is-paused .cm-breath, .cm-is-paused .cm-arm { animation-play-state: paused!important; }
html.quality-paused .cm-sway, html.quality-paused .cm-breath, html.quality-paused .cm-arm,
[hidden] .cm-sway, [hidden] .cm-breath, [hidden] .cm-arm,
[inert] .cm-sway, [inert] .cm-breath, [inert] .cm-arm { animation-play-state: paused!important; }
[data-motion="reduced"] .cm-visual, [data-motion="reduced"] .cm-sway, [data-motion="reduced"] .cm-breath, [data-motion="reduced"] .cm-arm { animation: none!important; transform: none; transition: none!important; }
@media (prefers-reduced-motion:reduce) {
  .cm-visual, .cm-sway, .cm-breath, .cm-arm { animation: none!important; transform: none; transition: none!important; }
}
.cm-pose[hidden], .cm-visual[hidden] { display: none!important; }
