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
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
// The 1975 Website JavaScript

document.addEventListener('DOMContentLoaded', () => {
    // Initialize Lucide Icons
    lucide.createIcons();

    // Mobile Menu Toggle
    const mobileMenuBtn = document.getElementById('mobile-menu-btn');
    const mobileMenu = document.getElementById('mobile-menu');

    if (mobileMenuBtn && mobileMenu) {
        mobileMenuBtn.addEventListener('click', () => {
            mobileMenu.classList.toggle('hidden');
            const icon = mobileMenuBtn.querySelector('i');
            if (mobileMenu.classList.contains('hidden')) {
                icon.setAttribute('data-lucide', 'menu');
            } else {
                icon.setAttribute('data-lucide', 'x');
            }
            lucide.createIcons();
        });
    }

    // Music Player Functionality
    const playPauseBtn = document.getElementById('play-pause-btn');
    const playIcon = document.getElementById('play-icon');
    const audioPlayer = document.getElementById('audio-player');
    const progressBar = document.getElementById('progress-bar');
    const progressContainer = document.getElementById('progress-container');
    const currentTimeEl = document.getElementById('current-time');
    const durationEl = document.getElementById('duration');
    const volumeSlider = document.getElementById('volume-slider');
    const prevBtn = document.getElementById('prev-btn');
    const nextBtn = document.getElementById('next-btn');
    
    let isPlaying = false;
    
    // Track list - update with your own audio files
    const tracks = [
        { title: "Happiness", artist: "The 1975 • BFIAFL", src: "music/happiness.mp3" },
        { title: "Looking For Somebody (To Love)", artist: "The 1975 • BFIAFL", src: "music/looking-for-somebody.mp3" },
        { title: "Part of the Band", artist: "The 1975 • BFIAFL", src: "music/part-of-the-band.mp3" },
        { title: "About You", artist: "The 1975 • BFIAFL", src: "music/about-you.mp3" },
        { title: "I'm In Love With You", artist: "The 1975 • BFIAFL", src: "music/im-in-love-with-you.mp3" }
    ];
    let currentTrackIndex = 0;

    // Format time in minutes:seconds
    const formatTime = (seconds) => {
        if (isNaN(seconds)) return "0:00";
        const mins = Math.floor(seconds / 60);
        const secs = Math.floor(seconds % 60);
        return `${mins}:${secs.toString().padStart(2, '0')}`;
    };

    // Load track
    const loadTrack = (index) => {
        if (index < 0 || index >= tracks.length) return;
        currentTrackIndex = index;
        audioPlayer.src = tracks[index].src;
        audioPlayer.load();
        
        const titleEl = document.getElementById('track-title');
        if (titleEl) {
            titleEl.textContent = tracks[index].title;
            // Update artist text in the next sibling
            const artistEl = titleEl.nextElementSibling;
            if (artistEl) artistEl.textContent = tracks[index].artist;
        }
        
        if (isPlaying) {
            audioPlayer.play().catch(e => console.error('Auto-play failed:', e));
        }
    };
    
    // Initialize first track on page load
    loadTrack(0);

    // Play/Pause functionality
    if (playPauseBtn && audioPlayer) {
        playPauseBtn.addEventListener('click', async () => {
            try {
                if (isPlaying) {
                    audioPlayer.pause();
                    isPlaying = false;
                    // Re-query the icon element since lucide replaces it with SVG
                    const currentIcon = playPauseBtn.querySelector('i, svg');
                    if (currentIcon) {
                        currentIcon.setAttribute('data-lucide', 'play');
                        currentIcon.innerHTML = ''; // Clear SVG content
                    }
                    playPauseBtn.classList.remove('animate-pulse');
                    // Remove visualizer
                    const visualizer = document.getElementById('audio-visualizer');
                    if (visualizer) visualizer.remove();
                } else {
                    // Ensure we have a track loaded
                    if (!audioPlayer.src || audioPlayer.src === window.location.href) {
                        loadTrack(0);
                    }
                    
                    const playPromise = audioPlayer.play();
                    if (playPromise !== undefined) {
                        await playPromise;
                        isPlaying = true;
                        // Re-query the icon element
                        const currentIcon = playPauseBtn.querySelector('i, svg');
                        if (currentIcon) {
                            currentIcon.setAttribute('data-lucide', 'pause');
                            currentIcon.innerHTML = ''; // Clear SVG content
                        }
                        playPauseBtn.classList.add('animate-pulse');
                        // Add visualizer
                        const playerControls = playPauseBtn.closest('.flex').querySelector('.flex.items-center.gap-4');
                        if (playerControls && !document.getElementById('audio-visualizer')) {
                            const visualizer = createVisualizer();
                            playerControls.appendChild(visualizer);
                        }
                    }
                }
                lucide.createIcons();
            } catch (error) {
                console.error('Playback failed:', error);
                alert('Audio playback failed. Please try again or check your browser permissions.');
            }
        });
    }

    // Update progress bar and time
    if (audioPlayer) {
        audioPlayer.addEventListener('timeupdate', () => {
            if (audioPlayer.duration) {
                const progress = (audioPlayer.currentTime / audioPlayer.duration) * 100;
                progressBar.style.width = `${progress}%`;
                currentTimeEl.textContent = formatTime(audioPlayer.currentTime);
            }
        });

        // Update duration when metadata loaded
        audioPlayer.addEventListener('loadedmetadata', () => {
            durationEl.textContent = formatTime(audioPlayer.duration);
        });

        // Handle track ended
        audioPlayer.addEventListener('ended', () => {
            isPlaying = false;
            playIcon.setAttribute('data-lucide', 'play');
            playPauseBtn.classList.remove('animate-pulse');
            progressBar.style.width = '0%';
            lucide.createIcons();
            
            // Auto play next track
            setTimeout(() => {
                let nextTrack = (currentTrackIndex + 1) % tracks.length;
                loadTrack(nextTrack);
                audioPlayer.play();
                isPlaying = true;
                playIcon.setAttribute('data-lucide', 'pause');
                playPauseBtn.classList.add('animate-pulse');
                lucide.createIcons();
            }, 1000);
        });

        // Click on progress bar to seek
        if (progressContainer) {
            progressContainer.addEventListener('click', (e) => {
                const rect = progressContainer.getBoundingClientRect();
                const pos = (e.clientX - rect.left) / rect.width;
                audioPlayer.currentTime = pos * audioPlayer.duration;
            });
        }

        // Volume control
        if (volumeSlider) {
            volumeSlider.addEventListener('input', (e) => {
                audioPlayer.volume = e.target.value / 100;
            });
            // Set initial volume
            audioPlayer.volume = 0.7;
        }
    }

    // Previous/Next buttons
    if (prevBtn) {
        prevBtn.addEventListener('click', async () => {
            let prevIndex = (currentTrackIndex - 1 + tracks.length) % tracks.length;
            loadTrack(prevIndex);
            if (isPlaying) {
                try {
                    await audioPlayer.play();
                } catch (e) {
                    console.error('Playback failed:', e);
                }
            }
        });
    }

    if (nextBtn) {
        nextBtn.addEventListener('click', async () => {
            let nextIndex = (currentTrackIndex + 1) % tracks.length;
            loadTrack(nextIndex);
            if (isPlaying) {
                try {
                    await audioPlayer.play();
                } catch (e) {
                    console.error('Playback failed:', e);
                }
            }
        });
    }

    // Add visualizer when playing
    const createVisualizer = () => {
        const visualizer = document.createElement('div');
        visualizer.className = 'flex items-end gap-1 h-8 ml-4 equalizer';
        visualizer.id = 'audio-visualizer';
        
        for (let i = 0; i < 5; i++) {
            const bar = document.createElement('div');
            bar.className = 'w-1 bg-pink-500 rounded-t transition-all duration-150';
            bar.style.height = '20%';
            bar.style.animation = `equalizer 0.8s ease-in-out ${i * 0.1}s infinite`;
            visualizer.appendChild(bar);
        }
        
        return visualizer;
    };

    // Smooth Scroll for Navigation Links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                // Close mobile menu if open
                if (mobileMenu && !mobileMenu.classList.contains('hidden')) {
                    mobileMenu.classList.add('hidden');
                }
                
                target.scrollIntoView({
                    behavior: 'smooth',
                    block: 'start'
                });
            }
        });
    });

    // Navbar Scroll Effect
    const nav = document.querySelector('nav');
    let lastScroll = 0;

    window.addEventListener('scroll', () => {
        const currentScroll = window.pageYOffset;
        
        if (currentScroll > 100) {
            nav.classList.add('shadow-lg');
            nav.classList.add('shadow-pink-500/10');
        } else {
            nav.classList.remove('shadow-lg');
            nav.classList.remove('shadow-pink-500/10');
        }

        // Hide/show nav on scroll direction
        if (currentScroll > lastScroll && currentScroll > 200) {
            nav.style.transform = 'translateY(-100%)';
        } else {
            nav.style.transform = 'translateY(0)';
        }
        
        lastScroll = currentScroll;
    });

    // Intersection Observer for Fade-in 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('opacity-100', 'translate-y-0');
                entry.target.classList.remove('opacity-0', 'translate-y-10');
            }
        });
    }, observerOptions);

    // Observe elements for animation
    document.querySelectorAll('section > div').forEach(section => {
        section.classList.add('transition-all', 'duration-1000', 'opacity-0', 'translate-y-10');
        observer.observe(section);
    });

    // Gallery Image Modal (Simple Implementation)
    const galleryImages = document.querySelectorAll('#gallery img');
    
    galleryImages.forEach(img => {
        img.addEventListener('click', () => {
            // Create modal
            const modal = document.createElement('div');
            modal.className = 'fixed inset-0 z-50 flex items-center justify-center bg-black/95 p-4';
            modal.innerHTML = `
                <div class="relative max-w-4xl w-full">
                    <button class="absolute -top-12 right-0 text-white hover:text-pink-500 transition-colors">
                        <i data-lucide="x" class="w-8 h-8"></i>
                    </button>
                    <img src="${img.src}" alt="${img.alt}" class="w-full h-auto rounded-lg shadow-[0_0_50px_rgba(236,72,153,0.3)]">
                </div>
            `;
            
            document.body.appendChild(modal);
            document.body.style.overflow = 'hidden';
            lucide.createIcons();

            // Close modal
            modal.addEventListener('click', (e) => {
                if (e.target === modal || e.target.closest('button')) {
                    modal.remove();
                    document.body.style.overflow = '';
                }
            });
        });
    });

    // Newsletter Form Validation Enhancement
    const newsletterForm = document.querySelector('form');
    if (newsletterForm) {
        const emailInput = newsletterForm.querySelector('input[type="email"]');
        
        emailInput.addEventListener('focus', () => {
            emailInput.parentElement.classList.add('scale-105');
        });
        
        emailInput.addEventListener('blur', () => {
            emailInput.parentElement.classList.remove('scale-105');
        });
    }

    // Add equalizer animation keyframes (if not already added)
    if (!document.getElementById('equalizer-style')) {
        const style = document.createElement('style');
        style.id = 'equalizer-style';
        style.textContent = `
            @keyframes equalizer {
                0%, 100% { height: 20%; }
                50% { height: 100%; }
            }
        `;
        document.head.appendChild(style);
    }

    // Add visualizer to player when playing
    if (playPauseBtn) {
        playPauseBtn.addEventListener('click', () => {
            const playerContainer = document.querySelector('.bg-black\\\\/50');
            if (!playerContainer) return;
            
            const playerControls = playerContainer.querySelector('.flex.items-center.gap-4');
            if (!playerControls) return;
            
            let visualizer = document.getElementById('audio-visualizer');
            
            if (isPlaying && !visualizer) {
                visualizer = createVisualizer();
                playerControls.appendChild(visualizer);
            } else if (!isPlaying && visualizer) {
                visualizer.remove();
            }
        });
    }

    // Parallax Effect for Hero Section
    window.addEventListener('scroll', () => {
        const scrolled = window.pageYOffset;
        const heroImage = document.querySelector('#home img');
        if (heroImage) {
            heroImage.style.transform = `translateY(${scrolled * 0.5}px)`;
        }
    });

    // Ticket Button Interactions
    document.querySelectorAll('button').forEach(button => {
        if (button.textContent.includes('Tickets') || button.textContent.includes('Get Tickets')) {
            if (!button.disabled) {
                button.addEventListener('click', (e) => {
                    if (!e.target.closest('form')) {
                        // Create ripple effect
                        const ripple = document.createElement('span');
                        ripple.style.cssText = `
                            position: absolute;
                            background: rgba(255,255,255,0.3);
                            border-radius: 50%;
                            transform: scale(0);
                            animation: ripple 0.6s ease-out;
                            pointer-events: none;
                        `;
                        
                        const rect = button.getBoundingClientRect();
                        const size = Math.max(rect.width, rect.height);
                        ripple.style.width = ripple.style.height = size + 'px';
                        ripple.style.left = (e.clientX - rect.left - size/2) + 'px';
                        ripple.style.top = (e.clientY - rect.top - size/2) + 'px';
                        
                        button.style.position = 'relative';
                        button.style.overflow = 'hidden';
                        button.appendChild(ripple);
                        
                        setTimeout(() => ripple.remove(), 600);
                        
                        // Show coming soon popup for demo
                        if (!button.classList.contains('opacity-50')) {
                            alert('Ticket purchase would open in a new window. This is a demo site.');
                        }
                    }
                });
            }
        }
    });

    // Add ripple animation keyframes
    const rippleStyle = document.createElement('style');
    rippleStyle.textContent = `
        @keyframes ripple {
            to {
                transform: scale(4);
                opacity: 0;
            }
        }
    `;
    document.head.appendChild(rippleStyle);
});