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
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
// Generation Bridge Wiki - Main JavaScript

// Mock data for terms
const termsData = [
    {
        id: 1,
        term: "No Cap",
        generation: "genz",
        meaning: "No lie, for real, truthfully",
        example: "This pizza is the best, no cap!",
        category: "slang",
        popularity: 95,
        tags: ["truth", "honesty", "slang"]
    },
    {
        id: 2,
        term: "Lit",
        generation: "millennial",
        meaning: "Amazing, exciting, fun",
        example: "That party was so lit last night!",
        category: "slang",
        popularity: 85,
        tags: ["fun", "exciting", "awesome"]
    },
    {
        id: 3,
        term: "Groovy",
        generation: "boomer",
        meaning: "Cool, fashionable, or pleasant",
        example: "That music is really groovy!",
        category: "slang",
        popularity: 60,
        tags: ["cool", "music", "vintage"]
    },
    {
        id: 4,
        term: "Slay",
        generation: "genz",
        meaning: "To do something exceptionally well",
        example: "You absolutely slayed that presentation!",
        category: "slang",
        popularity: 98,
        tags: ["success", "fashion", "performance"]
    },
    {
        id: 5,
        term: "Whatever",
        generation: "genx",
        meaning: "Indifference, dismissive",
        example: "You don't like my idea? Whatever.",
        category: "attitude",
        popularity: 70,
        tags: ["indifferent", "sarcastic", "dismissive"]
    },
    {
        id: 6,
        term: "Bussin",
        generation: "genz",
        meaning: "Really good, especially food",
        example: "This burger is bussin!",
        category: "food",
        popularity: 88,
        tags: ["food", "delicious", "good"]
    },
    {
        id: 7,
        term: "Rad",
        generation: "genx",
        meaning: "Radical, excellent, cool",
        example: "That skateboard trick was rad!",
        category: "slang",
        popularity: 65,
        tags: ["cool", "awesome", "extreme"]
    },
    {
        id: 8,
        term: "Skibidi",
        generation: "genalpha",
        meaning: "Fun, silly, nonsensical (from YouTube series)",
        example: "Skibidi toilet is so funny!",
        category: "meme",
        popularity: 75,
        tags: ["meme", "funny", "youtube"]
    },
    {
        id: 9,
        term: "Adulting",
        generation: "millennial",
        meaning: "Doing adult responsibilities",
        example: "I spent my Saturday doing taxes, adulting is hard.",
        category: "lifestyle",
        popularity: 90,
        tags: ["responsibility", "growing up", "life"]
    },
    {
        id: 10,
        term: "Bet",
        generation: "genz",
        meaning: "Okay, agreement, or confirmation",
        example: "Want to hang out later? Bet.",
        category: "slang",
        popularity: 92,
        tags: ["agreement", "yes", "cool"]
    },
    {
        id: 11,
        term: "FOMO",
        generation: "millennial",
        meaning: "Fear Of Missing Out",
        example: "I have serious FOMO seeing everyone's vacation photos.",
        category: "psychology",
        popularity: 88,
        tags: ["anxiety", "social", "missing out"]
    },
    {
        id: 12,
        term: "Cool Beans",
        generation: "genx",
        meaning: "Agreeable, good idea",
        example: "Want to grab pizza? Cool beans!",
        category: "slang",
        popularity: 55,
        tags: ["agreement", "casual", "friendly"]
    }
];

// Translation dictionary
const translationDictionary = {
    "awesome": { boomer: "groovy", genx: "rad", millennial: "lit", genz: "slaps" },
    "cool": { boomer: "hip", genx: "cool", millennial: "chill", genz: "fire" },
    "great": { boomer: "fabulous", genx: "excellent", millennial: "amazing", genz: "bussin" },
    "bad": { boomer: "bummer", genx: "lame", millennial: "trash", genz: "mid" },
    "friend": { boomer: "pal", genx: "buddy", millennial: "homie", genz: "fam" },
    "very": { boomer: "real", genx: "totally", millennial: "super", genz: "lowkey" },
    "yes": { boomer: "right on", genx: "for sure", millennial: "absolutely", genz: "bet" }
};

// DOM Elements
let searchInput, featuredTermsContainer, translateBtn, translateInput, 
    fromGenSelect, toGenSelect, translationResult, translatedText, 
    translationContext, generationButtons;

// Initialize the app
document.addEventListener('DOMContentLoaded', () => {
    initializeElements();
    setupEventListeners();
    loadFeaturedTerms();
});

function initializeElements() {
    searchInput = document.getElementById('mainSearch');
    featuredTermsContainer = document.getElementById('featuredTerms');
    translateBtn = document.getElementById('translateBtn');
    translateInput = document.getElementById('translateInput');
    fromGenSelect = document.getElementById('fromGen');
    toGenSelect = document.getElementById('toGen');
    translationResult = document.getElementById('translationResult');
    translatedText = document.getElementById('translatedText');
    translationContext = document.getElementById('translationContext');
    generationButtons = document.querySelectorAll('.generation-btn');
}

function setupEventListeners() {
    // Search functionality
    searchInput.addEventListener('input', handleSearch);
    searchInput.addEventListener('keypress', (e) => {
        if (e.key === 'Enter') {
            performSearch();
        }
    });

    // Translation
    translateBtn.addEventListener('click', performTranslation);
    translateInput.addEventListener('keypress', (e) => {
        if (e.key === 'Enter' && e.ctrlKey) {
            performTranslation();
        }
    });

    // Generation buttons
    generationButtons.forEach(btn => {
        btn.addEventListener('click', () => {
            const gen = btn.dataset.gen;
            filterByGeneration(gen);
        });
    });

    // Navbar interactions
    document.addEventListener('click', (e) => {
        if (e.target.matches('[data-action]')) {
            handleNavbarAction(e.target.dataset.action);
        }
    });
}

function loadFeaturedTerms() {
    // Sort by popularity and get top terms
    const topTerms = [...termsData]
        .sort((a, b) => b.popularity - a.popularity)
        .slice(0, 9);

    featuredTermsContainer.innerHTML = topTerms.map(term => createTermCard(term)).join('');
    
    // Re-initialize feather icons for new content
    if (typeof feather !== 'undefined') {
        feather.replace();
    }
}

function createTermCard(term) {
    const generationColors = {
        boomer: 'from-blue-500/30 to-blue-600/30',
        genx: 'from-purple-500/30 to-purple-600/30',
        millennial: 'from-pink-500/30 to-pink-600/30',
        genz: 'from-orange-500/30 to-orange-600/30',
        genalpha: 'from-green-500/30 to-teal-600/30'
    };

    const generationEmojis = {
        boomer: 'πŸ‘΄',
        genx: '🎸',
        millennial: 'πŸ“±',
        genz: 'πŸ’«',
        genalpha: 'πŸš€'
    };

    return `
        <div class="term-card" data-term-id="${term.id}">
            <div class="flex items-start justify-between mb-4">
                <span class="px-3 py-1 rounded-full text-xs font-bold bg-gradient-to-r ${generationColors[term.generation]} border border-white/20 backdrop-blur-sm">
                    ${generationEmojis[term.generation]} ${term.generation.toUpperCase()}
                </span>
                <div class="flex items-center text-sm text-gray-300">
                    <i data-feather="trending-up" class="w-4 h-4 mr-1 text-green-400"></i>
                    ${term.popularity}%
                </div>
            </div>
            
            <h3 class="text-2xl font-bold mb-2 text-white">${term.term}</h3>
            <p class="text-gray-300 mb-3">${term.meaning}</p>
            
            <div class="bg-white/5 p-3 rounded-lg mb-4 border border-white/10">
                <p class="text-sm text-gray-200 italic">"${term.example}"</p>
            </div>
            
            <div class="flex flex-wrap gap-2">
                ${term.tags.map(tag => `
                    <span class="px-2 py-1 bg-white/10 rounded-full text-xs text-gray-300 hover:bg-white/20 transition-colors cursor-pointer">
                        #${tag}
                    </span>
                `).join('')}
            </div>
            
            <button class="mt-4 w-full py-2 bg-gradient-to-r from-purple-500/30 to-pink-500/30 rounded-lg 
                           hover:from-purple-500/50 hover:to-pink-500/50 transition-all duration-300 text-sm font-bold"
                    onclick="showTermDetails(${term.id})">
                Learn More
            </button>
        </div>
    `;
}

function handleSearch(e) {
    const query = e.target.value.toLowerCase().trim();
    
    if (query.length === 0) {
        loadFeaturedTerms();
        return;
    }

    const filteredTerms = termsData.filter(term => 
        term.term.toLowerCase().includes(query) ||
        term.meaning.toLowerCase().includes(query) ||
        term.tags.some(tag => tag.toLowerCase().includes(query))
    );

    featuredTermsContainer.innerHTML = filteredTerms.map(term => createTermCard(term)).join('');
    feather.replace();
}

function performSearch() {
    const query = searchInput.value.trim();
    if (query) {
        console.log('Searching for:', query);
        // Could implement advanced search or redirect to search results page
    }
}

function filterByGeneration(generation) {
    const filteredTerms = termsData.filter(term => term.generation === generation);
    featuredTermsContainer.innerHTML = filteredTerms.map(term => createTermCard(term)).join('');
    feather.replace();
    
    // Update active state
    generationButtons.forEach(btn => {
        if (btn.dataset.gen === generation) {
            btn.classList.add('ring-4', 'ring-purple-400/40');
        } else {
            btn.classList.remove('ring-4', 'ring-purple-400/40');
        }
    });

    // Scroll to terms section
    document.getElementById('featuredTerms').scrollIntoView({ behavior: 'smooth' });
}

function performTranslation() {
    const input = translateInput.value.trim().toLowerCase();
    const fromGen = fromGenSelect.value;
    const toGen = toGenSelect.value;

    if (!input) {
        showTranslationError('Please enter a phrase to translate');
        return;
    }

    if (fromGen === toGen) {
        showTranslationError('Please select different generations');
        return;
    }

    // Simple translation logic - could be enhanced with a proper dictionary
    let translated = input;
    let context = '';

    // Check for common words in our dictionary
    Object.keys(translationDictionary).forEach(word => {
        if (input.includes(word)) {
            const replacement = translationDictionary[word][toGen];
            translated = translated.replace(new RegExp(word, 'g'), replacement);
            context += ` "${word}" β†’ "${replacement}"`;
        }
    });

    // Add generation-specific context
    const contexts = {
        boomer: "This phrase reflects Boomer values of authenticity and straightforwardness",
        genx: "Gen X expressions often carry a tone of rebellion and independence",
        millennial: "Millennial phrases blend digital culture with ironic humor",
        genz: "Gen Z language is fast-evolving and heavily influenced by social media"
    };

    translatedText.textContent = translated.charAt(0).toUpperCase() + translated.slice(1);
    translationContext.textContent = `Based on ${fromGen.toUpperCase()} β†’ ${toGen.toUpperCase()} translation.${context ? ' Translated:' + context : ''} ${contexts[toGen] || ''}`;
    
    translationResult.classList.remove('hidden', 'border-red-500/30', 'bg-red-500/10');
    translationResult.classList.add('border-green-500/30', 'bg-green-500/10');
    translationResult.scrollIntoView({ behavior: 'smooth' });
}

function showTranslationError(message) {
    translatedText.textContent = message;
    translationContext.textContent = 'Please check your input and try again.';
    
    translationResult.classList.remove('hidden', 'border-green-500/30', 'bg-green-500/10');
    translationResult.classList.add('border-red-500/30', 'bg-red-500/10');
}

function showTermDetails(termId) {
    const term = termsData.find(t => t.id === termId);
    if (term) {
        console.log('Showing details for:', term);
        // Could open modal or navigate to detail page
        alert(`${term.term}\n\nMeaning: ${term.meaning}\n\nExample: "${term.example}"\n\nPopularity: ${term.popularity}%`);
    }
}

function handleNavbarAction(action) {
    switch(action) {
        case 'home':
            window.scrollTo({ top: 0, behavior: 'smooth' });
            break;
        case 'search':
            searchInput.focus();
            break;
        case 'submit':
            alert('Submit feature coming soon!');
            break;
        case 'stories':
            alert('Stories feature coming soon!');
            break;
        case 'about':
            alert('About section coming soon!');
            break;
    }
}

// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
    // Ctrl/Cmd + K for search
    if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
        e.preventDefault();
        searchInput.focus();
    }
    
    // Escape to clear search
    if (e.key === 'Escape') {
        if (document.activeElement === searchInput) {
            searchInput.value = '';
            searchInput.blur();
            loadFeaturedTerms();
        }
    }
});

// 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.style.opacity = '1';
            entry.target.style.transform = 'translateY(0)';
        }
    });
}, observerOptions);

// Observe all term cards
setTimeout(() => {
    document.querySelectorAll('.term-card').forEach(card => {
        card.style.opacity = '0';
        card.style.transform = 'translateY(20px)';
        card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
        observer.observe(card);
    });
}, 100);