/* Design System Animations
 * All animations respect prefers-reduced-motion
 */

/* === KEYFRAMES === */
@keyframes scale-breath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes hover-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  60% { transform: scale(1.06); }
  80% { transform: scale(1.09); }
  100% { transform: scale(1.08); }
}

@keyframes selected-ring-breath {
  0%, 100% {
    box-shadow:
      var(--shadow-avatar),
      var(--ring-selected);
  }
  50% {
    box-shadow:
      var(--shadow-avatar),
      var(--ring-selected),
      var(--ring-selected-pulse);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes row-highlight-pulse {
  0% { background-color: var(--primary-alpha, rgba(99, 102, 241, 0.2)); }
  100% { background-color: transparent; }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes burst-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes gentle-sway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

/* === ANIMATION UTILITIES === */
/* Only apply animations when user hasn't requested reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .anim-breath {
    animation: scale-breath 2.5s ease-in-out infinite;
  }

  .anim-hover-bounce:hover {
    animation: hover-bounce 0.4s ease forwards;
  }

  .anim-selected-ring {
    animation: selected-ring-breath 2.5s ease-in-out infinite;
  }

  .anim-fade-in {
    animation: fade-in 0.3s ease;
  }

  .row-highlight {
    animation: row-highlight-pulse 2s ease-out forwards;
  }

  .anim-slide-up {
    animation: slide-up 0.4s ease;
  }

  .anim-burst {
    animation: burst-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .anim-sway {
    animation: gentle-sway 3s ease-in-out infinite;
  }

  /* Avatar picker animations */
  .avatar-option input[type="radio"]:checked + label {
    animation: selected-ring-breath 2.5s ease-in-out infinite;
  }

  .avatar-option label {
    animation: scale-breath 2.5s ease-in-out infinite;
  }

  .avatar-option label:hover {
    animation: hover-bounce 0.4s ease forwards;
  }

  /* Stop breathing when something is selected */
  .avatar-picker:has(input:checked) .avatar-option label:not(:has(+ input:checked)) {
    animation: none;
  }

  /* Card entrance */
  .card {
    animation: slide-up 0.4s ease;
  }

  /* Success page burst */
  .success-burst {
    animation: burst-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
  }

  .success-icon {
    animation: gentle-sway 3s ease-in-out infinite 0.7s;
  }
}

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

  /* Still allow essential visual feedback, just instant */
  .avatar-option input[type="radio"]:checked + label {
    box-shadow: var(--shadow-avatar), var(--ring-selected);
  }

  .avatar-option label:hover {
    transform: scale(1.08);
  }

  .success-burst,
  .success-icon {
    opacity: 1;
    transform: none;
  }
}

/* === TRANSITION UTILITIES === */
.transition-all {
  transition: all var(--transition-base);
}

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

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

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

/* === HOVER SCALE UTILITIES === */
@media (prefers-reduced-motion: no-preference) {
  .hover-scale-sm:hover { transform: scale(1.02); }
  .hover-scale-md:hover { transform: scale(1.05); }
  .hover-scale-lg:hover { transform: scale(1.08); }
}

/* === FOCUS VISIBLE === */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove focus ring on mouse click, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}
