/* On-screen guide: an original Epic Life mascot drawn in SVG and driven by guide.js.
   Decoration only (aria-hidden). Colours come from the theme tokens, so it works on the light and night stages.
   The walk is a performance element, like video: it may run longer than the 500ms UI limit in motion.md. */
.guide {
  position: absolute; z-index: 3; inset-block-start: 0; inset-inline-start: 0;
  inline-size: clamp(46px, 4.8vw, 72px); aspect-ratio: 120 / 160;
  pointer-events: none; opacity: 0;
  transform: translate(var(--gx, 0px), var(--gy, 0px));
  transition: transform var(--walk, 0ms) cubic-bezier(.45, 0, .3, 1), opacity .3s linear;
  will-change: transform;
}
.guide.is-on { opacity: 1; }
/* A lane beside the content for the guide to walk in, so it never stands on the slide's text. */
@media (min-width: 900px) {
  .stage.has-guide .scene:not(.scene--cover):not(.scene--closing) { padding-inline-start: calc(clamp(46px, 4.8vw, 72px) + 22px); }
}
.guide[hidden] { display: none; }
.guide svg { display: block; inline-size: 100%; block-size: 100%; overflow: visible; }

.g-shadow { fill: var(--ink); opacity: .14; }
.g-skin { fill: var(--surface-page); stroke: var(--ink); stroke-width: 3; }
.g-hand { fill: var(--surface-page); stroke: var(--ink); stroke-width: 2.5; }
.g-ink { fill: var(--ink); }
.g-limb { fill: none; stroke-linecap: round; stroke-width: 10; }
.g-leg { stroke: var(--ink); }
.g-arm { stroke: var(--spectrum-blue); }
.g-shoe { fill: var(--spectrum-orange); stroke: var(--ink); stroke-width: 2.5; }
.g-leaf { fill: var(--spectrum-green); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.g-cheek { fill: var(--spectrum-pink); opacity: .3; }
.g-smile { fill: none; stroke: var(--ink); stroke-width: 2.8; stroke-linecap: round; }
.g-body { stroke: var(--ink); stroke-width: 3; }

/* facing: the art faces the inline end; --face -1 turns it round */
.g-flip { transform: scaleX(var(--face, 1)); transform-origin: 60px 80px; transition: transform .2s cubic-bezier(.2, 0, 0, 1); }

/* idle: breathe and blink */
.g-upper { transform-origin: 60px 150px; animation: g-breathe 2.6s ease-in-out infinite alternate; }
@keyframes g-breathe { to { transform: translateY(-1.6px); } }
.g-eye { transform-box: fill-box; transform-origin: center; animation: g-blink 4.4s infinite; }
@keyframes g-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.g-pupils { transform: translate(calc(var(--lx, 0) * 1px), calc(var(--ly, 0) * 1px)); transition: transform .3s cubic-bezier(.2, 0, 0, 1); }
.g-head { transform-origin: 60px 66px; transform: rotate(calc(var(--tilt, 0) * 1deg)) translateY(calc(var(--mouth, 0) * -1.4px)); transition: transform .12s linear; }

/* arms: --arm is the rotation of the pointing arm; 0deg hangs straight down, -90deg points forward */
.g-arm-front { transform-origin: 75px 84px; transform: rotate(var(--arm, 10deg)); transition: transform .34s cubic-bezier(.2, 0, 0, 1); }
.g-arm-back { transform-origin: 45px 84px; transform: rotate(-10deg); transition: transform .34s cubic-bezier(.2, 0, 0, 1); }

/* walking */
.g-leg-a, .g-leg-b { transform-origin: 60px 114px; }
.is-walking .g-leg-a { animation: g-step .36s ease-in-out infinite alternate; }
.is-walking .g-leg-b { animation: g-step .36s ease-in-out infinite alternate-reverse; }
@keyframes g-step { from { transform: rotate(-26deg); } to { transform: rotate(26deg); } }
.is-walking .g-upper { animation: g-bob .18s ease-in-out infinite alternate; }
@keyframes g-bob { to { transform: translateY(-3px); } }
.is-walking .g-arm-front { animation: g-swing .36s ease-in-out infinite alternate-reverse; }
.is-walking .g-arm-back { animation: g-swing .36s ease-in-out infinite alternate; }
@keyframes g-swing { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }

/* poses */
.is-waving .g-arm-front { animation: g-wave .42s ease-in-out 8 alternate; }
@keyframes g-wave { from { transform: rotate(-158deg); } to { transform: rotate(-122deg); } }
.is-cheer .g-arm-front { transform: rotate(-158deg); }
.is-cheer .g-arm-back { transform: rotate(158deg); }
.is-cheer .g-all { animation: g-hop .4s cubic-bezier(.2, 0, 0, 1) 4 alternate; }
@keyframes g-hop { to { transform: translateY(-12px); } }

/* talking: --mouth 0..1 is set from the narration's loudness; without a level the mouth flaps on a loop */
.g-mouth { transform-origin: 64px 53px; transform: scale(calc(.75 + var(--mouth, 0) * .45), calc(.2 + var(--mouth, 0) * 1.1)); opacity: 0; }
.is-talking .g-mouth { opacity: 1; }
.is-talking .g-smile { opacity: 0; }
.is-talking.no-level .g-mouth { animation: g-flap .24s ease-in-out infinite alternate; }
@keyframes g-flap { from { transform: scale(.8, .25); } to { transform: scale(1.1, 1.15); } }

/* reduced motion: no walk, no loops; the guide changes place with a short fade */
html[data-motion="reduce"] .guide { transition: opacity .2s linear; }
html[data-motion="reduce"] .guide * { animation: none !important; transition: none !important; }
