/* ============================================
   MEDHYA ANIMATIONS
   Warm & Human Motion Design
   ============================================ */

/* ============================================
   1. PAGE LOAD ANIMATIONS
   ============================================ */

/* Staggered fade up - Apply to container, children animate */
.animate-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUpIn 0.5s var(--ease-out) forwards;
}

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

@keyframes fadeUpIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in */
.animate-fade-in {
  animation: fadeIn 0.3s var(--ease-out) forwards;
}

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

/* Fade up */
.animate-fade-up {
  animation: fadeUp 0.5s var(--ease-out) forwards;
}

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

/* Scale in */
.animate-scale-in {
  animation: scaleIn 0.3s var(--ease-bounce) forwards;
}

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

/* Slide in from right */
.animate-slide-right {
  animation: slideRight 0.4s var(--ease-out) forwards;
}

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

/* Slide in from left */
.animate-slide-left {
  animation: slideLeft 0.4s var(--ease-out) forwards;
}

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

/* ============================================
   2. HOVER ANIMATIONS
   ============================================ */

/* Lift on hover */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-bounce),
              box-shadow var(--duration-normal) var(--ease-default);
}

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

/* Scale on hover */
.hover-scale {
  transition: transform var(--duration-fast) var(--ease-bounce);
}

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

/* Glow on hover */
.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-default);
}

.hover-glow:hover {
  box-shadow: 0 0 20px var(--color-primary-light);
}

/* Rotate icon on hover */
.hover-rotate-icon:hover svg {
  transform: rotate(15deg);
  transition: transform var(--duration-normal) var(--ease-bounce);
}

/* Color shift on hover */
.hover-color-shift {
  transition: background-color var(--duration-normal) var(--ease-default);
}

.hover-color-shift:hover {
  background-color: var(--color-primary-lighter);
}

/* ============================================
   3. MICRO-INTERACTIONS
   ============================================ */

/* Button press effect */
.press-effect {
  transition: transform 0.1s var(--ease-default);
}

.press-effect:active {
  transform: scale(0.97);
}

/* Checkbox/toggle bounce */
.toggle-bounce {
  transition: transform var(--duration-fast) var(--ease-bounce);
}

.toggle-bounce:checked {
  animation: toggleBounce 0.3s var(--ease-bounce);
}

@keyframes toggleBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Input focus ring animation */
.focus-ring-animate:focus {
  animation: focusRing 0.3s var(--ease-out);
}

@keyframes focusRing {
  0% {
    box-shadow: 0 0 0 0 var(--color-primary-lighter);
  }
  100% {
    box-shadow: 0 0 0 4px var(--color-primary-lighter);
  }
}

/* Success checkmark */
.animate-checkmark {
  animation: checkmark 0.4s var(--ease-bounce) forwards;
}

@keyframes checkmark {
  0% {
    stroke-dashoffset: 50;
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* Error shake */
.animate-shake {
  animation: shake 0.4s var(--ease-default);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ============================================
   4. LOADING ANIMATIONS
   ============================================ */

/* Warm breathing pulse */
.animate-breathe {
  animation: breathe 2.5s var(--ease-default) infinite;
}

@keyframes breathe {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

/* Dot loading */
.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: dotBounce 1.4s var(--ease-default) infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 80%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.3);
    opacity: 1;
  }
}

/* Progress bar */
.progress-animate {
  animation: progressStripe 1s linear infinite;
  background-size: 30px 30px;
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
}

@keyframes progressStripe {
  from { background-position: 30px 0; }
  to { background-position: 0 0; }
}

/* ============================================
   5. DECORATIVE ANIMATIONS
   ============================================ */

/* Floating elements */
.animate-float {
  animation: float 6s var(--ease-default) infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-10px) rotate(1deg);
  }
  66% {
    transform: translateY(5px) rotate(-1deg);
  }
}

/* Slow rotate */
.animate-rotate-slow {
  animation: rotateSlow 20s linear infinite;
}

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

/* Gradient shift */
.animate-gradient {
  background-size: 200% 200%;
  animation: gradientShift 8s var(--ease-default) infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Blob morph */
.animate-blob {
  animation: blobMorph 8s var(--ease-default) infinite;
}

@keyframes blobMorph {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    border-radius: 50% 60% 30% 60% / 30% 30% 70% 50%;
  }
  75% {
    border-radius: 60% 40% 60% 40% / 70% 50% 30% 50%;
  }
}

/* ============================================
   6. SCROLL-TRIGGERED ANIMATIONS
   ============================================ */

/* Elements start invisible, animate when .in-view class added via JS */
.scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-out);
}

.scroll-animate.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Variants */
.scroll-animate-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-out);
}

.scroll-animate-left.in-view {
  opacity: 1;
  transform: translateX(0);
}

.scroll-animate-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-out);
}

.scroll-animate-right.in-view {
  opacity: 1;
  transform: translateX(0);
}

.scroll-animate-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-bounce);
}

.scroll-animate-scale.in-view {
  opacity: 1;
  transform: scale(1);
}

/* Stagger for scroll animations */
.scroll-stagger > * {
  transition-delay: calc(var(--stagger-index, 0) * 0.1s);
}

/* ============================================
   7. TRANSITION UTILITIES
   ============================================ */

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

.transition-fast {
  transition: all var(--duration-fast) var(--ease-default);
}

.transition-slow {
  transition: all var(--duration-slow) var(--ease-default);
}

.transition-colors {
  transition: color var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

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

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

/* Easing utilities */
.ease-bounce {
  transition-timing-function: var(--ease-bounce);
}

.ease-spring {
  transition-timing-function: var(--ease-spring);
}

/* ============================================
   8. REDUCED MOTION
   ============================================ */

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

  .animate-stagger > * {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .scroll-animate,
  .scroll-animate-left,
  .scroll-animate-right,
  .scroll-animate-scale {
    opacity: 1;
    transform: none;
  }
}
