/* ===================================
   ANIMATION KEYFRAMES & UTILITIES
   =================================== */

/* ===================================
   KEYFRAME ANIMATIONS
   =================================== */

@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(-30px);
  }
  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 slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

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

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

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

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

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

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

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

@keyframes drawLine {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 122, 51, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 122, 51, 0.8), 0 0 30px rgba(0, 122, 51, 0.6);
  }
}

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

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

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

/* Fade animations */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s ease-out;
}

/* Scale animations */
.animate-scale-in {
  animation: scaleIn 0.4s ease-out;
}

/* Slide animations */
.animate-slide-in-up {
  animation: slideInUp 0.5s ease-out;
}

.animate-slide-in-down {
  animation: slideInDown 0.5s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

/* Motion animations */
.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
}

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

.animate-rotate {
  animation: rotate 2s linear infinite;
}

.animate-shimmer {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

.animate-gradient {
  background-size: 200% 200%;
  animation: gradient 3s ease infinite;
}

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

/* ===================================
   ANIMATION DELAYS
   =================================== */

.delay-100 {
  animation-delay: 0.1s;
}

.delay-200 {
  animation-delay: 0.2s;
}

.delay-300 {
  animation-delay: 0.3s;
}

.delay-400 {
  animation-delay: 0.4s;
}

.delay-500 {
  animation-delay: 0.5s;
}

.delay-700 {
  animation-delay: 0.7s;
}

.delay-1000 {
  animation-delay: 1s;
}

/* ===================================
   ANIMATION DURATIONS
   =================================== */

.duration-fast {
  animation-duration: 0.3s;
}

.duration-base {
  animation-duration: 0.6s;
}

.duration-slow {
  animation-duration: 1s;
}

.duration-slower {
  animation-duration: 1.5s;
}

/* ===================================
   HOVER ANIMATIONS
   =================================== */

.hover-lift {
  transition: transform var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

.hover-scale {
  transition: transform var(--transition-base);
}

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

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

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 122, 51, 0.4);
}

.hover-rotate {
  transition: transform var(--transition-base);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-brightness {
  transition: filter var(--transition-base);
}

.hover-brightness:hover {
  filter: brightness(1.2);
}

/* ===================================
   STAGGER ANIMATIONS (for GSAP)
   =================================== */

.animate-stagger > * {
  opacity: 0;
  transform: translateY(20px);
}

.animate-stagger-scale > * {
  opacity: 0;
  transform: scale(0.8);
}

.animate-stagger-left > * {
  opacity: 0;
  transform: translateX(-20px);
}

.animate-stagger-right > * {
  opacity: 0;
  transform: translateX(20px);
}

/* ===================================
   SCROLL REVEAL (for GSAP)
   =================================== */

.scroll-reveal {
  opacity: 0;
  transform: translateY(50px);
}

.scroll-reveal-left {
  opacity: 0;
  transform: translateX(-50px);
}

.scroll-reveal-right {
  opacity: 0;
  transform: translateX(50px);
}

.scroll-reveal-scale {
  opacity: 0;
  transform: scale(0.9);
}

/* ===================================
   TRANSITION UTILITIES
   =================================== */

.transition-all {
  transition: all var(--transition-base);
}

.transition-fast {
  transition: all var(--transition-fast);
}

.transition-slow {
  transition: all var(--transition-slow);
}

.transition-colors {
  transition: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

/* ===================================
   SVG LINE DRAWING ANIMATION
   =================================== */

.flow-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
}

.flow-line.animated {
  animation: drawLine 1.5s ease-out forwards;
}

/* ===================================
   DIAGRAM COMPONENT ANIMATIONS
   =================================== */

.diagram-component {
  opacity: 0;
  transform: scale(0.8);
}

.diagram-component.animated {
  animation: scaleIn 0.5s ease-out forwards;
}

/* Stagger delays for diagram components */
.diagram-component:nth-child(1) { animation-delay: 0.1s; }
.diagram-component:nth-child(2) { animation-delay: 0.2s; }
.diagram-component:nth-child(3) { animation-delay: 0.3s; }
.diagram-component:nth-child(4) { animation-delay: 0.4s; }
.diagram-component:nth-child(5) { animation-delay: 0.5s; }
.diagram-component:nth-child(6) { animation-delay: 0.6s; }

/* ===================================
   TEXT ANIMATIONS
   =================================== */

.text-reveal {
  overflow: hidden;
}

.text-reveal span {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
}

.text-gradient-animated {
  background: linear-gradient(
    90deg,
    var(--spar-green),
    var(--accent-green-light),
    var(--spar-green)
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient 3s linear infinite;
}

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

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 2rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-paragraph {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-paragraph:last-child {
  width: 80%;
}

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

.entrance-zoom {
  animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.entrance-bounce {
  animation: fadeInUp 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===================================
   FOCUS ANIMATIONS
   =================================== */

.focus-ring {
  outline: none;
  transition: box-shadow var(--transition-fast);
}

.focus-ring:focus {
  box-shadow: 0 0 0 3px rgba(0, 122, 51, 0.4);
}

.focus-ring:focus:not(:focus-visible) {
  box-shadow: none;
}

/* ===================================
   INTERACTIVE HIGHLIGHTS
   =================================== */

.highlight-on-hover {
  position: relative;
  overflow: hidden;
}

.highlight-on-hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.highlight-on-hover:hover::before {
  left: 100%;
}

/* ===================================
   PARALLAX EFFECTS (CSS-only fallback)
   =================================== */

.parallax-slow {
  transform: translateZ(-1px) scale(2);
}

.parallax-medium {
  transform: translateZ(-0.5px) scale(1.5);
}

/* ===================================
   COUNTER ANIMATION
   =================================== */

@property --counter {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

.counter-animated {
  animation: counter 2s ease-out;
  counter-reset: num var(--counter);
}

.counter-animated::after {
  content: counter(num);
}

@keyframes counter {
  from {
    --counter: 0;
  }
  to {
    --counter: var(--target);
  }
}

/* ===================================
   ACCESSIBILITY
   =================================== */

/* Respect user's motion preferences */
@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-bounce,
  .animate-pulse,
  .animate-rotate,
  .animate-shimmer,
  .animate-gradient {
    animation: none !important;
  }
}
