-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
729 lines (683 loc) · 27.4 KB
/
script.js
File metadata and controls
729 lines (683 loc) · 27.4 KB
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
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
// Language toggle
const defaultLanguage = "en";
const storageKey = "preferredLanguage";
const cvByLanguage = {
en: "assets/Adrian_Mehran_CV_Eng.pdf",
fr: "assets/Adrian_Mehran_CV_Fra.pdf",
};
const translations = {
en: {
meta: {
description:
"Adrian Mehran is a Grade 10 student in Nice, France, interested in neuroscience, AI in medicine, leadership, and global health. Explore his CV, research, and projects.",
},
skip: "Skip to content",
brand: {
aria: "Go to top",
tag: "Student · Research & Leadership",
},
nav: {
aria: "Primary",
openMenu: "Open menu",
education: "Education",
research: "Research",
leadership: "Leadership",
experience: "Experience",
honors: "Honors",
skills: "Skills",
contact: "Contact",
download: "Download CV",
toggleLabel: "Switch language to French",
},
hero: {
location: "Nice, France",
title:
'Aspiring neurosurgeon building at the intersection of <span class="accent">medicine</span> and <span class="accent">technology</span>.',
subtitle:
"Research interests: Neuroscience, Artificial Intelligence in Medicine, Surgical Innovation, Bioethics, and Global Health.",
download: "Download CV",
contact: "Get in touch",
continue: "Continue reading ↓",
meta: {
academicLabel: "Academic standing",
academicValue: "Ranked 1st in cohort, 7.0/7.0 GPA",
languagesLabel: "Languages",
},
},
profile: {
aria: "Profile",
avatarAlt: "Portrait of Adrian Mehran",
role: "· Grade 10 IGCSE Student (2024—current)<br>· Candidate for IB Diploma Programme (2026—2028)",
contactLinks: "Contact links",
school: "International School of Nice, France",
email: "Email",
dropByDrop: "DropByDrop project",
ted: "TED-Ed talk",
},
education: {
title: "Education",
subtitle: "Academic trajectory, results, and leadership roles.",
igcse: {
title: "IGCSE Programme (Cambridge & Pearson Edexcel)",
meta: "Grade 9-10 · 2024-current",
item1: "<strong>Academic standing:</strong> Ranked 1st in cohort throughout middle & high school.",
item2:
"<strong>Key results:</strong> Math Extended (A*), Science Double Award (9/9), Computer Science (A*), English Language & Literature (A*), French First Language (A*).",
item3: "<strong>Acceleration:</strong> Advanced directly from Grade 4 to Grade 6.",
item4: "<strong>Leadership:</strong> Class Representative (Grades 9 & 10).",
},
ib: {
title: "IB Diploma Programme + American High School Diploma",
meta: "Grade 11-12 · 2026-2028",
body:
"Focusing on building depth in quantitative reasoning and research writing while sustaining extracurricular leadership and academic projects.",
subjectsTitle: "Subject Choices",
subjects: "Biology HL, Chemistry HL, Mathematics AA HL, Psychology HL, English A SL, French A SL",
},
},
research: {
title: "Research & Academic Projects",
subtitle: "Selected work at the intersection of healthcare, ethics, and technology.",
ai: {
pill: "Research · 2025",
title: "AI in Medical Diagnosis",
meta: "IGCSE Global Perspectives · Nice, France",
item1: "Authored a report on AI’s role in medical treatment & diagnosis.",
item2: "Achieved a perfect mock score (A*) for research and team-project components.",
item3: "Recognized for “forensic precision” and sophisticated analysis.",
},
essay: {
pill: "John Locke Institute · 2025",
title: "Junior Essay Prize",
body:
"Wrote <em>“Rethinking Fair Share in a Shared World”</em>, applying ethical theory to global policy analysis.",
link: "Read essay",
},
ted: {
pill: "TED-Ed · 2021",
title: "Robotic Surgery Presentation",
meta: "Presenter and Speaker · Global",
body: "Researched and delivered a TED-Ed talk on the future of medicine and robotic surgery.",
link: "Watch video",
},
},
leadership: {
title: "Leadership & Conferences",
subtitle: "Speaking, chairing, and policy leadership.",
conference: {
title: "Globeducate Leadership Conference — Presenter and Speaker",
meta: "Madrid, Spain",
body: "Selected as 1 of 4 students out of 42,000 globally to present on leadership and innovation.",
},
mun: {
title: "Globeducate Model United Nations — Head Chair (Security Council)",
meta: "Nice, France",
item1: "Awarded “Best Delegate” in the Security Council at GlobeducateMUN 2025.",
item2: "Served as Head Chair of the Security Council at GlobeducateMUN 2026.",
},
epp: {
title: "European Pupil’s Parliament — Chairperson of the EPP (European People's Party)",
meta: "European Parliament, Strasbourg, France",
body: "Served as Chairperson of the EPP in the ENG/FRA Committee, leading party coordination, directing legislative amendment work, chairing meetings, and shaping cross-party negotiation strategy.",
},
},
experience: {
title: "Experience & Volunteering",
subtitle: "Clinical exposure, building initiatives, and coaching.",
hospital: {
title: "St. George Hospital — Clinical Observation Intern",
meta: "Nice, France · 2025",
item1: "Completed a one-week observational internship at a plastic surgeon’s practice.",
item2: "Observed procedures within the operating block to gain early clinical exposure.",
},
water: {
title: "DropByDrop Water Initiative — Founder & Project Lead",
meta: "Nice, France · 2025-2026",
item1: "Led an interdisciplinary project on water scarcity.",
item2: "<strong>Raised 351€</strong> for TeamWater, funding clean water access for 351 individuals.",
item3: "Designed and coded a public awareness website (HTML/CSS).",
link: "Visit project",
},
tennis: {
title: "Tennis Instruction — Volunteer Tennis Coach",
meta: "Nice Lawn Tennis Club, France · 2025",
body: "Taught tennis to children for a full year, focusing on skill development, confidence, and fitness.",
},
objective: {
title: "Objective",
meta: "Long-term direction",
body:
"Aspiring neurosurgeon aiming to combine medical expertise with technological innovation—bringing analytical depth and interdisciplinary research at the intersection of medicine and ethics.",
},
},
honors: {
title: "Honors & Distinctions",
subtitle: "Competitive results and recognitions.",
bronze: {
value: "Bronze",
label: "Duke of Edinburgh’s International Award (2025)",
},
silver: {
value: "Silver",
label: "Duke of Edinburgh’s International Award (2026)",
},
delegate: {
value: "Best Delegate",
label: "GlobeducateMUN <br> Security Council (2025)",
},
caribou: {
value: "Top 5%",
label: "Caribou Math Competition (2020)",
},
kangaroo: {
value: "Honor",
label: "International Math Kangaroo (2020)",
},
tsl: {
value: "Winner",
label: "TSL Essay Competition",
},
athletics: {
title: "Athletics",
item1: "Tennis U16 Dept. Championships (Div 1) — Runner-up (2026)",
item2: "Tennis U14 Dept. Championships (Div 1) — Champion (2025)",
item3: "FFT Competitive Tennis — 90+ singles matches/year (2021—2026)",
item4: "National Karate Championship (U10) — Runner-up (Kumite)",
},
personal: {
title: "Personal Development",
item1: "Violin · 8 years · 3 performance diplomas",
item2: "Chess · 1700 ELO (Lichess)",
item3: "Languages · English, French, Persian; Spanish (semi-fluent)",
},
},
skills: {
title: "Skills",
subtitle: "A practical toolkit for research and building.",
research: {
title: "Research",
item1: "Literature synthesis",
item2: "Qualitative analysis",
item3: "Data interpretation",
item4: "Scientific writing",
},
technical: {
title: "Technical",
item3: "Public-facing web builds",
},
},
contact: {
title: "Contact",
subtitle: "Open to research opportunities, conferences, collaborations, and student-led initiatives.",
pill: "Let’s connect",
cardTitle: "Available for thoughtful conversations and meaningful opportunities.",
body:
"I am especially interested in discussions around medicine, research, leadership, and student innovation. Email is the best way to reach me for academic, speaking, or collaboration enquiries.",
emailButton: "Email Adrian",
copyButton: "Copy email",
emailAddress: "Email address",
emailLabel: "Email",
note: "Best for academic, research, and speaking enquiries.",
profileTitle: "Contact profile",
profileDetails: "Contact profile details",
basedLabel: "Based in",
basedValue: "Nice, France",
focusLabel: "Focus areas",
focusValue: "Neuroscience · AI in Medicine · Leadership opportunities",
languagesLabel: "Languages",
channelsLabel: "Other channels",
copied: "Copied to clipboard.",
copyFailed: "Copy failed — you can manually select the email above.",
},
footer: {
rights: "Adrian Mehran — All rights reserved",
},
},
fr: {
meta: {
description:
"Adrian Mehran est élève en Grade 10 à Nice, en France, avec un intérêt pour les neurosciences, l’IA en médecine, le leadership et la santé mondiale. Découvrez son CV, ses recherches et ses projets.",
},
skip: "Aller au contenu",
brand: {
aria: "Retour en haut de page",
tag: "Élève · Recherche & Leadership",
},
nav: {
aria: "Navigation principale",
openMenu: "Ouvrir le menu",
education: "Éducation",
research: "Recherche",
leadership: "Leadership",
experience: "Expérience",
honors: "Distinctions",
skills: "Compétences",
contact: "Contact",
download: "Télécharger le CV",
toggleLabel: "Passer le site en anglais",
},
hero: {
location: "Nice, France",
title:
'Aspirant neurochirurgien, à la croisée de la <span class="accent">médecine</span> et de la <span class="accent">technologie</span>.',
subtitle:
"Intérêts de recherche : neurosciences, intelligence artificielle en médecine, innovation chirurgicale, bioéthique et santé mondiale.",
download: "Télécharger le CV",
contact: "Me contacter",
continue: "Continuer la lecture ↓",
meta: {
academicLabel: "Niveau académique",
academicValue: "Classé 1er de promotion, moyenne de 7,0/7,0",
languagesLabel: "Langues",
},
},
profile: {
aria: "Profil",
avatarAlt: "Portrait d’Adrian Mehran",
role: "· Élève IGCSE en Grade 10 (2024—actuel)<br>· Candidat au Programme du diplôme de l’IB (2026—2028)",
contactLinks: "Liens de contact",
school: "International School of Nice, France",
email: "E-mail",
dropByDrop: "Projet DropByDrop",
ted: "Conférence TED-Ed",
},
education: {
title: "Éducation",
subtitle: "Parcours académique, résultats et responsabilités de leadership.",
igcse: {
title: "Programme IGCSE (Cambridge & Pearson Edexcel)",
meta: "Grade 9-10 · 2024-actuel",
item1: "<strong>Niveau académique :</strong> classé 1er de la cohorte tout au long du collège et du lycée.",
item2:
"<strong>Résultats clés :</strong> Mathématiques Extended (A*), Science Double Award (9/9), Computer Science (A*), English Language & Literature (A*), French First Language (A*).",
item3: "<strong>Accélération :</strong> passage direct du Grade 4 au Grade 6.",
item4: "<strong>Leadership :</strong> délégué de classe (Grades 9 et 10).",
},
ib: {
title: "Programme du diplôme de l’IB + diplôme de fin d’études secondaires américain",
meta: "Grade 11-12 · 2026-2028",
body:
"Approfondissement du raisonnement quantitatif et de l’écriture de recherche, tout en poursuivant des responsabilités extrascolaires et des projets académiques.",
subjectsTitle: "Choix des matières",
subjects: "Biology HL, Chemistry HL, Mathematics AA HL, Psychology HL, English A SL, French A SL",
},
},
research: {
title: "Recherche & projets académiques",
subtitle: "Travaux sélectionnés à l’intersection de la santé, de l’éthique et de la technologie.",
ai: {
pill: "Recherche · 2025",
title: "IA dans le diagnostic médical",
meta: "IGCSE Global Perspectives · Nice, France",
item1: "Rédaction d’un rapport sur le rôle de l’IA dans le traitement et le diagnostic médical.",
item2: "Obtention d’un score blanc parfait (A*) pour les composantes de recherche et de projet d’équipe.",
item3: "Travail reconnu pour sa « précision médico-légale » et son analyse sophistiquée.",
},
essay: {
pill: "John Locke Institute · 2025",
title: "Junior Essay Prize",
body:
"Rédaction de <em>« Rethinking Fair Share in a Shared World »</em>, appliquant la théorie éthique à l’analyse des politiques mondiales.",
link: "Lire l’essai",
},
ted: {
pill: "TED-Ed · 2021",
title: "Présentation sur la chirurgie robotique",
meta: "Présentateur et orateur · International",
body: "Recherche et présentation d’une conférence TED-Ed sur l’avenir de la médecine et de la chirurgie robotique.",
link: "Voir la vidéo",
},
},
leadership: {
title: "Leadership & conférences",
subtitle: "Prise de parole, présidence de comités et leadership en matière de politiques.",
conference: {
title: "Globeducate Leadership Conference — Présentateur et orateur",
meta: "Madrid, Espagne",
body: "Sélectionné parmi 4 élèves sur 42 000 dans le monde pour présenter sur le leadership et l’innovation.",
},
mun: {
title: "Globeducate Model United Nations — Head Chair (Conseil de sécurité)",
meta: "Nice, France",
item1: "Récompensé « Best Delegate » au Conseil de sécurité lors de GlobeducateMUN 2025.",
item2: "Head Chair du Conseil de sécurité lors de GlobeducateMUN 2026.",
},
epp: {
title: "Parlement Européen des Lycéens (PEL) — Président du PPE (Parti Populaire Européen) ",
meta: "Parlement Européen, Strasbourg, France",
body: "Président du PPE au sein de la commission ENG/FRA, responsable de la coordination du parti, du travail d’amendement législatif, de la présidence des réunions et de la stratégie de négociation interpartis.",
},
},
experience: {
title: "Expérience & bénévolat",
subtitle: "Exposition clinique, initiatives concrètes et encadrement.",
hospital: {
title: "Hôpital St. George — stagiaire en observation clinique",
meta: "Nice, France · 2025",
item1: "Stage d’observation d’une semaine dans le cabinet d’un chirurgien plasticien.",
item2: "Observation d’interventions au bloc opératoire afin d’acquérir une première exposition clinique.",
},
water: {
title: "Initiative DropByDrop — fondateur & responsable de projet",
meta: "Nice, France · 2025-2026",
item1: "Pilotage d’un projet interdisciplinaire sur la pénurie d’eau.",
item2: "<strong>351 € collectés</strong> pour TeamWater, finançant l’accès à l’eau potable pour 351 personnes.",
item3: "Conception et développement d’un site public de sensibilisation (HTML/CSS).",
link: "Voir le projet",
},
tennis: {
title: "Enseignement du tennis — moniteur de tennis bénévole",
meta: "Nice Lawn Tennis Club, France · 2025",
body: "Enseignement du tennis à des enfants pendant une année complète, avec un accent sur la technique, la confiance et la condition physique.",
},
objective: {
title: "Objectif",
meta: "Orientation à long terme",
body:
"Aspirant neurochirurgien souhaitant associer expertise médicale et innovation technologique, avec une approche analytique et interdisciplinaire à l’intersection de la médecine et de l’éthique.",
},
},
honors: {
title: "Distinctions & prix",
subtitle: "Résultats compétitifs et reconnaissances.",
bronze: {
value: "Bronze",
label: "Duke of Edinburgh’s International Award (2025)",
},
silver: {
value: "Argent",
label: "Duke of Edinburgh’s International Award (2026)",
},
delegate: {
value: "Best Delegate",
label: "GlobeducateMUN <br> Conseil de sécurité (2025)",
},
caribou: {
value: "Top 5 %",
label: "Concours Caribou Math (2020)",
},
kangaroo: {
value: "Mention",
label: "International Math Kangaroo (2020)",
},
tsl: {
value: "Lauréat",
label: "Concours d’essai TSL",
},
athletics: {
title: "Sport",
item1: "Championnats départementaux U16 de tennis (Div. 1) — finaliste (2026)",
item2: "Championnats départementaux U14 de tennis (Div. 1) — champion (2025)",
item3: "Tennis compétitif FFT — plus de 90 matchs en simple/an (2021—2026)",
item4: "Championnat national de karaté (U10) — finaliste (Kumite)",
},
personal: {
title: "Développement personnel",
item1: "Violon · 8 ans · 3 diplômes de performance",
item2: "Échecs · 1700 ELO (Lichess)",
item3: "Langues · anglais, français, persan ; espagnol (niveau intermédiaire avancé)",
},
},
skills: {
title: "Compétences",
subtitle: "Une boîte à outils pratique pour la recherche et la création.",
research: {
title: "Recherche",
item1: "Synthèse bibliographique",
item2: "Analyse qualitative",
item3: "Interprétation de données",
item4: "Rédaction scientifique",
},
technical: {
title: "Technique",
item3: "Création de sites web publics",
},
},
contact: {
title: "Contact",
subtitle: "Ouvert aux opportunités de recherche, conférences, collaborations et initiatives étudiantes.",
pill: "Entrons en contact",
cardTitle: "Disponible pour des échanges réfléchis et des opportunités significatives.",
body:
"Je suis particulièrement intéressé par les discussions autour de la médecine, de la recherche, du leadership et de l’innovation étudiante. L’e-mail reste le meilleur moyen de me contacter pour des demandes académiques, de prise de parole ou de collaboration.",
emailButton: "Écrire à Adrian",
copyButton: "Copier l’e-mail",
emailAddress: "Adresse e-mail",
emailLabel: "E-mail",
note: "Idéal pour les demandes académiques, de recherche et de prise de parole.",
profileTitle: "Profil de contact",
profileDetails: "Détails du profil de contact",
basedLabel: "Basé à",
basedValue: "Nice, France",
focusLabel: "Domaines d’intérêt",
focusValue: "Neurosciences · IA en médecine · Opportunités de leadership",
languagesLabel: "Langues",
channelsLabel: "Autres canaux",
copied: "Copié dans le presse-papiers.",
copyFailed: "Échec de la copie — vous pouvez sélectionner l’e-mail manuellement ci-dessus.",
},
footer: {
rights: "Adrian Mehran — Tous droits réservés",
},
},
};
const allowedTranslationTags = new Set(["BR", "EM", "STRONG", "SPAN"]);
const allowedTranslationClasses = new Set(["accent"]);
function t(key, language = getCurrentLanguage()) {
return key.split(".").reduce((value, part) => value?.[part], translations[language]) ?? "";
}
function getStoredLanguage() {
try {
return localStorage.getItem(storageKey);
} catch {
return null;
}
}
function storeLanguage(language) {
try {
localStorage.setItem(storageKey, language);
} catch {
// The site still works when browser storage is unavailable.
}
}
function sanitizeTranslation(html) {
const template = document.createElement("template");
template.innerHTML = html;
template.content.querySelectorAll("*").forEach((node) => {
if (!allowedTranslationTags.has(node.tagName)) {
node.replaceWith(document.createTextNode(node.textContent || ""));
return;
}
Array.from(node.attributes).forEach((attr) => {
if (node.tagName === "SPAN" && attr.name === "class") {
const safeClasses = attr.value.split(/\s+/).filter((className) => allowedTranslationClasses.has(className));
if (safeClasses.length) {
node.setAttribute("class", safeClasses.join(" "));
} else {
node.removeAttribute("class");
}
return;
}
node.removeAttribute(attr.name);
});
});
return template.innerHTML;
}
function getCurrentLanguage() {
const savedLanguage = getStoredLanguage();
return savedLanguage && translations[savedLanguage] ? savedLanguage : defaultLanguage;
}
function setLanguage(language) {
const nextLanguage = translations[language] ? language : defaultLanguage;
storeLanguage(nextLanguage);
document.documentElement.lang = nextLanguage;
document.querySelectorAll("[data-i18n]").forEach((element) => {
const value = t(element.dataset.i18n, nextLanguage);
if (value) element.innerHTML = sanitizeTranslation(value);
});
document.querySelectorAll("[data-i18n-attr]").forEach((element) => {
element.dataset.i18nAttr.split(",").forEach((mapping) => {
const [attribute, key] = mapping.split(":").map((part) => part.trim());
const value = t(key, nextLanguage);
if (attribute && value) element.setAttribute(attribute, value);
});
});
const metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.setAttribute("content", t("meta.description", nextLanguage));
}
document.querySelectorAll("[data-cv-link]").forEach((link) => {
link.setAttribute("href", cvByLanguage[nextLanguage] || cvByLanguage[defaultLanguage]);
});
document.querySelectorAll("[data-language-toggle]").forEach((button) => {
const targetLanguage = nextLanguage === "en" ? "fr" : "en";
button.textContent = targetLanguage.toUpperCase();
button.setAttribute("aria-label", t("nav.toggleLabel", nextLanguage));
});
}
let isLanguageSwitching = false;
function switchLanguage(language) {
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduceMotion) {
setLanguage(language);
return;
}
if (isLanguageSwitching) return;
isLanguageSwitching = true;
document.documentElement.classList.add("is-language-switching");
window.setTimeout(() => {
setLanguage(language);
window.requestAnimationFrame(() => {
document.documentElement.classList.remove("is-language-switching");
window.setTimeout(() => {
isLanguageSwitching = false;
}, 260);
});
}, 110);
}
document.querySelectorAll("[data-language-toggle]").forEach((button) => {
button.addEventListener("click", () => {
const nextLanguage = getCurrentLanguage() === "en" ? "fr" : "en";
switchLanguage(nextLanguage);
});
});
setLanguage(getCurrentLanguage());
// Mobile menu
const toggle = document.querySelector(".nav__toggle");
const menu = document.getElementById("navMenu");
if (toggle && menu) {
toggle.addEventListener("click", () => {
const open = menu.classList.toggle("is-open");
toggle.setAttribute("aria-expanded", String(open));
});
menu.querySelectorAll("a").forEach((a) => {
a.addEventListener("click", () => {
menu.classList.remove("is-open");
toggle.setAttribute("aria-expanded", "false");
});
});
document.addEventListener("click", (e) => {
if (!menu.classList.contains("is-open")) return;
const isClickInside = menu.contains(e.target) || toggle.contains(e.target);
if (!isClickInside) {
menu.classList.remove("is-open");
toggle.setAttribute("aria-expanded", "false");
}
});
document.addEventListener("keydown", (e) => {
if (e.key !== "Escape" || !menu.classList.contains("is-open")) return;
menu.classList.remove("is-open");
toggle.setAttribute("aria-expanded", "false");
toggle.focus();
});
}
// Active section highlighting
const navLinks = Array.from(document.querySelectorAll(".nav__link")).filter((a) =>
a.getAttribute("href")?.startsWith("#")
);
const sections = navLinks
.map((a) => document.querySelector(a.getAttribute("href")))
.filter(Boolean);
function setActive(id) {
navLinks.forEach((a) => {
const isActive = a.getAttribute("href") === `#${id}`;
a.classList.toggle("is-active", isActive);
if (isActive) {
a.setAttribute("aria-current", "page");
} else {
a.removeAttribute("aria-current");
}
});
}
function updateActiveNav() {
const header = document.querySelector(".topbar");
const headerOffset = header ? header.offsetHeight + 24 : 100;
let currentSection = null;
sections.forEach((section) => {
const sectionTop = section.offsetTop - headerOffset;
if (window.scrollY >= sectionTop) {
currentSection = section;
}
});
if (currentSection?.id) {
setActive(currentSection.id);
} else {
navLinks.forEach((a) => {
a.classList.remove("is-active");
a.removeAttribute("aria-current");
});
}
}
if (sections.length) {
window.addEventListener("scroll", updateActiveNav, { passive: true });
window.addEventListener("resize", updateActiveNav);
window.addEventListener("load", updateActiveNav);
updateActiveNav();
}
// Reveal on scroll
const revealEls = document.querySelectorAll(".reveal");
if (!prefersReduced && revealEls.length) {
const revealObs = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
revealObs.unobserve(entry.target);
}
});
},
{ threshold: 0.12 }
);
revealEls.forEach((el) => revealObs.observe(el));
} else {
revealEls.forEach((el) => el.classList.add("is-visible"));
}
// Copy email
const toast = document.getElementById("copyToast");
document.querySelectorAll("[data-copy]").forEach((btn) => {
btn.addEventListener("click", async () => {
const text = btn.getAttribute("data-copy") || "";
try {
await navigator.clipboard.writeText(text);
if (toast) {
toast.textContent = t("contact.copied");
setTimeout(() => {
toast.textContent = "";
}, 1800);
}
} catch {
if (toast) {
toast.textContent = t("contact.copyFailed");
setTimeout(() => {
toast.textContent = "";
}, 2200);
}
}
});
});
// Footer year
const yearEl = document.getElementById("year");
if (yearEl) {
yearEl.textContent = String(new Date().getFullYear());
}