/**
 * SumDay Celebration Animations
 */

/* Celebration Animation */
@keyframes celebrate {
  0% {
    transform: scale(1) rotate(0deg);
  }
  15% {
    transform: scale(1.1) rotate(-2deg);
  }
  30% {
    transform: scale(1.15) rotate(2deg);
  }
  45% {
    transform: scale(1.1) rotate(-1deg);
  }
  60% {
    transform: scale(1.05) rotate(1deg);
  }
  75% {
    transform: scale(1.02) rotate(0deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.equation-row.celebrate {
  animation: celebrate 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.5), 0 0 60px rgba(16, 185, 129, 0.3);
}

/* Checkmark Animation */
@keyframes checkmark {
  0% {
    transform: scale(0) rotate(-45deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(-45deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(-45deg);
    opacity: 1;
  }
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Timer container pulse removed for de-emphasis */

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: fadeIn 0.3s ease-out;
}

/* Shake Animation (for errors) */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

.message.error {
  animation: shake 0.5s ease-in-out, fadeIn 0.3s ease-out;
}

/* Slide Up Animation */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.equation-row {
  animation: slideUp 0.3s ease-out;
}

/* Modal Fade In */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.modal {
  animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
  animation: modalSlideIn 0.3s ease-out;
}

/* Button Hover Effects */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Focus Animation */
@keyframes focusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(21, 101, 192, 0.4);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(21, 101, 192, 0);
  }
}

.operator-input:focus {
  animation: focusPulse 1s ease-out;
}

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

/* Success Glow */
@keyframes successGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(46, 125, 50, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(46, 125, 50, 0.8);
  }
}

.equation-row.completed {
  animation: successGlow 2s ease-in-out;
}

/* Loading Dots */
@keyframes loadingDots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}

/* Bounce Animation */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

/* Sparkle Effect */
@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Gradient Animation for Header */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.header {
  background-size: 200% 200%;
  animation: gradientShift 10s ease infinite;
}

/* Stagger Animation for Equation Rows */
.equation-row:nth-child(1) {
  animation-delay: 0s;
}

.equation-row:nth-child(2) {
  animation-delay: 0.05s;
}

.equation-row:nth-child(3) {
  animation-delay: 0.1s;
}

.equation-row:nth-child(4) {
  animation-delay: 0.15s;
}

.equation-row:nth-child(5) {
  animation-delay: 0.2s;
}

.equation-row:nth-child(6) {
  animation-delay: 0.25s;
}

.equation-row:nth-child(7) {
  animation-delay: 0.3s;
}

.equation-row:nth-child(8) {
  animation-delay: 0.35s;
}

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

  .timer-container {
    animation: none;
  }

  .header {
    animation: none;
  }
}
