/* ==========================================================================
   BioTools - Animations (animations.css)
   Keyframes, utility animation classes, page transitions, reduced motion.
   ========================================================================== */

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

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

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

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

/* --------------------------------------------------------------------------
   KEYFRAMES — Slide
   -------------------------------------------------------------------------- */
@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 slideInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scaleY(0.96);
    transform-origin: top center;
  }
  to {
    opacity: 1;
    transform: translateY(0) scaleY(1);
    transform-origin: top center;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px) scaleY(0.96);
    transform-origin: bottom center;
  }
  to {
    opacity: 1;
    transform: translateY(0) scaleY(1);
    transform-origin: bottom center;
  }
}

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

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

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* --------------------------------------------------------------------------
   KEYFRAMES — Effects
   -------------------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.08);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(-8px);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

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

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes progressBar {
  0% { width: 0; }
  100% { width: var(--progress, 100%); }
}

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

@keyframes borderGlow {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.3);
  }
}

/* --------------------------------------------------------------------------
   UTILITY ANIMATION CLASSES
   -------------------------------------------------------------------------- */
.animate-fade-in {
  animation: fadeIn var(--duration-normal) ease both;
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-normal) ease both;
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-normal) ease both;
}

.animate-slide-up {
  animation: slideInUp var(--duration-normal) ease both;
}

.animate-slide-down {
  animation: slideInDown var(--duration-normal) ease both;
}

.animate-slide-left {
  animation: slideInLeft var(--duration-normal) ease both;
}

.animate-slide-right {
  animation: slideInRight var(--duration-normal) ease both;
}

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

.animate-pop-in {
  animation: popIn var(--duration-slow) ease both;
}

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

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

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

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-shimmer {
  animation: shimmer 1.8s linear infinite;
}

/* Stagger children animation delays */
.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; }

/* --------------------------------------------------------------------------
   PAGE TRANSITION
   -------------------------------------------------------------------------- */
.page-transition {
  animation: fadeInUp var(--duration-normal) ease both;
}

.page-transition-exit {
  animation: fadeOut var(--duration-fast) ease both;
}

/* --------------------------------------------------------------------------
   LOADING SPINNER (composed element)
   -------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner--lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.spinner--sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* --------------------------------------------------------------------------
   REDUCED MOTION — Accessibility
   -------------------------------------------------------------------------- */
@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-pulse,
  .animate-spin,
  .animate-bounce,
  .animate-float,
  .animate-shimmer {
    animation: none !important;
  }
}
