File size: 6,214 Bytes
017867a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// TrendBlitz Privacy Policy - Interactive Features

document.addEventListener('DOMContentLoaded', function() {
    // Set current date
    const currentDateEl = document.getElementById('currentDate');
    if (currentDateEl) {
        const now = new Date();
        const options = { year: 'numeric', month: 'long', day: 'numeric' };
        currentDateEl.textContent = now.toLocaleDateString('en-US', options);
    }

    // Set footer year
    const footerYearEl = document.getElementById('footerYear');
    if (footerYearEl) {
        footerYearEl.textContent = new Date().getFullYear();
    }

    // Theme toggle functionality
    const themeToggle = document.getElementById('themeToggle');
    const body = document.body;
    const html = document.documentElement;

    // Check for saved theme preference or default to 'light'
    const currentTheme = localStorage.getItem('theme') || 'light';
    if (currentTheme === 'dark') {
        html.classList.add('dark');
        body.classList.remove('bg-slate-50', 'text-slate-800');
        body.classList.add('bg-slate-900', 'text-slate-100');
        updateThemeIcon('dark');
    }

    themeToggle.addEventListener('click', function() {
        const isDark = html.classList.contains('dark');
        
        if (isDark) {
            // Switch to light
            html.classList.remove('dark');
            body.classList.remove('bg-slate-900', 'text-slate-100');
            body.classList.add('bg-slate-50', 'text-slate-800');
            localStorage.setItem('theme', 'light');
            updateThemeIcon('light');
        } else {
            // Switch to dark
            html.classList.add('dark');
            body.classList.remove('bg-slate-50', 'text-slate-800');
            body.classList.add('bg-slate-900', 'text-slate-100');
            localStorage.setItem('theme', 'dark');
            updateThemeIcon('dark');
        }

        // Re-initialize Feather icons after theme change
        if (typeof feather !== 'undefined') {
            feather.replace();
        }
    });

    function updateThemeIcon(theme) {
        const icon = themeToggle.querySelector('i');
        if (theme === 'dark') {
            icon.setAttribute('data-feather', 'sun');
        } else {
            icon.setAttribute('data-feather', 'moon');
        }
    }

    // Smooth scroll for anchor links with offset for fixed header
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            const targetId = this.getAttribute('href');
            if (targetId === '#') return;
            
            const targetElement = document.querySelector(targetId);
            if (targetElement) {
                const headerOffset = 100;
                const elementPosition = targetElement.getBoundingClientRect().top;
                const offsetPosition = elementPosition + window.pageYOffset - headerOffset;

                window.scrollTo({
                    top: offsetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });

    // Highlight active section in navigation
    const sections = document.querySelectorAll('section[id]');
    const navLinks = document.querySelectorAll('nav a[href^="#"]');

    function highlightActiveSection() {
        const scrollPos = window.scrollY + 150;

        sections.forEach(section => {
            const sectionTop = section.offsetTop;
            const sectionHeight = section.offsetHeight;
            const sectionId = section.getAttribute('id');

            if (scrollPos >= sectionTop && scrollPos < sectionTop + sectionHeight) {
                navLinks.forEach(link => {
                    link.classList.remove('bg-primary-100', 'text-primary-700');
                    if (link.getAttribute('href') === `#${sectionId}`) {
                        link.classList.add('bg-primary-100', 'text-primary-700');
                    }
                });
            }
        });
    }

    window.addEventListener('scroll', highlightActiveSection);

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

    const fadeInObserver = 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-4');
            }
        });
    }, observerOptions);

    // Observe all sections for fade-in effect
    document.querySelectorAll('section').forEach((section, index) => {
        section.classList.add('transition-all', 'duration-500', 'opacity-0', 'translate-y-4');
        section.style.transitionDelay = `${index * 50}ms`;
        fadeInObserver.observe(section);
    });

    // Copy email to clipboard functionality
    const emailLink = document.querySelector('a[href^="mailto:hello@moneyed28.com"]');
    if (emailLink) {
        emailLink.addEventListener('click', function(e) {
            // Don't prevent default, just add a subtle feedback
            const originalText = this.innerHTML;
            this.innerHTML = `<i data-feather="check" class="w-4 h-4"></i> Email copied!`;
            feather.replace();
            
            setTimeout(() => {
                this.innerHTML = originalText;
                feather.replace();
            }, 2000);
        });
    }

    // Keyboard navigation enhancement
    document.addEventListener('keydown', function(e) {
        // Press 'T' to toggle theme
        if (e.key === 't' && !e.ctrlKey && !e.metaKey && !e.altKey) {
            if (document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {
                themeToggle.click();
            }
        }
    });

    // Console easter egg
    console.log('%c🔒 TrendBlitz Privacy Policy', 'font-size: 20px; font-weight: bold; color: #6366f1;');
    console.log('%cYour privacy matters to us. Read our full policy at https://trendblitz.app/privacy', 'font-size: 12px; color: #64748b;');
});