/* ===== Shadow Protocol — Animations ===== */

/* ---------- Screen Transitions ---------- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.screen-enter {
  animation: fadeSlideIn var(--duration-normal) var(--ease-out) forwards;
}

.screen-exit {
  animation: fadeSlideOut var(--duration-fast) var(--ease-out) forwards;
}

/* ---------- Card Flip (Role Reveal) ---------- */
.card-flip-container {
  perspective: 1000px;
  width: 100%;
}

.card-flip {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.6s var(--ease-in-out);
  transform-style: preserve-3d;
}

.card-flip.flipped {
  transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}

.card-flip-front {
  background: var(--bg-card);
  border: 2px solid var(--border-medium);
}

.card-flip-back {
  transform: rotateY(180deg);
}

.card-flip-back.role-civilian {
  background: linear-gradient(135deg, #1a3a25, #0d2818);
  border: 2px solid var(--role-civilian);
  box-shadow: 0 0 40px rgba(46, 204, 113, 0.15);
}

.card-flip-back.role-spy {
  background: linear-gradient(135deg, #3a1a1a, #280d0d);
  border: 2px solid var(--role-spy);
  box-shadow: 0 0 40px rgba(231, 76, 60, 0.15);
}

.card-flip-back.role-imposter {
  background: linear-gradient(135deg, #3a2a1a, #28190d);
  border: 2px solid var(--role-imposter);
  box-shadow: 0 0 40px rgba(230, 126, 34, 0.15);
}

/* ---------- Pulse Glow ---------- */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(212, 133, 42, 0.15);
  }
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ---------- Float ---------- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.float {
  animation: float 3s ease-in-out infinite;
}

/* ---------- Spy Eye Blink ---------- */
@keyframes blink {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0; }
}

.blink {
  animation: blink 4s ease-in-out infinite;
}

/* ---------- Shake (wrong action) ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

/* ---------- Scale In (modal, result card) ---------- */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-spring) forwards;
}

/* ---------- Stagger children ---------- */
.stagger-children > * {
  opacity: 0;
  animation: fadeSlideIn var(--duration-normal) var(--ease-out) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 360ms; }
.stagger-children > *:nth-child(8) { animation-delay: 420ms; }
.stagger-children > *:nth-child(9) { animation-delay: 480ms; }
.stagger-children > *:nth-child(10) { animation-delay: 540ms; }
.stagger-children > *:nth-child(11) { animation-delay: 600ms; }
.stagger-children > *:nth-child(12) { animation-delay: 660ms; }

/* ---------- Spin ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

/* ---------- Confetti-like result burst ---------- */
@keyframes burstIn {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-10deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.1) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.burst-in {
  animation: burstIn 0.6s var(--ease-spring) forwards;
}

/* ---------- Slide up (bottom sheets) ---------- */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp var(--duration-normal) var(--ease-out) forwards;
}

/* ---------- Number count-up effect ---------- */
@keyframes countPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.count-pop {
  animation: countPop 0.3s var(--ease-spring);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
