(()=>{
const rng=seed=>()=>{seed=(seed*1664525+1013904223)>>>0;return seed/4294967296};
const wave=(y,amp,len,w)=>{let d=`M-200 ${y}`;for(let x=-200;x<=w+200;x+=len/2){const k=Math.round((x+200)/(len/2))%2?1:-1;d+=`Q${x+len/4} ${y+amp*k} ${x+len/2} ${y}`}return d};
const bubbleArt=i=>{
const outlines=[
'M99 12C148 11 188 49 189 98C191 149 152 189 101 190C52 192 12 153 11 103C9 53 48 14 99 12Z',
'M103 10C152 13 185 55 187 102C189 152 148 190 99 188C49 187 14 150 13 99C12 48 54 8 103 10Z',
'M96 14C145 9 188 47 190 95C193 145 155 185 105 188C55 192 14 157 10 108C6 59 46 18 96 14Z'];
const angles=[0,100,207,46,151,285];
return ``;
};
document.querySelectorAll(".prog__sea").forEach(svg=>{
const r=rng(+svg.dataset.seed||3),W=1920,H=1080;let h="";
h+=``;
for(let k=0;k<29;k++){const x=60+r()*420,y=35+r()*250,rr=1.5+r()*3;h+=``}
[[.06,.13,.028],[.95,.1,.024],[.94,.88,.03],[.05,.9,.022]].forEach(([x,y,k],i)=>{if(!i)return;const R=k*H;h+=`${bubbleArt(i)}`});
svg.setAttribute("viewBox",`0 0 ${W} ${H}`);svg.setAttribute("preserveAspectRatio","xMidYMid slice");svg.innerHTML=h;
});
document.querySelectorAll('.prog__bubble').forEach((el,i)=>{
el.insertAdjacentHTML('afterbegin', ``);
});
const jit=rng(29);
const jitter=()=>`translate(0 ${((jit()-.5)*9).toFixed(1)}) rotate(${((jit()-.5)*7).toFixed(1)} 20 100) scale(1 ${(.94+jit()*.1).toFixed(3)})`;
const BRUSH=window.brushTable({});
document.querySelectorAll(".prog__brush").forEach((svg,n)=>{
let cx=0,h="";
[...svg.dataset.word].forEach((ch,i)=>{const g=BRUSH[ch],t=`translate(${cx} 0) ${jitter()}`;h+=``;cx+=g.w+16});
svg.setAttribute("viewBox",`-24 -6 ${cx-16+48} 118`);svg.setAttribute("role","img");
svg.innerHTML=`${h}`;
});
const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add("prog--play");io.unobserve(e.target)}}),{threshold:.4});
document.querySelectorAll("[data-prog]").forEach(s=>io.observe(s));
})();