let killed=false;
function rD(){return Math.random()b.length-a.length).forEach(w=>{const
i=h.indexOf(w);if(i!==-1)h=h.substring(0,i)+''+w+''+h.substring(i+w.length)});return h}
function typeInto(el,plain,golds,cb){let i=0;(function
go(){if(killed)return;i++;if(i<=plain.length){el.innerHTML=applyGold(plain.substring(0,i),golds)+'';setTimeout(go,rD())}else{el.innerHTML=applyGold(plain,golds);if(cb)cb()}})()}
function typeWithCursor(el,plain,golds,cb){let i=0;(function
go(){if(killed)return;i++;if(i<=plain.length){el.innerHTML=applyGold(plain.substring(0,i),golds)+'';setTimeout(go,rD())}else{el.innerHTML=applyGold(plain,golds)+'';if(cb)cb()}})()}
function rmCursor(el){const c=el.querySelector('.cursor');if(c)c.remove()}
function
sw(a,b,cb){document.getElementById(a).classList.remove('active');setTimeout(()=>{document.getElementById(b).classList.add('active');if(cb)setTimeout(cb,300)},600)}
// ═══ PHASE 1 ═══
function startOpening(){
typeInto(document.getElementById('openingText'),"You wanted the steps. Meet someone who took them.",["steps"],()=>{
setTimeout(()=>sw('openingPhase','photoPhase',startPhotos),1200);
});
}
// ═══ PHASE 2 ═══
function startPhotos(){
if(killed)return;
const b=document.getElementById('pjBefore'),a=document.getElementById('pjAfter');
const
line=document.querySelector('.flight-line'),plane=document.getElementById('planeEl'),tp=plane.querySelector('textPath');
setTimeout(()=>b.classList.add('visible'),200);
setTimeout(()=>line.classList.add('visible'),1000);
setTimeout(()=>{
plane.classList.add('visible');
const dur=2000,st=performance.now();
(function anim(now){if(killed)return;const
p=Math.min((now-st)/dur,1)*100;tp.setAttribute('startOffset',p+'%');if(pa.classList.add('visible'),200);setTimeout(()=>sw('photoPhase','storyPhase',startStory),2000)}})(performance.now());
},1600);
}
// ═══ PHASE 3: STORY ═══
const beats=[
{t:"Arjun joined UniHawk in Grade 9. We mapped his 7 IGCSEs, 4 A Levels, and university plans — from day one.",g:["Grade
9"]},
{t:"SAT: 1530. Ferrari World intern. MUN Director General. Operation Smile volunteer.",g:["1530"]},
{t:"Offers from the US, Australia, and Europe. 50% scholarship to NYU.",g:["NYU","50%"]},
{t:"But his perfect fit? University of Helsinki, Finland — for Computer Science.",g:["University of
Helsinki"],pause:3000},
];
function startStory(){
if(killed)return;
const col=document.getElementById('textCol');
let idx=0;
function next(){
if(killed)return;
if(idx>=beats.length){
// Go to destinations page
setTimeout(()=>sw('storyPhase','destPhase',startDest),600);
return;
}
const b=beats[idx];
const span=document.createElement('span');
span.className='beat-line';
col.appendChild(span);
if(b.pause){
typeWithCursor(span,b.t,b.g,()=>{
setTimeout(()=>{rmCursor(span);idx++;setTimeout(next,400)},b.pause);
});
}else{
typeInto(span,b.t,b.g,()=>{idx++;setTimeout(next,500)});
}
}
next();
}
// ═══ PHASE 4: DESTINATIONS ═══
const countries=[
{name:"Europe",flag:"🇪🇺"},
{name:"Canada",flag:"🇨🇦"},
{name:"China",flag:"🇨🇳"},
{name:"Singapore",flag:"🇸🇬"},
];
function startDest(){
if(killed)return;
const lead=document.getElementById('destLead');
const list=document.getElementById('countryList');
const cta=document.getElementById('destCta');
typeInto(lead,"The US and UK aren't the only options anymore. There are emerging destinations that many families are now
considering.",["aren't the only options anymore"],()=>{
// Show countries one by one
let ci=0;
function showCountry(){
if(killed)return;
if(ci>=countries.length){
const mr=document.createElement('div');
mr.className='country-row';
mr.innerHTML='🌏 and more';
mr.style.color='var(--gray-500)';
mr.style.fontStyle='italic';
list.appendChild(mr);
setTimeout(()=>mr.classList.add('show'),50);
setTimeout(()=>{
cta.classList.add('show');
typeInto(cta,"Now, let's build your child's journey.",["your child's journey"],()=>{
setTimeout(()=>sw('destPhase','formPhase'),1400);
});
},1000);
return;
}
const c=countries[ci];
const row=document.createElement('div');
row.className='country-row';
row.innerHTML=''+c.flag+' '+c.name;
list.appendChild(row);
setTimeout(()=>row.classList.add('show'),50);
ci++;
setTimeout(showCountry,400);
}
setTimeout(showCountry,500);
});
}
// SKIP
function skipAll(){
killed=true;
['openingPhase','photoPhase','storyPhase','destPhase'].forEach(id=>document.getElementById(id).classList.remove('active'));
setTimeout(()=>document.getElementById('formPhase').classList.add('active'),200);
}
startOpening();
// ═══ ROADMAP PIE ═══
// 7 segments matching reference: Grades, Standardized Tests, Other Academic, Profile, Essays/PS, Recommendation
Letters, Interviews
// Colors from brand: dark purple, mid purple, light purple, gold, gold-light, dark purple, mid purple
const PIE_PALETTE=['#3B0A5A','#9B8AAE','#6B4D82','#F5A623','#FFD076','#3B0A5A','#9B8AAE'];
const pieMaps={
us:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:16,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:14,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart from the crowd',pct:14,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:18,color:'#FFD076',a:'Profile'},
{name:'Essays / Personal Statement',detail:'Your voice — the essay that makes them remember
you',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:14,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:10,color:'#9B8AAE',a:'Int.'},
],
uk:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:22,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:12,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:16,color:'#FFD076',a:'Profile'},
{name:'Personal Statement',detail:'Your voice — the essay that makes them remember you',pct:18,color:'#3B0A5A',a:'PS'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:12,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:8,color:'#9B8AAE',a:'Int.'},
],
'uk-med':[
{name:'High School Grades',detail:'The academic foundation for a career in medicine',pct:18,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The medical admissions test that decides your
shortlist',pct:18,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:10,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'Real-world exposure that proves your commitment',pct:14,color:'#FFD076',a:'Profile'},
{name:'Personal Statement',detail:'Your voice — why medicine, and why you',pct:12,color:'#3B0A5A',a:'PS'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:10,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'The make-or-break conversation with your future university',pct:18,color:'#9B8AAE',a:'Int.'},
],
europe:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:22,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:14,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:18,color:'#FFD076',a:'Profile'},
{name:'Essays / Motivation Letter',detail:'Your voice — the essay that makes them remember
you',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:12,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:8,color:'#9B8AAE',a:'Int.'},
],
canada:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:20,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:14,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:18,color:'#FFD076',a:'Profile'},
{name:'Essays / Personal Statement',detail:'Your voice — the essay that makes them remember
you',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:14,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:8,color:'#9B8AAE',a:'Int.'},
],
singapore:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:22,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:16,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:16,color:'#FFD076',a:'Profile'},
{name:'Essays / Personal Statement',detail:'Your voice — the essay that makes them remember
you',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:12,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:8,color:'#9B8AAE',a:'Int.'},
],
china:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:22,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors to top universities',pct:16,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:16,color:'#FFD076',a:'Profile'},
{name:'Essays / Personal Statement',detail:'Your voice — the essay that makes them remember
you',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:12,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Your chance to make a lasting personal impression',pct:8,color:'#9B8AAE',a:'Int.'},
],
other:[
{name:'High School Grades',detail:'Your grades tell the first chapter of your story',pct:18,color:'#9B8AAE',a:'HS'},
{name:'Standardized Tests',detail:'The scores that open doors — we will figure out which
ones',pct:14,color:'#6B4D82',a:'ST'},
{name:'Other Academic',detail:'Extra credentials that set you apart from the crowd',pct:12,color:'#F5A623',a:'OA'},
{name:'Profile',detail:'What you do outside the classroom matters most',pct:18,color:'#FFD076',a:'Profile'},
{name:'Essays / Personal Statement',detail:'Personal statement & essays',pct:14,color:'#3B0A5A',a:'Essay'},
{name:'Recommendation Letters',detail:'Others vouching for your character and
potential',pct:14,color:'#3B0A5A',a:'Recs'},
{name:'Interviews',detail:'Some paths require a final conversation',pct:10,color:'#9B8AAE',a:'Int.'},
],
};
const dNames={us:'the United States',canada:'Canada',uk:'the United
Kingdom',europe:'Europe',singapore:'Singapore',china:'China',other:'their dream university'};
function makePieSlice(cx,cy,r,startAngle,endAngle,color){
const gap=0.02;
const s=startAngle+gap,e=endAngle-gap;
if(eMath.PI?1:0;
const d=`M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
const path=document.createElementNS('http://www.w3.org/2000/svg','path');
path.setAttribute('d',d);
path.setAttribute('fill',color);
path.setAttribute('stroke','#faf9f6');
path.setAttribute('stroke-width','3');
path.classList.add('pie-seg');
return path;
}
function makePieLabel(cx,cy,r,startAngle,endAngle,abbr,color){
const mid=(startAngle+endAngle)/2;
const lr=r*0.62;
const tx=cx+lr*Math.cos(mid);
const ty=cy+lr*Math.sin(mid);
const txt=document.createElementNS('http://www.w3.org/2000/svg','text');
txt.setAttribute('x',tx);
txt.setAttribute('y',ty);
txt.setAttribute('text-anchor','middle');
txt.setAttribute('dominant-baseline','central');
txt.setAttribute('fill', isLightColor(color)?'#1a1a1a':'#ffffff');
txt.setAttribute('font-size','12');
txt.setAttribute('font-weight','700');
txt.setAttribute('font-family','DM Sans, system-ui, sans-serif');
txt.classList.add('pie-seg');
txt.textContent=abbr;
return txt;
}
function isLightColor(hex){
const r=parseInt(hex.slice(1,3),16),g=parseInt(hex.slice(3,5),16),b=parseInt(hex.slice(5,7),16);
return (r*0.299+g*0.587+b*0.114)>160;
}
function generateRoadmap(){
const name=document.getElementById('childName').value.trim()||'Your child';
const dest=document.getElementById('destination').value;
const field=document.getElementById('fieldOfStudy').value.trim()||'their dream field';
const grade=document.getElementById('grade').value;
let ok=true;
['f-dest','f-grade'].forEach(id=>{const el=document.getElementById(id);const
s=el.querySelector('select');if(!s.value){el.classList.add('error');ok=false}else{el.classList.remove('error')}});
if(!ok)return;
const segs=pieMaps[dest]||pieMaps.other;
document.getElementById('rmOver').textContent=name+"'s Journey";
// center label is static now
// Draw pie
const svg=document.getElementById('pieSvg');
svg.innerHTML='';
// Outer ring border
const border=document.createElementNS('http://www.w3.org/2000/svg','circle');
border.setAttribute('cx','200');border.setAttribute('cy','200');border.setAttribute('r','185');
border.setAttribute('fill','none');border.setAttribute('stroke','#3B0A5A');border.setAttribute('stroke-width','3');
svg.appendChild(border);
let angle=-Math.PI/2; // start top
const labels=[];
segs.forEach(s=>{
const sweep=(s.pct/100)*Math.PI*2;
const path=makePieSlice(200,200,182,angle,angle+sweep,s.color);
if(path)svg.appendChild(path);
if(s.a){labels.push({start:angle,end:angle+sweep,abbr:s.a,color:s.color});}
angle+=sweep;
});
labels.forEach(l=>{
const lbl=makePieLabel(200,200,182,l.start,l.end,l.abbr,l.color);
svg.appendChild(lbl);
});
// Legend
const legend=document.getElementById('segLegend');
legend.innerHTML='';
segs.forEach(s=>{
const el=document.createElement('div');
el.className='seg-item';
el.innerHTML='
'+s.name+'
'+s.detail+'
';
legend.appendChild(el);
});
// WhatsApp
const msg=encodeURIComponent("Hi! I'd like to book a free consultation for "+name+" (Grade "+grade+"). Interested in
studying "+field+" in "+dNames[dest]+".");
document.getElementById('waBtn').href='https://wa.me/919911229944?text='+msg;
// Transition
document.getElementById('formPhase').classList.remove('active');
setTimeout(()=>{
document.getElementById('roadmapPhase').classList.add('active');
setTimeout(()=>{
const ps=svg.querySelectorAll('.pie-seg');
const li=legend.querySelectorAll('.seg-item');
ps.forEach((p,i)=>{setTimeout(()=>{p.classList.add('show');if(li[i])li[i].classList.add('show')},i*350)});
setTimeout(()=>{document.getElementById('rmCta').classList.add('show')},ps.length*350+300);
},400);
},400);
}