/**
 * Landing Page Animations - AEO Analyzer
 * All keyframe animations and scroll-triggered effects
 */

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

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

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

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

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

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

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

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

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

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

/* Portal Effects */
@keyframes portalPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

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

/* Star Pulse */
@keyframes starPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Floating */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.6);
    }
}

/* Typing Cursor */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* Particle Float */
@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) translateX(10px) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateY(10vh) translateX(-10px) scale(1);
    }
    100% {
        transform: translateY(-10vh) translateX(0) scale(0);
        opacity: 0;
    }
}

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

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

/* Hexagon Rotation (3D) */
@keyframes hexRotate {
    0% {
        transform: rotateY(0deg) rotateX(0deg);
    }
    25% {
        transform: rotateY(90deg) rotateX(10deg);
    }
    50% {
        transform: rotateY(180deg) rotateX(0deg);
    }
    75% {
        transform: rotateY(270deg) rotateX(-10deg);
    }
    100% {
        transform: rotateY(360deg) rotateX(0deg);
    }
}

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

/* Slide Reveal */
@keyframes slideReveal {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* Draw Line */
@keyframes drawLine {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Orbit */
@keyframes orbit {
    from {
        transform: rotate(0deg) translateX(180px) rotate(0deg);
    }
    to {
        transform: rotate(360deg) translateX(180px) rotate(-360deg);
    }
}

/* ==========================================================================
   SCROLL-TRIGGERED ANIMATION CLASSES
   ========================================================================== */

/* Elements with these classes will animate when scrolled into view */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animations for children */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.6s; }

.stagger-children.visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* Scale animation variant */
.animate-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* Slide variants */
.animate-slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

.animate-slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* ==========================================================================
   PARTICLE SYSTEM
   ========================================================================== */

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-light);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat linear infinite;
    opacity: 0;
}

.particle.blue {
    background: var(--primary);
}

.particle.purple {
    background: var(--secondary);
}

.particle.pink {
    background: var(--accent);
}

.particle:nth-child(odd) {
    animation-duration: 15s;
}

.particle:nth-child(even) {
    animation-duration: 20s;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.loading-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ==========================================================================
   COUNTER ANIMATIONS
   ========================================================================== */

.counter-animated {
    display: inline-block;
    animation: countUp 0.3s ease-out;
}

/* ==========================================================================
   INTERACTIVE HOVER EFFECTS
   ========================================================================== */

/* Card Lift */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Glow on Hover */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

/* Scale on Hover */
.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Button Press Effect */
.btn-press {
    transition: transform 0.1s ease;
}

.btn-press:active {
    transform: scale(0.98);
}

/* ==========================================================================
   SPECIAL EFFECTS
   ========================================================================== */

/* Gradient Border Animation */
.gradient-border {
    position: relative;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(45deg, var(--primary), var(--secondary), var(--accent), var(--primary));
    background-size: 400% 400%;
    border-radius: inherit;
    z-index: -1;
    animation: gradientShift 5s ease infinite;
}

/* Typing Effect Container */
.typing-effect {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation:
        typing 3.5s steps(40, end),
        blink 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

/* Spotlight Effect */
.spotlight {
    position: relative;
    overflow: hidden;
}

.spotlight::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 50%
    );
    opacity: 0;
    transform: rotate(30deg);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.spotlight:hover::after {
    opacity: 1;
}

/* ==========================================================================
   MOTION PREFERENCE
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-on-scroll,
    .animate-scale,
    .animate-slide-left,
    .animate-slide-right {
        opacity: 1;
        transform: none;
    }

    .stagger-children > * {
        opacity: 1;
        transform: none;
    }

    .particle {
        display: none;
    }
}

/* ==========================================================================
   PRICING CARD ANIMATIONS
   ========================================================================== */

/* Staggered entrance for pricing cards */
.pricing-cards .pricing-card {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
}

.pricing-cards.visible .pricing-card {
    animation: pricingCardEnter 0.6s ease-out forwards;
}

.pricing-cards.visible .pricing-card:nth-child(1) {
    animation-delay: 0.1s;
}

.pricing-cards.visible .pricing-card:nth-child(2) {
    animation-delay: 0.25s;
}

.pricing-cards.visible .pricing-card:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pricingCardEnter {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Featured card special entrance */
.pricing-cards.visible .pricing-card.featured {
    animation: pricingCardEnterFeatured 0.7s ease-out forwards;
    animation-delay: 0.25s;
}

@keyframes pricingCardEnterFeatured {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(1);
    }
    60% {
        opacity: 1;
        transform: translateY(-8px) scale(1.08);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1.05);
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Use GPU acceleration for animated elements */
.hero-section,
.portal-orb,
.star-node,
.hex-face,
.particle {
    will-change: transform;
}

/* Disable animations below the fold until scrolled */
.below-fold {
    animation-play-state: paused;
}

.below-fold.in-view {
    animation-play-state: running;
}
