/* =========================================
   spin2choose — Animations
   ========================================= */

/* ---------- Background Float ---------- */
@keyframes bg-float {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-2%, 1%) rotate(1deg); }
  100% { transform: translate(1%, -1%) rotate(-0.5deg); }
}

/* ---------- Logo Pulse ---------- */
@keyframes logo-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(167,139,250,0.3)); }
  50% { filter: drop-shadow(0 0 12px rgba(167,139,250,0.6)); }
}

/* ---------- Hint Pulse ---------- */
@keyframes hint-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ---------- Modal In ---------- */
@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---------- Fade In ---------- */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Winner Pop ---------- */
@keyframes winner-pop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Button Shimmer ---------- */
@keyframes btn-shimmer {
  0% { transform: translateX(-100%); }
  50%, 100% { transform: translateX(100%); }
}

/* ---------- Confetti Fall ---------- */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ---------- Slide In Right ---------- */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---------- Slide In Up ---------- */
@keyframes slide-in-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- Glow Pulse ---------- */
@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(167,139,250,0.15);
  }
  50% {
    box-shadow: 0 0 40px rgba(167,139,250,0.3), 0 0 80px rgba(167,139,250,0.1);
  }
}

/* ---------- Template Pop-in ---------- */
@keyframes wheel-pop-in {
  0%   { transform: scale(0.05); }
  65%  { transform: scale(1.1);  }
  82%  { transform: scale(0.96); }
  100% { transform: scale(1);    }
}

#wheel-canvas.wheel-pop-in {
  animation: wheel-pop-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ---------- Wheel Loader ---------- */
/* Preserve the translate(-50%, -50%) centering that lives on .wheel-loader__spinner.
   Without it the keyframe would replace transform and the element would drift from
   the centered position to the unset origin as it rotates. */
@keyframes wheel-loader-spin {
  from { transform: translate(-50%, -50%) rotate(0deg);   }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes wheel-loader-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Featured Card Rotation ---------- */
@keyframes feat-card-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes feat-card-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

.feat-card--in {
  animation: feat-card-in 0.35s ease forwards;
}
.feat-card--out {
  animation: feat-card-out 0.35s ease forwards;
  pointer-events: none;
}

/* ---------- Sidebar Slide ---------- */
.sidebar--open {
  animation: slide-in-right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Result Item Entry ---------- */
.result-item {
  animation: slide-in-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Toast ---------- */
@keyframes toast-in {
  from {
    transform: translateY(100%) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ---------- Confetti Particle ---------- */
.confetti-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 9999;
  pointer-events: none;
  animation: confetti-fall 3s ease-in forwards;
}

/* ---------- Micro Interactions ---------- */
.btn {
  transition: all var(--transition-fast);
}

.sidebar__tab,
.customize-tabs__btn,
.option-chip,
.theme-swatch {
  transition: all var(--transition-fast);
}

/* Hover lift for cards */
.entry-item,
.result-item {
  transition: all var(--transition-fast);
}
.entry-item:hover {
  transform: translateX(2px);
}

/* Focus ring animation */
@keyframes focus-ring {
  0% { box-shadow: 0 0 0 0 rgba(167,139,250,0.4); }
  100% { box-shadow: 0 0 0 4px rgba(167,139,250,0); }
}

/* While any modal-overlay is open, pause the continuous infinite animations
   that sit behind it. The modal's `backdrop-filter: blur(...)` re-rasterizes
   the entire viewport every time anything underneath repaints, so a 25s
   bg-float gradient and a 3s drop-shadow logo pulse — both cheap on their
   own — together drop frame-rate by ~50% in Chrome while a modal is up. */
body.modal-open::before,
body.modal-open .header__logo,
body.modal-open .btn--glow::after {
  animation-play-state: paused;
}

/* While confetti is flying, drop the modal's backdrop-filter blur. The
   confetti canvas sits above the modal at z-index 10000, but Chrome's
   compositor still re-rasterizes the blurred region as the canvas
   invalidates above it — measured cost: ~30fps median, ~37 dropped
   frames over 2.5s. The body.confetti-active class is set for the full
   shower (spawn + particle fall) by main.js. */
body.confetti-active .modal-overlay {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
