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

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

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

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

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

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

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

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

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

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

@keyframes borderPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
  50%       { box-shadow: 0 0 0 6px rgba(99,102,241,0.15); }
}

/* ============================================
   ANIMATION UTILITY CLASSES
   ============================================ */
.animate-fade-in { animation: fadeIn var(--transition-base) both; }
.animate-fade-in-up { animation: fadeInUp 0.5s cubic-bezier(0.16,1,0.3,1) both; }
.animate-scale-in  { animation: scaleIn 0.4s cubic-bezier(0.16,1,0.3,1) both; }
.animate-slide-left { animation: slideInLeft 0.4s cubic-bezier(0.16,1,0.3,1) both; }
.animate-float { animation: float 3s ease-in-out infinite; }

/* Staggered children */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 80ms; }
.stagger-children > *:nth-child(3) { animation-delay: 160ms; }
.stagger-children > *:nth-child(4) { animation-delay: 240ms; }
.stagger-children > *:nth-child(5) { animation-delay: 320ms; }
.stagger-children > *:nth-child(6) { animation-delay: 400ms; }
.stagger-children > *:nth-child(7) { animation-delay: 480ms; }
.stagger-children > *:nth-child(8) { animation-delay: 560ms; }
.stagger-children > *:nth-child(9) { animation-delay: 640ms; }

/* ============================================
   INTERSECTION OBSERVER TRIGGERS
   ============================================ */

/* Initial state (hidden, before entering viewport) */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16,1,0.3,1),
              transform 0.6s cubic-bezier(0.16,1,0.3,1);
}

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

.reveal-delay-1 { transition-delay: 100ms; }
.reveal-delay-2 { transition-delay: 200ms; }
.reveal-delay-3 { transition-delay: 300ms; }
.reveal-delay-4 { transition-delay: 400ms; }

/* ============================================
   RESULTS REVEAL
   ============================================ */
.calc-results {
  transition: opacity 0.4s ease;
}

.calc-results.result-appear {
  animation: scaleIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
}

.result-card {
  animation: none;
}

.result-card.appear {
  animation: fadeInUp 0.4s cubic-bezier(0.16,1,0.3,1) both;
}

/* ============================================
   HERO GRADIENT ANIMATION
   ============================================ */
.hero-section {
  background-size: 200% 200%;
}

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

/* ============================================
   NAV LINK TRANSITIONS
   ============================================ */
.nav-link {
  transition: background var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
}

/* ============================================
   SIDEBAR SLIDE
   ============================================ */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
}

/* ============================================
   BUTTON RIPPLE EFFECT
   ============================================ */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ============================================
   SMOOTH HOVER EFFECTS
   ============================================ */
.calculator-card {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

/* ============================================
   SCROLL PROGRESS INDICATOR (optional)
   ============================================ */
.scroll-progress {
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transform-origin: left;
  z-index: var(--z-topbar);
  transition: transform 0.1s linear;
}
