File size: 10,890 Bytes
3f366fd
 
 
 
b174791
66a0be0
3f366fd
 
 
66a0be0
 
 
b174791
 
 
 
 
 
 
66a0be0
b174791
 
 
66a0be0
b174791
66a0be0
 
b174791
 
 
 
 
 
66a0be0
3f366fd
 
 
 
66a0be0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f366fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b174791
3f366fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b174791
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f366fd
 
b174791
 
 
 
 
 
 
 
 
 
b683743
 
3f366fd
b683743
3f366fd
 
b683743
 
3f366fd
b683743
 
3f366fd
b683743
3f366fd
b683743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f366fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Main JavaScript for TechForge Nexus

document.addEventListener('DOMContentLoaded', function() {
    // Initialize any global functionality
    // Enhanced smooth scrolling for anchor links with animation
    document.querySelectorAll('a.scroll-link').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            const targetId = this.getAttribute('href');
            if (targetId.startsWith('#')) {
                const targetElement = document.querySelector(targetId);
                if (targetElement) {
                    // Add active class for visual feedback
                    document.querySelectorAll('a.scroll-link').forEach(link => {
                        link.classList.remove('active');
                    });
                    this.classList.add('active');
                    
                    // Calculate scroll position
                    const headerHeight = document.querySelector('techforge-header')?.shadowRoot?.querySelector('.header')?.offsetHeight || 80;
                    const targetPosition = targetElement.offsetTop - headerHeight - 20;
                    
                    // Smooth scroll with easing
                    window.scrollTo({
                        top: targetPosition,
                        behavior: 'smooth'
                    });
                    
                    // Add visual highlight to target section
                    targetElement.classList.add('highlight-section');
                    setTimeout(() => {
                        targetElement.classList.remove('highlight-section');
                    }, 2000);
                }
            }
        });
    });

    // Smooth scrolling for general # links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        if (!anchor.classList.contains('scroll-link')) {
            anchor.addEventListener('click', function (e) {
                const targetId = this.getAttribute('href');
                if (targetId === '#') return;
                
                const targetElement = document.querySelector(targetId);
                if (targetElement) {
                    e.preventDefault();
                    const headerHeight = document.querySelector('techforge-header')?.shadowRoot?.querySelector('.header')?.offsetHeight || 80;
                    window.scrollTo({
                        top: targetElement.offsetTop - headerHeight - 20,
                        behavior: 'smooth'
                    });
                }
            });
        }
    });
// Parallax effect for hero section
    const heroSection = document.querySelector('section:first-of-type');
    if (heroSection) {
        window.addEventListener('scroll', function() {
            const scrolled = window.pageYOffset;
            const rate = scrolled * -0.5;
            if (heroSection.querySelector('video')) {
                heroSection.querySelector('video').style.transform = `translate3d(0px, ${rate}px, 0px)`;
            }
        });
    }

    // Intersection Observer for animations
    const observerOptions = {
        threshold: 0.1,
        rootMargin: '0px 0px -50px 0px'
    };

    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('animate-fade-in');
            }
        });
    }, observerOptions);

    // Observe all sections and cards
    document.querySelectorAll('section, .feature-card, .rounded-2xl').forEach(el => {
        el.classList.add('opacity-0', 'transition-opacity', 'duration-700');
        observer.observe(el);
    });
    // Add CSS for animations
    const style = document.createElement('style');
    style.textContent = `
        .animate-fade-in {
            opacity: 1 !important;
            animation: fadeIn 0.7s ease-out forwards;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* Highlight animation for target sections */
        .highlight-section {
            animation: highlightPulse 2s ease;
        }
        
        @keyframes highlightPulse {
            0% {
                box-shadow: 0 0 0 0 rgba(245, 196, 107, 0);
            }
            50% {
                box-shadow: 0 0 0 20px rgba(245, 196, 107, 0.2);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(245, 196, 107, 0);
            }
        }
        
        /* New button animations */
        .scroll-link {
            transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        
        .scroll-link:hover {
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
        }
    `;
    document.head.appendChild(style);
    
    // Add float animation to new buttons after a delay
    setTimeout(() => {
        const scrollButtons = document.querySelectorAll('.scroll-link');
        scrollButtons.forEach((button, index) => {
            button.style.animationDelay = `${index * 0.1}s`;
            button.classList.add('animate-float-soft');
        });
    }, 1000);
// Video controls
    const heroVideos = document.querySelectorAll('video');
    heroVideos.forEach(video => {
        // Ensure video plays
        video.play().catch(error => {
            console.log('Video autoplay failed:', error);
            // Fallback: play on user interaction
            const playVideoOnce = () => {
                video.play();
                document.removeEventListener('click', playVideoOnce);
            };
            document.addEventListener('click', playVideoOnce);
        });
    });

    // Video player controls for foreground video
    const videoPlayerContainer = document.querySelector('.group');
    if (videoPlayerContainer) {
        const video = videoPlayerContainer.querySelector('video');
        const playButton = videoPlayerContainer.querySelector('button:nth-of-type(1)');
        const muteButton = videoPlayerContainer.querySelector('button:nth-of-type(2)');

        if (playButton && video) {
            playButton.addEventListener('click', () => {
                if (video.paused) {
                    video.play();
                    playButton.innerHTML = '<i data-feather="pause" class="w-5 h-5"></i>';
                } else {
                    video.pause();
                    playButton.innerHTML = '<i data-feather="play" class="w-5 h-5"></i>';
                }
                feather.replace();
            });
        }

        if (muteButton && video) {
            muteButton.addEventListener('click', () => {
                video.muted = !video.muted;
                muteButton.innerHTML = video.muted 
                    ? '<i data-feather="volume-x" class="w-5 h-5"></i>'
                    : '<i data-feather="volume-2" class="w-5 h-5"></i>';
                feather.replace();
            });
        }

        // Update timeline progress (simulated)
        const timelineProgress = videoPlayerContainer.querySelector('.h-full.bg-accent');
        if (timelineProgress && video) {
            const updateProgress = () => {
                if (video.duration) {
                    const percent = (video.currentTime / video.duration) * 100;
                    timelineProgress.style.width = percent + '%';
                }
            };
            video.addEventListener('timeupdate', updateProgress);
        }
    }
// Testimonial hover effects
    const testimonials = document.querySelectorAll('.bg-secondary\\/50');
    testimonials.forEach(testimonial => {
        testimonial.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-5px)';
        });
        
        testimonial.addEventListener('mouseleave', function() {
            this.style.transform = 'translateY(0)';
        });
    });

    // Mobile menu toggle (if needed in future)
    function initMobileMenu() {
        const menuToggle = document.createElement('button');
        menuToggle.className = 'md:hidden fixed top-6 right-6 z-50 bg-accent text-primary p-3 rounded-xl';
        menuToggle.innerHTML = '<i data-feather="menu"></i>';
        document.body.appendChild(menuToggle);
        
        feather.replace();
        
        menuToggle.addEventListener('click', function() {
            const nav = document.querySelector('nav');
            if (nav) {
                nav.classList.toggle('hidden');
                nav.classList.toggle('flex');
                nav.classList.toggle('flex-col');
                nav.classList.toggle('absolute');
                nav.classList.toggle('top-20');
                nav.classList.toggle('left-0');
                nav.classList.toggle('right-0');
                nav.classList.toggle('bg-secondary');
                nav.classList.toggle('p-4');
            }
        });
    }

    // Initialize mobile menu on small screens
    if (window.innerWidth < 768) {
        initMobileMenu();
    }

    // Update year in footer (if needed)
    const yearElement = document.querySelector('#current-year');
    if (yearElement) {
        yearElement.textContent = new Date().getFullYear();
    }

    // Performance monitoring
    window.addEventListener('load', function() {
        const loadTime = window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart;
        console.log(`Page loaded in ${loadTime}ms`);
    });
});

// Utility functions
const TechForgeUtils = {
    debounce: function(func, wait) {
        let timeout;
        return function executedFunction(...args) {
            const later = () => {
                clearTimeout(timeout);
                func(...args);
            };
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
        };
    },

    throttle: function(func, limit) {
        let inThrottle;
        return function() {
            const args = arguments;
            const context = this;
            if (!inThrottle) {
                func.apply(context, args);
                inThrottle = true;
                setTimeout(() => inThrottle = false, limit);
            }
        };
    },

    formatBytes: function(bytes, decimals = 2) {
        if (bytes === 0) return '0 Bytes';
        const k = 1024;
        const dm = decimals < 0 ? 0 : decimals;
        const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
        const i = Math.floor(Math.log(bytes) / Math.log(k));
        return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
    }
};

// Export for potential module usage
if (typeof module !== 'undefined' && module.exports) {
    module.exports = TechForgeUtils;
}