/* さるA (the question-asker of the articles) toddles up and down the stone steps between the Journal and JINJA:
   down, a short rest, back up, a longer rest at the top. Smaller and much slower than the alpaca.
   The alpaca runs past the foot of these steps once per 56s lap; the monkey's 28s loop is timed so that it is
   resting at the top whenever that happens (both loops start with the page and pause together).
   The track is one map-size box placed up-left of the map with the monkey at its bottom-right corner, so the route is
   a transform in map percentages (no layout per frame) and the moving box never widens the page. */
.map-monkey{
  position:absolute;left:-100%;top:-100%;width:100%;height:100%;z-index:2;pointer-events:none;user-select:none;
  transform:translate(65.3%,36.4%);
  animation:monkey-route 28s linear infinite;
}
.monkey-walker{position:absolute;right:0;bottom:0;width:2.9%;aspect-ratio:68/95;transform:translate(50%,5%)}
.monkey-shadow{position:absolute;left:16%;bottom:0;width:68%;height:9%;border-radius:50%;background:#24333550;filter:blur(1px)}
.monkey-facing{position:absolute;inset:0;transform:scaleX(-1);animation:monkey-facing 28s steps(1,end) infinite}
.monkey-sprite{position:absolute;inset:0;background:url(modules/monkey-walk.webp) 0 0/400% 100% no-repeat;transform-origin:50% 95%}
/* Four frames: step, feet together, other step, feet together. One small step every 0.28s. */
.monkey-walking{opacity:0;animation:monkey-frames 1.12s steps(4) infinite,monkey-toddle 1.12s ease-in-out infinite,monkey-walks 28s steps(1,end) infinite}
.monkey-standing{background-position:33.333% 0;animation:monkey-stands 28s steps(1,end) infinite}
/* 0-1.5s rest at the top, 1.5-10.5s down, 10.5-13s rest at the foot, 13-21.5s up, 21.5-28s rest at the top */
@keyframes monkey-route{
  0%,5.36%{transform:translate(65.3%,36.4%)}
  37.5%,46.43%{transform:translate(61%,45.4%)}
  76.79%,100%{transform:translate(65.3%,36.4%)}
}
/* The drawing faces right; it turns around in the middle of each rest. */
@keyframes monkey-facing{0%{transform:scaleX(-1)}42%{transform:scaleX(1)}96%{transform:scaleX(-1)}}
@keyframes monkey-walks{0%{opacity:0}5.36%{opacity:1}37.5%{opacity:0}46.43%{opacity:1}76.79%{opacity:0}}
@keyframes monkey-stands{0%{opacity:1}5.36%{opacity:0}37.5%{opacity:1}46.43%{opacity:0}76.79%{opacity:1}}
@keyframes monkey-frames{to{background-position:133.333% 0}}
@keyframes monkey-toddle{
  0%,100%{transform:translateY(0) rotate(-1.5deg)}
  25%{transform:translateY(-3%) rotate(0)}
  50%{transform:translateY(0) rotate(1.5deg)}
  75%{transform:translateY(-3%) rotate(0)}
}
.island-motion-paused .map-monkey,
.island-motion-paused .map-monkey *{animation-play-state:paused!important}
@media(max-width:760px){.monkey-walker{width:3.6%}}
/* Between 761px and 1100px the JINJA nameplate reaches over the top of the steps, so the monkey turns back a little lower. */
@media(min-width:761px) and (max-width:1100px){
  .map-monkey{transform:translate(64.1%,38.8%);animation-name:monkey-route-mid}
}
@keyframes monkey-route-mid{
  0%,5.36%{transform:translate(64.1%,38.8%)}
  37.5%,46.43%{transform:translate(61%,45.4%)}
  76.79%,100%{transform:translate(64.1%,38.8%)}
}
/* Reduced motion: it stands still at the top of the steps. */
@media(prefers-reduced-motion:reduce){
  .map-monkey,.map-monkey *{animation:none!important}
}
