/* Motion (CI chapter 10). Everything here only runs when motion.js has set html.motion,
   which it does only if the visitor has not asked for reduced motion. Elements play
   once, when they are well in view (motion.js adds .is-in); no loops, no parallax.

   loud   (max. two per page): headline slam, comic pop
   medium: ring turns in, numbers count up (JS), photo opens in a circle, marker
   quiet:  lines draw, half circle drives in, logo half circle turns, links, arrows */

@keyframes slam { from { opacity: 0; transform: translateY(60px) scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 70% { opacity: 1; transform: scale(1.08) rotate(1deg); } 100% { opacity: 1; transform: none; } }
@keyframes ring { from { opacity: 0; transform: rotate(-40deg) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes iris { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(75% at 50% 50%); } }
@keyframes marker { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes half { from { transform: translateY(100%); } to { transform: none; } }
@keyframes spin { from { transform: rotate(-360deg); } to { transform: none; } }
@keyframes switch-spin { from { transform: rotate(0); } to { transform: rotate(720deg); } }
@keyframes jump { 0%, 100% { transform: translateY(-50%); } 40% { transform: translateY(-130%); } 70% { transform: translateY(-40%); } }
@keyframes fly { 0% { opacity: 1; transform: translate(0, 0) scale(.6) rotate(0); } 100% { opacity: 0; transform: translate(var(--fx), var(--fy)) scale(1) rotate(160deg); } }
@keyframes click-ring { from { opacity: 1; transform: translate(-50%, -50%) scale(.3); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.3); } }

/* Hidden until in view */
html.motion [data-reveal]:not(.is-in) { opacity: 0; }
html.motion [data-reveal="line"]:not(.is-in)::before,
html.motion [data-reveal="line"]:not(.is-in)::after { transform: scaleX(0); }
html.motion [data-reveal="line"]:not(.is-in) { opacity: 1; }

html.motion [data-reveal="slam"].is-in { animation: slam .55s var(--ease-slam) both; }
html.motion [data-reveal="pop"].is-in { animation: pop .6s var(--ease-pop) both; }
html.motion [data-reveal="ring"].is-in { animation: ring 1.2s var(--ease-slam) both; }
html.motion [data-reveal="iris"].is-in { animation: iris 1.1s var(--ease-out) both; }
html.motion [data-reveal="marker"].is-in { animation: marker .7s var(--ease-wipe) both; }
html.motion [data-reveal="half"].is-in { animation: half .9s var(--ease-out) both; }
html.motion [data-reveal="line"].is-in::before,
html.motion [data-reveal="line"].is-in::after { animation: line .9s var(--ease-out) both; }

/* The logo half circle turns once on hover (quiet, 1 s) ... */
html.motion .site-header__logo:hover .logo__half { animation: spin 1s var(--ease-out); }
.logo__half { transform-box: fill-box; transform-origin: 0 50%; }
/* ... and twice after a language switch (1.7 s), see motion.js. */
html.motion .site-header__logo.is-switching .logo__half { animation: switch-spin 1.7s var(--ease-out); }

/* Andy jumps at the end of the page; comic stars fly off. */
html.motion .progress__andy.is-end { animation: jump .7s var(--ease-pop); }
.fly-star {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  pointer-events: none;
  animation: fly .9s var(--ease-out) forwards;
}

/* Click circle: the logo rings draw where the visitor clicked. */
.click-rings {
  position: fixed;
  z-index: 200;
  width: 64px;
  height: 64px;
  pointer-events: none;
  animation: click-ring .6s var(--ease-out) forwards;
}
