/**
 * VeraMath Premium Animations
 * Modern, smooth animations for a stunning user experience
 * Optimized for performance with GPU acceleration
 */

/* ================================================
   PERFORMANCE OPTIMIZATION BASE
   ================================================ */

/* GPU-accelerated animation base */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Optimize elements that will animate */
.reveal,
.reveal-up,
.reveal-down,
.reveal-left,
.reveal-right,
.reveal-scale,
.floating-orb,
.tilt-card,
.btn-animated,
.glow {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Remove will-change after animation completes for memory optimization */
.reveal.active,
.reveal-up.active,
.reveal-down.active,
.reveal-left.active,
.reveal-right.active,
.reveal-scale.active {
    will-change: auto;
}

/* ================================================
   KEYFRAME ANIMATIONS
   ================================================ */

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Pulse Glow */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(var(--primary-rgb), 0.6), 0 0 60px rgba(var(--primary-rgb), 0.3);
    }
}

/* Shimmer */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Rotate */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Blob Morph */
@keyframes blobMorph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 40% 70% 50%;
    }
    75% {
        border-radius: 40% 30% 60% 50% / 70% 50% 40% 60%;
    }
}

/* Gradient Flow */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 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);
    }
}

/* Slide Up Reveal */
@keyframes slideUpReveal {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Counter Flip */
@keyframes counterFlip {
    0% {
        transform: rotateX(-90deg);
        opacity: 0;
    }
    100% {
        transform: rotateX(0);
        opacity: 1;
    }
}

/* Twinkle */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ================================================
   FLOATING BACKGROUND ELEMENTS
   ================================================ */

.floating-orbs {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.floating-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 8s ease-in-out infinite, blobMorph 12s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.5), rgba(99, 102, 241, 0.3));
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(var(--primary-rgb), 0.2));
    top: 50%;
    right: -80px;
    animation-delay: -3s;
    animation-duration: 10s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(var(--primary-rgb), 0.2));
    bottom: -50px;
    left: 30%;
    animation-delay: -6s;
    animation-duration: 12s;
}

/* ================================================
   SCROLL REVEAL CLASSES
   ================================================ */

/* Base state - hidden */
.reveal {
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
}

/* Fade In Up */
.reveal-up {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-up.active {
    opacity: 1;
    transform: translateY(0);
}

/* Fade In Down */
.reveal-down {
    opacity: 0;
    transform: translateY(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-down.active {
    opacity: 1;
    transform: translateY(0);
}

/* Fade In Left */
.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

/* Fade In Right */
.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

/* Scale In */
.reveal-scale {
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* Stagger delay utilities */
.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; }
.delay-6 { transition-delay: 0.6s; }
.delay-7 { transition-delay: 0.7s; }
.delay-8 { transition-delay: 0.8s; }

/* ================================================
   HERO ANIMATIONS
   ================================================ */

.hero-animated {
    position: relative;
}

.hero-badge-animated {
    animation: fadeInDown 0.8s ease-out 0.2s both;
}

.hero-title-animated {
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.hero-subtitle-animated {
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.hero-buttons-animated {
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.hero-stats-animated {
    animation: fadeInUp 0.8s ease-out 1s both;
}

/* Individual stat counter animation */
.hero-stat-animated {
    animation: scaleIn 0.6s ease-out both;
}

.hero-stat-animated:nth-child(1) { animation-delay: 1.1s; }
.hero-stat-animated:nth-child(2) { animation-delay: 1.3s; }
.hero-stat-animated:nth-child(3) { animation-delay: 1.5s; }

/* ================================================
   3D TILT CARD EFFECT
   ================================================ */

.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.tilt-card:hover {
    box-shadow: 0 25px 50px rgba(var(--primary-rgb), 0.2);
}

.tilt-card .tilt-content {
    transform: translateZ(30px);
    transition: transform 0.3s ease-out;
}

/* ================================================
   BUTTON ANIMATIONS
   ================================================ */

.btn-animated {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-animated::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-animated:hover::before {
    width: 300px;
    height: 300px;
}

.btn-animated:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.4);
}

.btn-animated:active {
    transform: translateY(-1px);
}

/* Shine effect */
.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        60deg,
        transparent 25%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 75%
    );
    transform: translateX(-100%) rotate(45deg);
    transition: none;
}

.btn-shine:hover::after {
    animation: shine 0.75s ease forwards;
}

@keyframes shine {
    to {
        transform: translateX(100%) rotate(45deg);
    }
}

/* ================================================
   COUNTER ANIMATION
   ================================================ */

.counter {
    display: inline-block;
    perspective: 100px;
}

.counter.counting {
    animation: counterFlip 0.3s ease-out;
}

/* ================================================
   GLOWING ELEMENTS
   ================================================ */

.glow {
    animation: pulseGlow 3s ease-in-out infinite;
}

.glow-hover:hover {
    animation: pulseGlow 1.5s ease-in-out infinite;
}

/* Gradient text with animation */
.gradient-text-animated {
    background: linear-gradient(
        90deg,
        var(--primary),
        var(--secondary),
        var(--primary)
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 3s linear infinite;
}

/* ================================================
   CARD HOVER EFFECTS
   ================================================ */

.card-hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.card-hover-glow {
    transition: all 0.3s ease;
}

.card-hover-glow:hover {
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.2);
}

/* ================================================
   STEP NUMBER ANIMATION
   ================================================ */

.step-number-animated {
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.step-number-animated:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 15px 40px rgba(var(--primary-rgb), 0.4);
}

.step-number-animated::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px dashed rgba(var(--primary-rgb), 0.3);
    animation: rotate 10s linear infinite;
}

/* ================================================
   TESTIMONIAL CARD ANIMATIONS
   ================================================ */

.testimonial-card-animated {
    transition: all 0.4s ease;
}

.testimonial-card-animated:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.testimonial-avatar-animated {
    transition: all 0.3s ease;
}

.testimonial-card-animated:hover .testimonial-avatar-animated {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(var(--primary-rgb), 0.3);
}

/* ================================================
   FAQ ANIMATIONS
   ================================================ */

.faq-item-animated .faq-question {
    transition: all 0.3s ease;
}

.faq-item-animated .faq-question:hover {
    padding-left: calc(var(--space-lg) + 5px);
    background: rgba(var(--primary-rgb), 0.05);
}

.faq-item-animated .faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    display: block !important;
    padding: 0 var(--space-lg);
}

.faq-item-animated.open .faq-answer {
    max-height: 200px;
    padding: 0 var(--space-lg) var(--space-lg);
    opacity: 1;
}

/* ================================================
   FOOTER ANIMATIONS
   ================================================ */

.footer-link-animated {
    position: relative;
    display: inline-block;
}

.footer-link-animated::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.footer-link-animated:hover::after {
    width: 100%;
}

.footer-social-animated a {
    transition: all 0.3s ease;
}

.footer-social-animated a:hover {
    transform: translateY(-5px) rotate(10deg);
}

/* ================================================
   PARTICLE EFFECTS
   ================================================ */

.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: twinkle 3s ease-in-out infinite;
}

/* ================================================
   LOADING SKELETON
   ================================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 0%,
        var(--bg-elevated) 50%,
        var(--bg-card) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

/* ================================================
   NAV BAR ANIMATION
   ================================================ */

.nav-bar-animated {
    transition: all 0.3s ease;
}

.nav-bar-animated.scrolled,
.public-nav.scrolled {
    padding: var(--space-sm) 0;
    background: var(--bg-surface);
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

/* ================================================
   SMOOTH SCROLL BEHAVIOR
   ================================================ */

html {
    scroll-behavior: smooth;
}

/* ================================================
   REDUCED MOTION
   ================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .floating-orbs,
    .particles-container {
        display: none !important;
    }
    
    .glow {
        animation: none !important;
        box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.3) !important;
    }
}

/* ================================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ================================================ */

@media (max-width: 768px) {
    /* Reduce blur intensity on mobile for performance */
    .floating-orb {
        filter: blur(40px);
        opacity: 0.25;
    }
    
    /* Simplify animations on mobile */
    .floating-orb {
        animation: float 12s ease-in-out infinite;
    }
    
    /* Reduce particle count handled in JS */
    .particles-container {
        opacity: 0.5;
    }
    
    /* Disable 3D tilt on mobile - too intensive */
    .tilt-card {
        transform: none !important;
        perspective: none;
    }
    
    .tilt-card:hover {
        transform: translateY(-5px) !important;
    }
    
    /* Simpler glow effect on mobile */
    .glow {
        animation: none;
        box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.25);
    }
    
    /* Faster transitions on mobile for snappier feel */
    .reveal,
    .reveal-up,
    .reveal-down,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        transition-duration: 0.5s;
    }
    
    /* Reduce box-shadow complexity */
    .card-hover-lift:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    }
    
    .card-hover-glow:hover {
        box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.15);
    }
    
    /* Simpler button animations */
    .btn-animated::before {
        display: none;
    }
    
    .btn-shine::after {
        display: none;
    }
}

/* Very low-end mobile optimization */
@media (max-width: 480px) {
    .floating-orbs {
        display: none;
    }
    
    .particles-container {
        display: none;
    }
    
    /* Remove all glow effects */
    .glow {
        box-shadow: none;
        animation: none;
    }
    
    /* Minimal card effects */
    .card-hover-lift:hover,
    .card-hover-glow:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ================================================
   SAVE DATA MODE - For users with data saver enabled
   ================================================ */

@media (prefers-reduced-data: reduce) {
    .floating-orbs,
    .particles-container {
        display: none;
    }
    
    .glow {
        animation: none;
    }
}
