/* Celebratory motifs sit behind the active statistic, without moving its layout. */
.stat-flourish {
  display: none;
  pointer-events: none;
}

.cinematic-motion .stat-flourish {
  --stat-spread: 1;
  --stat-rise: 1;
  display: block;
  position: absolute;
  top: 76px;
  left: 50%;
  width: 1px;
  height: 1px;
  z-index: 0;
  pointer-events: none;
}

.stat-token,
.stat-confetti {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  opacity: 0;
  transform-origin: center;
  color: var(--stat-colour);
}

.stat-token svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-token-fill {
  fill: currentColor;
  stroke: none;
  opacity: 0.12;
}

.stat-token--money {
  width: 84px;
  height: 52px;
}
.stat-token--people {
  width: 66px;
  height: 66px;
}
.stat-token-ring {
  opacity: 0.8;
}

.stat-confetti {
  width: 7px;
  height: 12px;
  background: currentColor;
  border-radius: 1px;
}

.stat-confetti--dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.stat-confetti--ribbon {
  width: 3px;
  height: 19px;
  border-radius: 2px;
}

.cinematic-motion .stat-card.is-active > .stat-flourish .stat-token {
  will-change: transform, opacity;
  animation: stat-motif-celebrate var(--stat-duration)
    cubic-bezier(0.16, 0.7, 0.22, 1) var(--stat-delay) infinite both;
}

.cinematic-motion .stat-card.is-active > .stat-flourish .stat-confetti {
  will-change: transform, opacity;
  animation: stat-confetti-celebrate var(--stat-duration)
    cubic-bezier(0.16, 0.7, 0.22, 1) var(--stat-delay) infinite both;
}

@keyframes stat-motif-celebrate {
  0% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread) * 0.28),
        calc(-50% + 22px)
      )
      rotate(0deg) scale(0.62);
  }
  9% {
    opacity: 0.86;
  }
  25% {
    opacity: 0.86;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread)),
        calc(-50% + var(--stat-y) * var(--stat-rise))
      )
      rotate(var(--stat-turn)) scale(1);
  }
  66% {
    opacity: 0.74;
  }
  92%,
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread) * 1.025),
        calc(-50% + var(--stat-y) * var(--stat-rise) + 32px)
      )
      rotate(calc(var(--stat-turn) + 8deg)) scale(0.94);
  }
}

@keyframes stat-confetti-celebrate {
  0% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread) * 0.16),
        12px
      )
      rotate(0deg) scale(0.55);
  }
  5% {
    opacity: 0.98;
  }
  22% {
    opacity: 0.98;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread)),
        calc(var(--stat-y) * var(--stat-rise) - 24px)
      )
      rotate(calc(var(--stat-turn) * 0.55)) scale(1);
  }
  64% {
    opacity: 0.85;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread) * 1.06),
        calc(var(--stat-y) * var(--stat-rise) + 31px)
      )
      rotate(var(--stat-turn)) scale(0.94);
  }
  94%,
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--stat-x) * var(--stat-spread) * 1.12),
        calc(var(--stat-y) * var(--stat-rise) + 91px)
      )
      rotate(calc(var(--stat-turn) * 1.4)) scale(0.76);
  }
}

@media (max-width: 1100px) and (min-width: 701px) {
  .cinematic-motion .stat-flourish {
    --stat-spread: 0.83;
  }
}

@media (max-width: 700px) {
  .cinematic-motion .stat-flourish {
    --stat-spread: 0.64;
    --stat-rise: 0.78;
    top: 45px;
  }
  .stat-token--money {
    width: 59px;
    height: 37px;
  }
  .stat-token--people {
    width: 47px;
    height: 47px;
  }
  .stat-confetti {
    width: 5px;
    height: 9px;
  }
  .stat-confetti--dot {
    width: 5px;
    height: 5px;
  }
  .stat-confetti--ribbon {
    width: 2px;
    height: 15px;
  }
}

@media (max-width: 480px) {
  .cinematic-motion .stat-flourish {
    --stat-spread: 0.43;
  }
}

@media (max-width: 380px) {
  .cinematic-motion .stat-flourish {
    --stat-spread: 0.36;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat-flourish,
  .cinematic-motion .stat-flourish {
    display: none !important;
  }
  .stat-token,
  .stat-confetti {
    animation: none !important;
  }
}
