/* ============================================
   ANIMATIONS — Staffing Academy
   Keyframes, scroll-driven animations, transitions
   ============================================ */

/* ---- Core Keyframes ---- */

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

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

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

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

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

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---- Looping Animations ---- */

@keyframes float-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 10px) scale(1.02); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

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

@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

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

@keyframes orbit {
  from { transform: rotate(0deg) translateX(var(--orbit-radius, 120px)) rotate(0deg); }
  to { transform: rotate(360deg) translateX(var(--orbit-radius, 120px)) rotate(-360deg); }
}

@keyframes dash {
  to { stroke-dashoffset: 0; }
}

@keyframes flowParticle {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

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

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

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

/* ---- Scroll-triggered animation classes ---- */
/* Elements start hidden, become visible when .animate-in is added by JS */

[data-animate] > [data-delay] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

[data-animate] > [data-delay].animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Animation direction variants */
[data-animate-dir="left"] > [data-delay] {
  transform: translateX(-30px);
}

[data-animate-dir="right"] > [data-delay] {
  transform: translateX(30px);
}

[data-animate-dir="scale"] > [data-delay] {
  transform: scale(0.9);
}

[data-animate-dir="left"] > [data-delay].animate-in,
[data-animate-dir="right"] > [data-delay].animate-in {
  transform: translateX(0);
}

[data-animate-dir="scale"] > [data-delay].animate-in {
  transform: scale(1);
}

/* Standalone scroll-reveal class */
.scroll-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.scroll-reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.scroll-reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

.scroll-reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.scroll-reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

.scroll-reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.scroll-reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* ---- CSS Scroll-Driven Animations (progressive enhancement) ---- */

@supports (animation-timeline: view()) {
  .scroll-driven {
    animation: fadeInUp linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }

  .scroll-driven-left {
    animation: fadeInLeft linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }

  .scroll-driven-right {
    animation: fadeInRight linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }

  .scroll-driven-scale {
    animation: scaleIn linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }
}

/* ---- Hero entrance animations ---- */

.hero-animate-1 {
  animation: fadeInUp 0.8s var(--ease-out) 0.2s both;
}

.hero-animate-2 {
  animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
}

.hero-animate-3 {
  animation: fadeInUp 0.8s var(--ease-out) 0.6s both;
}

.hero-animate-4 {
  animation: fadeInUp 0.8s var(--ease-out) 0.8s both;
}

/* ---- SVG path drawing ---- */

.svg-draw {
  stroke-dasharray: var(--path-length, 1000);
  stroke-dashoffset: var(--path-length, 1000);
  transition: stroke-dashoffset 1.5s ease-in-out;
}

.svg-draw.drawn {
  stroke-dashoffset: 0;
}

/* SVG data flow particles */
.flow-particle {
  offset-path: var(--flow-path);
  animation: flowParticle 3s linear infinite;
}

/* ---- Hover micro-interactions ---- */

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

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

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

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
}

.hover-scale {
  transition: transform var(--duration-fast) var(--ease-spring);
}

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

/* ---- Stagger delays (for use with data-delay or JS) ---- */

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

/* ---- Number counter animation ---- */

.counter-value {
  display: inline-block;
  min-width: 2ch;
}

.counter-animating {
  animation: countUp 0.3s var(--ease-out);
}

/* ---- Reduce 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;
  }

  .scroll-reveal,
  .scroll-reveal-left,
  .scroll-reveal-right,
  .scroll-reveal-scale,
  [data-animate] > [data-delay] {
    opacity: 1;
    transform: none;
  }

  .marquee-track {
    animation: none;
  }
}
