/* Adventure motion layer. Load after adventure-20261016.css.
 * Position belongs to .adv-person, breathing to __visual, pose fades to img.
 * Feedback never delays reading; all action cues finish within 420 ms.
 */
.adv-sheet .adv-content { isolation: isolate; }
.adv-sheet .adv-person { transition: transform 280ms cubic-bezier(.2,.7,.25,1); opacity: 1; }
.adv-sheet .adv-person.is-listening { filter: none; transform: translateX(-50%); }
/* No speaking lift: the speaker's hop comes from the character layer, after any pose swap (2026-10-23). */
.adv-sheet .adv-person.is-speaking { transform: translateX(-50%); }
.adv-person__visual { position: relative; display: block; width: 100%; height: 100%; transform-origin: 50% 96%; }
.adv-person__visual > .adv-person__pose { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; opacity: 1; }
.adv-person__visual > .adv-person__pose.is-old { z-index: 1; opacity: 0; pointer-events: none; }
.adv-next__arrow { display: inline-block; flex: 0 0 auto; line-height: 1; transform-origin: center; }

/* Transitions retain the incoming screen's normal layout and scroll height. */
.adv-sheet .adv-view-enter { position: relative; z-index: 1; }
.adv-sheet .adv-view-exit { position: absolute; top: 0; left: 0; right: 0; z-index: 2; margin-top: 0; pointer-events: none!important; user-select: none; opacity: 0; }
.adv-view-exit *, .adv-view-exit::before, .adv-view-exit::after { pointer-events: none!important; }

/* Tiny individual highlights are cheaper and calmer than moving a texture. */
.adv-sheet .adv-stage__motes { background: none; opacity: 1; animation: none; }
.adv-stage__motes i { position: absolute; display: block; left: var(--x,30%); top: calc(16% + var(--i,0) * 4.3%); width: 4px; height: 4px; border-radius: 50%; background: #fff8cc; opacity: .42; pointer-events: none; }
.adv-stage__motes i:nth-child(3n) { width: 3px; height: 3px; background: #fffef0; }
.adv-stage__motes i:nth-child(3n + 1) { border-radius: 1px; transform: rotate(45deg); }
.adv-stage__light { opacity: .75; transform-origin: 22% 0; }

/* One ring acknowledges a destination without hiding the completion badge. */
.adv-node::before { content: ''; position: absolute; inset: -5px; border: 2px solid #fff3b2; border-radius: inherit; opacity: 0; pointer-events: none; }
.adv-node.is-traveling { border-color: #efc85d; }
.adv-choice::before { content: ''; position: absolute; inset: -5px; border: 2px solid #78ad75; border-radius: inherit; opacity: 0; pointer-events: none; }
.adv-choice.is-retry { border-color: #c4b878; background: linear-gradient(155deg,#fffef4,#f8f3df); }
.adv-choice.is-retry::before { border-color: #d8c17b; }

/* The gem is the anchor. Twelve small stars radiate once from its centre. */
.adv-gem-wrap { position: relative; }
.adv-gem-wrap .adv-fx-burst { position: absolute; z-index: -1; top: 50%; left: 50%; width: 0; height: 0; pointer-events: none; }
.adv-fx-burst > i { --burst-reach: 116px; position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; color: var(--color,#e4b84b); background: currentColor; clip-path: polygon(50% 0,61% 35%,100% 50%,61% 65%,50% 100%,39% 65%,0 50%,39% 35%); opacity: 0; transform: rotate(var(--angle,0deg)) translateY(-30px) rotate(calc(-1 * var(--angle,0deg))); }
.adv-fx-burst > i:nth-child(3n) { width: 7px; height: 7px; --burst-reach: 95px; }
.adv-fx-burst > i:nth-child(3n + 1) { --burst-reach: 135px; }

@keyframes adv-person-breathe {
  0%,100% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-2px) rotate(.22deg); }
  72% { transform: translateY(-1px) rotate(-.12deg); }
}
@keyframes adv-person-listen {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-1.3px); }
}
@keyframes adv-person-joy {
  0%,100% { transform: translateY(0) rotate(0deg); }
  32% { transform: translateY(-8px) rotate(-1.2deg); }
  65% { transform: translateY(-2px) rotate(.6deg); }
  82% { transform: translateY(-4px) rotate(0deg); }
}
@keyframes adv-person-notice {
  0%,100% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(-3px) rotate(-.8deg); }
  72% { transform: translateY(-1px) rotate(.3deg); }
}
@keyframes adv-pose-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes adv-pose-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes adv-line-in { from { opacity: .7; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes adv-name-in { from { opacity: .72; transform: translateX(-3px); } to { opacity: 1; transform: translateX(0); } }
@keyframes adv-next-invite { 0%,64%,100% { transform: translateX(0); } 77% { transform: translateX(3px); } 89% { transform: translateX(0); } }
@keyframes adv-view-in { from { opacity: .12; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes adv-view-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes adv-mote-float {
  0%,100% { opacity: .2; transform: translate(0,4px) rotate(0deg); }
  45% { opacity: .58; transform: translate(7px,-13px) rotate(32deg); }
  72% { opacity: .36; transform: translate(3px,-5px) rotate(15deg); }
}
@keyframes adv-light-breathe { 0%,100% { opacity: .62; } 50% { opacity: .9; } }
@keyframes adv-background-drift { 0%,100% { transform: translate(-2px,1px); } 50% { transform: translate(2px,-1px); } }
@keyframes adv-node-depart {
  0%,100% { transform: translate(-50%,-50%); }
  45% { transform: translate(-50%,calc(-50% - 6px)); }
  75% { transform: translate(-50%,calc(-50% - 2px)); }
}
@keyframes adv-choice-affirm { 0%,100% { transform: translateY(0); } 42% { transform: translateY(-5px); } 74% { transform: translateY(-1px); } }
@keyframes adv-choice-retry { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-3px); } }
@keyframes adv-feedback-ring { 0% { opacity: .85; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.14); } }
@keyframes adv-star-burst {
  0% { opacity: 0; transform: rotate(var(--angle,0deg)) translateY(-30px) rotate(calc(-1 * var(--angle,0deg))) scale(.5); }
  18% { opacity: .9; }
  65% { opacity: .65; }
  100% { opacity: 0; transform: rotate(var(--angle,0deg)) translateY(calc(-1 * var(--burst-reach))) rotate(calc(-1 * var(--angle,0deg))) scale(.7); }
}

/* All motion is opt-in through the game's existing preference. */
/* Fallback only: with the character layer (.cm-visual) the joy / notice reactions play as the swap's
 * overshoot or as the line beat (character-motion-20261017.js), on top of its own feet-anchored idle. */
[data-motion="full"] .adv-person.is-speaking .adv-person__visual:not(.cm-visual) { animation: adv-person-breathe 4.8s ease-in-out infinite; }
[data-motion="full"] .adv-person.is-listening .adv-person__visual:not(.cm-visual) { animation: adv-person-listen 6.3s ease-in-out -1.7s infinite; }
[data-motion="full"] .adv-person[data-person="girl"].is-listening .adv-person__visual:not(.cm-visual) { animation-delay: -3.1s; }
[data-motion="full"] .adv-person[data-pose="boy_jump"].is-speaking .adv-person__visual:not(.cm-visual),
[data-motion="full"] .adv-person[data-pose="girl_cheer"].is-speaking .adv-person__visual:not(.cm-visual) { animation: adv-person-joy 420ms cubic-bezier(.2,.7,.3,1) both,adv-person-breathe 4.8s ease-in-out 420ms infinite; }
[data-motion="full"] .adv-person[data-pose="boy_surprise"].is-speaking .adv-person__visual:not(.cm-visual),
[data-motion="full"] .adv-person[data-pose="girl_surprise"].is-speaking .adv-person__visual:not(.cm-visual),
[data-motion="full"] .adv-person[data-pose="girl_idea"].is-speaking .adv-person__visual:not(.cm-visual) { animation: adv-person-notice 360ms ease-out both,adv-person-breathe 4.8s ease-in-out 360ms infinite; }
[data-motion="full"] .adv-person__visual > .adv-person__pose.is-old { animation: adv-pose-out 180ms ease-out both; }
[data-motion="full"] .adv-person__visual:has(> .is-old) > .adv-person__pose:not(.is-old) { animation: adv-pose-in 180ms ease-out both; }
[data-motion="full"] .adv-dialogue.is-line-changing .adv-dialogue__name { animation: adv-name-in 220ms ease-out both; }
[data-motion="full"] .adv-dialogue.is-line-changing .adv-dialogue__text { animation: adv-line-in 240ms ease-out both; }
[data-motion="full"] .adv-next:not(:disabled) .adv-next__arrow { animation: adv-next-invite 3.2s ease-in-out 1.4s infinite; }
[data-motion="full"] .adv-view-enter { animation: adv-view-in 260ms cubic-bezier(.2,.7,.25,1) both; }
[data-motion="full"] .adv-view-exit { animation: adv-view-out 180ms ease-out both; }
[data-motion="full"] .adv-sheet .adv-stage__motes { animation: none; }
[data-motion="full"] .adv-stage__motes i { animation: adv-mote-float calc(8s + var(--i,0) * .45s) ease-in-out var(--delay,0s) infinite; }
[data-motion="full"] .adv-stage__light { animation: adv-light-breathe 10s ease-in-out infinite; }
[data-motion="full"] .adv-node.is-traveling { animation: adv-node-depart 360ms cubic-bezier(.2,.7,.25,1) both; }
[data-motion="full"] .adv-node.is-traveling::before { animation: adv-feedback-ring 420ms ease-out both; }
[data-motion="full"] .adv-choice.is-correct { animation: adv-choice-affirm 360ms cubic-bezier(.2,.7,.25,1) both; }
[data-motion="full"] .adv-choice.is-correct::before { animation: adv-feedback-ring 420ms ease-out both; }
[data-motion="full"] .adv-choice.is-retry { animation: adv-choice-retry 280ms ease-out both; }
[data-motion="full"] .adv-choice.is-retry::before { animation: adv-feedback-ring 320ms ease-out both; }
[data-motion="full"] .adv-fx-burst > i { animation: adv-star-burst 420ms cubic-bezier(.15,.65,.35,1) calc(var(--i,0) * 5ms) both; }

/* Only large screens pan the background by two pixels, without scaling art. */
@media (min-width:900px) and (min-height:500px) and (prefers-reduced-motion:no-preference) {
  [data-motion="full"] .adv-sheet .adv-stage__background { inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); animation: adv-background-drift 18s ease-in-out infinite; }
}
@media (max-width:599px) {
  .adv-stage__motes i:nth-child(n + 6) { display: none; }
  .adv-fx-burst > i { --burst-reach: 100px; }
  .adv-fx-burst > i:nth-child(3n) { --burst-reach: 85px; }
  .adv-fx-burst > i:nth-child(3n + 1) { --burst-reach: 115px; }
}

/* Visibility pause follows the shared lifecycle listener. No resume flash. */
html.quality-paused .adv-sheet *, html.quality-paused .adv-sheet *::before, html.quality-paused .adv-sheet *::after,
.adv-sheet[aria-hidden="true"] *, .adv-sheet[aria-hidden="true"] *::before, .adv-sheet[aria-hidden="true"] *::after { animation-play-state: paused!important; }

/* Reduced motion keeps the latest text, pose, success state and focus visible. */
[data-motion="reduced"] .adv-sheet *, [data-motion="reduced"] .adv-sheet *::before, [data-motion="reduced"] .adv-sheet *::after { animation: none!important; transition: none!important; }
[data-motion="reduced"] .adv-view-enter, [data-motion="reduced"] .adv-person__visual, [data-motion="reduced"] .adv-dialogue__text, [data-motion="reduced"] .adv-dialogue__name, [data-motion="reduced"] .adv-next__arrow { opacity: 1; transform: none; }
[data-motion="reduced"] .adv-view-exit, [data-motion="reduced"] .adv-person__pose.is-old, [data-motion="reduced"] .adv-fx-burst { display: none!important; }
@media (prefers-reduced-motion:reduce) {
  .adv-sheet *, .adv-sheet *::before, .adv-sheet *::after { animation: none!important; transition: none!important; }
  .adv-view-enter, .adv-person__visual, .adv-dialogue__text, .adv-dialogue__name, .adv-next__arrow { opacity: 1; transform: none; }
  .adv-view-exit, .adv-person__pose.is-old, .adv-fx-burst { display: none!important; }
}
.adv-sheet [hidden], .adv-person__visual[hidden], .adv-person__pose[hidden] { display: none!important; }
