@use 'sass:color';

// ==========================================================================
// Monitor.Cat — Animations
// ==========================================================================

@use 'tokens' as *;

// ---------------------------------------------------------------------------
// Keyframes (defined at root, not scoped)
// ---------------------------------------------------------------------------
@keyframes mc-fade-in-up {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mc-scale-in {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes mc-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes mc-slide-in-right {
  0% {
    opacity: 0;
    transform: translateX(24px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.monitorcat-wrap {
  // ---------------------------------------------------------------------------
  // Reveal on scroll / intersection
  // ---------------------------------------------------------------------------
  .mc-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition:
      opacity 0.6s $mc-ease-spring,
      transform 0.6s $mc-ease-spring;

    &.is-revealed {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mc-reveal-scale {
    opacity: 0;
    transform: scale(0.85);
    transition:
      opacity 0.6s $mc-ease-spring,
      transform 0.6s $mc-ease-spring;

    &.is-revealed {
      opacity: 1;
      transform: scale(1);
    }
  }

  // ---------------------------------------------------------------------------
  // Staggered animation delays
  // ---------------------------------------------------------------------------
  .mc-stagger-1 { transition-delay: 0.05s; }
  .mc-stagger-2 { transition-delay: 0.10s; }
  .mc-stagger-3 { transition-delay: 0.15s; }
  .mc-stagger-4 { transition-delay: 0.20s; }
  .mc-stagger-5 { transition-delay: 0.25s; }
  .mc-stagger-6 { transition-delay: 0.30s; }

  // ---------------------------------------------------------------------------
  // Animation utility classes
  // ---------------------------------------------------------------------------
  .mc-animate-fade-in-up {
    animation: mc-fade-in-up 0.6s $mc-ease-spring both;
  }

  .mc-animate-scale-in {
    animation: mc-scale-in 0.5s $mc-ease-spring both;
  }

  .mc-animate-fade-in {
    animation: mc-fade-in 0.4s ease both;
  }

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

  // ---------------------------------------------------------------------------
  // Skeleton / loading shimmer
  // ---------------------------------------------------------------------------
  .mc-skeleton {
    background: linear-gradient(
      90deg,
      $mc-base-alt 25%,
      color.adjust($mc-base-alt, $lightness: -3%) 37%,
      $mc-base-alt 63%
    );
    background-size: 200% 100%;
    animation: mc-skeleton-shimmer 1.5s ease infinite;
    border-radius: $mc-radius-input;
  }

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

// ---------------------------------------------------------------------------
// Reduced motion — disable all animations
// ---------------------------------------------------------------------------
@media (prefers-reduced-motion: reduce) {
  .monitorcat-wrap {
    .mc-reveal,
    .mc-reveal-scale {
      opacity: 1;
      transform: none;
      transition: none;
    }

    .mc-stagger-1,
    .mc-stagger-2,
    .mc-stagger-3,
    .mc-stagger-4,
    .mc-stagger-5,
    .mc-stagger-6 {
      transition-delay: 0s;
    }

    .mc-animate-fade-in-up,
    .mc-animate-scale-in,
    .mc-animate-fade-in,
    .mc-animate-pulse,
    .mc-skeleton {
      animation: none;
    }

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}
