/* MartinsTech Platform - Animation Library v3.0 */
/* Smooth, elegant animations with natural easing */

/* ========== KEYFRAMES ========== */

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

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

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

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

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

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

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

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

@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 ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

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

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

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

.animate-fade-out {
  animation: fadeOut var(--duration-200) var(--ease-out) forwards;
}

/* Slide animations */
.animate-slide-up {
  animation: slideInUp var(--duration-300) var(--ease-out) forwards;
}

.animate-slide-down {
  animation: slideInDown var(--duration-300) var(--ease-out) forwards;
}

.animate-slide-left {
  animation: slideInLeft var(--duration-300) var(--ease-out) forwards;
}

.animate-slide-right {
  animation: slideInRight var(--duration-300) var(--ease-out) forwards;
}

/* Scale animation */
.animate-scale-in {
  animation: scaleIn var(--duration-200) var(--ease-out) forwards;
}

/* Continuous animations */
.animate-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}

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

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

.animate-ping {
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-bg) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

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

/* Staggered page entrance */
.page-enter > * {
  opacity: 0;
  animation: slideInUp var(--duration-300) var(--ease-out) forwards;
}

.page-enter > *:nth-child(1) { animation-delay: 0ms; }
.page-enter > *:nth-child(2) { animation-delay: 50ms; }
.page-enter > *:nth-child(3) { animation-delay: 100ms; }
.page-enter > *:nth-child(4) { animation-delay: 150ms; }
.page-enter > *:nth-child(5) { animation-delay: 200ms; }
.page-enter > *:nth-child(6) { animation-delay: 250ms; }
.page-enter > *:nth-child(7) { animation-delay: 300ms; }
.page-enter > *:nth-child(8) { animation-delay: 350ms; }

/* Grid stagger */
.stagger-grid > * {
  opacity: 0;
  animation: scaleIn var(--duration-300) var(--ease-out) forwards;
}

.stagger-grid > *:nth-child(1) { animation-delay: 0ms; }
.stagger-grid > *:nth-child(2) { animation-delay: 40ms; }
.stagger-grid > *:nth-child(3) { animation-delay: 80ms; }
.stagger-grid > *:nth-child(4) { animation-delay: 120ms; }
.stagger-grid > *:nth-child(5) { animation-delay: 160ms; }
.stagger-grid > *:nth-child(6) { animation-delay: 200ms; }
.stagger-grid > *:nth-child(7) { animation-delay: 240ms; }
.stagger-grid > *:nth-child(8) { animation-delay: 280ms; }

/* ========== HOVER EFFECTS ========== */

.hover-lift {
  transition: transform var(--duration-200) var(--ease-out),
              box-shadow var(--duration-200) var(--ease-out);
}

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

.hover-scale {
  transition: transform var(--duration-150) var(--ease-out);
}

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

.hover-glow {
  transition: box-shadow var(--duration-200) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 53, 102, 0.15);
}

[data-theme="dark"] .hover-glow:hover {
  box-shadow: 0 0 20px rgba(245, 204, 0, 0.1);
}

/* ========== FOCUS EFFECTS ========== */

.focus-ring {
  transition: box-shadow var(--duration-150) var(--ease-out),
              outline var(--duration-150) var(--ease-out);
}

.focus-ring:focus-visible {
  outline: var(--ring-width) solid var(--ring-color);
  outline-offset: var(--ring-offset);
}

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

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

.transition-shadow {
  transition: box-shadow var(--duration-200) var(--ease-out);
}

.transition-transform {
  transition: transform var(--duration-200) var(--ease-out);
}

.transition-all {
  transition: all var(--duration-200) var(--ease-out);
}

/* ========== LOADING STATES ========== */

.loading-dots::after {
  content: '';
  animation: loadingDots 1.4s infinite;
}

@keyframes loadingDots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Skeleton loading */
.skeleton-loading {
  background: linear-gradient(
    90deg,
    var(--color-bg) 25%,
    var(--color-surface) 50%,
    var(--color-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-bg) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ========== ENTRANCE ANIMATIONS ========== */

/* For use with JavaScript - add 'is-visible' class when element enters viewport */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--duration-500) var(--ease-out),
              transform var(--duration-500) var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity var(--duration-500) var(--ease-out),
              transform var(--duration-500) var(--ease-out);
}

.reveal-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

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

@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-ping,
  .animate-shimmer,
  .skeleton-loading {
    animation: none;
  }

  .reveal,
  .reveal-scale,
  .page-enter > *,
  .stagger-grid > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
