/* ============================================================
   AgentFolio — Animations & Transitions
   ============================================================ */

/* ============================================================
   Keyframe Definitions
   ============================================================ */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-24px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

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

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

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

@keyframes countUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes borderGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(0, 212, 255, 0.15); }
}

@keyframes dotBlink {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes gridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}

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

.animate-fade-in { animation: fadeIn 0.4s ease forwards; }
.animate-fade-in-up { animation: fadeInUp 0.5s ease forwards; }
.animate-fade-in-down { animation: fadeInDown 0.4s ease forwards; }
.animate-scale-in { animation: scaleIn 0.3s ease forwards; }
.animate-slide-right { animation: slideInRight 0.4s ease forwards; }
.animate-slide-left { animation: slideInLeft 0.4s ease forwards; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* Staggered children animation */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.8s; }

/* Intersection Observer controlled animations */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

.reveal-left {
  opacity: 0;
  transform: translateX(-32px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(32px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Delay variants */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }

/* ============================================================
   Hero Background Animation
   ============================================================ */

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Animated gradient orbs */
.hero-orb {
  position: absolute;
  border-radius: var(--radius-full);
  filter: blur(80px);
  opacity: 0.15;
  animation: float 6s ease-in-out infinite;
}

.hero-orb-1 {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.hero-orb-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: -100px;
  left: -50px;
  animation-delay: 2s;
}

.hero-orb-3 {
  width: 300px;
  height: 300px;
  background: #7c3aed;
  top: 40%;
  left: 40%;
  animation-delay: 4s;
}

/* Dot grid */
.hero-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.6;
}

[data-theme="light"] .hero-grid {
  background-image: radial-gradient(circle, rgba(0,0,0,0.05) 1px, transparent 1px);
}

[data-theme="light"] .hero-orb { opacity: 0.08; }

/* ============================================================
   Form Step Transitions
   ============================================================ */

.form-step {
  display: none;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.form-step.active {
  display: block;
  animation: slideInRight 0.3s ease forwards;
}

.form-step.exit {
  animation: slideOutLeft 0.3s ease forwards;
}

@keyframes slideOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-20px); }
}

/* ============================================================
   Card Hover Effects
   ============================================================ */

.card-glow:hover {
  animation: borderGlow 2s ease infinite;
}

/* Loading dots */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: dotBlink 1.4s ease-in-out infinite;
}

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

/* ============================================================
   Gradient Animated Background
   ============================================================ */

.gradient-bg {
  background: linear-gradient(-45deg, #0a0a1a, #12122a, #1a1240, #0a1a30);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

/* ============================================================
   Number Counter Animation
   ============================================================ */

.counter {
  display: inline-block;
  animation: countUp 0.6s ease forwards;
}

/* ============================================================
   Page Transition
   ============================================================ */

.page-enter {
  animation: fadeInUp 0.4s ease forwards;
}

/* ============================================================
   Hover Bounce
   ============================================================ */

.hover-bounce:hover {
  animation: float 0.6s ease-in-out;
}

/* ============================================================
   Typing Cursor
   ============================================================ */

.typing-cursor::after {
  content: '|';
  color: var(--accent-primary);
  animation: pulse 1s ease infinite;
  margin-left: 2px;
}

/* ============================================================
   Progress Bar
   ============================================================ */

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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