File size: 10,867 Bytes
b33d337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
// Main JavaScript functionality for Unity Fleet website

document.addEventListener('DOMContentLoaded', function() {
    // Initialize animations and interactions
    initScrollAnimations();
    initAccordion();
    initParallaxEffect();
    initHeroAnimation();
    
    // Mobile navigation toggle
    const navLinks = document.querySelector('.nav-links');
    const mobileNavToggle = document.createElement('div');
    mobileNavToggle.className = 'mobile-nav-toggle';
    mobileNavToggle.innerHTML = '<i class="fas fa-bars"></i>';
    document.querySelector('nav').appendChild(mobileNavToggle);
    
    mobileNavToggle.addEventListener('click', function() {
        navLinks.classList.toggle('active');
        this.innerHTML = navLinks.classList.contains('active') 
            ? '<i class="fas fa-times"></i>' 
            : '<i class="fas fa-bars"></i>';
    });
});

// Scroll animations for elements
function initScrollAnimations() {
    const animatedElements = document.querySelectorAll('.section-header, .feature-item, .subscription-card, .impact-metric, .token-diagram, .rural-content, .timeline-item');
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('animate');
                observer.unobserve(entry.target);
            }
        });
    }, {
        threshold: 0.1
    });
    
    animatedElements.forEach(element => {
        element.classList.add('pre-animation');
        observer.observe(element);
    });
    
    // Add CSS for animations
    const style = document.createElement('style');
    style.textContent = `
        .pre-animation {
            opacity: 0;
            transform: translateY(30px);
            transition: opacity 0.6s ease, transform 0.6s ease;
        }
        
        .animate {
            opacity: 1;
            transform: translateY(0);
        }
        
        .subscription-card.pre-animation {
            transform: translateY(50px);
            transition-delay: calc(var(--animation-order, 0) * 0.1s);
        }
        
        .feature-item.pre-animation {
            transform: translateX(-30px);
            transition-delay: calc(var(--animation-order, 0) * 0.1s);
        }
        
        .timeline-item.pre-animation {
            transform: translateX(-30px);
            transition-delay: calc(var(--animation-order, 0) * 0.15s);
        }
    `;
    document.head.appendChild(style);
    
    // Set animation order for staggered animations
    document.querySelectorAll('.subscription-card').forEach((card, index) => {
        card.style.setProperty('--animation-order', index);
    });
    
    document.querySelectorAll('.feature-item').forEach((item, index) => {
        item.style.setProperty('--animation-order', index);
    });
    
    document.querySelectorAll('.timeline-item').forEach((item, index) => {
        item.style.setProperty('--animation-order', index);
    });
}

// Accordion functionality for grant proposal section
function initAccordion() {
    const accordionItems = document.querySelectorAll('.accordion-item');
    
    accordionItems.forEach(item => {
        const header = item.querySelector('.accordion-header');
        const content = item.querySelector('.accordion-content');
        
        header.addEventListener('click', () => {
            // Close all other accordion items
            accordionItems.forEach(otherItem => {
                if (otherItem !== item && otherItem.classList.contains('active')) {
                    otherItem.classList.remove('active');
                    otherItem.querySelector('.accordion-content').style.maxHeight = '0px';
                }
            });
            
            // Toggle current item
            item.classList.toggle('active');
            
            if (item.classList.contains('active')) {
                content.style.display = 'block';
                content.style.maxHeight = content.scrollHeight + 'px';
            } else {
                content.style.maxHeight = '0px';
                setTimeout(() => {
                    content.style.display = 'none';
                }, 300);
            }
        });
    });
    
    // Open first accordion item by default
    if (accordionItems.length > 0) {
        accordionItems[0].classList.add('active');
        const firstContent = accordionItems[0].querySelector('.accordion-content');
        firstContent.style.display = 'block';
        firstContent.style.maxHeight = firstContent.scrollHeight + 'px';
    }
    
    // Add CSS for accordion animations
    const style = document.createElement('style');
    style.textContent = `
        .accordion-content {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }
    `;
    document.head.appendChild(style);
}

// Parallax effect for sections
function initParallaxEffect() {
    window.addEventListener('scroll', () => {
        const scrollPosition = window.pageYOffset;
        
        // Parallax for hero section
        const heroImage = document.querySelector('.hero-image');
        if (heroImage) {
            heroImage.style.transform = `translateY(${scrollPosition * 0.4}px)`;
        }
        
        // Subtle parallax for section backgrounds
        document.querySelectorAll('.section-gradient').forEach(section => {
            const sectionTop = section.offsetTop;
            const sectionHeight = section.offsetHeight;
            const sectionMiddle = sectionTop + sectionHeight / 2;
            const distanceFromMiddle = scrollPosition - sectionMiddle;
            const parallaxValue = distanceFromMiddle * 0.05;
            
            section.style.backgroundPosition = `center ${50 + parallaxValue}%`;
        });
    });
}

// Hero section animations
function initHeroAnimation() {
    const heroContent = document.querySelector('.hero-content');
    const heroElements = heroContent.querySelectorAll('h1, h2, p, .cta-buttons');
    
    // Add CSS for hero animations
    const style = document.createElement('style');
    style.textContent = `
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .hero-animate {
            animation: fadeInUp 0.8s forwards;
            opacity: 0;
        }
    `;
    document.head.appendChild(style);
    
    // Apply staggered animations to hero elements
    heroElements.forEach((element, index) => {
        element.classList.add('hero-animate');
        element.style.animationDelay = `${0.3 + (index * 0.2)}s`;
    });
    
    // Add hover effect to CTA buttons
    document.querySelectorAll('.cta-buttons .btn').forEach(button => {
        button.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-5px)';
            this.style.boxShadow = '0 15px 30px rgba(0, 224, 255, 0.3)';
        });
        
        button.addEventListener('mouseleave', function() {
            this.style.transform = '';
            this.style.boxShadow = '';
        });
    });
}

// Add smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
    anchor.addEventListener('click', function(e) {
        e.preventDefault();
        
        const targetId = this.getAttribute('href');
        const targetElement = document.querySelector(targetId);
        
        if (targetElement) {
            // Close mobile navigation if open
            document.querySelector('.nav-links').classList.remove('active');
            document.querySelector('.mobile-nav-toggle').innerHTML = '<i class="fas fa-bars"></i>';
            
            // Scroll to target
            window.scrollTo({
                top: targetElement.offsetTop - 80, // Offset for fixed header
                behavior: 'smooth'
            });
        }
    });
});

// Add fixed navigation on scroll
window.addEventListener('scroll', function() {
    const nav = document.querySelector('nav');
    if (window.scrollY > 100) {
        nav.classList.add('nav-scrolled');
    } else {
        nav.classList.remove('nav-scrolled');
    }
});

// Add CSS for fixed navigation
const navStyle = document.createElement('style');
navStyle.textContent = `
    .nav-scrolled {
        position: fixed;
        background: rgba(11, 11, 15, 0.9);
        backdrop-filter: blur(10px);
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
        animation: slideDown 0.3s forwards;
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(-100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    @media (max-width: 768px) {
        .mobile-nav-toggle {
            display: block;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--accent-color-1);
        }
        
        .nav-links {
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            background: rgba(11, 11, 15, 0.95);
            flex-direction: column;
            padding: 1rem 0;
            clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
            transition: clip-path 0.4s ease;
        }
        
        .nav-links.active {
            clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        }
        
        .nav-links a {
            padding: 1rem 2rem;
        }
    }
`;
document.head.appendChild(navStyle);

// Add token orbit animation
const orbitStyle = document.createElement('style');
orbitStyle.textContent = `
    .orbit-item {
        transition: transform 0.3s ease, background 0.3s ease;
    }
    
    .orbit-item:hover {
        transform: scale(1.2) !important;
        background: var(--accent-color-1);
        color: var(--bg-color);
    }
`;
document.head.appendChild(orbitStyle);

// Add hover effects to image cards
document.querySelectorAll('.image-card').forEach(card => {
    card.addEventListener('mouseenter', function() {
        this.querySelector('img').style.transform = 'scale(1.05)';
        this.querySelector('.image-overlay').style.opacity = '1';
    });
    
    card.addEventListener('mouseleave', function() {
        this.querySelector('img').style.transform = 'scale(1)';
        this.querySelector('.image-overlay').style.opacity = '0.8';
    });
});

// Add CSS for image card hover effects
const imageCardStyle = document.createElement('style');
imageCardStyle.textContent = `
    .image-card img {
        transition: transform 0.5s ease;
    }
    
    .image-overlay {
        opacity: 0.8;
        transition: opacity 0.3s ease;
    }
`;
document.head.appendChild(imageCardStyle);