/* ============================================
   PHASE 7: WOW FACTOR POLISH - ANIMATIONS & EFFECTS
   Performance-first animations with accessibility support
   ============================================ */

/* ============================================
   1. RESPECT USER PREFERENCES
   ============================================ */

/* Disable animations for users who prefer 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;
    }
}

/* ============================================
   2. CSS CUSTOM PROPERTIES FOR ANIMATIONS
   ============================================ */

:root {
    /* Timing */
    --anim-fast: 150ms;
    --anim-normal: 250ms;
    --anim-slow: 400ms;
    --anim-slower: 600ms;

    /* Easing */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Stagger delays */
    --stagger-delay: 80ms;
}

/* ============================================
   3. PAGE LOAD ANIMATIONS
   ============================================ */

/* Hero Section Fade-In */
.hero {
    animation: fadeInUp var(--anim-slower) var(--ease-out);
}

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

/* Logo Animation on Load */
.logo-icon {
    animation: logoEntrance 800ms var(--ease-out);
    transform-origin: center;
}

@keyframes logoEntrance {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Navbar Slide-In from Top */
.nav {
    animation: slideDownNav var(--anim-slow) var(--ease-out);
}

@keyframes slideDownNav {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered Fade-In for Feature Cards */
.feature-card,
.problem-card {
    opacity: 0;
    animation: fadeInUpStagger var(--anim-slower) var(--ease-out) forwards;
}

/* Pricing cards - always visible, no animation */
.pricing-card {
    opacity: 1 !important;
}

.feature-card:nth-child(1),
.problem-card:nth-child(1),
.pricing-card:nth-child(1) {
    animation-delay: 100ms;
}

.feature-card:nth-child(2),
.problem-card:nth-child(2),
.pricing-card:nth-child(2) {
    animation-delay: 200ms;
}

.feature-card:nth-child(3),
.problem-card:nth-child(3),
.pricing-card:nth-child(3) {
    animation-delay: 300ms;
}

.feature-card:nth-child(4),
.problem-card:nth-child(4) {
    animation-delay: 400ms;
}

.feature-card:nth-child(5),
.problem-card:nth-child(5) {
    animation-delay: 500ms;
}

.feature-card:nth-child(6),
.problem-card:nth-child(6) {
    animation-delay: 600ms;
}

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

/* ============================================
   4. SCROLL-TRIGGERED ANIMATIONS
   ============================================ */

/* Elements that will animate on scroll */
.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--anim-slower) var(--ease-out),
                transform var(--anim-slower) var(--ease-out);
}

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

/* Slide from left */
.scroll-slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity var(--anim-slower) var(--ease-out),
                transform var(--anim-slower) var(--ease-out);
}

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

/* Slide from right */
.scroll-slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity var(--anim-slower) var(--ease-out),
                transform var(--anim-slower) var(--ease-out);
}

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

/* Scale up */
.scroll-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity var(--anim-slower) var(--ease-out),
                transform var(--anim-slower) var(--ease-out);
}

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

/* ============================================
   5. COUNTER ANIMATIONS
   ============================================ */

.counter {
    font-variant-numeric: tabular-nums;
    transition: all var(--anim-normal) var(--ease-out);
}

.counter.counting {
    color: var(--accent-blue);
}

/* ============================================
   6. PROGRESS BAR ANIMATIONS
   ============================================ */

.progress-bar {
    position: relative;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    transform: translateX(-100%);
    transition: transform 1200ms var(--ease-out);
    will-change: transform;
}

.progress-bar-fill.is-visible {
    transform: translateX(0);
}

/* Animated shimmer effect */
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

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

/* ============================================
   7. VISUAL ENHANCEMENTS
   ============================================ */

/* Subtle background gradient transitions */
.section {
    transition: background var(--anim-slow) var(--ease-out);
}

/* Glow effects on primary CTAs */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width var(--anim-slow) var(--ease-out),
                height var(--anim-slow) var(--ease-out);
}

.btn-primary:hover::after {
    width: 300px;
    height: 300px;
}

/* Pulsing glow effect */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(0, 102, 255, 0.25);
    }
    50% {
        box-shadow: 0 4px 24px rgba(0, 102, 255, 0.45),
                    0 0 30px rgba(0, 102, 255, 0.2);
    }
}

.btn-primary:not(:hover) {
    animation: pulse-glow 2500ms ease-in-out infinite;
}

/* Enhanced hover effects for all interactive elements */
.feature-card,
.pricing-card,
.problem-card {
    transition: transform var(--anim-normal) var(--ease-out),
                box-shadow var(--anim-normal) var(--ease-out),
                border-color var(--anim-normal) var(--ease-out);
    will-change: transform;
}

.capability-card {
    transition: transform var(--anim-normal) var(--ease-out),
                background var(--anim-normal) var(--ease-out),
                border-color var(--anim-normal) var(--ease-out),
                box-shadow var(--anim-normal) var(--ease-out);
    will-change: transform;
}

/* ============================================
   8. LOADING STATES
   ============================================ */

/* Button loading state */
.btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

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

/* Skeleton loading for content */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 0%,
        var(--gray-100) 50%,
        var(--gray-200) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1500ms ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

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

/* ============================================
   9. SMOOTH SCROLLING
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* Scroll padding for fixed navbar */
html {
    scroll-padding-top: 100px;
}

/* ============================================
   10. FOCUS STATES FOR ACCESSIBILITY
   ============================================ */

/* Enhanced focus visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

/* Remove default outline but keep focus-visible */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 10001;
    padding: 1rem 2rem;
    background: var(--accent-blue);
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: top var(--anim-normal) var(--ease-out);
}

.skip-to-main:focus {
    top: 0;
}

/* ============================================
   11. MODAL TRANSITIONS
   ============================================ */

.automation-modal {
    transition: opacity var(--anim-slow) var(--ease-out);
}

.automation-modal .modal-content {
    transition: transform var(--anim-slow) var(--ease-out),
                opacity var(--anim-slow) var(--ease-out);
}

.automation-modal.active .modal-content {
    animation: modalEnter var(--anim-slow) var(--ease-out);
}

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

/* ============================================
   12. MICRO-INTERACTIONS
   ============================================ */

/* Nav links hover effect */
.nav-links a {
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-blue);
    transition: width var(--anim-normal) var(--ease-out);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Form input focus animations */
input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    transition: border-color var(--anim-normal) var(--ease-out),
                box-shadow var(--anim-normal) var(--ease-out),
                background-color var(--anim-normal) var(--ease-out);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

/* Checkbox and radio animations */
input[type="checkbox"],
input[type="radio"] {
    transition: all var(--anim-fast) var(--ease-out);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    animation: checkBounce 300ms var(--ease-bounce);
}

@keyframes checkBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* ============================================
   13. SHADOWS & DEPTH
   ============================================ */

/* Subtle depth for cards */
.feature-card,
.pricing-card,
.problem-card,
.capability-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05),
                0 1px 2px rgba(0, 0, 0, 0.1);
}

.feature-card:hover,
.pricing-card:hover,
.problem-card:hover,
.capability-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08),
                0 6px 12px rgba(0, 0, 0, 0.04);
}

/* ============================================
   14. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Use will-change for elements that will animate */
.btn-primary,
.feature-card,
.pricing-card,
.capability-card,
.modal-content {
    will-change: transform;
}

/* Remove will-change after animation completes */
.animation-complete {
    will-change: auto;
}

/* Force GPU acceleration for smooth animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ============================================
   15. LAZY LOADING FADE-IN
   ============================================ */

img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--anim-slow) var(--ease-out);
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ============================================
   16. PRICING CARD SPECIAL EFFECTS
   ============================================ */

.pricing-card-featured {
    animation: featured-pulse 3000ms ease-in-out infinite;
}

@keyframes featured-pulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(0, 102, 255, 0.15);
    }
    50% {
        box-shadow: 0 12px 40px rgba(0, 102, 255, 0.25);
    }
}

/* ============================================
   17. TOOLTIP ANIMATIONS
   ============================================ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 0.5rem 0.75rem;
    background: var(--gray-900);
    color: white;
    font-size: 0.875rem;
    white-space: nowrap;
    border-radius: var(--border-radius-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--anim-normal) var(--ease-out),
                transform var(--anim-normal) var(--ease-out);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   18. HERO BACKGROUND ANIMATION
   ============================================ */

.hero::before,
.hero::after {
    animation: float 20s ease-in-out infinite;
}

.hero::after {
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0);
    }
    33% {
        transform: translate(30px, -30px);
    }
    66% {
        transform: translate(-20px, 20px);
    }
}

/* ============================================
   19. MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    /* Reduce animation complexity on mobile */
    .hero::before,
    .hero::after {
        animation: none;
    }

    /* Faster animations on mobile */
    :root {
        --anim-normal: 200ms;
        --anim-slow: 300ms;
        --anim-slower: 400ms;
    }
}

/* ============================================
   20. PRINT STYLES (Remove animations)
   ============================================ */

@media print {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        box-shadow: none !important;
    }
}
