/* ===================================
   Animation Keyframes
   =================================== */

/* Fade Up Animation - Subtle and smooth */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Scale In Animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

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

/* Pulse Animation */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

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

/* Rotate Animation */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Gradient Shift */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Count Up Animation (handled by JS) */
@keyframes countUp {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Bounce In */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Page Load Animations */
.fade-up {
  animation: fadeUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  /* Hardware acceleration for smoother animations */
  will-change: opacity, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  /* Prevent subpixel rendering issues */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hero content specific stagger - smooth cascade */
/* CRITICAL: Delays start AFTER fonts load and overlay fades */
.hero-content .hero-headline.fade-up {
  animation-delay: 0.2s;
}

.hero-content .hero-subheadline.fade-up {
  animation-delay: 0.35s;
}

.hero-content .hero-cta.fade-up {
  animation-delay: 0.5s;
}

.hero-visual.fade-up {
  animation-delay: 0.65s;
}

/* Generic nth-child fallback */
.fade-up:nth-child(1) {
  animation-delay: 0.1s;
}

.fade-up:nth-child(2) {
  animation-delay: 0.2s;
}

.fade-up:nth-child(3) {
  animation-delay: 0.3s;
}

.fade-up:nth-child(4) {
  animation-delay: 0.4s;
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
  opacity: 0;
}

.scale-in {
  animation: scaleIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

/* Continuous Animations */
.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* Scroll-Triggered Animations */
.scroll-fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-fade-in {
  opacity: 0;
  transition: opacity 0.8s ease-out;
}

.scroll-fade-in.visible {
  opacity: 1;
}

.scroll-scale-in {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-scale-in.visible {
  opacity: 1;
  transform: scale(1);
}

.scroll-slide-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.scroll-slide-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Staggered Animations */
.stagger-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.stagger-item:nth-child(1).visible {
  transition-delay: 0.1s;
}

.stagger-item:nth-child(2).visible {
  transition-delay: 0.2s;
}

.stagger-item:nth-child(3).visible {
  transition-delay: 0.3s;
}

.stagger-item:nth-child(4).visible {
  transition-delay: 0.4s;
}

.stagger-item:nth-child(5).visible {
  transition-delay: 0.5s;
}

.stagger-item:nth-child(6).visible {
  transition-delay: 0.6s;
}

/* Dashboard Specific Animations */
.dashboard-mockup {
  animation: float 6s ease-in-out infinite;
}

/* Disable float animation during loading to prevent flicker */
.dashboard-mockup.dashboard-loading {
  animation: none;
  /* Keep transform stable during load */
  transform: translateY(0) translateZ(0);
}

/* Smooth transition when float animation starts */
.dashboard-mockup:not(.dashboard-loading) {
  /* Brief transition to smooth the handoff from fade-up to float */
  animation-delay: 0.3s;
}

.metric-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Activity items animation is now handled by JavaScript for better control */
.dashboard-mockup .activity-item {
  /* Animation controlled by JS - no CSS animation conflicts */
  will-change: opacity, transform;
}

.dashboard-mockup .metric-value {
  /* Smooth metric reveals controlled by JS */
  will-change: opacity;
}

/* Gradient Orb Animations */
.gradient-orb {
  animation: floatOrb 8s ease-in-out infinite;
}

.orb-1 {
  animation-delay: 0s;
}

.orb-2 {
  animation-delay: 4s;
}

/* GPU accelerated orb float */
@keyframes floatOrb {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  33% {
    transform: translate3d(30px, -30px, 0) scale(1.1);
  }
  66% {
    transform: translate3d(-20px, 20px, 0) scale(0.9);
  }
}

/* Button Hover Effects */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Link Hover Underline Animation */
.animated-underline {
  position: relative;
  display: inline-block;
}

.animated-underline::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 0;
  background: currentColor;
  transition: width 0.3s ease-out;
}

.animated-underline:hover::after {
  width: 100%;
}

/* Number Counter Animation (enhanced by JS) */
.counter {
  display: inline-block;
  transition: transform 0.3s ease-out;
}

.counter.counting {
  animation: pulse 0.5s ease-in-out;
}

/* Loading State */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

/* Reveal on Scroll Optimization */
@media (prefers-reduced-motion: no-preference) {
  .reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus Visible Styles for Accessibility */
*:focus-visible {
  outline: 2px solid #05472A;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Selection Styles */
::selection {
  background: rgba(5, 71, 42, 0.2);
  color: inherit;
}

/* Smooth Color Transitions */
* {
  transition-property: color, background-color, border-color;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disable transitions for specific properties */
*,
*::before,
*::after {
  transition-property: none;
}

/* CRITICAL: Exclude text elements from all transitions to prevent flicker */
.hero-headline,
.hero-subheadline,
.hero-cta,
.dashboard-content,
.metric-value,
.activity-item,
.dashboard-content * {
  transition: none !important;
}

/* Re-enable for specific interactive elements only */
a, button, .btn, .nav-link, .feature-card,
.integration-card, .metric-block, .testimonial-card {
  transition-property: all;
  transition-duration: 250ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prefers Reduced Motion */
@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;
  }

  .dashboard-mockup,
  .gradient-orb,
  .animate-float,
  .animate-pulse {
    animation: none !important;
  }
}
