/* ==========================================================================
   Crumbless Animation System
   Subtle, polished animations for dark-themed UI
   ========================================================================== */

/* CSS Variables for Animations
   ========================================================================== */
:root {
  /* Duration tokens */
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  /* Easing functions */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Glow shadows */
  --shadow-glow-violet: 0 4px 20px -4px rgba(139, 92, 246, 0.4);
  --shadow-glow-emerald: 0 4px 20px -4px rgba(16, 185, 129, 0.4);
}

/* Page Transitions
   ========================================================================== */

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

.animate-fade-up {
  animation: fadeUpIn 0.3s ease-out;
}

/* Skeleton Loaders
   ========================================================================== */

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

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Button Effects
   ========================================================================== */

.btn-glow {
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
}

.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-violet);
}

.btn-glow:active {
  transform: translateY(0);
}

/* Gradient button variant for generate buttons */
.btn-glow-gradient {
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
}

.btn-glow-gradient:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-violet), var(--shadow-glow-emerald);
}

.btn-glow-gradient:active {
  transform: translateY(0);
}

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

.card-lift {
  transition: all var(--duration-normal) var(--ease-out);
}

.card-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.5);
}

/* Subtle lift for nested interactive elements */
.card-lift-subtle {
  transition: all var(--duration-fast) var(--ease-out);
}

.card-lift-subtle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.4);
}

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

/* Smooth transitions for interactive elements */
.transition-smooth {
  transition: all var(--duration-normal) var(--ease-out);
}

.transition-fast {
  transition: all var(--duration-fast) var(--ease-out);
}

.transition-slow {
  transition: all var(--duration-slow) var(--ease-out);
}

/* Spring animations for playful interactions */
.transition-spring {
  transition: all var(--duration-normal) var(--ease-spring);
}

/* Sticky Table Headers
   ========================================================================== */

/* Table container for scroll */
.table-container {
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  border-radius: 1rem;
}

/* Sticky header positioning */
.table-sticky thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #12121a;
}

.table-sticky thead tr {
  background: #12121a;
}

.table-sticky thead th {
  position: relative;
  background: inherit;
}

/* Subtle gradient shadow when scrolled */
.table-sticky thead::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(139, 92, 246, 0.3) 0%,
    rgba(16, 185, 129, 0.3) 100%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.table-sticky.scrolled thead::after {
  opacity: 1;
}

/* Custom scrollbar for tables */
.table-container::-webkit-scrollbar {
  width: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  transition: background var(--duration-fast) var(--ease-out);
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* A/B Test Visualizations
   ========================================================================== */

/* Progress bar animation for A/B test comparison bars */
@keyframes progressGrow {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.ab-test-bar {
  animation: progressGrow 0.8s ease-out forwards;
}

/* Confidence ring animation */
@keyframes drawCircle {
  from {
    stroke-dasharray: 0 100;
  }
}

.confidence-ring {
  animation: drawCircle 1s ease-out forwards;
}

/* Pulse animation for winner badges */
@keyframes pulseGlow {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.winner-badge {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* Number counter animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-number {
  animation: countUp 0.5s ease-out forwards;
}

/* Stagger animation for multiple metrics */
.metric-item:nth-child(1) { animation-delay: 0ms; }
.metric-item:nth-child(2) { animation-delay: 100ms; }
.metric-item:nth-child(3) { animation-delay: 200ms; }
.metric-item:nth-child(4) { animation-delay: 300ms; }

/* Auth Page - Animated Gradient Mesh Background
   ========================================================================== */

@keyframes meshDrift1 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.15;
  }
  25% {
    transform: translate(80px, -60px) scale(1.1);
    opacity: 0.2;
  }
  50% {
    transform: translate(-40px, 40px) scale(0.95);
    opacity: 0.12;
  }
  75% {
    transform: translate(60px, 80px) scale(1.05);
    opacity: 0.18;
  }
}

@keyframes meshDrift2 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.1;
  }
  33% {
    transform: translate(-100px, 60px) scale(1.15);
    opacity: 0.15;
  }
  66% {
    transform: translate(70px, -80px) scale(0.9);
    opacity: 0.08;
  }
}

@keyframes meshDrift3 {
  0%, 100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 0.08;
  }
  50% {
    transform: translate(50px, 50px) scale(1.2) rotate(30deg);
    opacity: 0.14;
  }
}

@keyframes meshDrift4 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.06;
  }
  40% {
    transform: translate(-60px, -40px) scale(1.1);
    opacity: 0.12;
  }
  80% {
    transform: translate(40px, 60px) scale(0.95);
    opacity: 0.08;
  }
}

@keyframes meshPulse {
  0%, 100% {
    opacity: 0.04;
  }
  50% {
    opacity: 0.08;
  }
}

.auth-mesh-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.auth-mesh-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
  animation: meshPulse 8s ease-in-out infinite;
}

.auth-mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform, opacity;
}

.auth-mesh-blob--violet-1 {
  width: 900px;
  height: 900px;
  top: -20%;
  left: -10%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.5) 0%, rgba(124, 58, 237, 0.2) 40%, transparent 70%);
  filter: blur(60px);
  animation: meshDrift1 20s ease-in-out infinite;
}

.auth-mesh-blob--emerald {
  width: 800px;
  height: 800px;
  bottom: -15%;
  right: -5%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.4) 0%, rgba(52, 211, 153, 0.15) 40%, transparent 70%);
  filter: blur(60px);
  animation: meshDrift2 25s ease-in-out infinite;
}

.auth-mesh-blob--violet-2 {
  width: 600px;
  height: 600px;
  top: 30%;
  right: 5%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.35) 0%, rgba(139, 92, 246, 0.1) 50%, transparent 70%);
  filter: blur(50px);
  animation: meshDrift3 18s ease-in-out infinite;
}

.auth-mesh-blob--violet-3 {
  width: 500px;
  height: 500px;
  bottom: 10%;
  left: 15%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.3) 0%, rgba(167, 139, 250, 0.08) 50%, transparent 70%);
  filter: blur(50px);
  animation: meshDrift4 22s ease-in-out infinite;
}

.auth-mesh-blob--accent {
  width: 400px;
  height: 400px;
  top: 10%;
  left: 45%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.25) 0%, transparent 60%);
  filter: blur(40px);
  animation: meshDrift1 30s ease-in-out infinite reverse;
}

/* Noise texture overlay for depth */
.auth-mesh-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(/%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: overlay;
}

/* Auth form card with glassmorphism */
.auth-card {
  background: rgba(17, 17, 20, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.5rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 20px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 80px -20px rgba(139, 92, 246, 0.08);
}

/* Subtle glow line at top of card */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(139, 92, 246, 0.4) 30%,
    rgba(52, 211, 153, 0.3) 70%,
    transparent
  );
  border-radius: 1px;
}

/* Entrance animation for auth card */
@keyframes authCardEnter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card-enter {
  animation: authCardEnter 0.6s cubic-bezier(0.33, 1, 0.68, 1) forwards;
}

/* Logo entrance */
@keyframes authLogoEnter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-logo-enter {
  animation: authLogoEnter 0.4s ease-out forwards;
}

/* Landing Page Card Animations
   ========================================================================== */

/* Scroll-reveal: cards start hidden, animate in when visible */
.landing-card {
  opacity: 0;
  transform: translateY(40px) scale(0.95);
  transition: opacity 0.7s cubic-bezier(0.33, 1, 0.68, 1),
              transform 0.7s cubic-bezier(0.33, 1, 0.68, 1);
  will-change: opacity, transform;
}

.landing-card.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Staggered entrance delays */
.landing-card:nth-child(1) { transition-delay: 0s; }
.landing-card:nth-child(2) { transition-delay: 0.1s; }
.landing-card:nth-child(3) { transition-delay: 0.2s; }

/* 3D perspective container */
.landing-cards-grid {
  perspective: 1200px;
}

/* 3D tilt card wrapper */
.landing-card-tilt {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1),
              box-shadow 0.4s cubic-bezier(0.33, 1, 0.68, 1),
              border-color 0.35s ease;
}

.landing-card-tilt:hover {
  border-color: rgba(139, 92, 246, 0.25) !important;
  box-shadow:
    0 20px 40px -12px rgba(139, 92, 246, 0.15),
    0 0 0 1px rgba(139, 92, 246, 0.08);
}

/* Gradient overlay on hover */
.landing-card-tilt::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent 40%, rgba(139, 92, 246, 0.06) 100%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 0;
}

.landing-card-tilt:hover::before {
  opacity: 1;
}

/* CTA button shimmer effect */
.landing-btn-shimmer {
  position: relative;
  overflow: hidden;
}

.landing-btn-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.15),
    transparent
  );
  animation: btnShimmer 3s infinite;
  pointer-events: none;
}

@keyframes btnShimmer {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* Status pulse for tier tags */
@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.landing-status-dot {
  animation: statusPulse 2s ease-in-out infinite;
}

/* Discount badge subtle glow */
.landing-discount-badge {
  position: relative;
}

.landing-discount-badge::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: inherit;
  opacity: 0.4;
  filter: blur(8px);
  z-index: -1;
}

/* Section header scroll reveal */
.landing-section-header {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.33, 1, 0.68, 1),
              transform 0.6s cubic-bezier(0.33, 1, 0.68, 1);
}

.landing-section-header.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Popular card extra glow pulse */
@keyframes popularGlow {
  0%, 100% {
    box-shadow:
      0 0 40px -8px rgba(139, 92, 246, 0.15),
      0 0 0 1px rgba(139, 92, 246, 0.1);
  }
  50% {
    box-shadow:
      0 0 60px -8px rgba(139, 92, 246, 0.25),
      0 0 0 1px rgba(139, 92, 246, 0.15);
  }
}

.landing-card-popular {
  animation: popularGlow 4s ease-in-out infinite;
}

/* Feature list stagger animation */
.landing-card.is-visible .landing-feature-item {
  opacity: 1;
  transform: translateX(0);
}

.landing-feature-item {
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.landing-feature-item:nth-child(1) { transition-delay: 0.3s; }
.landing-feature-item:nth-child(2) { transition-delay: 0.4s; }
.landing-feature-item:nth-child(3) { transition-delay: 0.5s; }
.landing-feature-item:nth-child(4) { transition-delay: 0.6s; }
