/* The guide strolls between the reader and the door. Each stop has its own
   pose; the doors open fully only when the reader chooses to enter. */
.playroom-guide {
  --at-visitor: -135%;
  transform: translateX(var(--at-visitor));
}
.playroom-entry[data-mode] .playroom-guide {
  transition: transform var(--walk-duration, 4s) cubic-bezier(.3,.04,.7,.96);
}
.playroom-entry:is([data-scene="approach"], [data-scene="arrive"], [data-scene="reach"], [data-scene="push"], [data-scene="hold"]) .playroom-guide {
  transform: var(--push-position);
}
/* During contact the panel and the palm share the animation frame and
   perspective projection. A second CSS transition here would make her lag. */
.playroom-entry:is([data-scene="reach"], [data-scene="push"], [data-scene="hold"]) .playroom-guide {
  transition: none;
}
.playroom-entry:is([data-scene="reach"], [data-scene="push"], [data-scene="hold"]) .playroom-sprite {
  background: var(--push-art) center / 100% 100% no-repeat;
  transform-origin: 77.4% 24.1%;
}
.playroom-entry[data-scene="push"] .playroom-sprite {
  animation: usher-push var(--walk-duration) ease-in-out both;
}
.playroom-entry[data-scene="return"] .playroom-sprite {
  --facing: -1;
}
.playroom-entry:is([data-scene="approach"], [data-scene="return"]) .playroom-sprite {
  animation: usher-walk-frames 1.04s steps(1,end) infinite, usher-footfall .52s ease-in-out infinite;
}
.playroom-sprite {
  transform-origin: 50% 93%;
}
.playroom-entry[data-scene="beckon"] .playroom-sprite {
  background-position-x: 66.66667%;
  animation: usher-offer 1.9s ease-in-out both;
}
.playroom-entry:is([data-scene="smile"], [data-scene="welcome"]) .playroom-sprite {
  animation: usher-curtsy 1.6s ease-in-out both;
}
.playroom-entry[data-scene="joy"] .playroom-guide {
  transform:var(--tap-origin);
  transition:none;
}
.playroom-entry[data-scene="joy"] .playroom-sprite {
  background-position-x:100%;
  animation:usher-joy-hop .45s both;
}
.playroom-entry[data-scene="joy"] .playroom-shadow {
  animation:usher-joy-shadow .45s both;
}
.playroom-entry[data-scene="arrive"] .playroom-guide {
  transition-timing-function:cubic-bezier(.23,.04,.62,1);
}
.playroom-entry[data-scene="arrive"] .playroom-sprite {
  animation:usher-walk-frames .32s steps(1,end) infinite, usher-footfall .16s ease-in-out infinite;
}
.playroom-entry[data-scene="inside"] .playroom-guide {
  transform:translate(calc(-50% + var(--pass-x)), -40%) scale(.5);
  opacity:0;
  transition:transform .63s cubic-bezier(.3,.04,.72,.95), opacity .22s .42s ease-in;
  animation: usher-cross-threshold .65s steps(1, end) both;
}
.playroom-entry[data-scene="inside"] .playroom-sprite {
  background-image:var(--back-art);
  background-size:200% 100%;
  animation:usher-away .32s steps(1,end) infinite, usher-footfall .16s ease-in-out infinite;
}
.playroom-entry:is([data-scene="beckon"], [data-scene="push"]) .playroom-go {
  animation: usher-invitation 2s ease-in-out both;
}
.playroom-entry:is([data-scene="beckon"], [data-scene="push"]) .playroom-go span {
  animation: usher-heart 2s ease-in-out both;
}
@keyframes usher-walk-frames { 0%,100% {background-position-x:0} 50% {background-position-x:33.33333%} }
@keyframes usher-away { 0%,100% {background-position-x:0} 50% {background-position-x:100%} }
@keyframes usher-footfall {
  0%,100% { transform:scaleX(var(--facing,1)) translateY(0); }
  50% { transform:scaleX(var(--facing,1)) translateY(-1.15%) rotate(.45deg); }
}
@keyframes usher-offer {
  0%,100% { transform:rotate(0); }
  38% { transform:rotate(2.4deg) translateY(-.8%); }
}
@keyframes usher-curtsy {
  0%,100% { transform:translateY(0); }
  47% { transform:translateY(1.7%) rotate(-1.8deg) scaleY(.984); }
}
@keyframes usher-cross-threshold { 0% {z-index:2} 55%,100% {z-index:-1} }
@keyframes usher-invitation { 0%,100% {transform:rotate(-7deg)} 45% {transform:translateY(-.05em) rotate(-8deg) scale(1.025)} }
@keyframes usher-heart { 46% {transform:translateY(-.065em) rotate(7deg) scale(1.08)} }

/* The shadow stays on the parquet as the smiling figure leaves the ground. */
@keyframes usher-joy-hop {
  0% { transform:scale(1); animation-timing-function:ease-in; }
  14% { transform:scale(1.065,.91); animation-timing-function:cubic-bezier(.16,.71,.35,1); }
  49% { transform:translateY(-22%) rotate(-5deg) scale(.97,1.035); animation-timing-function:cubic-bezier(.58,0,.86,.44); }
  78% { transform:translateY(0) rotate(1deg) scale(1.075,.93); animation-timing-function:ease-out; }
  100% { transform:none; }
}
@keyframes usher-joy-shadow {
  0%,100% { transform:scale(1); opacity:1; }
  49% { transform:scale(.67,.78); opacity:.44; }
  78% { transform:scale(1.1); opacity:1; }
}
@keyframes usher-push {
  0% { transform:rotate(0); }
  62% { transform:rotate(2.2deg); }
  100% { transform:rotate(0); }
}
