/* ==========================================================================
   DoYouPrompt Design System - Animations & Micro-interactions
   ========================================================================== */

/* ==================================================================
   KEYFRAME DEFINITIONS
   ================================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-4px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(4px);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-12px);
  }
  60% {
    transform: translateY(-6px);
  }
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-3deg);
  }
  75% {
    transform: rotate(3deg);
  }
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes expandHeight {
  from {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
  }
  to {
    max-height: 500px;
    opacity: 1;
    overflow: visible;
  }
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Typing indicator dots */
@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Progress indeterminate */
@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* Glow animation for active states */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 4px rgba(79, 70, 229, 0.2);
  }
  50% {
    box-shadow: 0 0 16px rgba(79, 70, 229, 0.4);
  }
}

/* ==================================================================
   ANIMATION UTILITY CLASSES
   ================================================================== */

.animate-fade-in {
  animation: fadeIn var(--transition-normal) ease both;
}

.animate-fade-out {
  animation: fadeOut var(--transition-normal) ease both;
}

.animate-slide-up {
  animation: slideUp var(--transition-slow) ease both;
}

.animate-slide-down {
  animation: slideDown var(--transition-slow) ease both;
}

.animate-slide-in-left {
  animation: slideInLeft var(--transition-slow) ease both;
}

.animate-slide-in-right {
  animation: slideInRight var(--transition-slow) ease both;
}

.animate-scale-in {
  animation: scaleIn var(--transition-normal) ease both;
}

.animate-scale-out {
  animation: scaleOut var(--transition-normal) ease both;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

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

.animate-bounce {
  animation: bounce 1s ease;
}

.animate-wiggle {
  animation: wiggle 0.3s ease;
}

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

/* ==================================================================
   ANIMATION DURATION MODIFIERS
   ================================================================== */

.animation-fast {
  animation-duration: 150ms;
}

.animation-normal {
  animation-duration: 300ms;
}

.animation-slow {
  animation-duration: 500ms;
}

.animation-slower {
  animation-duration: 700ms;
}

/* ==================================================================
   ANIMATION DELAY MODIFIERS
   ================================================================== */

.animation-delay-100 { animation-delay: 100ms; }
.animation-delay-200 { animation-delay: 200ms; }
.animation-delay-300 { animation-delay: 300ms; }
.animation-delay-400 { animation-delay: 400ms; }
.animation-delay-500 { animation-delay: 500ms; }
.animation-delay-700 { animation-delay: 700ms; }
.animation-delay-1000 { animation-delay: 1000ms; }

/* ==================================================================
   STAGGERED ANIMATION CHILDREN
   ================================================================== */

.stagger-children > * {
  animation: slideUpFade var(--transition-slow) ease both;
}

.stagger-children > *:nth-child(1)  { animation-delay: 0ms; }
.stagger-children > *:nth-child(2)  { animation-delay: 50ms; }
.stagger-children > *:nth-child(3)  { animation-delay: 100ms; }
.stagger-children > *:nth-child(4)  { animation-delay: 150ms; }
.stagger-children > *:nth-child(5)  { animation-delay: 200ms; }
.stagger-children > *:nth-child(6)  { animation-delay: 250ms; }
.stagger-children > *:nth-child(7)  { animation-delay: 300ms; }
.stagger-children > *:nth-child(8)  { animation-delay: 350ms; }
.stagger-children > *:nth-child(9)  { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }

/* ==================================================================
   TYPING INDICATOR
   ================================================================== */

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
}

.typing-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-text-muted);
  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;
}

/* ==================================================================
   PROGRESS INDETERMINATE
   ================================================================== */

.progress-indeterminate .progress-bar {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

/* ==================================================================
   HOVER TRANSITIONS
   ================================================================== */

.hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.hover-scale {
  transition: transform var(--transition-fast);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.hover-brightness {
  transition: filter var(--transition-fast);
}

.hover-brightness:hover {
  filter: brightness(1.05);
}

.hover-opacity {
  transition: opacity var(--transition-fast);
}

.hover-opacity:hover {
  opacity: 0.8;
}

/* ==================================================================
   TRANSITIONS
   ================================================================== */

.transition-all {
  transition: all var(--transition-normal);
}

.transition-colors {
  transition: color var(--transition-fast),
              background-color var(--transition-fast),
              border-color var(--transition-fast);
}

.transition-transform {
  transition: transform var(--transition-normal);
}

.transition-opacity {
  transition: opacity var(--transition-normal);
}

.transition-shadow {
  transition: box-shadow var(--transition-normal);
}

/* ==================================================================
   COLLAPSE/EXPAND ANIMATION
   ================================================================== */

.collapse {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow) ease, opacity var(--transition-slow) ease;
  opacity: 0;
}

.collapse.is-open {
  max-height: 2000px;
  opacity: 1;
}

/* ==================================================================
   REDUCED MOTION SUPPORT
   ================================================================== */

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

  .animate-fade-in,
  .animate-fade-out,
  .animate-slide-up,
  .animate-slide-down,
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-scale-in,
  .animate-scale-out,
  .animate-pulse,
  .animate-spin,
  .animate-shake,
  .animate-bounce,
  .animate-wiggle,
  .animate-glow {
    animation: none !important;
  }

  .hover-lift:hover {
    transform: none;
  }

  .hover-scale:hover {
    transform: none;
  }

  .stagger-children > * {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .collapse {
    transition: none;
  }

  .collapse.is-open {
    max-height: none;
  }
}
