/* ============================================
   NAMSEZANA TRADING & PROJECTS
   Animations CSS - Keyframes & Utilities
   ============================================ */

/* Fade Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@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);
  }
}

/* Scale Animations */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Slide Animations */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Rotate Animations */
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

/* Draw/Stroke Animations */
@keyframes drawLine {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes underlineGrow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Counter Animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glow Animations */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(var(--color-secondary-rgb), 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(var(--color-secondary-rgb), 0.8);
  }
}

@keyframes glowYellow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(var(--color-accent-rgb), 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(var(--color-accent-rgb), 0.8);
  }
}

/* Shimmer Effect */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(var(--palette-white-rgb), 0.4) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* Flip Animation */
@keyframes flipIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotateY(90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateY(0);
  }
}

/* Bounce Animation */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Checkmark Animation */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Typing Animation */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  50% {
    border-color: transparent;
  }
}

/* Particle Float Animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0) translateX(0);
  }
  25% {
    transform: translateY(-20px) translateX(10px);
  }
  50% {
    transform: translateY(-10px) translateX(-10px);
  }
  75% {
    transform: translateY(-30px) translateX(5px);
  }
}

/* Wave Animation */
@keyframes wave {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Reveal Animation Classes - Optimized for industrial precision */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-left.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-right.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.94);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-scale.active {
  opacity: 1;
  transform: scale(1);
}

/* Stagger Children - Precision sequential entry */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.stagger-children.active > * {
  opacity: 1;
  transform: translateY(0);
}

.stagger-children.active > *:nth-child(1) { transition-delay: 100ms; }
.stagger-children.active > *:nth-child(2) { transition-delay: 200ms; }
.stagger-children.active > *:nth-child(3) { transition-delay: 300ms; }
.stagger-children.active > *:nth-child(4) { transition-delay: 400ms; }
.stagger-children.active > *:nth-child(5) { transition-delay: 500ms; }
.stagger-children.active > *:nth-child(6) { transition-delay: 600ms; }
.stagger-children.active > *:nth-child(7) { transition-delay: 700ms; }
.stagger-children.active > *:nth-child(8) { transition-delay: 800ms; }
.stagger-children.active > *:nth-child(9) { transition-delay: 900ms; }
.stagger-children.active > *:nth-child(10) { transition-delay: 1000ms; }

/* Morph Reveal - Cinematic scaling and blurring entrance */
.reveal-morph {
  opacity: 0;
  filter: blur(15px);
  transform: scale(0.9) translateY(40px);
  transition: 
    opacity 1000ms cubic-bezier(0.16, 1, 0.3, 1), 
    filter 1000ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 1000ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, filter, transform;
}

.reveal-morph.active {
  opacity: 1;
  filter: blur(0);
  transform: scale(1) translateY(0);
}

/* Stagger Morph - For collections of items (cards, pods) */
.stagger-morph > * {
  opacity: 0;
  filter: blur(10px);
  transform: scale(0.85) translateY(30px);
  transition: 
    opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    filter 800ms cubic-bezier(0.16, 1, 0.3, 1), 
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, filter, transform;
}

.stagger-morph.active > * {
  opacity: 1;
  filter: blur(0);
  transform: scale(1) translateY(0);
  transition-delay: calc(var(--i, 0) * 80ms);
}

/* Animation Utilities */
.animate-fadeIn { animation: fadeIn var(--transition-slow) forwards; }
.animate-fadeInUp { animation: fadeInUp var(--transition-slow) forwards; }
.animate-fadeInDown { animation: fadeInDown var(--transition-slow) forwards; }
.animate-fadeInLeft { animation: fadeInLeft var(--transition-slow) forwards; }
.animate-fadeInRight { animation: fadeInRight var(--transition-slow) forwards; }

.animate-scaleIn { animation: scaleIn var(--transition-slow) forwards; }
.animate-rotateIn { animation: rotateIn var(--transition-slow) forwards; }
.animate-flipIn { animation: flipIn var(--transition-slow) forwards; }
.animate-bounceIn { animation: bounceIn var(--transition-slow) forwards; }

.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-rotate { animation: rotate 20s linear infinite; }
.animate-bounce { animation: bounce 2s ease-in-out infinite; }
.animate-float { animation: float 6s ease-in-out infinite; }
.animate-glow { animation: glow 2s ease-in-out infinite; }
.animate-glow-yellow { animation: glowYellow 2s ease-in-out infinite; }

/* Animation Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }

/* Duration Overrides */
.duration-fast { animation-duration: var(--transition-fast); }
.duration-base { animation-duration: var(--transition-base); }
.duration-slow { animation-duration: var(--transition-slow); }
.duration-slower { animation-duration: var(--transition-slower); }

/* Fill Mode */
.fill-forwards { animation-fill-mode: forwards; }
.fill-both { animation-fill-mode: both; }

/* Hover Animations */
.hover-lift {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--transition-fast);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow var(--transition-fast);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
}

/* Underline Animation */
.animated-underline {
  position: relative;
  display: inline-block;
}

.animated-underline::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--safety-yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-slow);
}

.animated-underline:hover::after,
.animated-underline.active::after {
  transform: scaleX(1);
}

/* Counter Animation Class */
.counter-animate {
  display: inline-block;
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(var(--palette-white-rgb), 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1;
}

/* Success Animation */
.success-checkmark {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--success-green);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn var(--transition-base);
}

.success-checkmark svg {
  width: 32px;
  height: 32px;
  stroke: white;
  stroke-width: 3;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark 0.5s ease forwards 0.3s;
}

/* Page Transition */
.page-transition {
  position: fixed;
  inset: 0;
  background: var(--primary-blue);
  z-index: 9999;
  transform: translateY(100%);
  transition: transform var(--transition-slower);
}

.page-transition.active {
  transform: translateY(0);
}

.page-transition.exit {
  transform: translateY(-100%);
}
