/* Chronicles — Popcorn & Candy welcome celebration */

.chr-welcome-celebration {
  position: absolute;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.92s ease-out;
}

.chr-welcome-celebration--out {
  opacity: 0;
}

.chr-theater-popcorn {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.chr-theater-popcorn__piece {
  position: absolute;
  font-size: clamp(2.125rem, 5.5vw, 3.375rem);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.chr-theater-popcorn--welcome {
  --chr-celebration-piece-size: 4.625rem;
  --chr-celebration-bar-w: 1.35rem;
  --chr-celebration-bar-h: 2.25rem;
}

.chr-theater-popcorn--welcome .chr-theater-popcorn__piece {
  font-size: var(--chr-celebration-piece-size);
}

.chr-theater-popcorn__piece--toss {
  bottom: var(--chr-pop-origin, 9%);
  left: var(--chr-pop-left, 50%);
  animation: chr-theater-popcorn-toss var(--chr-pop-dur, 1.8s) cubic-bezier(0.33, 0.12, 0.55, 1)
    var(--chr-pop-delay, 0s) forwards;
}

.chr-theater-popcorn__piece--fall {
  top: var(--chr-pop-top, -6%);
  left: var(--chr-pop-left, 50%);
  animation: chr-theater-popcorn-fall var(--chr-pop-dur, 1.5s) ease-in var(--chr-pop-delay, 0s) forwards;
}

.chr-theater-popcorn__piece--spill {
  bottom: var(--chr-pop-origin, 7%);
  left: var(--chr-pop-left, 50%);
  animation: chr-theater-popcorn-spill var(--chr-pop-dur, 1.25s) ease-out var(--chr-pop-delay, 0s) forwards;
}

@keyframes chr-theater-popcorn-toss {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.55) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  42% {
    transform: translate3d(var(--chr-pop-drift-mid, 0px), calc(-1 * var(--chr-pop-rise, 32vh)), 0)
      scale(1.05) rotate(var(--chr-pop-rot-mid, 95deg));
  }
  72% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--chr-pop-drift, 0px), var(--chr-pop-drop, 14vh), 0) scale(0.8)
      rotate(var(--chr-pop-rot-end, 240deg));
  }
}

@keyframes chr-theater-popcorn-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.65) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--chr-pop-drift, 0px), 105vh, 0) scale(1) rotate(200deg);
  }
}

@keyframes chr-theater-popcorn-spill {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.5) rotate(-20deg);
  }
  8% {
    opacity: 1;
  }
  35% {
    transform: translate3d(var(--chr-pop-drift-mid, 0px), calc(-1 * var(--chr-pop-rise, 12vh)), 0)
      scale(0.95) rotate(40deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--chr-pop-drift, 0px), var(--chr-pop-drop, 8vh), 0) scale(0.75)
      rotate(160deg);
  }
}

.chr-theater-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.chr-theater-confetti__piece {
  position: absolute;
  top: var(--chr-conf-top, -8%);
  left: var(--chr-conf-left, 50%);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  animation: chr-theater-confetti-fall var(--chr-conf-dur, 2s) ease-in var(--chr-conf-delay, 0s) forwards;
}

.chr-theater-confetti__piece--spark {
  font-size: clamp(1.875rem, 5vw, 3.125rem);
  text-shadow: 0 0 6px rgba(255, 240, 180, 0.55);
}

.chr-theater-confetti--welcome {
  --chr-celebration-piece-size: 4.625rem;
  --chr-celebration-bar-w: 1.35rem;
  --chr-celebration-bar-h: 2.25rem;
}

.chr-theater-confetti--welcome .chr-theater-confetti__piece--spark {
  font-size: var(--chr-celebration-piece-size);
}

.chr-theater-confetti--welcome .chr-theater-confetti__piece--rect {
  width: var(--chr-celebration-bar-w);
  height: var(--chr-celebration-bar-h);
  border-radius: 2px;
}

.chr-theater-confetti__piece--rect {
  display: block;
  width: 1.05rem;
  height: 1.8rem;
  border-radius: 1px;
  background: hsl(var(--chr-conf-hue, 42) 85% 58%);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
}

@keyframes chr-theater-confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--chr-conf-drift, 0px), 110vh, 0) rotate(var(--chr-conf-spin, 360deg));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chr-welcome-celebration,
  .chr-theater-popcorn__piece,
  .chr-theater-confetti__piece {
    animation: none !important;
    transition: none !important;
  }
}
