File size: 24,354 Bytes
fb1bb39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
// Translations
const translations = {
    en: {
        tagline: "The frontier calls. Your legend awaits.",
        watchTrailer: "Watch Trailer",
        preOrder: "Pre-Order Now",
        storySubtitle: "The Next Chapter",
        storyTitle: "A New Legend<br>Rises from the Ashes",
        storyText1: "The year is 1912. The Wild West is dying, but its spirit refuses to fade. In the untamed territories of the Pacific Northwest, a new generation of outlaws, lawmen, and dreamers clash in the final golden days of the frontier.",
        storyText2: "Play as Elena \"Raven\" Blackwood, a former Pinkerton detective turned outlaw, navigating a world where civilization encroaches and the old ways crumble. Your choices will forge a legacy that echoes through generations.",
        year: "Year",
        protagonists: "Protagonists",
        possibilities: "Possibilities",
        newTerritories: "New Territories",
        dynamicGang: "Dynamic Gang",
        featuresSubtitle: "Experience",
        featuresTitle: "The Evolution of Open World",
        feature1Title: "Living Ecosystem",
        feature1Desc: "Every animal, plant, and weather pattern evolves dynamically. Witness seasons change, herds migrate, and settlements grow or wither based on your actions.",
        feature2Title: "Deep Reputation",
        feature2Desc: "Your legend spreads through word of mouth. Bounty hunters, admirers, and enemies react to your deeds in complex, unpredictable ways.",
        feature3Title: "Dead Eye Evolution",
        feature3Desc: "Master the enhanced Dead Eye system with new abilities: predictive targeting, environmental exploitation, and tactical time manipulation.",
        feature4Title: "Homestead Building",
        feature4Desc: "Construct and customize your own ranch. Hire hands, defend against raids, and build a legacy that outlives your character.",
        feature5Title: "Seamless Multiplayer",
        feature5Desc: "Friends can drop into your world at any moment. Form posses, compete in frontier sports, or build thriving communities together.",
        feature6Title: "Dynamic Score",
        feature6Desc: "The music responds to your journey. Original compositions blend with procedural elements to create a unique soundtrack for every player.",
        gallerySubtitle: "Visual Journey",
        galleryTitle: "The World Awaits",
        gallery1Title: "Cascade Mountains",
        gallery1Desc: "Untamed wilderness of the Pacific Northwest",
        gallery2Title: "Prosperity Falls",
        gallery2Desc: "A boomtown on the edge of civilization",
        gallery3Title: "Night Camp",
        gallery3Desc: "Stories shared under starlit skies",
        gallery4Title: "The Rusty Spur",
        gallery4Desc: "Where deals are made and secrets kept",
        ctaSubtitle: "Coming 2025",
        ctaTitle: "Secure Your Place in History",
        ctaText: "Pre-order now to receive exclusive in-game content: the War Horse, the Eagle Eye outfit, and early access to the online mode.",
        standardEdition: "Standard",
        specialEdition: "Special",
        ultimateEdition: "Ultimate",
        baseGame: "Base Game",
        preOrderBonus: "Pre-Order Bonus",
        storyDLC: "Story DLC",
        exclusiveItems: "Exclusive Items",
        allContent: "All Content",
        seasonPass: "Season Pass",
        collectibles: "Collectibles",
        mostPopular: "Most Popular",
        select: "Select",
        instantAccess: "Instant Access",
        securePayment: "Secure Payment",
        cancelAnytime: "Cancel Anytime",
        navStory: "Story",
        navFeatures: "Features",
        navGallery: "Gallery",
        navPreOrder: "Pre-Order",
        footerLegal: "Red Dead Redemption is a trademark of Rockstar Games. All rights reserved.",
        footerSocial: "Follow Us"
    },
    ru: {
        tagline: "Фронтир зовет. Ваша легенда ждет.",
        watchTrailer: "Смотреть трейлер",
        preOrder: "Предзаказ",
        storySubtitle: "Новая глава",
        storyTitle: "Новая легенда<br>восстает из пепла",
        storyText1: "1912 год. Дикий Запад умирает, но его дух не хочет угасать. В неукротимых землях Тихоокеанского Северо-Запада новое поколение преступников, законников и мечтателей сражается в последние золотые дни фронтира.",
        storyText2: "Играйте за Елену \"Ворону\" Блэквуд, бывшую детективку Пинкертона, ставшую преступницей, в мире, где цивилизация наступает, а старые порядки рушатся. Ваши решения создадут наследие, которое отзовется в веках.",
        year: "Год",
        protagonists: "Протагонисты",
        possibilities: "Возможности",
        newTerritories: "Новые территории",
        dynamicGang: "Динамическая банда",
        featuresSubtitle: "Опыт",
        featuresTitle: "Эволюция открытого мира",
        feature1Title: "Живая экосистема",
        feature1Desc: "Каждое животное, растение и погодный паттерн развивается динамично. Наблюдайте за сменой сезонов, миграцией стад и ростом или упадком поселений в зависимости от ваших действий.",
        feature2Title: "Глубокая репутация",
        feature2Desc: "Ваша легенда распространяется из уст в уста. Охотники за головами, поклонники и враги реагируют на ваши поступки сложными, непредсказуемыми способами.",
        feature3Title: "Эволюция Мертвого Глаза",
        feature3Desc: "Овладейте улучшенной системой Мертвого Глаза с новыми способностями: предиктивное прицеливание, использование окружения и тактическая манипуляция временем.",
        feature4Title: "Строительство ранчо",
        feature4Desc: "Стройте и настраивайте собственное ранчо. Нанимайте помощников, защищайтесь от набегов и создавайте наследие, которое переживет вашего персонажа.",
        feature5Title: "Бесшовный мультиплеер",
        feature5Desc: "Друзья могут присоединиться к вашему миру в любой момент. Формируйте отряды, соревнуйтесь в фронтирных видах спорта или стройте процветающие сообщества вместе.",
        feature6Title: "Динамический саундтрек",
        feature6Desc: "Музыка реагирует на ваше путешествие. Оригинальные композиции сочетаются с процедурными элементами, создавая уникальный саундтрек для каждого игрока.",
        gallerySubtitle: "Визуальное путешествие",
        galleryTitle: "Мир ждет",
        gallery1Title: "Каскадные горы",
        gallery1Desc: "Неукротимая пустошь Тихоокеанского Северо-Запада",
        gallery2Title: "Просперити Фоллс",
        gallery2Desc: "Бумтаун на краю цивилизации",
        gallery3Title: "Ночной лагерь",
        gallery3Desc: "Истории под звездным небом",
        gallery4Title: "Ржавый Шпор",
        gallery4Desc: "Где заключают сделки и хранят секреты",
        ctaSubtitle: "Выходит в 2025",
        ctaTitle: "Займите свое место в истории",
        ctaText: "Оформите предзаказ сейчас, чтобы получить эксклюзивный контент: Боевого коня, наряд Орлиный Глаз и ранний доступ к онлайн-режиму.",
        standardEdition: "Стандартное",
        specialEdition: "Специальное",
        ultimateEdition: "Максимальное",
        baseGame: "Базовая игра",
        preOrderBonus: "Бонус предзаказа",
        storyDLC: "Сюжетное DLC",
        exclusiveItems: "Эксклюзивные предметы",
        allContent: "Весь контент",
        seasonPass: "Сезонный пропуск",
        collectibles: "Коллекционное",
        mostPopular: "Популярное",
        select: "Выбрать",
        instantAccess: "Мгновенный доступ",
        securePayment: "Безопасная оплата",
        cancelAnytime: "Отмена в любое время",
        navStory: "Сюжет",
        navFeatures: "Особенности",
        navGallery: "Галерея",
        navPreOrder: "Предзаказ",
        footerLegal: "Red Dead Redemption — товарный знак Rockstar Games. Все права защищены.",
        footerSocial: "Подписывайтесь"
    },
    zh: {
        tagline: "边疆在召唤。你的传奇等待书写。",
        watchTrailer: "观看预告片",
        preOrder: "立即预购",
        storySubtitle: "下一章",
        storyTitle: "新传奇<br>从灰烬中崛起",
        storyText1: "1912年。狂野西部正在消亡,但其精神拒绝消逝。在太平洋西北地区的未驯服领土上,新一代的歹徒、执法者和梦想家在边疆最后的黄金日子里发生冲突。",
        storyText2: "扮演埃琳娜\"乌鸦\"布莱克伍德,一位从前平克顿侦探转变为歹徒的角色,在一个文明入侵、旧秩序崩溃的世界中航行。你的选择将锻造一个代代相传的遗产。",
        year: "年份",
        protagonists: "主角",
        possibilities: "可能性",
        newTerritories: "新领土",
        dynamicGang: "动态帮派",
        featuresSubtitle: "体验",
        featuresTitle: "开放世界的进化",
        feature1Title: "生态系统",
        feature1Desc: "每种动物、植物和天气模式都动态演变。见证季节变化、兽群迁徙,以及根据你的行动而繁荣或衰败的定居点。",
        feature2Title: "深度声望",
        feature2Desc: "你的传奇通过口口相传。赏金猎人、崇拜者和敌人以复杂、不可预测的方式对你的行为做出反应。",
        feature3Title: "死神之眼进化",
        feature3Desc: "掌握增强的死神之眼系统,获得新能力:预测瞄准、环境利用和战术时间操控。",
        feature4Title: "家园建设",
        feature4Desc: "建造和定制你自己的牧场。雇佣帮手,抵御袭击,建立一个超越你角色的遗产。",
        feature5Title: "无缝多人游戏",
        feature5Desc: "朋友可以随时加入你的世界。组建队伍,参加边疆运动,或一起建设繁荣的社区。",
        feature6Title: "动态配乐",
        feature6Desc: "音乐响应你的旅程。原创作品与程序元素相结合,为每位玩家创造独特的配乐。",
        gallerySubtitle: "视觉之旅",
        galleryTitle: "世界在等待",
        gallery1Title: "喀斯喀特山脉",
        gallery1Desc: "太平洋西北的未驯荒野",
        gallery2Title: "繁荣瀑布镇",
        gallery2Desc: "文明边缘的繁荣小镇",
        gallery3Title: "夜间营地",
        gallery3Desc: "星空下分享的故事",
        gallery4Title: "生锈马刺",
        gallery4Desc: "交易达成、秘密保守之地",
        ctaSubtitle: "2025年推出",
        ctaTitle: "在历史中占据一席之地",
        ctaText: "立即预购即可获得独家游戏内容:战马、鹰眼服装和在线模式的抢先体验。",
        standardEdition: "标准版",
        specialEdition: "特别版",
        ultimateEdition: "终极版",
        baseGame: "基础游戏",
        preOrderBonus: "预购奖励",
        storyDLC: "剧情DLC",
        exclusiveItems: "专属物品",
        allContent: "全部内容",
        seasonPass: "季票",
        collectibles: "收藏品",
        mostPopular: "最受欢迎",
        select: "选择",
        instantAccess: "即时访问",
        securePayment: "安全支付",
        cancelAnytime: "随时取消",
        navStory: "剧情",
        navFeatures: "特色",
        navGallery: "画廊",
        navPreOrder: "预购",
        footerLegal: "Red Dead Redemption是Rockstar Games的商标。版权所有。",
        footerSocial: "关注我们"
    }
};

// Current language
let currentLang = 'en';

// Initialize
document.addEventListener('DOMContentLoaded', () => {
    initCustomCursor();
    initDustParticles();
    initParallax();
    initHeroAnimations();
    initScrollAnimations();
    initGallery();
    initLanguageSelector();
    initSmoothScroll();
    initButtonEffects();
    
    // Add grain overlay
    const grain = document.createElement('div');
    grain.className = 'grain-overlay';
    document.body.appendChild(grain);
});

// Custom Cursor
function initCustomCursor() {
    const cursor = document.getElementById('cursor');
    const follower = document.getElementById('cursorFollower');
    
    if (!cursor || !follower || window.matchMedia('(pointer: coarse)').matches) return;
    
    let mouseX = 0, mouseY = 0;
    let cursorX = 0, cursorY = 0;
    let followerX = 0, followerY = 0;
    
    document.addEventListener('mousemove', (e) => {
        mouseX = e.clientX;
        mouseY = e.clientY;
    });
    
    function animate() {
        // Smooth follow
        cursorX += (mouseX - cursorX) * 0.2;
        cursorY += (mouseY - cursorY) * 0.2;
        followerX += (mouseX - followerX) * 0.1;
        followerY += (mouseY - followerY) * 0.1;
        
        cursor.style.transform = `translate(${cursorX - 10}px, ${cursorY - 10}px)`;
        follower.style.transform = `translate(${followerX - 20}px, ${followerY - 20}px)`;
        
        requestAnimationFrame(animate);
    }
    animate();
    
    // Hover effects
    const interactiveElements = document.querySelectorAll('a, button, .feature-card, .gallery-slide, .edition-card');
    interactiveElements.forEach(el => {
        el.addEventListener('mouseenter', () => {
            cursor.style.transform = `translate(${cursorX - 10}px, ${cursorY - 10}px) scale(1.5)`;
            cursor.style.borderColor = '#ef4444';
            follower.style.transform = `translate(${followerX - 20}px, ${followerY - 20}px) scale(1.5)`;
        });
        el.addEventListener('mouseleave', () => {
            cursor.style.transform = `translate(${cursorX - 10}px, ${cursorY - 10}px) scale(1)`;
            cursor.style.borderColor = '#d97706';
            follower.style.transform = `translate(${followerX - 20}px, ${followerY - 20}px) scale(1)`;
        });
    });
}

// Dust Particles
function initDustParticles() {
    const canvas = document.getElementById('dustCanvas');
    if (!canvas) return;
    
    const ctx = canvas.getContext('2d');
    let particles = [];
    const particleCount = 50;
    
    function resize() {
        canvas.width = canvas.offsetWidth;
        canvas.height = canvas.offsetHeight;
    }
    resize();
    window.addEventListener('resize', resize);
    
    class Particle {
        constructor() {
            this.reset();
        }
        
        reset() {
            this.x = Math.random() * canvas.width;
            this.y = Math.random() * canvas.height;
            this.size = Math.random() * 2 + 0.5;
            this.speedX = (Math.random() - 0.5) * 0.3;
            this.speedY = (Math.random() - 0.5) * 0.3;
            this.opacity = Math.random() * 0.5 + 0.1;
        }
        
        update() {
            this.x += this.speedX;
            this.y += this.speedY;
            
            if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
                this.reset();
            }
        }
        
        draw() {
            ctx.fillStyle = `rgba(217, 119, 6, ${this.opacity})`;
            ctx.beginPath();
            ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
            ctx.fill();
        }
    }
    
    for (let i = 0; i < particleCount; i++) {
        particles.push(new Particle());
    }
    
    let frameCount = 0;
    function animate() {
        frameCount++;
        if (frameCount % 2 === 0) { // Render every 2nd frame for performance
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            particles.forEach(p => {
                p.update();
                p.draw();
            });
        }
        requestAnimationFrame(animate);
    }
    animate();
}

// Parallax Effect
function initParallax() {
    const layers = document.querySelectorAll('.parallax-layer');
    
    window.addEventListener('scroll', () => {
        const scrolled = window.pageYOffset;
        
        layers.forEach(layer => {
            const speed = parseFloat(layer.dataset.speed) || 0.5;
            const yPos = -(scrolled * speed);
            layer.style.transform = `translateY(${yPos}px)`;
        });
    });
}

// Hero Animations
function initHeroAnimations() {
    const badge = document.getElementById('heroBadge');
    const title = document.getElementById('heroTitle');
    const tagline = document.getElementById('heroTagline');
    const buttons = document.getElementById('heroButtons');
    
    // Staggered entrance
    setTimeout(() => {
        badge?.classList.add('animate-fade-up');
        badge?.style.setProperty('opacity', '1');
        badge?.style.setProperty('transform', 'translateY(0)');
    }, 300);
    
    setTimeout(() => {
        title?.classList.add('animate-scale-in');
        title?.style.setProperty('opacity', '1');
        title?.style.setProperty('transform', 'scale(1)');
    }, 600);
    
    setTimeout(() => {
        tagline?.classList.add('animate-fade-up');
        tagline?.style.setProperty('opacity', '1');
        tagline?.style.setProperty('transform', 'translateY(0)');
    }, 900);
    
    setTimeout(() => {
        buttons?.classList.add('animate-fade-up');
        buttons?.style.setProperty('opacity', '1');
        buttons?.style.setProperty('transform', 'translateY(0)');
    }, 1200);
}

// Scroll Animations
function initScrollAnimations() {
    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('revealed');
            }
        });
    }, observerOptions);
    
    // Add reveal classes to elements
    document.querySelectorAll('.story-text, .story-visual, .feature-card, .edition-card').forEach((el, i) => {
        el.classList.add('reveal-up');
        el.style.transitionDelay = `${i * 0.1}s`;
        observer.observe(el);
    });
}

// Gallery Slider
function initGallery() {
    const track = document.getElementById('galleryTrack');
    const prevBtn = document.querySelector('.gallery-nav-prev');
    const nextBtn = document.querySelector('.gallery-nav-next');
    
    if (!track || !prevBtn || !nextBtn) return;
    
    let currentIndex = 0;
    const slides = track.querySelectorAll('.gallery-slide');
    const slideWidth = slides[0]?.offsetWidth + 24 || 0; // Including gap
    
    function updateSlider() {
        track.style.transform = `translateX(-${currentIndex * slideWidth}px)`;
    }
    
    prevBtn.addEventListener('click', () => {
        currentIndex = Math.max(0, currentIndex - 1);
        updateSlider();
    });
    
    nextBtn.addEventListener('click', () => {
        currentIndex = Math.min(slides.length - 2, currentIndex + 1);
        updateSlider();
    });
    
    // Touch support
    let startX = 0;
    let isDragging = false;
    
    track.addEventListener('touchstart', (e) => {
        startX = e.touches[0].clientX;
        isDragging = true;
    });
    
    track.addEventListener('touchmove', (e) => {
        if (!isDragging) return;
        const diff = startX - e.touches[0].clientX;
        if (Math.abs(diff) > 50) {
            if (diff > 0 && currentIndex < slides.length - 2) {
                currentIndex++;
            } else if (diff < 0 && currentIndex > 0) {
                currentIndex--;
            }
            updateSlider();
            isDragging = false;
        }
    });
    
    track.addEventListener('touchend', () => {
        isDragging = false;
    });
}

// Language Selector
function initLanguageSelector() {
    const langButtons = document.querySelectorAll('.lang-btn');
    
    langButtons.forEach(btn => {
        btn.addEventListener('click', () => {
            const lang = btn.dataset.lang;
            setLanguage(lang);
            
            // Update active state
            langButtons.forEach(b => {
                b.classList.remove('active', 'text-amber-50', 'border-amber-500');
                b.classList.add('text-amber-500/70', 'border-transparent');
            });
            btn.classList.add('active', 'text-amber-50', 'border-amber-500');
            btn.classList.remove('text-amber-500/70', 'border-transparent');
        });
    });
    
    // Set initial language
    setLanguage('en');
}

function setLanguage(lang) {
    currentLang = lang;
    const t = translations[lang];
    
    // Update all elements with data-i18n
    document.querySelectorAll('[data-i18n]').forEach(el => {
        const key = el.dataset.i18n;
        if (t[key]) {
            if (key.includes('Title') && t[key].includes('<br>')) {
                el.innerHTML = t[key];
            } else {
                el.textContent = t[key];
            }
        }
    });
    
    // Update html lang attribute
    document.documentElement.lang = lang;
    
    // Dispatch event for components
    window.dispatchEvent(new CustomEvent('languagechange', { detail: { lang } }));
}

// Smooth Scroll
function initSmoothScroll() {
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                target.scrollIntoView({
                    behavior: 'smooth',
                    block: 'start'
                });
            }
        });
    });
}

// Button Ripple Effect
function initButtonEffects() {
    document.querySelectorAll('button, .group').forEach(btn => {
        btn.addEventListener('click', function(e) {
            const rect = this.getBoundingClientRect();
            const x = e.clientX - rect.left;
            const y = e.clientY - rect.top;
            
            const ripple = document.createElement('span');
            ripple.className = 'ripple';
            ripple.style.left = x + 'px';
            ripple.style.top = y + 'px';
            
            this.style.position = 'relative';
            this.style.overflow = 'hidden';
            this.appendChild(ripple);
            
            setTimeout(() => ripple.remove(), 600);
        });
    });
}

// Navigation visibility on scroll
let lastScroll = 0;
window.addEventListener('scroll', () => {
    const nav = document.querySelector('rdr-nav');
    const currentScroll = window.pageYOffset;
    
    if (currentScroll > 100) {
        nav?.classList.add('nav-scrolled');
    } else {
        nav?.classList.remove('nav-scrolled');
    }
    
    lastScroll = currentScroll;
});