/* ============================================
   CodeMechanix - Animations
   Industrial Mechanical Animations
   ============================================ */

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

/* Gear Rotation - Continuous slow rotation */
@keyframes gear-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Counter Rotation for interlocking gears */
@keyframes gear-rotate-reverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

/* Fade In - General entrance animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In from Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In from Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Zoom In */
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulsing Status Indicator */
@keyframes pulse-status {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

/* Glow Pulse - Blue glow effect */
@keyframes glow-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 138, 61, 0.3),
      0 0 20px rgba(255, 138, 61, 0.2), 0 0 30px rgba(255, 138, 61, 0.1);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 138, 61, 0.6),
      0 0 40px rgba(255, 138, 61, 0.4), 0 0 60px rgba(255, 138, 61, 0.2);
  }
}

/* Data Flow - Line animation */
@keyframes data-flow {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Data Packet Movement - Sequential Flow */
@keyframes packet-flow {
  0% {
    left: -10px;
    opacity: 0;
    transform: scale(0.5);
  }
  5% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  95% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    left: calc(100% + 10px);
    opacity: 0;
    transform: scale(0.5);
  }
}

/* Scroll Bounce - Scroll indicator */
@keyframes scroll-bounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(10px);
  }
}

/* Monitor Scan Effect */
@keyframes scan {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

/* Typing Cursor */
@keyframes blink {
  0%,
  50%,
  100% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0;
  }
}

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

/* Shimmer Effect */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Rotate on Hover - Quick spin */
@keyframes spin-once {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Progress Bar Fill */
@keyframes fill-progress {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* Slide Down */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide Up */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Border Draw */
@keyframes border-draw {
  0% {
    stroke-dashoffset: 1000;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Number Counter Roll */
@keyframes counter-roll {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Gear Rotation Classes */
.gear-rotate-slow {
  animation: gear-rotate 20s linear infinite;
}

.gear-rotate {
  animation: gear-rotate 10s linear infinite;
}

.gear-rotate-fast {
  animation: gear-rotate 5s linear infinite;
}

.gear-rotate-reverse {
  animation: gear-rotate-reverse 10s linear infinite;
}

.gear-icon:hover {
  animation: gear-rotate 2s linear infinite;
}

/* Connection Line Animations */
.connection-line {
  stroke-dasharray: 10 10;
  animation: data-flow 3s linear infinite;
}

.data-flow-line {
  stroke-dasharray: 20 10;
  animation: data-flow 4s linear infinite;
}

.data-flow-line.delay-1 {
  animation-delay: 1s;
}

.data-flow-line.delay-2 {
  animation-delay: 2s;
}

/* Pulsing Elements */
.pulse {
  animation: pulse-status 2s ease-in-out infinite;
}

.pulse-glow {
  animation: glow-pulse 3s ease-in-out infinite;
}

/* Entrance Animations */
.fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

.fade-in-left {
  animation: fadeInLeft 0.8s ease-out forwards;
}

.fade-in-right {
  animation: fadeInRight 0.8s ease-out forwards;
}

.zoom-in {
  animation: zoomIn 0.6s ease-out forwards;
}

.slide-down {
  animation: slideDown 0.5s ease-out forwards;
}

.slide-up {
  animation: slideUp 0.5s ease-out forwards;
}

/* Delay Classes for Staggered Animations */
.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;
}

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

/* Hover Animations */
.hover-glow:hover {
  animation: glow-pulse 1s ease-in-out;
}

.hover-spin:hover {
  animation: spin-once 0.5s ease-in-out;
}

/* ============================================
   Scroll-triggered Animations (data-aos)
   ============================================ */

[data-aos] {
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: 0.8s;
  transition-timing-function: ease-out;
}

[data-aos].aos-animate {
  opacity: 1;
}

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

[data-aos="fade-up"].aos-animate {
  transform: translateY(0);
}

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

[data-aos="fade-down"].aos-animate {
  transform: translateY(0);
}

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

[data-aos="fade-left"].aos-animate {
  transform: translateX(0);
}

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

[data-aos="fade-right"].aos-animate {
  transform: translateX(0);
}

[data-aos="zoom-in"] {
  transform: scale(0.9);
}

[data-aos="zoom-in"].aos-animate {
  transform: scale(1);
}

[data-aos="zoom-out"] {
  transform: scale(1.1);
}

[data-aos="zoom-out"].aos-animate {
  transform: scale(1);
}

/* Delay variations */
[data-aos][data-aos-delay="100"] {
  transition-delay: 0.1s;
}

[data-aos][data-aos-delay="200"] {
  transition-delay: 0.2s;
}

[data-aos][data-aos-delay="300"] {
  transition-delay: 0.3s;
}

[data-aos][data-aos-delay="400"] {
  transition-delay: 0.4s;
}

/* ============================================
   Special Effects
   ============================================ */

/* Corner Gear Animation */
.corner-gear {
  position: absolute;
  pointer-events: none;
}

.gear-slow {
  animation: gear-rotate 30s linear infinite;
}

/* AI Hub Pulse */
.ai-hub circle {
  animation: pulse-status 3s ease-in-out infinite;
}

/* Shimmer on Hover */
.shimmer-hover {
  position: relative;
  overflow: hidden;
}

.shimmer-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;
}

.shimmer-hover:hover::before {
  left: 100%;
}

/* Card Lift Effect */
.card-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(255, 138, 61, 0.3);
}

/* Icon Glow on Hover */
.icon-glow {
  transition: all 0.3s ease;
}

.icon-glow:hover {
  filter: drop-shadow(0 0 15px rgba(255, 138, 61, 0.8));
  transform: scale(1.1);
}

/* Text Glow Effect */
.text-glow {
  text-shadow: 0 0 10px rgba(255, 138, 61, 0.5),
    0 0 20px rgba(255, 138, 61, 0.3), 0 0 30px rgba(255, 138, 61, 0.2);
}

/* Border Glow Animation */
.border-glow {
  position: relative;
  border: 2px solid transparent;
}

.border-glow::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, #ff8a3d, #FF8A3D);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
}

.border-glow:hover::before {
  opacity: 1;
  animation: glow-pulse 2s ease-in-out infinite;
}

/* Loading Spinner - Gear Style */
.loading-gear {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 138, 61, 0.2);
  border-top-color: #ff8a3d;
  border-radius: 50%;
  animation: gear-rotate 1s linear infinite;
}

/* Progress Bar Animation */
.progress-bar {
  position: relative;
  height: 4px;
  background: var(--primary-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--gradient-brand);
  animation: fill-progress 2s ease-in-out forwards;
}

/* Typewriter Effect */
.typewriter {
  overflow: hidden;
  border-right: 3px solid var(--accent-primary);
  white-space: nowrap;
  animation: typing 3s steps(30, end), blink 0.75s step-end infinite;
}

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

/* Hexagon Rotate on Hover */
.hex-rotate {
  transition: transform 0.5s ease;
}

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

/* Scale Pulse */
.scale-pulse {
  animation: scale-pulse 2s ease-in-out infinite;
}

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

/* Machine Status Blink */
.status-blink {
  animation: blink 1s step-end infinite;
}

/* Slide In from Bottom */
@keyframes slideInBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-in-bottom {
  animation: slideInBottom 0.6s ease-out forwards;
}

/* Number Counter Animation */
.counter-animate {
  animation: counter-roll 0.8s ease-out forwards;
}

/* Gradient Animation */
@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

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

/* ============================================
   Performance Optimizations
   ============================================ */

/* GPU Acceleration for smoother animations */
.gpu-accelerate {
  transform: translateZ(0);
  will-change: transform;
}

/* Reduce motion for accessibility */
@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;
  }

  .gear-rotate,
  .gear-rotate-slow,
  .gear-rotate-fast,
  .pulse,
  .pulse-glow,
  .float {
    animation: none;
  }
}
