Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
251 lines (236 loc) · 21.2 KB
/
Copy pathapp.js
File metadata and controls
251 lines (236 loc) · 21.2 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
/* ---------- content that comes from data/*.json ---------- */
const SITE=(()=>{
const esc=t=>String(t==null?'':t).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
/* The only markup allowed in text fields: **bold** and {kaggle.rank} style numbers from data/kaggle.json */
const rich=t=>esc(t).replace(/\*\*(.+?)\*\*/g,'<b>$1</b>').replace(/\{kaggle\.(\w+)\}/g,(m,k)=>`<span data-kg="${k}">${esc(typeof KAGGLE!=='undefined'&&KAGGLE[k]!==undefined?KAGGLE[k]:'')}</span>`);
/* image paths may be written with or without a leading slash */
const path=p=>String(p||'').replace(/^\//,'');
return {esc,rich,path};
})();
/* a timeline (education, leadership, achievements): dated cards with optional bullets, photo gallery and buttons */
function renderTimeline(el,items){
if(!el)return;
const {esc,rich,path}=SITE;
el.innerHTML=(items||[]).map(it=>{
const photos=(it.photos||[]).map(p=>`<button class="thumb" data-full="${esc(path(p.image))}" aria-label="${esc(p.alt)}"><img src="${esc(path(p.thumb||p.image))}" alt="${esc(p.alt)}" loading="lazy"></button>`).join('');
const btns=(it.buttons||[]).map(b=>{
const cls='btn sm'+(b.style?' '+esc(b.style):''),ic=b.icon?`<i class="${esc(b.icon)}"></i>`:'';
return b.image?`<button class="${cls}" data-full="${esc(path(b.image))}" data-alt="${esc(b.alt||b.label)}">${ic}${esc(b.label)}</button>`
:`<a class="${cls}" href="${esc(b.url)}" target="_blank" rel="noopener">${ic}${esc(b.label)}</a>`;}).join('');
return `<div class="tl-item reveal${it.award?' award':''}"><div class="card"><span class="when">${it.date_icon?`<i class="${esc(it.date_icon)}"></i> `:''}${esc(it.date)}</span><h4>${esc(it.title)}</h4>${it.text?`<p>${rich(it.text)}</p>`:''}${(it.points||[]).length?`<ul class="cert-list">${it.points.map(x=>`<li>${rich(x)}</li>`).join('')}</ul>`:''}${photos?`<div class="gallery">${photos}</div>`:''}${btns?`<div class="cert-btns">${btns}</div>`:''}</div></div>`;
}).join('\n');
}
renderTimeline(document.getElementById('tl-education'),EDUCATION);
renderTimeline(document.getElementById('tl-leadership'),LEADERSHIP);
renderTimeline(document.getElementById('tl-achievements'),ACHIEVEMENTS);
function renderAbout(a){
const {esc,rich}=SITE,q=s=>document.querySelector(s);
q('#about-heading').textContent=a.heading;
q('#about-text').innerHTML=a.paragraphs.map(p=>`<p>${rich(p)}</p>`).join('\n');
q('#about-facts').innerHTML=a.facts.map(f=>`<div class="card fact tilt"><span class="ic"><i class="${esc(f.icon)}"></i></span><div><small>${esc(f.label)}</small><b>${esc(f.value)}</b></div></div>`).join('\n');
q('#focus-grid').innerHTML=a.focus.map(f=>`<div class="card focus tilt reveal"><span class="ic"><i class="${esc(f.icon)}"></i></span><h3>${esc(f.title)}</h3><p>${rich(f.text)}</p></div>`).join('\n');
q('#research-heading').textContent=a.research_heading;
q('#research-tags').innerHTML=a.research_tags.map(t=>`<span><i class="${esc(t.icon)}"></i>${esc(t.label)}</span>`).join('\n');
}
renderAbout(ABOUT);
/*@render*/
/* ---------- Kaggle numbers from data/kaggle.json ---------- */
document.querySelectorAll('[data-kg]').forEach(e=>{const v=KAGGLE[e.dataset.kg];if(v!==undefined)e.textContent=(e.dataset.prefix||'')+v});
/* ---------- latest repos, live from GitHub ---------- */
(async()=>{try{
let data=null;const key='gh_repos_v1';
try{const c=JSON.parse(sessionStorage.getItem(key)||'null');if(c&&Date.now()-c.t<600000)data=c.d}catch(e){}
if(!data){let r=null;try{r=await fetch('api/repos')}catch(e){}if(!r||!r.ok){try{r=await fetch('https://api.github.com/users/'+GITHUB_USER+'/repos?sort=pushed&per_page=30')}catch(e){return}}if(!r||!r.ok)return;data=await r.json();if(!Array.isArray(data))return;try{sessionStorage.setItem(key,JSON.stringify({t:Date.now(),d:data}))}catch(e){}}
const esc=t=>String(t==null?'':t).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
const list=data.filter(x=>!x.fork&&!x.archived&&!GITHUB_HIDE.includes(x.name)).slice(0,GITHUB_SHOW);
if(!list.length)return;
document.getElementById('gh-grid').innerHTML=list.map(x=>`<a class="card gh-item tilt" href="${esc(x.html_url)}" target="_blank" rel="noopener"><b>${esc(x.name.replace(/[-_]+/g,' '))}</b><p>${esc(x.description||'Repository on GitHub')}</p><div class="gh-meta">${x.language?`<span><i class="dot"></i>${esc(x.language)}</span>`:''}<span><i class="fa-regular fa-star"></i> ${esc(x.stargazers_count)}</span><span><i class="fa-regular fa-clock"></i> ${esc(new Date(x.pushed_at).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'}))}</span></div></a>`).join('');
document.getElementById('gh-live').hidden=false;
}catch(e){}})();
/* ---------- certificates from data/certificates.json ---------- */
(function(){const e=t=>String(t).replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
const dir=p=>String(p).replace(/^\//,'');
const card=c=>{
const full=c.image?dir(c.image):'img/cert-'+c.key+'.jpg';
const thumb=c.thumb?dir(c.thumb):(c.image?full:'img/cert-'+c.key+'-thumb.jpg');
const badge=c.badge||(c.group==='ai'?'AI · ML · CV':'');
const ext=/^https?:/.test(c.link_url||'');
const link=c.verify?`<a class="vlink" href="https://coursera.org/verify/${e(c.verify)}" target="_blank" rel="noopener">Verify on Coursera <i class="fa-solid fa-arrow-up-right-from-square"></i></a>`
:(c.link_url?`<a class="vlink" href="${e(c.link_url)}"${ext?' target="_blank" rel="noopener"':''}>${e(c.link_label||'Details')} <i class="fa-solid fa-arrow-${ext?'up-right-from-square':'down'}"></i></a>`:'');
return `<div class="card cert tilt reveal${c.star?' star':''}" data-topics="${e((c.topics||[]).join(' '))}">${badge?`<span class="badge">${e(badge)}</span>`:''}
${(c.image||c.key)?`<button class="cert-img" data-full="${e(full)}" data-alt="${e(c.t)} certificate" aria-label="Enlarge certificate: ${e(c.t)}"><img src="${e(thumb)}" alt="${e(c.t)} certificate" loading="lazy"></button>`:''}
<div class="org"><i class="${e(c.icon)}"></i>${e(c.org)}</div><h3>${e(c.t)}</h3>${c.by?`<span class="date">Taught by ${e(c.by)}</span>`:''}
<p class="learn"><b>Learned:</b> ${e(c.learned)}</p><span class="date">${e(c.date)}</span>
${link}</div>`;};
document.getElementById('cert-ai').innerHTML=CERTS.filter(c=>c.group==='ai').map(card).join('');
document.getElementById('cert-other').innerHTML=CERTS.filter(c=>c.group!=='ai').map(card).join('');})();
/* ---------- contact + socials from data/profile.json ---------- */
document.getElementById('contact-items').innerHTML=`
<div class="c-item"><span class="ic"><i class="fa-solid fa-envelope"></i></span><div><small>Email</small><a href="mailto:${PROFILE.email}">${PROFILE.email}</a></div></div>
<div class="c-item"><span class="ic"><i class="fa-solid fa-phone"></i></span><div><small>Phone / WhatsApp</small><a href="https://wa.me/${PROFILE.phoneIntl}" target="_blank" rel="noopener">${PROFILE.phoneDisplay}</a></div></div>
<div class="c-item" style="border-bottom:0"><span class="ic"><i class="fa-solid fa-location-dot"></i></span><div><small>Location</small>${PROFILE.location}</div></div>`;
document.getElementById('socials').innerHTML=PROFILE.socials.map(x=>`<a class="soc" href="${x.url}" target="_blank" rel="noopener" aria-label="${x.label}" title="${x.label}"><i class="${x.icon}"></i></a>`).join('');
document.getElementById('foot-links').innerHTML=[`<a href="mailto:${PROFILE.email}">${PROFILE.email}</a>`].concat(PROFILE.socials.slice(0,5).map(x=>`<a href="${x.url}" target="_blank" rel="noopener">${x.label}</a>`)).join(' · ');
document.getElementById('cv-btn').href=PROFILE.cv;
/* ---------- demos ---------- */
document.getElementById('demo-grid').innerHTML=DEMOS.map((d,k)=>`<article class="card demo tilt">
${d.video?`<div class="demo-media"><video src="${d.video}"${d.thumb?` poster="${d.thumb}"`:''} controls preload="metadata" playsinline></video></div>`
:`<a class="demo-media${d.thumb?' has-thumb':''}"${d.thumb?` style="background-image:url('${d.thumb}')"`:''} href="${d.url}" target="_blank" rel="noopener" aria-label="Watch ${d.title}">${d.thumb?'':`<span class="bb"><b>demo_${k+1}</b></span>`}<span class="play"><i class="fa-solid fa-play"></i></span></a>`}
<div class="demo-body"><h3>${d.title}</h3><p>${d.desc}</p>
<div class="proj-links"><a class="btn sm ghost" href="${d.url}" target="_blank" rel="noopener"><i class="fa-brands fa-linkedin-in"></i>Watch on LinkedIn</a>${d.live?`<a class="btn sm" href="${d.live}" target="_blank" rel="noopener"><i class="fa-solid fa-globe"></i>Live app</a>`:''}</div></div>
</article>`).join('');
/* ---------- photo lightbox ---------- */
const lb=document.getElementById('lightbox'),lbImg=document.getElementById('lb-img'),lbCount=document.getElementById('lb-count');
let lbGroup=[],lbIdx=0;
const lbShow=()=>{const t=lbGroup[lbIdx],im=t.querySelector('img');lbImg.src=t.dataset.full;lbImg.alt=t.dataset.alt||t.getAttribute('aria-label')||(im?im.alt:'');lbCount.textContent=(lbIdx+1)+' / '+lbGroup.length;};
const lbStep=d=>{if(lbGroup.length<2)return;lbIdx=(lbIdx+d+lbGroup.length)%lbGroup.length;lbShow();};
document.addEventListener('click',e=>{const t=e.target.closest('[data-full]');if(!t)return;
const g=t.closest('.gallery');lbGroup=g?[...g.querySelectorAll('.thumb')]:[t];lbIdx=Math.max(0,lbGroup.indexOf(t));
lb.classList.toggle('multi',lbGroup.length>1);lbShow();lb.classList.add('open');});
const closeLb=()=>lb.classList.remove('open');
document.getElementById('lb-close').onclick=closeLb;
document.getElementById('lb-prev').onclick=()=>lbStep(-1);document.getElementById('lb-next').onclick=()=>lbStep(1);
lb.addEventListener('click',e=>{if(e.target===lb)closeLb();});
addEventListener('keydown',e=>{if(!lb.classList.contains('open'))return;if(e.key==='Escape')closeLb();if(e.key==='ArrowLeft')lbStep(-1);if(e.key==='ArrowRight')lbStep(1);});
/* Facebook-style collage: show up to 5 tiles, "+N" on the last one */
document.querySelectorAll('.gallery').forEach(g=>{const th=[...g.querySelectorAll('.thumb')],n=th.length;g.dataset.n=Math.min(n,5);
th.forEach((t,i)=>{if(i>=5)t.classList.add('gx');});
if(n>5){th[4].classList.add('gmore');th[4].dataset.more='+'+(n-5);}});
/* ---------- render ---------- */
const sg=document.getElementById('skill-grid');
const DOTS=16;
sg.innerHTML=SKILLS.map(([n,ic,c,note,pct])=>{const v=pct||(c.split(' ').includes('core')?90:75),on=Math.round(v/100*DOTS);
return `<div class="card skill tilt" data-c="${c}"><i class="${ic}"></i><b>${n}</b>${note?`<small>${note}</small>`:''}<div class="meter" aria-hidden="true"><div class="dots">${Array.from({length:DOTS},(_,k)=>`<span class="${k<on?'on':''}" style="--k:${k}"></span>`).join('')}</div><em>${v}%</em></div></div>`}).join('');
const mqItems=SKILLS.filter(x=>x[2].split(' ').includes('core')).map(([n,ic])=>`<span class="mq-item"><i class="${ic}"></i>${n}</span>`).join('');
document.getElementById('mq').innerHTML=mqItems+mqItems;
const pg=document.getElementById('proj-grid');
pg.innerHTML=PROJECTS.map(p=>`<article class="card proj tilt" data-c="${p.c}">
<div class="proj-top ${p.g}${p.img?' has-img':''}"${p.img?` style="background-image:url('${p.img}')"`:''}>${p.lead?'<span class="lead-badge">Team leader</span>':''}${p.img?'':`<i class="${p.i}"></i>`}</div>
<div class="proj-body"><span class="proj-tag">${p.tag}</span><h3>${p.t}</h3><p>${p.d}</p>
${p.m?`<div class="metric">${p.m}</div>`:''}
<div class="tags">${p.s.map(x=>`<span>${x}</span>`).join('')}</div>
<div class="proj-links">${p.l.map(([a,h])=>`<a class="btn sm ${a==='GitHub'?'ghost':a==='Live app'?'':'violet'}" href="${h}" target="_blank" rel="noopener"><i class="${({'GitHub':'fa-brands fa-github','Kaggle':'fa-brands fa-kaggle','Live app':'fa-solid fa-globe','Demo video':'fa-solid fa-circle-play'})[a]||'fa-solid fa-link'}"></i>${a}</a>`).join('')}${p.l.length?'':`<span class="tags" style="margin:0"><span>${p.note||'Private repository'}</span></span>`}</div>
</div></article>`).join('');
/* ---------- filters ---------- */
document.querySelectorAll('.filters').forEach(bar=>{
const sel=bar.dataset.target==='skill'?'#skill-grid .skill':'#proj-grid .proj';
const apply=f=>document.querySelectorAll(sel).forEach(el=>el.classList.toggle('hide',f!=='all'&&!el.dataset.c.split(' ').includes(f)));
bar.addEventListener('click',e=>{const b=e.target.closest('.fbtn');if(!b)return;bar.querySelectorAll('.fbtn').forEach(x=>x.classList.remove('on'));b.classList.add('on');apply(b.dataset.f);});
apply(bar.querySelector('.fbtn.on').dataset.f);
});
/* ---------- typing ---------- */
const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
document.getElementById('spec-list').innerHTML=SPECIALTIES.map((x,k)=>`<span><b>${x}</b>${k<SPECIALTIES.length-1?'<i aria-hidden="true">|</i>':''}</span>`).join('');
/* ---------- 3D tilt ---------- */
if(!reduce&&matchMedia('(hover:hover)').matches){
document.addEventListener('mousemove',e=>{
const el=e.target.closest('.tilt');
document.querySelectorAll('.tilt.tilting').forEach(t=>{if(t!==el){t.classList.remove('tilting');t.style.transform='';}});
if(!el)return;
const r=el.getBoundingClientRect(),x=(e.clientX-r.left)/r.width-.5,y=(e.clientY-r.top)/r.height-.5;
el.classList.add('tilting');
el.style.transform=`perspective(800px) rotateX(${(-y*8).toFixed(2)}deg) rotateY(${(x*10).toFixed(2)}deg) translateY(-4px)`;
});
}
/* ---------- reveal ---------- */
const io=('IntersectionObserver' in window)?new IntersectionObserver(es=>{
es.filter(en=>en.isIntersecting).forEach((en,k)=>{const t=en.target;t.style.setProperty('--rd',(Math.min(k,6)*0.08).toFixed(2)+'s');t.classList.add('in');io.unobserve(t);setTimeout(()=>t.classList.add('done'),1500);});
},{threshold:.12}):null;
document.querySelectorAll('.reveal').forEach(el=>io?io.observe(el):el.classList.add('in'));
/* ---------- timeline line draw ---------- */
const tio=('IntersectionObserver' in window)?new IntersectionObserver(es=>es.forEach(en=>{if(en.isIntersecting){en.target.classList.add('drawn');tio.unobserve(en.target);}}),{threshold:.04}):null;
document.querySelectorAll('.tl').forEach(el=>tio?tio.observe(el):el.classList.add('drawn'));
/* ---------- count-up numbers ---------- */
const cio=('IntersectionObserver' in window&&!reduce)?new IntersectionObserver(es=>es.forEach(en=>{
if(!en.isIntersecting)return;cio.unobserve(en.target);
const el=en.target,m=el.textContent.trim().match(/^(\D*)([\d,.]+)(.*)$/);if(!m)return;
const end=parseFloat(m[2].replace(/,/g,'')),dec=(m[2].split('.')[1]||'').length,comma=m[2].includes(',');
const fmt=v=>{let t=v.toFixed(dec);if(comma)t=Number(t).toLocaleString('en-US',{minimumFractionDigits:dec,maximumFractionDigits:dec});return m[1]+t+m[3]};
const t0=performance.now(),dur=1300;
(function step(now){const p=Math.min(1,(now-t0)/dur),e=1-Math.pow(1-p,3);el.textContent=fmt(end*e);if(p<1)requestAnimationFrame(step);else el.textContent=fmt(end);})(t0);
}),{threshold:.6}):null;
if(cio)document.querySelectorAll('.stat b,.kg-stat b').forEach(el=>cio.observe(el));
/* ---------- pill nav ---------- */
const navEl=document.querySelector('nav');
const onScrollFx=()=>{navEl.classList.toggle('scrolled',scrollY>40);};
addEventListener('scroll',onScrollFx,{passive:true});onScrollFx();
/* ---------- pages: Home + one page per button ---------- */
const PAGES=['home','ml','dl','cv','projects','kaggle','certificates','achievements','leadership','education','contact'];
const ALIAS={about:'home',skills:'home',research:'home',demos:'projects',certifications:'certificates'};
const TITLES={home:'Md Feroz Ahmed · AI/ML and Computer Vision',ml:'Machine Learning',dl:'Deep Learning',cv:'Computer Vision',projects:'Projects',kaggle:'Kaggle',certificates:'Certificates',achievements:'Achievements',leadership:'Leadership',education:'Education',contact:'Contact'};
const TOPICS={
ml:{icon:'fa-solid fa-chart-pie',eb:'Machine Learning',h:'Machine learning, end to end',p:'Regression, classification, feature engineering, evaluation and Kaggle practice, backed by the Stanford and DeepLearning.AI specialization.',f:'ml',act:[['#kaggle','fa-brands fa-kaggle','Kaggle notebooks'],['#certificates','fa-solid fa-certificate','All certificates']]},
dl:{icon:'fa-solid fa-brain',eb:'Deep Learning',h:'Neural networks that ship',p:'CNNs, transfer learning, Transformers and detectors trained in PyTorch and TensorFlow.',f:'dl',act:[['#projects','fa-solid fa-laptop-code','All projects'],['#kaggle','fa-brands fa-kaggle','Kaggle notebooks']]},
cv:{icon:'fa-solid fa-eye',eb:'Computer Vision',h:'Teaching machines to see',p:'Detection, tracking, face recognition and OCR, from a trained model to a working app.',f:'cv',act:[['#demos','fa-solid fa-circle-play','Watch demos'],['#projects','fa-solid fa-laptop-code','All projects']]}
};
const pgEls=[...document.querySelectorAll('.pg')];
const navLinks=[...document.querySelectorAll('[data-p]')];
const menu=document.getElementById('links');
const observeNew=root=>root.querySelectorAll('.reveal').forEach(el=>io?io.observe(el):el.classList.add('in'));
function buildTopic(k){
const T=TOPICS[k];
document.getElementById('tp-eb').innerHTML=`<i class="${T.icon}"></i>${T.eb}`;
document.getElementById('tp-h').textContent=T.h;
document.getElementById('tp-p').textContent=T.p;
document.getElementById('tp-act').innerHTML=T.act.map(([h,ic,t],i)=>`<a href="${h}" class="btn sm${i?' ghost':''}"><i class="${ic}"></i>${t}</a>`).join('');
const clone=el=>{const c=el.cloneNode(true);c.classList.remove('hide','in','done','tilting');c.style.transform='';c.style.removeProperty('--rd');return c;};
const fill=(id,els)=>{const box=document.getElementById(id);box.replaceChildren(...els.map(clone));};
fill('tp-skills',[...document.querySelectorAll('#skill-grid .skill')].filter(x=>x.dataset.c.split(' ').includes(T.f)));
const pr=[...document.querySelectorAll('#proj-grid .proj')].filter(x=>x.dataset.c.split(' ').includes(T.f));
fill('tp-projs',pr);
document.getElementById('tp-ph').style.display=document.getElementById('tp-projs').style.display=pr.length?'':'none';
const ce=[...document.querySelectorAll('#cert-ai .card, #cert-other .card')].filter(x=>(x.dataset.topics||'').split(' ').includes(k));
fill('tp-certs',ce);
document.getElementById('tp-ch').style.display=document.getElementById('tp-certs').style.display=ce.length?'':'none';
observeNew(document.getElementById('topic'));
}
function pageOf(h){
if(PAGES.includes(h))return h;
if(ALIAS[h])return ALIAS[h];
const el=document.getElementById(h),host=el&&el.closest('.pg');
return host?host.dataset.pages.split(' ')[0]:'home';
}
let curPage=null;
function show(page){
if(page===curPage)return;curPage=page;
if(TOPICS[page])buildTopic(page);
pgEls.forEach(el=>{const on=el.dataset.pages.split(' ').includes(page);el.classList.toggle('off',!on);el.classList.remove('enter');if(on){void el.offsetWidth;el.classList.add('enter');}});
navLinks.forEach(a=>a.classList.toggle('active',a.dataset.p===page));
document.title=page==='home'?TITLES.home:TITLES[page]+' · Md Feroz Ahmed';
}
function route(){
const h=decodeURIComponent(location.hash.replace(/^#\/?/,''))||'home';
show(pageOf(h));
const target=!PAGES.includes(h)&&document.getElementById(h);
if(target&&h!=='home'){target.scrollIntoView({behavior:'instant',block:'start'});}
else scrollTo({top:0,behavior:'instant'});
menu.classList.remove('open');
}
addEventListener('hashchange',route);
document.addEventListener('click',e=>{const a=e.target.closest('a[href^="#"]');if(!a)return;if(a.getAttribute('href')===location.hash){e.preventDefault();route();}});
route();
document.getElementById('burger').onclick=()=>menu.classList.toggle('open');
/* ---------- contact form (opens the visitor's email app) ---------- */
document.getElementById('cform').addEventListener('submit',e=>{
e.preventDefault();
const n=cname.value.trim(),m=cmail.value.trim(),t=cmsg.value.trim();
const url=`mailto:${PROFILE.email}?subject=${encodeURIComponent('Portfolio message from '+n)}&body=${encodeURIComponent(t+'\n\n'+n+' <'+m+'>')}`;
window.location.href=url;
document.getElementById('cnote').textContent='Your email app should open with the message. If it does not, write to '+PROFILE.email+'.';
});
/* ---------- soft light that follows the pointer ---------- */
(function(){
const spot=document.getElementById('spot');if(!spot||!matchMedia('(hover:hover)').matches)return;
let tx=0,ty=0,x=0,y=0,run=false;
const loop=()=>{x+=(tx-x)*.12;y+=(ty-y)*.12;spot.style.transform=`translate3d(${x}px,${y}px,0)`;if(Math.abs(tx-x)+Math.abs(ty-y)>.5)requestAnimationFrame(loop);else run=false;};
addEventListener('pointermove',e=>{tx=e.clientX;ty=e.clientY;if(!spot.classList.contains('on')){x=tx;y=ty;spot.classList.add('on');}if(!run){run=true;requestAnimationFrame(loop);}},{passive:true});
document.addEventListener('pointerleave',()=>spot.classList.remove('on'));
})();
/* ---------- section divider lines ---------- */
(function(){
if(!('IntersectionObserver' in window))return;
const o=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add('seen');o.unobserve(e.target);}}),{threshold:.08});
document.querySelectorAll('section').forEach(x=>o.observe(x));
})();
/* ---------- card glow follows the pointer ---------- */
document.addEventListener('pointermove',e=>{const c=e.target.closest&&e.target.closest('.card');if(!c)return;const r=c.getBoundingClientRect();c.style.setProperty('--mx',(e.clientX-r.left)+'px');c.style.setProperty('--my',(e.clientY-r.top)+'px');},{passive:true});