/* The original text keeps its inline footprint while each glyph becomes a
   keyboard-accessible control. */
.edible-letter {
  appearance: none;
  display: inline-block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  vertical-align: baseline;
  cursor: pointer;
  touch-action: manipulation;
  transition: color .15s ease, background-color .15s ease;
}

.edible-letter:hover {
  color: #b75c78;
  background: #f9dbe1aa;
}

.edible-letter:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid #a85873;
  outline-offset: 2px;
}

.edible-letter.is-eaten {
  visibility: hidden;
}

/* Fixed particles can leave the browser shell, which matters when the title
   is above the shell. They never intercept the app's pointer input. */
.words-overlay {
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

.word-particle {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  width: 1.3em;
  height: 1.3em;
  color: #a75070;
  font: 600 1.05rem/1 "Helvetica Neue", "Hiragino Kaku Gothic ProN", Arial, sans-serif;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: left, top, transform, opacity;
}

.word-chew {
  animation: word-chew-flight .46s cubic-bezier(.22, .84, .38, 1) both;
}

.word-burp-word {
  color: #8d4664;
  font-size: 1.15rem;
  animation: word-burp-flight .76s cubic-bezier(.2, .8, .25, 1) both;
}

.word-star {
  color: #d19b40;
  font-size: .9rem;
  animation: word-star-flight .76s cubic-bezier(.18, .82, .25, 1) both;
}

@keyframes word-chew-flight {
  0% {
    left: var(--words-from-x);
    top: var(--words-from-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.02) rotate(-4deg);
  }
  72% {
    opacity: 1;
  }
  100% {
    left: var(--words-to-x);
    top: var(--words-to-y);
    opacity: .18;
    transform: translate(-50%, -50%) scale(.48) rotate(16deg);
  }
}

@keyframes word-burp-flight {
  0% {
    left: var(--words-from-x);
    top: var(--words-from-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(.5) rotate(-10deg);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12) rotate(4deg);
  }
  100% {
    left: var(--words-to-x);
    top: var(--words-to-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(.84) rotate(24deg);
  }
}

@keyframes word-star-flight {
  0% {
    left: var(--words-from-x);
    top: var(--words-from-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(.3) rotate(0deg);
  }
  20% { opacity: 1; }
  100% {
    left: var(--words-to-x);
    top: var(--words-to-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(.75) rotate(80deg);
  }
}

.words-belly-layer {
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

.word-belly-glyph {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.1em;
  height: 1.1em;
  border-radius: 48% 52% 55% 45%;
  color: #fffaf4;
  background: #b96582d9;
  box-shadow: 0 2px 0 #7f405c55;
  font: 600 clamp(8px, 2.6vw, 14px)/1 "Helvetica Neue", "Hiragino Kaku Gothic ProN", Arial, sans-serif;
  transform: translate(-50%, -50%);
  animation: word-belly-squish 1.25s ease-in-out .05s infinite;
}

@keyframes word-belly-squish {
  0%, 100% { transform: translate(-50%, -50%) scale(1, .94) rotate(-2deg); }
  50% { transform: translate(-50%, -50%) scale(1.08, .88) rotate(3deg); }
}

.word-beat {
  animation-duration: .42s;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
  animation-delay: var(--word-beat-delay, 0ms);
}

.word-beat[data-word-beat-phase="0"] { animation-name: word-letter-beat-a; }
.word-beat[data-word-beat-phase="1"] { animation-name: word-letter-beat-b; }

.words-overlay[data-reduced-motion="true"] .word-particle {
  animation-duration: .08s;
}

.words-belly-layer[data-reduced-motion="true"] .word-belly-glyph {
  animation: none;
}

@keyframes word-letter-beat-a {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-3px) rotate(-3deg); }
  70% { transform: translateY(1px) rotate(2deg); }
}

@keyframes word-letter-beat-b {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-3px) rotate(3deg); }
  70% { transform: translateY(1px) rotate(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .edible-letter { transition: none; }
  .edible-letter:hover { background: transparent; }
  .word-particle {
    animation: none;
    left: var(--words-to-x);
    top: var(--words-to-y);
  }
  .word-belly-glyph, .word-beat {
    animation: none;
  }
}
