/* Zakzak's run to the next door (js/walk.js), and smaller doors in the house */

/* Smaller doors, so the room breathes (touch.js still gives a near miss to the nearest door) */
.doors .door { width: clamp(68px, 18vmin, 104px); }
@media (orientation: landscape) {
  .doors .door { width: 76px; height: 76px; }
}

/* Hopping to the door: he shrinks around his feet (the transform's 0 is his middle), in front of the doors */
.zakzak.is-walking { transform-origin: 0 100%; z-index: 3; }

/* The door opens on its hinge and shows the light inside */
.door-hole { fill: #fff6cf; display: none; }
.door.is-opening .door-hole { display: inline; filter: drop-shadow(0 0 4px #fff); }
.door :is(.door-leaf, .door-plank, .door-inner, .door-window, .door-window-bar, .door-knob) {
  transform-box: view-box;
  transform-origin: 12px 50%;
  transition: transform .3s ease-in;
}
.door.is-opening :is(.door-leaf, .door-plank, .door-inner, .door-window, .door-window-bar, .door-knob) { transform: scaleX(.1); }
.door.is-opening svg, .door.is-target svg { animation: none; }
.door.is-opening::after, .door.is-target::after { display: none; }   /* the pointing hand */

/* Between two lessons (is-between) and during the run the house never shows: no doors, no house buttons */
.room:is(.is-between, .is-running) :is(.doors, .books-btn, .kid-btn, .parents-btn, .music-btn) { visibility: hidden; }

/* The run: he runs on the spot, the place slides past (walk.js moves the scene's parts) */
.room.is-running .bubble { visibility: hidden; }
.zakzak.is-running svg { animation: walk-run .26s ease-in-out infinite; }
.zakzak.is-running .zk-arm { animation: walk-arm .26s ease-in-out infinite alternate; }
@keyframes walk-run {
  0%, 100% { transform: translateY(0) rotate(-7deg); }
  50%      { transform: translateY(-9%) rotate(-4deg); }
}
@keyframes walk-arm {
  from { transform: rotate(calc(var(--sw) * -4)); }
  to   { transform: rotate(calc(var(--sw) * 4)); }
}

/* Speed lines: white streaks rushing by (to the right: he runs left, forward in Arabic) */
.walk-lines { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.walk-lines::before, .walk-lines::after {
  content: "";
  position: absolute;
  left: -35%;
  width: 35%;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .85));
  box-shadow: 25vw 13vh 0 -1px rgba(255, 255, 255, .6), -15vw 27vh 0 rgba(255, 255, 255, .5);
  animation: walk-line .42s linear infinite;
}
.walk-lines::before { top: 26%; }
.walk-lines::after { top: 47%; animation-delay: .18s; }
@keyframes walk-line { to { translate: 420% 0; } }

@media (prefers-reduced-motion: reduce) {
  .walk-lines { display: none; }
  .zakzak.is-running svg, .zakzak.is-running .zk-arm { animation: none; }
  .door :is(.door-leaf, .door-plank, .door-inner, .door-window, .door-window-bar, .door-knob) { transition: none; }
}
