/*
 * JediPic shared animation library
 * Reusable keyframes + utility classes for whole project.
 * Imported into component CSS that needs animations.
 *
 * All animations respect prefers-reduced-motion (handled by tokens.css).
 */

@import url('./tokens.css');

/* ========================================
   Keyframes — primitives
   ======================================== */

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

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

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

@keyframes jp-fade-scale {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes jp-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  60% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes jp-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes jp-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================
   Keyframes — feedback / loading
   ======================================== */

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

@keyframes jp-pulse-glow {
  0%, 100% {
    opacity: 0.6;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes jp-typing-dot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

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

/* ========================================
   Keyframes — voice / AI signature
   ======================================== */

@keyframes jp-voice-pulse {
  0% { box-shadow: 0 0 0 0 var(--color-ai-glow); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes jp-voice-wave {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

@keyframes jp-ai-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes jp-ai-sparkle {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.9) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) rotate(180deg);
  }
}

/* ========================================
   Keyframes — chart / data viz
   ======================================== */

@keyframes jp-bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes jp-bar-grow-y {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes jp-stroke-draw {
  from { stroke-dashoffset: var(--stroke-length, 1000); }
  to { stroke-dashoffset: 0; }
}

/* ========================================
   Utility classes — apply to any element
   ======================================== */

.jp-anim-fade-in {
  animation: jp-fade-in var(--duration-normal) var(--ease-standard) both;
}

.jp-anim-fade-up {
  animation: jp-fade-up var(--duration-normal) var(--ease-out-expo) both;
}

.jp-anim-fade-down {
  animation: jp-fade-down var(--duration-normal) var(--ease-out-expo) both;
}

.jp-anim-fade-scale {
  animation: jp-fade-scale var(--duration-normal) var(--ease-spring) both;
}

.jp-anim-pop-in {
  animation: jp-pop-in var(--duration-slow) var(--ease-spring) both;
}

.jp-anim-slide-in-right {
  animation: jp-slide-in-right var(--duration-normal) var(--ease-out-expo) both;
}

.jp-anim-slide-in-left {
  animation: jp-slide-in-left var(--duration-normal) var(--ease-out-expo) both;
}

.jp-anim-bar-grow {
  animation: jp-bar-grow var(--duration-slower) var(--ease-out-expo) both;
  transform-origin: left center;
}

.jp-anim-pulse-glow {
  animation: jp-pulse-glow 2s ease-in-out infinite;
}

.jp-anim-shimmer {
  background: linear-gradient(
    90deg,
    rgba(35,32,48,0.04) 0%,
    rgba(35,32,48,0.08) 50%,
    rgba(35,32,48,0.04) 100%
  );
  background-size: 200% 100%;
  animation: jp-shimmer 1.4s ease-in-out infinite;
}

/* ========================================
   Stagger delays — apply along with anim class
   ======================================== */

.jp-stagger-1 { animation-delay: 50ms; }
.jp-stagger-2 { animation-delay: 100ms; }
.jp-stagger-3 { animation-delay: 150ms; }
.jp-stagger-4 { animation-delay: 200ms; }
.jp-stagger-5 { animation-delay: 250ms; }
.jp-stagger-6 { animation-delay: 300ms; }
.jp-stagger-7 { animation-delay: 350ms; }
.jp-stagger-8 { animation-delay: 400ms; }

/* ========================================
   Auto-stagger via :nth-child — for dynamic lists
   ======================================== */

.jp-auto-stagger > * {
  animation: jp-fade-up var(--duration-normal) var(--ease-out-expo) both;
}
.jp-auto-stagger > *:nth-child(1) { animation-delay: 0ms; }
.jp-auto-stagger > *:nth-child(2) { animation-delay: 50ms; }
.jp-auto-stagger > *:nth-child(3) { animation-delay: 100ms; }
.jp-auto-stagger > *:nth-child(4) { animation-delay: 150ms; }
.jp-auto-stagger > *:nth-child(5) { animation-delay: 200ms; }
.jp-auto-stagger > *:nth-child(6) { animation-delay: 250ms; }
.jp-auto-stagger > *:nth-child(7) { animation-delay: 300ms; }
.jp-auto-stagger > *:nth-child(8) { animation-delay: 350ms; }
.jp-auto-stagger > *:nth-child(9) { animation-delay: 400ms; }
.jp-auto-stagger > *:nth-child(10) { animation-delay: 450ms; }
