File size: 2,601 Bytes
ef139ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Initialize cosmic effects
document.addEventListener('DOMContentLoaded', () => {
    // Parallax effect
    const parallaxElements = document.querySelectorAll('.cosmic-item, .feature-card');
    
    window.addEventListener('mousemove', (e) => {
        const x = (window.innerWidth / 2 - e.pageX) / 20;
        const y = (window.innerHeight / 2 - e.pageY) / 20;
        
        parallaxElements.forEach(el => {
            el.style.transform = `translate(${x}px, ${y}px)`;
        });
    });

    // Testimonial slider
    const testimonials = document.querySelectorAll('.testimonial');
    const sliderButtons = document.querySelectorAll('.slider-btn');
    let currentIndex = 0;

    function showTestimonial(index) {
        testimonials.forEach(testimonial => testimonial.classList.remove('active'));
        sliderButtons.forEach(btn => btn.classList.remove('active'));
        
        testimonials[index].classList.add('active');
        sliderButtons[index].classList.add('active');
        currentIndex = index;
    }

    sliderButtons.forEach((btn, index) => {
        btn.addEventListener('click', () => showTestimonial(index));
    });

    // Auto-rotate testimonials
    setInterval(() => {
        let nextIndex = (currentIndex + 1) % testimonials.length;
        showTestimonial(nextIndex);
    }, 5000);

    // Animate cosmic items on scroll
    const cosmicItems = document.querySelectorAll('.cosmic-item');
    
    function checkScroll() {
        cosmicItems.forEach(item => {
            const itemPosition = item.getBoundingClientRect().top;
            const screenPosition = window.innerHeight / 1.3;
            
            if(itemPosition < screenPosition) {
                item.classList.add('animated');
            }
        });
    }
    
    window.addEventListener('scroll', checkScroll);
    checkScroll(); // Run once on load

    // Particle click effect
    document.addEventListener('click', (e) => {
        const particles = document.createElement('div');
        particles.className = 'particles';
        particles.style.left = `${e.clientX}px`;
        particles.style.top = `${e.clientY}px`;
        document.body.appendChild(particles);
        
        setTimeout(() => {
            particles.remove();
        }, 1000);
    });
});

// Smooth scroll for navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
    anchor.addEventListener('click', function(e) {
        e.preventDefault();
        
        document.querySelector(this.getAttribute('href')).scrollIntoView({
            behavior: 'smooth'
        });
    });
});