/*
 * Cubix AI - Animation System
 * Motion design tokens and keyframe animations
 */

/* ============================================
   MOTION TOKENS
   ============================================ */

:root {
  /* Timing */
  --time-instant: 100ms;
  --time-fast: 200ms;
  --time-normal: 300ms;
  --time-slow: 500ms;
  --time-dramatic: 800ms;
  --time-ambient: 4000ms;
  
  /* Easing Functions */
  --ease-natural: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-dramatic: cubic-bezier(0.87, 0, 0.13, 1);
  --ease-robot: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* Delays (stagger system) */
  --stagger-base: 0.1s;
  --stagger-1: 0.1s;
  --stagger-2: 0.2s;
  --stagger-3: 0.3s;
  --stagger-4: 0.4s;
  --stagger-5: 0.5s;
}

/* ============================================
   ROBOT LOGO ANIMATIONS
   ============================================ */

/* Floating Animation */
@keyframes robot-float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-12px) rotate(-1deg);
  }
  50% {
    transform: translateY(-20px) rotate(0deg);
  }
  75% {
    transform: translateY(-12px) rotate(1deg);
  }
}

/* Gentle Hover (subtle) */
@keyframes robot-hover {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Eye Pulse */
@keyframes eye-pulse {
  0%, 100% {
    opacity: 0.7;
    filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.5));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 25px rgba(6, 182, 212, 0.9));
  }
}

/* Circuit Line Draw */
@keyframes circuit-draw {
  0% {
    stroke-dashoffset: 1000;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Circuit Pulse (continuous) */
@keyframes circuit-pulse {
  0%, 100% {
    stroke-opacity: 0.4;
  }
  50% {
    stroke-opacity: 1;
  }
}

/* Glow Pulse */
@keyframes glow-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 50px rgba(59, 130, 246, 0.7));
  }
}

/* Robot Entrance (page load) */
@keyframes robot-entrance {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(100px);
    filter: blur(30px);
  }
  60% {
    transform: scale(1.08) translateY(-10px);
    filter: blur(0);
  }
  80% {
    transform: scale(0.98) translateY(5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Thinking Animation */
@keyframes robot-thinking {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-3deg);
  }
  75% {
    transform: rotate(3deg);
  }
}

/* Processing Dots */
@keyframes processing-dots {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* ============================================
   CENTERED HERO STYLES
   ============================================ */

.hero-centered {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 20px 80px;
  overflow: hidden;
  text-align: center;
}

/* Background with animated gradient */
.hero-centered::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.05) 0%, transparent 70%),
    var(--color-deep-navy);
  animation: gradient-shift 15s ease-in-out infinite;
}

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

/* Animated grid overlay */
.hero-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: grid-move 20s linear infinite;
  pointer-events: none;
}

@keyframes grid-move {
  0% {
    transform: perspective(500px) rotateX(60deg) translateY(0);
  }
  100% {
    transform: perspective(500px) rotateX(60deg) translateY(60px);
  }
}

/* Content container */
.hero-content-centered {
  position: relative;
  z-index: 10;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ============================================
   BIG CENTERED ROBOT
   ============================================ */

.robot-container {
  position: relative;
  width: 400px;
  height: 400px;
  margin: 20px 0;
}

@media (max-width: 768px) {
  .robot-container {
    width: 280px;
    height: 280px;
  }
}

@media (max-width: 480px) {
  .robot-container {
    width: 220px;
    height: 220px;
  }
}

/* The Robot Logo */
.robot-logo-big {
  width: 100%;
  height: 100%;
  animation: 
    robot-entrance 1.2s var(--ease-bounce) forwards,
    robot-float 6s var(--ease-natural) 1.2s infinite;
  filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.4));
}

.robot-logo-big:hover {
  animation: 
    robot-entrance 1.2s var(--ease-bounce) forwards,
    robot-hover 3s var(--ease-natural) 1.2s infinite;
  cursor: pointer;
}

/* Robot parts animations */
.robot-eyes {
  animation: eye-pulse 2s var(--ease-natural) infinite;
}

.robot-circuits {
  stroke-dasharray: 1000;
  stroke-dashoffset: 0;
  animation: circuit-draw 2s var(--ease-natural) forwards;
}

.robot-glow {
  animation: glow-pulse 4s var(--ease-natural) infinite;
}

/* Particle ring around robot */
.robot-particles {
  position: absolute;
  inset: -50px;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--color-cyan);
  border-radius: 50%;
  animation: orbit 10s linear infinite;
}

.particle:nth-child(1) { animation-delay: 0s; animation-duration: 8s; }
.particle:nth-child(2) { animation-delay: -2s; animation-duration: 12s; }
.particle:nth-child(3) { animation-delay: -4s; animation-duration: 10s; }
.particle:nth-child(4) { animation-delay: -6s; animation-duration: 14s; }
.particle:nth-child(5) { animation-delay: -8s; animation-duration: 9s; }

@keyframes orbit {
  0% {
    transform: rotate(0deg) translateX(220px) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: rotate(360deg) translateX(220px) rotate(-360deg);
    opacity: 0;
  }
}

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

/* Badge animation */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 100px;
  font-size: 14px;
  color: var(--color-cyan-light);
  opacity: 0;
  animation: fade-down 0.6s var(--ease-smooth) 0.3s forwards;
}

@keyframes fade-down {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Headline animation */
.hero-headline {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  opacity: 0;
  animation: fade-up 0.8s var(--ease-smooth) 0.8s forwards;
}

@keyframes fade-up {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Subtitle */
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--color-gray-300);
  max-width: 600px;
  opacity: 0;
  animation: fade-up 0.8s var(--ease-smooth) 1s forwards;
}

/* CTA Buttons */
.hero-cta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  animation: fade-up 0.8s var(--ease-smooth) 1.2s forwards;
}

/* Stats */
.hero-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--color-gray-500);
  opacity: 0;
  animation: fade-up 0.8s var(--ease-smooth) 1.4s forwards;
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: 
    opacity var(--time-slow) var(--ease-smooth),
    transform var(--time-slow) var(--ease-smooth);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

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

.stagger-children.visible > *:nth-child(1) { animation: fade-up 0.5s var(--ease-smooth) 0.1s forwards; }
.stagger-children.visible > *:nth-child(2) { animation: fade-up 0.5s var(--ease-smooth) 0.2s forwards; }
.stagger-children.visible > *:nth-child(3) { animation: fade-up 0.5s var(--ease-smooth) 0.3s forwards; }
.stagger-children.visible > *:nth-child(4) { animation: fade-up 0.5s var(--ease-smooth) 0.4s forwards; }
.stagger-children.visible > *:nth-child(5) { animation: fade-up 0.5s var(--ease-smooth) 0.5s forwards; }
.stagger-children.visible > *:nth-child(6) { animation: fade-up 0.5s var(--ease-smooth) 0.6s forwards; }

/* ============================================
   INTERACTIVE ANIMATIONS
   ============================================ */

/* Magnetic button effect */
.magnetic-btn {
  position: relative;
  transition: transform var(--time-fast) var(--ease-spring);
}

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

/* Card hover lift */
.card-hover {
  transition: 
    transform var(--time-normal) var(--ease-smooth),
    box-shadow var(--time-normal) var(--ease-smooth);
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Link underline animation */
.link-animate {
  position: relative;
}

.link-animate::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: width var(--time-normal) var(--ease-smooth);
}

.link-animate:hover::after {
  width: 100%;
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-navy) 25%,
    var(--color-navy-light) 50%,
    var(--color-navy) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

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

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(59, 130, 246, 0.3);
  border-top-color: var(--color-electric-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   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;
  }
  
  .robot-logo-big {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

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

.animate-instant { animation-duration: var(--time-instant); }
.animate-fast { animation-duration: var(--time-fast); }
.animate-normal { animation-duration: var(--time-normal); }
.animate-slow { animation-duration: var(--time-slow); }
.animate-dramatic { animation-duration: var(--time-dramatic); }

.delay-1 { animation-delay: var(--stagger-1); }
.delay-2 { animation-delay: var(--stagger-2); }
.delay-3 { animation-delay: var(--stagger-3); }
.delay-4 { animation-delay: var(--stagger-4); }
.delay-5 { animation-delay: var(--stagger-5); }
