/* ==========================================================================
   RustPress Enterprise Theme - Animations Library
   ========================================================================== */

/* ========== Keyframe Animations ========== */

/* Fade 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 fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  60% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

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

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

/* Slide Animations */
@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);
  }
}

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

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

/* Bounce Animations */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
  50% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
}

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

/* Float Animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(2deg);
  }
}

/* Glow Animations */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px var(--color-rust-glow);
  }
  50% {
    box-shadow: 0 0 40px var(--color-rust-glow), 0 0 60px rgba(206, 66, 43, 0.3);
  }
}

@keyframes glowText {
  0%, 100% {
    text-shadow: 0 0 10px var(--color-rust-glow);
  }
  50% {
    text-shadow: 0 0 20px var(--color-rust-glow), 0 0 40px rgba(206, 66, 43, 0.5);
  }
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Typewriter Animation */
@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

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

/* Wave Animation */
@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(20deg); }
  75% { transform: rotate(-15deg); }
}

/* Shimmer Animation */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Gradient Flow */
@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ========== Animation Classes ========== */

/* Fade Classes */
.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-left {
  animation: fadeInLeft var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-right {
  animation: fadeInRight var(--duration-normal) var(--ease-out) forwards;
}

/* Scale Classes */
.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-out) forwards;
}

.animate-scale-in-bounce {
  animation: scaleInBounce var(--duration-slow) var(--ease-spring) forwards;
}

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

.animate-pulse-soft {
  animation: pulseSoft 2s var(--ease-in-out) infinite;
}

/* Slide Classes */
.animate-slide-in-up {
  animation: slideInUp var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-in-down {
  animation: slideInDown var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-in-left {
  animation: slideInLeft var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-in-right {
  animation: slideInRight var(--duration-normal) var(--ease-out) forwards;
}

/* Rotate Classes */
.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-spin-slow {
  animation: spinSlow 3s linear infinite;
}

/* Bounce Classes */
.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-bounce-in {
  animation: bounceIn var(--duration-slow) var(--ease-spring) forwards;
}

/* Float Classes */
.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-float-slow {
  animation: floatSlow 6s ease-in-out infinite;
}

/* Glow Classes */
.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

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

/* Special Classes */
.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-wave {
  animation: wave 2s ease-in-out infinite;
  transform-origin: bottom right;
}

/* Shimmer Effect */
.animate-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* Gradient Flow */
.animate-gradient {
  background-size: 200% 200%;
  animation: gradientFlow 4s ease infinite;
}

/* ========== Scroll-Triggered Animations ========== */

/* Initial hidden state for scroll animations */
[data-animate] {
  opacity: 0;
}

[data-animate="fade-up"] {
  transform: translateY(40px);
}

[data-animate="fade-down"] {
  transform: translateY(-40px);
}

[data-animate="fade-left"] {
  transform: translateX(-40px);
}

[data-animate="fade-right"] {
  transform: translateX(40px);
}

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

[data-animate="scale-up"] {
  transform: scale(0.9) translateY(20px);
}

/* Animated state */
[data-animate].animated {
  opacity: 1;
  transform: translateY(0) translateX(0) scale(1);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

/* Staggered children */
[data-animate-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
}

[data-animate-stagger].animated > * {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

[data-animate-stagger].animated > *:nth-child(1) { transition-delay: 0ms; }
[data-animate-stagger].animated > *:nth-child(2) { transition-delay: 100ms; }
[data-animate-stagger].animated > *:nth-child(3) { transition-delay: 200ms; }
[data-animate-stagger].animated > *:nth-child(4) { transition-delay: 300ms; }
[data-animate-stagger].animated > *:nth-child(5) { transition-delay: 400ms; }
[data-animate-stagger].animated > *:nth-child(6) { transition-delay: 500ms; }
[data-animate-stagger].animated > *:nth-child(7) { transition-delay: 600ms; }
[data-animate-stagger].animated > *:nth-child(8) { transition-delay: 700ms; }

/* ========== Typewriter Effect ========== */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 3px solid var(--color-rust);
  animation:
    typewriter 3s steps(40) forwards,
    blink 0.75s step-end infinite;
}

.typewriter--no-cursor {
  border-right: none;
  animation: typewriter 3s steps(40) forwards;
}

/* ========== Parallax Layers ========== */
.parallax-container {
  perspective: 1000px;
  overflow: hidden;
}

.parallax-layer {
  will-change: transform;
}

.parallax-layer--back {
  transform: translateZ(-200px) scale(1.2);
}

.parallax-layer--deep {
  transform: translateZ(-400px) scale(1.4);
}

/* ========== Counter Animation ========== */
.counter {
  font-variant-numeric: tabular-nums;
}

/* ========== Hover Animations ========== */
.hover-lift {
  transition: transform var(--duration-fast) var(--ease-out);
}

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

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

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

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

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

.hover-shine {
  position: relative;
  overflow: hidden;
}

.hover-shine::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left var(--duration-slow) var(--ease-out);
}

.hover-shine:hover::after {
  left: 100%;
}

/* ========== Loading States ========== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-bg-elevated) 50%,
    var(--color-bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--color-rust);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* ========== Delay Utilities ========== */
.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; }
.delay-900 { animation-delay: 900ms; }
.delay-1000 { animation-delay: 1000ms; }

/* ========== Duration Utilities ========== */
.duration-fast { animation-duration: var(--duration-fast); }
.duration-normal { animation-duration: var(--duration-normal); }
.duration-slow { animation-duration: var(--duration-slow); }
.duration-slower { animation-duration: var(--duration-slower); }

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  [data-animate],
  [data-animate-stagger] > * {
    opacity: 1;
    transform: none;
  }
}
