/* Home hero: the headline eases in, then one letter at a time turns into a balloon. */

/* Set from the <head> so the headline never flashes before it animates.
   The delayed animation is a safety net in case hero.js doesn't load. */
.hero-anim .intro h1:not(.hero-ready) { opacity: 0; animation: hero-failsafe 0s 1.6s forwards; }
@keyframes hero-failsafe { to { opacity: 1; } }

.hero-line { display: block; }
.hero-word { display: inline-block; white-space: nowrap; }
.hero-char {
  position: relative;
  display: inline-block;
  transition: transform .14s cubic-bezier(.3, 1.4, .5, 1);
}

/* Entrance: each letter slides up from behind a hard line just under the text,
   one after another. The line sits below the descenders (g, p, y) so their
   tails are never cut. The clip comes off once every letter is in (hero-in),
   so it never cuts the balloons. */
.hero-ready:not(.hero-in) .hero-word { clip-path: inset(-.5em -.3em -.14em -.3em); }
.hero-ready .hero-char {
  animation: hero-rise .7s cubic-bezier(.16, 1, .3, 1) backwards;
  animation-delay: calc(var(--i) * 45ms + var(--line) * 320ms + 80ms);
}
@keyframes hero-rise {
  from { transform: translateY(1.2em); }
}

/* Swap: the plain letter disappears, its neighbours make room. */
.hero-char.is-fun { z-index: 2; color: transparent; transition: none; }
.hero-char.push-left { transform: translateX(calc(var(--push) * -1)); }
.hero-char.push-right { transform: translateX(var(--push)); }
.hero-line { --push: .1em; }

.hero-fun {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  max-width: none;
  height: auto;
  margin: calc(var(--size) / -2 + var(--drop)) 0 0 calc(var(--size) / -2);
  transform: rotate(var(--tilt));
  transform-origin: 50% 50%;
  pointer-events: none;
  user-select: none;
  animation: hero-pop .3s cubic-bezier(.2, 1, .3, 1) both;
}
.hero-fun.balloon { --size: 2.1em; --drop: 0em; }
@keyframes hero-pop {
  0% { transform: rotate(calc(var(--tilt) * 2.2)) scale(.22); }
  55% { transform: rotate(calc(var(--tilt) * .7)) scale(1.07); }
  100% { transform: rotate(var(--tilt)) scale(1); }
}
