File size: 5,195 Bytes
93e8869
8768677
 
 
 
 
 
 
b4d7faf
 
 
 
 
 
 
 
 
 
 
 
 
8768677
 
b4d7faf
 
 
8768677
93e8869
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8768677
 
 
 
 
 
 
 
 
93e8869
 
 
 
 
 
 
 
 
 
 
 
 
f7e7f38
b4d7faf
 
bdf91d1
b4d7faf
 
f7e7f38
b4d7faf
 
 
 
bdf91d1
b4d7faf
 
f7e7f38
b4d7faf
 
 
bdf91d1
b4d7faf
 
f7e7f38
b4d7faf
 
 
 
bdf91d1
b4d7faf
 
f7e7f38
b4d7faf
 
bdf91d1
b4d7faf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93e8869
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

document.addEventListener('DOMContentLoaded', () => {
    // Smooth scroll for any anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
    // Smooth scrolling for navigation links
    document.querySelectorAll('nav a').forEach(anchor => {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            const targetId = this.getAttribute('href');
            if (targetId.startsWith('#')) {
                const targetElement = document.querySelector(targetId);
                if (targetElement) {
                    targetElement.scrollIntoView({
                        behavior: 'smooth'
                    });
                }
            }
        });
    });
});
});
    });

    // Mobile menu toggle
    const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
    const nav = document.querySelector('nav');
    
    if (mobileMenuBtn && nav) {
        mobileMenuBtn.addEventListener('click', () => {
            nav.classList.toggle('show');
            const icon = mobileMenuBtn.querySelector('i');
            if (nav.classList.contains('show')) {
                feather.icons.x.toSvg().then(svg => icon.outerHTML = svg);
            } else {
                feather.icons.menu.toSvg().then(svg => icon.outerHTML = svg);
            }
        });
    }

    // Handle feather icons replacement after dynamic content changes
    const observer = new MutationObserver(() => {
        feather.replace();
    });
    
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Adjust layout for mobile
    function handleResize() {
        if (window.innerWidth > 1024 && nav) {
            nav.classList.remove('show');
            const icon = mobileMenuBtn?.querySelector('i');
            if (icon) {
                feather.icons.menu.toSvg().then(svg => icon.outerHTML = svg);
            }
        }
    }
    window.addEventListener('resize', handleResize);
    handleResize();
    // Search functionality
    document.addEventListener('click', (e) => {
        // Handle search toggle
        if (e.target.closest('.search-toggle') || e.target.closest('.search-toggle svg')) {
            e.preventDefault();
            document.querySelector('.search-overlay').classList.remove('hidden');
            document.body.style.overflow = 'hidden';
            document.querySelector('.search-overlay input').focus();
        }
        
        // Handle search close
        if (e.target.closest('.search-close') || e.target.closest('.search-close svg')) {
            e.preventDefault();
            document.querySelector('.search-overlay').classList.add('hidden');
            document.body.style.overflow = '';
        }
        
        // Handle auth toggle
        if (e.target.closest('.auth-toggle') || e.target.closest('.auth-toggle svg')) {
            e.preventDefault();
            document.querySelector('.auth-overlay').classList.remove('hidden');
            document.body.style.overflow = 'hidden';
            document.querySelector('#email')?.focus();
        }
        
        // Handle auth close
        if (e.target.closest('.auth-close') || e.target.closest('.auth-close svg')) {
            e.preventDefault();
            document.querySelector('.auth-overlay').classList.add('hidden');
            document.body.style.overflow = '';
        }
    });
// Close overlays when clicking outside
    document.addEventListener('click', (e) => {
        const searchOverlay = document.querySelector('.search-overlay');
        const authOverlay = document.querySelector('.auth-overlay');
        
        if (searchOverlay && !searchOverlay.classList.contains('hidden')) {
            if (!e.target.closest('.search-overlay > div') && !e.target.closest('.search-toggle')) {
                searchOverlay.classList.add('hidden');
                document.body.style.overflow = '';
            }
        }
        
        if (authOverlay && !authOverlay.classList.contains('hidden')) {
            if (!e.target.closest('.auth-overlay > div') && !e.target.closest('.auth-toggle')) {
                authOverlay.classList.add('hidden');
                document.body.style.overflow = '';
            }
        }
    });

    // Handle escape key to close overlays
    document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape') {
            const searchOverlay = document.querySelector('.search-overlay');
            const authOverlay = document.querySelector('.auth-overlay');
            
            if (searchOverlay && !searchOverlay.classList.contains('hidden')) {
                searchOverlay.classList.add('hidden');
                document.body.style.overflow = '';
            }
            
            if (authOverlay && !authOverlay.classList.contains('hidden')) {
                authOverlay.classList.add('hidden');
                document.body.style.overflow = '';
            }
        }
    });
});