/* ============================================
   CHESSER — Animations & Transitions
   ============================================ */

/* --- Screen Transitions --- */
.screen-enter {
  animation: screenFadeIn 0.5s ease forwards;
}

.screen-exit {
  animation: screenFadeOut 0.4s ease forwards;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes screenFadeOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

/* --- Logo Animation --- */
@keyframes logoGlow {
  0%, 100% {
    text-shadow:
      0 0 20px rgba(212, 168, 67, 0.3),
      0 0 40px rgba(212, 168, 67, 0.15);
    filter: brightness(1);
  }
  50% {
    text-shadow:
      0 0 30px rgba(212, 168, 67, 0.5),
      0 0 60px rgba(212, 168, 67, 0.25),
      0 0 80px rgba(212, 168, 67, 0.1);
    filter: brightness(1.05);
  }
}

.logo-glow {
  animation: logoGlow 3s ease-in-out infinite;
}

/* --- Floating chess pieces background --- */
@keyframes floatPiece1 {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(40px, -60px) rotate(15deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatPiece2 {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-30px, 80px) rotate(-10deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatPiece3 {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(50px, -80px) rotate(20deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatPiece4 {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-40px, -100px) rotate(-15deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.floating-piece {
  position: absolute;
  width: 75px;
  height: 75px;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  opacity: 0.035;
}

.floating-piece:nth-child(1) { animation: floatPiece1 22s ease-in-out infinite; top: 12%; left: 10%; }
.floating-piece:nth-child(2) { animation: floatPiece2 28s ease-in-out infinite 2s; top: 22%; right: 12%; }
.floating-piece:nth-child(3) { animation: floatPiece3 24s ease-in-out infinite 4s; top: 48%; left: 6%; }
.floating-piece:nth-child(4) { animation: floatPiece4 32s ease-in-out infinite 6s; top: 62%; right: 8%; }
.floating-piece:nth-child(5) { animation: floatPiece1 26s ease-in-out infinite 8s; bottom: 18%; left: 24%; }
.floating-piece:nth-child(6) { animation: floatPiece2 30s ease-in-out infinite 3s; top: 82%; right: 28%; }
.floating-piece:nth-child(7) { animation: floatPiece3 25s ease-in-out infinite 7s; top: 38%; left: 38%; }
.floating-piece:nth-child(8) { animation: floatPiece4 23s ease-in-out infinite 1s; bottom: 8%; right: 6%; }

/* --- Card Entrance --- */
@keyframes cardSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-animate {
  animation: cardSlideUp 0.5s ease forwards;
}
.card-animate:nth-child(1) { animation-delay: 0.05s; }
.card-animate:nth-child(2) { animation-delay: 0.1s; }
.card-animate:nth-child(3) { animation-delay: 0.15s; }
.card-animate:nth-child(4) { animation-delay: 0.2s; }
.card-animate:nth-child(5) { animation-delay: 0.25s; }
.card-animate:nth-child(6) { animation-delay: 0.3s; }

/* --- Pulse animation --- */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

/* --- Pulse ring for current trail node --- */
@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-accent-gold);
  animation: pulseRing 2s ease-out infinite;
}

/* --- Typing animation for Chesser assistant --- */
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-accent-gold);
  animation: typingDot 1.4s ease-in-out infinite;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

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

.shake {
  animation: shake 0.5s ease;
}

/* --- Glow pulse --- */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(212, 168, 67, 0.2);
  }
  50% {
    box-shadow: 0 0 24px rgba(212, 168, 67, 0.4), 0 0 48px rgba(212, 168, 67, 0.1);
  }
}

.glow-pulse {
  animation: glowPulse 2.5s ease-in-out infinite;
}

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

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

/* --- Slide In from Right --- */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight 0.4s ease forwards;
}

/* --- Scale In --- */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scale-in {
  animation: scaleIn 0.3s ease forwards;
}

/* --- Trophy bounce --- */
@keyframes trophyBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-15px) rotate(-5deg); }
  40% { transform: translateY(-8px) rotate(3deg); }
  60% { transform: translateY(-4px) rotate(-2deg); }
  80% { transform: translateY(-1px) rotate(1deg); }
}

.trophy-bounce {
  animation: trophyBounce 1s ease forwards;
}

/* --- Confetti (simple CSS version) --- */
@keyframes confettiFall {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 9999;
  pointer-events: none;
  animation: confettiFall 3s ease-out forwards;
}

/* --- Progress bar fill --- */
@keyframes progressFill {
  from { width: 0; }
}

.progress-bar-fill {
  animation: progressFill 0.8s ease forwards;
}

/* --- Subtle background pattern for menu --- */
.bg-chess-pattern {
  background-image:
    linear-gradient(45deg, rgba(212, 168, 67, 0.02) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(212, 168, 67, 0.02) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(212, 168, 67, 0.02) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(212, 168, 67, 0.02) 75%);
  background-size: 60px 60px;
  background-position: 0 0, 0 30px, 30px -30px, -30px 0px;
}

/* --- Notification badge bounce --- */
@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.badge-bounce {
  animation: badgeBounce 0.5s ease;
}

/* --- Stagger children --- */
.stagger-children > * {
  opacity: 0;
  animation: cardSlideUp 0.4s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(9) { animation-delay: 0.45s; }
.stagger-children > *:nth-child(10) { animation-delay: 0.5s; }
