Animation · project 32 of 37
Carve the Turkey.
A roasted turkey in 3D that shows exactly where its six joints are and where the knife goes, one cut at a time.
BeforeA recipe that says "remove the legs at the joint" and never shows where the joint is, read with a knife in your hand and the family waiting.
AfterA roasted turkey in 3D with a red ring on each of its six joints and a dashed line where the knife goes, taken apart in seven cuts.
What it is worthYou see where each joint is and how to find it with your hands before you pick up the knife, then check yourself in a quiz. Instead of sawing through bone because the written steps never showed you the joint.
How to use it
- Open it and look at the red rings: each one is a joint. Tap Hip, Knee, Shoulder, Keel or Wishbone to fly to that spot. Drag to turn the bird and pinch to zoom.
- Tap Start carving. On each step read Find it, then Cut, and watch the part swing at its joint. The dashed white line is the knife path.
- Tap Make the cut to see the cut, then Next. Tap Replay to see a cut again.
- Tap X-ray at any time to see the bones. The gold bones are the ones for the step you are on.
- When you know the joints, go back to the start and tap Play the quiz: tap where each joint is and see how many centimetres off you were.
Where it helps most
- The ten minutes before you carve your first turkey, with the phone propped next to the board.
- Showing a helper or a child why the knife should go through a joint and not through bone.
- A base for any take-it-apart lesson where the hard part is seeing where the hidden joint is: a chicken, a duck, a leg of lamb.
The idea
On Thanksgiving I wanted to learn how to cut a turkey. Written steps say "cut through the joint" and never show where the joint is. I sent Claude one photo of our bird being carved on the board and asked for a 3D animation of the joints that I could zoom into, something close to a game. The first version looked good, but the joints were still not obvious, so I asked for better help. The second round put a ring on every joint, drew the knife path, and made the parts move.
The build
Claude built it in one evening as a single page with three.js. Nothing is loaded from a picture or a model file: the bird is made of simple shapes in code (a carcass, two breast lobes, legs and wings on pivots at the hip, knee and shoulder, and a skeleton inside), and the roasted skin, the meat grain and the walnut board are painted by the code. The carving order is the common home method, rest, legs, wings, breast off whole, then slice across the grain, and it was checked against published carving guides (Cook's Country from America's Test Kitchen, Cook's Illustrated, and the University of Illinois Extension turkey page). The board, the sheet tray and the autumn leaves come from my photo. Its limits: the bird is a simplified model, so the joint positions are close but not exact anatomy, and the centimetres in the quiz assume a bird about 40 cm long. It teaches where to look and feel; a real bird still takes a few tries. It has no sound. It was tested in a test browser at four screen sizes, not on a real phone.
Free to take
Build your own.
Copy the skill, paste it into your own AI, and say what you want different. How to use a skill, step by step ›
Get the skillThe instructions your AI follows. Works in Claude, ChatGPT, Gemini or any other
# Master prompt: Carve the Turkey, the six joints in 3D
You are a three.js developer and a patient cooking teacher. Build one web page that teaches a first-time carver where a roasted turkey comes apart, on a phone held in one hand at the table. The reader must be able to answer two questions at every step without reading much: where exactly is the joint, and where does the knife go.
What to build
- One page: index.html, one CSS file, one JS file, three.js r128 from your own server. No CDN, no outside fonts, no inline scripts or styles, no image or model files: the bird, the board, the wood grain and the roasted skin are all made by the code (canvas textures, vertex colours).
- A full-screen 3D scene: a roasted turkey breast side up on a walnut carving board with a juice groove, a sheet tray behind it for the carved pieces, a few autumn leaves, warm key light with soft shadows, a little steam.
- The bird is built from separate parts so it can come apart: carcass, two breast lobes, two legs (thigh and drumstick as parent and child, pivot at the hip, child pivot at the knee), two wings (pivot at the shoulder). Inside: spine, ribs, keel bone, pelvis, wishbone, thigh and drumstick bones, wing bones.
The carving method behind it (keep this order)
- A turkey comes apart at six joints: two hips, two knees, two shoulders. The knife goes through a joint with almost no force; never saw through bone.
- Rest the bird 20 to 30 minutes. Then: 1 open the hip (cut the skin between breast and leg, push the leg down until the joint pops, cut through the gap); 2 split the knee on the fat line, leg skin side down; 3 cut along the thigh bone, lift it out, slice across the grain; 4 pull the wing out and cut through the shoulder, which sits low and near the neck end; 5 cut down one side of the keel bone, follow the ribs, lift each breast off whole; 6 slice the breast crosswise, about half an inch thick, skin on; 7 serve, keep the carcass for stock.
- Check the order against two published carving guides before you write the texts. Say plainly in the page's write-up that the bird is a simplified model and the joint positions are close, not exact anatomy.
Make the joints obvious (this is the whole point)
- A red ring with a white edge and a slow pulse marks each joint. It draws on top of the skin, so no X-ray is needed to see it. Only the joint of the current step is bright; the others are dim; the far side is dimmer still.
- A dashed white line with a dark edge shows the knife path before the cut. When the user taps Make the cut, a knife follows that line, the part swings open at the joint, and the piece travels to the tray.
- Before each joint cut, the part moves by itself: the leg swings at the hip, the drumstick at the knee, the wing at the shoulder. A part that moves shows where it bends.
- X-ray button: the skin turns to glass. The bones of the current step turn gold; ribs and spine go dim so they do not compete.
- Every step card has two labelled lines: "Find it" (what to feel for with your hands on a real bird) and "Cut" (where the knife goes), one short check line, and a small diagram of the joint (ball and socket, hinge, the section through the keel, the grain).
Views and controls
- Step 0 is a joint tour: chips for Hip, Knee, Shoulder, Keel, Wishbone fly the camera to each and explain it.
- Steps 1 to 7 as above. Buttons: Back, Make the cut, Next; after a cut, Back becomes Replay. A persistent legend (ring = joint, dashed line = knife path) and a Help sheet that explains the ring, the line, the moving part, the gold bones and the gestures.
- Quiz: X-ray off, rings and lines hidden; tap where the joint is. Score 0 to 3 by the distance from the tap ray to the joint, show the distance in centimetres, then reveal the joint and make the cut. Four targets, 12 points.
- Camera: drag to turn, pinch or wheel to zoom, two fingers to move, double tap to return to the step's view. Each step has its own view, fitted to the free area of the screen.
Finish
- Phone first. The card sits at the bottom in portrait and at the left side on a wide or sideways screen; the camera view shifts so the bird is never under the card. On short screens hide the check line and the diagram and let the text scroll inside the card.
- Respect reduced motion (no pulse, no swinging part, no steam). Lower the pixel ratio by itself if frames are slow. Show a plain message if WebGL is missing.
- No sound. If you add any, it must also play on an iPhone on silent.
Stress test before you call it done
- Open it at 320x568, 393x700, 740x360 and 1366x800 under the site's security policy. No console errors, no sideways scroll, no clipped text, no control over the bird.
- Run all seven cuts, Replay and Back at every step, Carve again, the whole quiz with random taps, fast repeated taps on every button while a cut is running, drag and zoom during a cut, turn the screen both ways. The camera values must stay finite and every piece must end on the tray.
Get the code3 files, exactly as they run on this site · free under the MIT license
These three files are exactly what runs at sghadimi.com/animations/carve-the-turkey. The page also loads three.js r128 from the site's own /animations/vendor/ folder and two open-licence fonts (Fraunces and Figtree) from its own fonts folder. It uses no images, models or sound files. The page is written as one HTML file (docs/carve-the-turkey/carve-the-turkey.html) and split into these three by a small script.
turkey.js (the bird, the joints, the seven cuts, the quiz)362 lines
{
const $=id=>document.getElementById(id);
if(!window.THREE){$('fail').style.display='grid';throw new Error('three.js did not load')}
const V3=THREE.Vector3,Q=THREE.Quaternion,Y=new V3(0,1,0),PI=Math.PI;
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v)),lerp=(a,b,t)=>a+(b-a)*t;
const C=h=>new THREE.Color(h).convertSRGBToLinear();
const still=matchMedia('(prefers-reduced-motion:reduce)').matches;
/* ---------- renderer, scene, light ---------- */
const cv=$('c');
let renderer;
try{renderer=new THREE.WebGLRenderer({canvas:cv,antialias:true,powerPreference:'high-performance'})}catch(e){$('fail').style.display='grid';throw e}
renderer.setPixelRatio(Math.min(devicePixelRatio||1,2));
renderer.outputEncoding=THREE.sRGBEncoding;renderer.toneMapping=THREE.ACESFilmicToneMapping;renderer.toneMappingExposure=1;
renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFSoftShadowMap;
const scene=new THREE.Scene(),BG=C(0x170d08);scene.background=BG;scene.fog=new THREE.Fog(BG,15,34);
const camera=new THREE.PerspectiveCamera(36,1,.1,80);
{const pm=new THREE.PMREMGenerator(renderer),es=new THREE.Scene();
es.add(new THREE.Mesh(new THREE.SphereGeometry(30,16,8),new THREE.MeshBasicMaterial({color:C(0x4a2c18),side:THREE.BackSide})));
const pan=(c,k,w,h,p)=>{const m=new THREE.Mesh(new THREE.PlaneGeometry(w,h),new THREE.MeshBasicMaterial({color:C(c).multiplyScalar(k),side:THREE.DoubleSide}));m.position.set(p[0],p[1],p[2]);m.lookAt(0,0,0);es.add(m)};
pan(0xffe2b8,7,12,12,[0,14,3]);pan(0xffc890,4,7,9,[-13,6,5]);pan(0xfff0dc,1.3,7,7,[11,5,-9]);pan(0xffb070,2,5,5,[9,3,10]);
scene.environment=pm.fromScene(es,.03).texture;pm.dispose()}
const key=new THREE.DirectionalLight(C(0xffe0b0),1.9);key.position.set(-5,10,6);key.castShadow=true;
key.shadow.mapSize.set(2048,2048);Object.assign(key.shadow.camera,{left:-7,right:7,top:8,bottom:-8,near:1,far:30});key.shadow.bias=-.0004;key.shadow.normalBias=.02;key.shadow.radius=4;
scene.add(key,new THREE.HemisphereLight(C(0xffd9b0),C(0x2a1408),.5));
const rim=new THREE.DirectionalLight(C(0xa9c0ff),.7);rim.position.set(5,5,-8);scene.add(rim);
/* ---------- textures ---------- */
const R=(a=1,b)=>b===undefined?Math.random()*a:a+Math.random()*(b-a);
function tex(w,h,draw,srgb=true){const c=document.createElement('canvas');c.width=w;c.height=h;draw(c.getContext('2d'),w,h);const t=new THREE.CanvasTexture(c);if(srgb)t.encoding=THREE.sRGBEncoding;t.wrapS=t.wrapT=THREE.RepeatWrapping;t.anisotropy=8;return t}
const skinTex=tex(512,512,(g,w,h)=>{g.fillStyle='#ececec';g.fillRect(0,0,w,h);
for(let i=0;i<900;i++){const v=R(120,255)|0,r=R(5,30),x=R(w),y=R(h),gr=g.createRadialGradient(x,y,0,x,y,r);gr.addColorStop(0,`rgba(${v},${v*.92|0},${v*.85|0},${R(.1,.28)})`);gr.addColorStop(1,'rgba(0,0,0,0)');g.fillStyle=gr;g.fillRect(x-r,y-r,r*2,r*2)}
for(let i=0;i<2600;i++){g.fillStyle=R()<.35?`rgba(40,60,20,${R(.25,.6)})`:`rgba(30,14,6,${R(.2,.55)})`;g.beginPath();g.ellipse(R(w),R(h),R(.5,1.7),R(.5,1.2),R(3),0,7);g.fill()}});
const bumpTex=tex(512,512,(g,w,h)=>{g.fillStyle='#808080';g.fillRect(0,0,w,h);
for(let i=0;i<5200;i++){const x=R(w),y=R(h),r=R(1.5,4.5),gr=g.createRadialGradient(x,y,0,x,y,r);gr.addColorStop(0,'rgba(255,255,255,.55)');gr.addColorStop(1,'rgba(255,255,255,0)');g.fillStyle=gr;g.fillRect(x-r,y-r,r*2,r*2)}
for(let i=0;i<60;i++){g.strokeStyle='rgba(0,0,0,.25)';g.lineWidth=R(1,3);g.beginPath();const x=R(w),y=R(h);g.moveTo(x,y);g.quadraticCurveTo(x+R(-40,40),y+R(-40,40),x+R(-70,70),y+R(-70,70));g.stroke()}},false);
skinTex.repeat.set(2,2);bumpTex.repeat.set(2,2);
const grainTex=tex(256,256,(g,w,h)=>{g.fillStyle='#fff';g.fillRect(0,0,w,h);for(let i=0;i<420;i++){g.strokeStyle=`rgba(${R(150,205)|0},${R(110,150)|0},${R(80,115)|0},${R(.1,.3)})`;g.lineWidth=R(.6,1.8);const y=R(h),x=R(w);g.beginPath();g.moveTo(x,y);g.bezierCurveTo(x+25,y+R(-5,5),x+55,y+R(-7,7),x+R(60,110),y+R(-9,9));g.stroke()}});
grainTex.repeat.set(2.2,2.6);
const wood=(base,a,b,n,groove)=>tex(1024,1024,(g,w,h)=>{g.fillStyle=base;g.fillRect(0,0,w,h);
for(let i=0;i<n;i++){g.strokeStyle=R()<.5?a:b;g.globalAlpha=R(.05,.3);g.lineWidth=R(1,9);const y=R(h);g.beginPath();g.moveTo(0,y);g.bezierCurveTo(w*.3,y+R(-22,22),w*.7,y+R(-22,22),w,y+R(-12,12));g.stroke()}
g.globalAlpha=1;if(groove){g.strokeStyle='rgba(18,8,4,.62)';g.lineWidth=17;g.lineJoin='round';const m=62;g.beginPath();g.moveTo(m+50,m);g.arcTo(w-m,m,w-m,h-m,50);g.arcTo(w-m,h-m,m,h-m,50);g.arcTo(m,h-m,m,m,50);g.arcTo(m,m,w-m,m,50);g.closePath();g.stroke();
g.strokeStyle='rgba(255,220,170,.16)';g.lineWidth=2;g.stroke();
for(let i=0;i<60;i++){g.strokeStyle=`rgba(255,225,190,${R(.05,.16)})`;g.lineWidth=1;const x=R(140,w-140),y=R(140,h-140),an=R(-.5,.5),l=R(40,170);g.beginPath();g.moveTo(x,y);g.lineTo(x+Math.cos(an)*l,y+Math.sin(an)*l);g.stroke()}}});
/* ---------- materials ---------- */
const skinMat=new THREE.MeshPhysicalMaterial({vertexColors:true,map:skinTex,bumpMap:bumpTex,bumpScale:.014,roughness:.4,clearcoat:.75,clearcoatRoughness:.22,envMapIntensity:1});
const meatMat=new THREE.MeshStandardMaterial({color:C(0xf3dfc2),map:grainTex,roughness:.72,side:THREE.DoubleSide});
const darkMat=new THREE.MeshStandardMaterial({color:C(0xb98463),map:grainTex,roughness:.7,side:THREE.DoubleSide});
const flesh=[skinMat,meatMat];
const boneMat=new THREE.MeshStandardMaterial({color:C(0xf4ead4),roughness:.55,emissive:C(0xffdca0),emissiveIntensity:.04});
const legMat=boneMat.clone(),wingMat=boneMat.clone(),keelMat=boneMat.clone(),BM=[[legMat,'leg'],[wingMat,'wing'],[keelMat,'keel']],HI=C(0xff9a10),LO=C(0xffdca0),B0=C(0xf4ead4),B1=C(0x77664f),GOLD=C(0xffae22);
const sideMat=new THREE.MeshStandardMaterial({vertexColors:true,roughness:.5,side:THREE.DoubleSide});
const faceW=new THREE.MeshStandardMaterial({color:C(0xf6e4c8),map:grainTex,roughness:.7,side:THREE.DoubleSide});
const faceD=new THREE.MeshStandardMaterial({color:C(0x9a7460),map:grainTex,roughness:.7,side:THREE.DoubleSide});
const cRoast=[C(0xe0a544),C(0xb85a17),C(0x64230a)],cMeat=C(0xf0dcc0),cDark=C(0xb07a58),cRib=C(0x9d6f55),cBone=C(0xefe2c8),cCav=C(0x2a0f08);
/* ---------- small maths ---------- */
const hash=(x,y,z)=>{const h=Math.sin(x*127.1+y*311.7+z*74.7)*43758.5453;return h-Math.floor(h)};
function vn(x,y,z){const xi=Math.floor(x),yi=Math.floor(y),zi=Math.floor(z),s=t=>t*t*(3-2*t),u=s(x-xi),v=s(y-yi),w=s(z-zi);
return lerp(lerp(lerp(hash(xi,yi,zi),hash(xi+1,yi,zi),u),lerp(hash(xi,yi+1,zi),hash(xi+1,yi+1,zi),u),v),lerp(lerp(hash(xi,yi,zi+1),hash(xi+1,yi,zi+1),u),lerp(hash(xi,yi+1,zi+1),hash(xi+1,yi+1,zi+1),u),v),w)}
const fbm=(p,f)=>vn(p.x*f,p.y*f,p.z*f)*.6+vn(p.x*f*2.7,p.y*f*2.7,p.z*f*2.7)*.4;
const tmpC=new THREE.Color();
function skinCol(p,n,bias=0){const k=clamp(.42*n.y+.4+(fbm(p,2.1)-.5)*.95+bias,0,1);return k<.5?tmpC.copy(cRoast[0]).lerp(cRoast[1],k*2):tmpC.copy(cRoast[1]).lerp(cRoast[2],(k-.5)*2)}
function paint(m,fn){m.updateWorldMatrix(true,false);const g=m.geometry,P=g.attributes.position,N=g.attributes.normal,c=new Float32Array(P.count*3),p=new V3,n=new V3,nm=new THREE.Matrix3().getNormalMatrix(m.matrixWorld);
for(let i=0;i<P.count;i++){p.fromBufferAttribute(P,i).applyMatrix4(m.matrixWorld);n.fromBufferAttribute(N,i).applyMatrix3(nm).normalize();const k=fn(p,n);c[i*3]=k.r;c[i*3+1]=k.g;c[i*3+2]=k.b}
g.setAttribute('color',new THREE.BufferAttribute(c,3))}
const CC=new V3(0,.6,0),CR=new V3(1.3,.56,.8),BC=new V3(-.12,.86,0),BR=new V3(1.12,.62,.7),Y0=.87;
const inE=(p,c,r,pad)=>((p.x-c.x)/(r.x+pad))**2+((p.y-c.y)/(r.y+pad))**2+((p.z-c.z)/(r.z+pad))**2<1;
const inBody=(p,pad)=>inE(p,CC,CR,pad)||inE(p,BC,BR,pad);
/* ---------- table, board, tray, leaves ---------- */
const TY=-.27,TZ=-3.85;
{const t=wood('#33150a','#1c0903','#57260f',260,false);t.repeat.set(7,7);
const table=new THREE.Mesh(new THREE.PlaneGeometry(70,70).rotateX(-PI/2),new THREE.MeshStandardMaterial({map:t,roughness:.6,envMapIntensity:.22}));table.position.y=-.31;table.receiveShadow=true;scene.add(table);
const bt=wood('#472a17','#22110a','#6d4526',220,true);bt.repeat.set(1/5.4,1/4.2);bt.offset.set(.5,.5);
const sh=new THREE.Shape(),w=2.7,h=2.1,r=.28;sh.moveTo(-w+r,-h);sh.lineTo(w-r,-h);sh.quadraticCurveTo(w,-h,w,-h+r);sh.lineTo(w,h-r);sh.quadraticCurveTo(w,h,w-r,h);sh.lineTo(-w+r,h);sh.quadraticCurveTo(-w,h,-w,h-r);sh.lineTo(-w,-h+r);sh.quadraticCurveTo(-w,-h,-w+r,-h);
const board=new THREE.Mesh(new THREE.ExtrudeGeometry(sh,{depth:.25,bevelEnabled:true,bevelSize:.03,bevelThickness:.03,bevelSegments:3,curveSegments:10}).rotateX(PI/2).translate(0,-.03,.6),[new THREE.MeshStandardMaterial({map:bt,roughness:.5,envMapIntensity:.7}),new THREE.MeshStandardMaterial({color:C(0x3d2414),roughness:.55,envMapIntensity:.6})]);
board.receiveShadow=true;board.castShadow=true;scene.add(board);
const al=new THREE.MeshStandardMaterial({color:C(0xa9acae),metalness:.9,roughness:.6,envMapIntensity:.45}),tray=new THREE.Group();
const bx=(w,h,d,x,y,z)=>{const m=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),al);m.position.set(x,y,z);m.receiveShadow=true;m.castShadow=true;tray.add(m)};
bx(4.7,.04,4.3,0,-.29,TZ);bx(4.8,.16,.06,0,-.23,TZ-2.15);bx(4.8,.16,.06,0,-.23,TZ+2.15);bx(.06,.16,4.3,-2.37,-.23,TZ);bx(.06,.16,4.3,2.37,-.23,TZ);scene.add(tray);
const leaf=new THREE.Shape();for(let i=0;i<=90;i++){const a=i/90*PI*2,c=Math.cos(a),k=1+.07*Math.cos(11*a),x=.62*c*k,y=.27*Math.sin(a)*Math.pow(1-.45*c*c,1.2)*(1+.25*c)*k;i?leaf.lineTo(x,y):leaf.moveTo(x,y)}
const lg=new THREE.ShapeGeometry(leaf).rotateX(-PI/2),cols=[0x8e2c12,0xb87a1e,0x5f5220,0x6a1824,0xbd8a2c,0x7d3a14];
[[3.6,1.9],[4.3,1.0],[3.9,2.9],[4.9,2.2],[-3.7,2.6],[-4.4,1.6],[-3.6,-.6],[3.5,-.2],[4.7,.1],[-4.6,.3]].forEach((p,i)=>{const m=new THREE.Mesh(lg,new THREE.MeshStandardMaterial({color:C(cols[i%6]).multiplyScalar(.4),roughness:.9,envMapIntensity:.3,side:THREE.DoubleSide}));m.position.set(p[0],-.3+i*.002,p[1]);m.rotation.y=R(6.3);m.scale.setScalar(R(.8,1.25));m.receiveShadow=true;scene.add(m)})}
/* ---------- geometry helpers ---------- */
const shadow=o=>{o.traverse(m=>{if(m.isMesh){m.castShadow=true;m.receiveShadow=true}});return o};
const lathe=(prof,L)=>new THREE.LatheGeometry(prof.map(a=>new THREE.Vector2(a[1],a[0]*L)),26);
function rod(a,b,r,ball=0,mat=boneMat){const d=b.clone().sub(a),L=d.length(),g=new THREE.Group();g.add(new THREE.Mesh(new THREE.CylinderGeometry(r,r,L,10),mat));
if(ball)for(const s of[-1,1]){const k=new THREE.Mesh(new THREE.SphereGeometry(ball,14,10),mat);k.position.y=s*L/2;k.scale.set(1.15,.85,1);g.add(k)}
g.position.copy(a).addScaledVector(d,.5);g.quaternion.setFromUnitVectors(Y,d.normalize());return g}
const v=(x,y,z)=>new V3(x,y,z);
const mov=[];const M=o=>{mov.push(o);return o};
/* ---------- carcass and fixed bones ---------- */
const carcass=new THREE.Mesh(new THREE.SphereGeometry(1,72,44).scale(CR.x,CR.y,CR.z).translate(CC.x,CC.y,CC.z),skinMat);
{const P=carcass.geometry.attributes.position;for(let i=0;i<P.count;i++){const x=P.getX(i);if(x>0){const u=Math.min(1,x/1.2);P.setZ(i,P.getZ(i)*(1-.22*u*u*(3-2*u)))}if(x>1.15)P.setX(i,1.15+(x-1.15)*.12);if(x<-1.2)P.setX(i,-1.2+(x+1.2)*.25)}carcass.geometry.computeVertexNormals();
scene.add(carcass);paint(carcass,(p,n)=>{if(p.x>1.148&&n.x>.6)return cCav;if(p.y>.85&&inE(p,BC,BR,-.03)){const s=.5+.5*Math.sin(p.x*21);return tmpC.copy(cRib).lerp(cBone,Math.pow(s,6))}return skinCol(p,n,-.12)})}
const bones=new THREE.Group();scene.add(bones);
{bones.add(rod(v(-.9,.32,0),v(.95,.3,0),.06));
for(const x of[-.8,-.55,-.3,-.05,.2]){const t=new THREE.Mesh(new THREE.TorusGeometry(1,.035,8,44).rotateY(PI/2),boneMat);const f=Math.sqrt(1-(x/1.3)**2);t.scale.set(1,.5*f,.7*f);t.position.set(x,.6,0);t.rotation.z=.12;bones.add(t)}
const k=new THREE.Shape();k.moveTo(-.95,.93);k.quadraticCurveTo(-.8,1.3,-.45,1.37);k.quadraticCurveTo(0,1.43,.5,1.25);k.quadraticCurveTo(.75,1.12,.82,.98);k.lineTo(.5,.94);k.lineTo(-.5,.9);
bones.add(new THREE.Mesh(new THREE.ExtrudeGeometry(k,{depth:.07,bevelEnabled:false,curveSegments:14}).translate(0,0,-.035),keelMat));
const pel=new THREE.Mesh(new THREE.SphereGeometry(1,20,12).scale(.5,.11,.44),boneMat);pel.position.set(.62,.3,0);bones.add(pel)}
/* ---------- joint markers ---------- */
const ringT=tex(128,128,(g,w)=>{const c=w/2,gr=g.createRadialGradient(c,c,30,c,c,63);gr.addColorStop(0,'rgba(255,50,90,.5)');gr.addColorStop(1,'rgba(255,50,90,0)');g.fillStyle=gr;g.fillRect(0,0,w,w);
const ring=(r,lw,col)=>{g.lineWidth=lw;g.strokeStyle=col;g.beginPath();g.arc(c,c,r,0,7);g.stroke()},dot=(r,col)=>{g.fillStyle=col;g.beginPath();g.arc(c,c,r,0,7);g.fill()};
ring(33,18,'#fff');ring(33,10,'#ff3358');dot(10,'#fff');dot(5.5,'#ff3358')});
const pulseT=tex(128,128,g=>{g.lineWidth=6;g.strokeStyle='#fff';g.beginPath();g.arc(64,64,58,0,7);g.stroke()});
const marks=[];
function mark(p,parent,id,s){const mk=(t,ro)=>{const m=new THREE.Sprite(new THREE.SpriteMaterial({map:t,depthTest:false,depthWrite:false,transparent:true,opacity:0}));m.position.copy(p);m.renderOrder=ro;parent.add(m);return m};
const m=mk(ringT,31);m.userData={k:1,id,s,p:mk(pulseT,30)};marks.push(m);return m}
/* ---------- legs ---------- */
const HIP=s=>v(.7,.42,.5*s),KNEE=s=>v(.12,.92,.86*s),ANK=s=>v(1.45,1.02,.44*s);
const DRUM=[[0,.02],[.03,.17],[.13,.3],[.3,.335],[.48,.27],[.66,.18],[.8,.115],[.88,.085],[.9,.02]];
function flatPose(P1,P2,s,head,target,rad){const n=P1.clone().cross(P2.clone().sub(P1)).normalize();if(n.z*s<0)n.negate();
const q1=new Q().setFromUnitVectors(n,Y),d=P2.clone().applyQuaternion(q1),q=new Q().setFromAxisAngle(Y,Math.atan2(d.z,d.x)+head).multiply(q1);
const c=P1.clone().add(P2).multiplyScalar(1/3).applyQuaternion(q);return{p:v(target.x-c.x,target.y+rad,target.z-c.z),q}}
const leg={},wing={},lobe={};
function sliceSet(n,dim,face,s){const g=M(new THREE.Group());g.visible=false;scene.add(g);const T=.13;
for(let i=0;i<n;i++){const d=dim(i),sh=new THREE.Shape();
if(d.full)sh.absellipse(0,d.h,d.w,d.h,0,PI*2,false,0);else{sh.moveTo(0,0);sh.lineTo(d.w,0);sh.absellipse(0,0,d.w,d.h,0,PI/2,false,0);sh.lineTo(0,0)}
const geo=new THREE.ExtrudeGeometry(sh,{depth:T,bevelEnabled:false,curveSegments:14}),P=geo.attributes.position,col=new Float32Array(P.count*3),p=new V3,n0=new V3(0,.4,0);
for(let j=0;j<P.count;j++){p.fromBufferAttribute(P,j);const k=(!d.full&&(p.x<.002||p.y<.002))?cMeat:skinCol(p.set(p.x+i,p.y,p.z),n0,.1);col[j*3]=k.r;col[j*3+1]=k.g;col[j*3+2]=k.b}
geo.setAttribute('color',new THREE.BufferAttribute(col,3));geo.rotateY(-PI/2).translate(T/2,0,0);
const m=M(new THREE.Mesh(geo,[face,sideMat]));m.position.x=d.x;m.scale.z=s;m.castShadow=true;m.receiveShadow=true;g.add(m)}
return g}
for(const s of[1,-1]){
const g=M(new THREE.Group());g.position.copy(HIP(s));scene.add(g);
const K=KNEE(s).sub(HIP(s)),A=ANK(s).sub(HIP(s)),D=A.clone().sub(K),kq=new Q().setFromUnitVectors(Y,K.clone().normalize()),dq=new Q().setFromUnitVectors(Y,D.clone().normalize());
const th=M(new THREE.Mesh(new THREE.SphereGeometry(1,36,26).scale(.34,.6,.37),skinMat));th.position.copy(K).multiplyScalar(.5).add(v(.02,-.04,.05*s));th.quaternion.copy(kq);g.add(th);
const fem=M(rod(v(0,0,0),K,.045,.09,legMat));g.add(fem);
const kg=M(new THREE.Group());kg.position.copy(K);g.add(kg);
const dr=new THREE.Mesh(lathe(DRUM,D.length()),skinMat);dr.quaternion.copy(dq);kg.add(dr);
kg.add(rod(v(0,0,0),D,.042,.085,legMat));
const kneeM=M(mark(K,g,'knee',s)),hipM=mark(HIP(s),scene,'hip',s);
shadow(g);
const sl=sliceSet(5,i=>({full:1,w:.3-.03*Math.abs(i-2),h:.2-.02*Math.abs(i-2),x:(i-2)*.16}),faceD,1);
leg[s]={g,K,A,D,th,fem,kg,dr,kneeM,hipM,sl,flat:flatPose(K,A,s,0,v(1.2*s,0,1.98),.31)}}
/* ---------- wings ---------- */
const SH=s=>v(-.72,.78,.6*s),EL=s=>v(-.12,.42,.9*s),WR=s=>v(-.74,.26,.98*s),TP=s=>v(-1.02,.2,.74*s);
for(const s of[1,-1]){
const g=M(new THREE.Group());g.position.copy(SH(s));scene.add(g);
const E=EL(s).sub(SH(s)),W=WR(s).sub(SH(s)),T=TP(s).sub(SH(s));
const seg=(a,b,prof)=>{const d=b.clone().sub(a),m=new THREE.Mesh(lathe(prof,d.length()),skinMat);m.position.copy(a);m.quaternion.setFromUnitVectors(Y,d.clone().normalize());g.add(m);return m};
const parts=[seg(v(0,0,0),E,[[0,.03],[.06,.15],[.35,.18],[.75,.14],[.96,.115],[1,.03]]),seg(E,W,[[0,.03],[.05,.115],[.5,.13],[.92,.09],[1,.03]]),seg(W,T,[[0,.03],[.08,.085],[.6,.06],[1,.008]])];
g.add(rod(v(0,0,0),E,.03,.05,wingMat),rod(E,W,.022,.035,wingMat),rod(W,T,.014,0,wingMat));
const shM=mark(SH(s),scene,'shoulder',s);shadow(g);
wing[s]={g,parts,shM,tray:flatPose(E,W,s,PI/2*s,v(1.95*s,TY,-2.7),.15)};
bones.add(rod(SH(s).multiplyScalar(.93),v(-.9,.94,0),.03),rod(SH(s).multiplyScalar(.93),v(-.05,.3,.36*s),.02),rod(v(-1.05,.72,0),SH(s).multiplyScalar(.9),.018));
}
/* ---------- breast lobes ---------- */
{const te=Math.acos((Y0-BC.y)/BR.y),a0=Math.asin((Y0-BC.y)/BR.y),f=Math.cos(a0);
const kc=new THREE.Shape();for(let i=0;i<=40;i++){const a=a0+(PI-2*a0)*i/40,x=BR.x*Math.cos(a),y=BR.y*Math.sin(a)-(Y0-BC.y);i?kc.lineTo(x,y):kc.moveTo(x,y)}
const rc=new THREE.Shape();for(let i=0;i<=40;i++){const a=PI*i/40,x=BR.x*f*Math.cos(a),y=BR.z*f*Math.sin(a);i?rc.lineTo(x,y):rc.moveTo(x,y)}
for(const s of[1,-1]){const g=M(new THREE.Group());g.position.set(BC.x,Y0,.004*s);scene.add(g);
const dome=new THREE.Mesh(new THREE.SphereGeometry(1,56,30,s>0?0:PI,PI,0,te).scale(BR.x,BR.y,BR.z),skinMat);dome.position.y=BC.y-Y0;
const c1=new THREE.Mesh(new THREE.ShapeGeometry(kc),meatMat),c2=new THREE.Mesh(new THREE.ShapeGeometry(rc).rotateX(PI/2*s),meatMat);
g.add(dome,c1,c2);shadow(g);
const n=10,sl=sliceSet(n,i=>{const x=-.93+i*1.86/(n-1),k=Math.sqrt(1-(x/BR.x)**2);return{w:.7*k,h:.56*k,x}},faceW,s);
lobe[s]={g,dome,sl,work:v(1.3*s,.004,s>0?1.5:2.3)}}}
/* paint every skin part in its assembled place */
scene.updateMatrixWorld(true);
for(const s of[1,-1]){paint(leg[s].th,(p,n)=>inBody(p,.05)?cDark:skinCol(p,n,.2+.25*Math.abs(n.z)));paint(leg[s].dr,(p,n)=>skinCol(p,n,.16+.2*Math.abs(n.z)));wing[s].parts.forEach(m=>paint(m,(p,n)=>inBody(p,.02)?cMeat:skinCol(p,n,.02)));paint(lobe[s].dome,(p,n)=>skinCol(p,n,.06))}
/* ---------- knife and cut line ---------- */
const knife=new THREE.Group();knife.rotation.order='YZX';knife.visible=false;scene.add(knife);
{const b=new THREE.Shape();b.moveTo(-.75,0);b.lineTo(.6,0);b.quadraticCurveTo(.84,.02,.88,.13);b.lineTo(-.75,.17);
const blade=new THREE.Mesh(new THREE.ExtrudeGeometry(b,{depth:.014,bevelEnabled:false}).translate(0,0,-.007),new THREE.MeshStandardMaterial({color:C(0xf2f4f6),metalness:.55,roughness:.28}));
const hd=new THREE.Mesh(new THREE.BoxGeometry(.62,.15,.075),new THREE.MeshStandardMaterial({color:C(0x24140c),roughness:.45}));hd.position.set(-1.07,.095,0);
const bo=new THREE.Mesh(new THREE.BoxGeometry(.06,.17,.085),blade.material);bo.position.set(-.76,.09,0);knife.add(blade,hd,bo);knife.traverse(m=>m.castShadow=true)}
const cutLine=new THREE.Mesh(new THREE.BufferGeometry(),new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.95}));cutLine.renderOrder=25;cutLine.frustumCulled=false;cutLine.visible=false;scene.add(cutLine);
/* knife path preview and the part that moves */
const guides=new THREE.Group();scene.add(guides);
const guideMat=new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.85}),guideFar=new THREE.MeshBasicMaterial({color:0xfff6dd,depthTest:false,transparent:true,opacity:.14}),guideEdge=new THREE.MeshBasicMaterial({color:0x1d0c05,depthTest:false,transparent:true,opacity:.6});
function setGuides(list,sided){for(const m of[...guides.children]){m.geometry.dispose();guides.remove(m)}
(list||[]).forEach((pts,i)=>{const cur=new THREE.CatmullRomCurve3(pts.map(a=>a.isVector3?a:new V3(a[0],a[1],a[2]))),n=Math.max(6,Math.round(cur.getLength()/.06));
for(const[r,mat,ro]of[[.034,guideEdge,23],[.021,guideMat,24]]){const g=new THREE.TubeGeometry(cur,n,r,5,false),ix=g.index.array,keep=[];
for(let j=0;j<n;j++)if(j%3<2)for(let k=0;k<30;k++)keep.push(ix[j*30+k]);g.setIndex(keep);
const m=new THREE.Mesh(g,mat);m.renderOrder=ro;m.frustumCulled=false;m.userData={s:sided?(i?-1:1):0,edge:mat===guideEdge};guides.add(m)}})}
let wigs=null;const qT=new Q(),XA=new V3(1,0,0);
function unwig(){if(wigs)for(const w of wigs)w.o.quaternion.copy(w.q0);wigs=null}
function setWig(list){unwig();wigs=list?list.map(w=>Object.assign({q0:w.o.quaternion.clone()},w)):null}
/* steam */
const steam=new THREE.Group();scene.add(steam);
{const st=tex(64,64,(g,w)=>{const gr=g.createRadialGradient(32,32,0,32,32,32);gr.addColorStop(0,'rgba(255,255,255,.9)');gr.addColorStop(1,'rgba(255,255,255,0)');g.fillStyle=gr;g.fillRect(0,0,w,w)});
for(let i=0;i<9;i++){const s=new THREE.Sprite(new THREE.SpriteMaterial({map:st,transparent:true,opacity:0,depthWrite:false}));s.userData={ph:i/9,x:R(-.8,.8),z:R(-.4,.4)};steam.add(s)}}
/* ---------- tweens ---------- */
const tweens=new Set(),eio=k=>k<.5?4*k*k*k:1-((-2*k+2)**3)/2,lin=k=>k,back=k=>{const c=1.9;return 1+(c+1)*((k-1)**3)+c*((k-1)**2)};
const tw=(d,fn,ease=eio)=>new Promise(res=>tweens.add({t:0,d:Math.max(.01,d),fn,ease,res}));
const wait=ms=>tw(ms/1000,()=>{});
function moveTo(o,p,q,d,lift=.8){scene.attach(o);const p0=o.position.clone(),q0=o.quaternion.clone();return tw(d,k=>{o.position.lerpVectors(p0,p,k);o.position.y+=Math.sin(k*PI)*lift;o.quaternion.copy(q0).slerp(q,k)})}
async function knifeCut(arr,d,saw=3){const pts=arr.map(a=>a.isVector3?a:v(a[0],a[1],a[2])),cur=new THREE.CatmullRomCurve3(pts);cutLine.geometry.dispose();const lineGeo=cutLine.geometry=new THREE.TubeGeometry(cur,48,.016,6,false);lineGeo.setDrawRange(0,0);cutLine.visible=true;knife.visible=true;
const p=new V3,t=new V3,place=(k,lift)=>{cur.getPoint(k,p);cur.getTangent(k,t);knife.rotation.set(0,Math.atan2(-t.z,t.x),Math.asin(clamp(t.y,-1,1))*.7);knife.position.copy(p);knife.position.y+=lift;knife.translateX(Math.sin(k*saw*PI*2)*.15)};
await tw(.35,k=>place(0,(1-k)*.9));await tw(d,k=>{place(k,0);lineGeo.setDrawRange(0,Math.ceil(k*48)*36)},lin);await tw(.3,k=>place(1,k*.9));knife.visible=false}
async function chops(a,b,n,d){knife.visible=true;const dir=b.clone().sub(a),yaw=Math.atan2(-dir.z,dir.x)+PI/2;await tw(d,k=>{knife.position.lerpVectors(a,b,k);knife.position.y+=Math.abs(Math.cos(k*n*PI))*.4;knife.rotation.set(0,yaw,0)},lin);knife.visible=false}
const flash=m=>tw(.9,k=>{m.userData.k=1+Math.sin(k*PI)*2.2},lin);
const fan=(g,gap,lean,d)=>{const n=g.children.length,x0=g.children.map(c=>c.position.x);return tw(d,k=>g.children.forEach((c,i)=>{c.position.x=lerp(x0[i],(i-(n-1)/2)*gap,k);c.rotation.z=lean*k}))};
/* ---------- camera ---------- */
const cam={tx:0,ty:.75,tz:.1,th:.5,ph:1.02,r:9.5};let goal=null,W=1,H=1,cardH=0;
const SIDE=matchMedia('(min-width:900px),(max-height:520px) and (min-width:560px)');let availW=1,cardW=0;
const fitR=(w,h)=>{const t=Math.tan(18*PI/180),a=W/H;return clamp(Math.max(w/(2*t*a*availW),h/(2*t*clamp((H-cardH-(SIDE.matches?70:50))/H,.3,1))),2,17)};
const fly=g=>{goal=Object.assign({},g);if(g.w){goal.r=fitR(g.w,g.h);delete goal.w;delete goal.h}};
const VIEW={all:{tx:0,ty:.6,tz:.2,th:.42,ph:1,w:3.8,h:4.2},top:{tx:0,ty:.9,tz:0,th:.32,ph:.66,w:3.4,h:3.6},tray:{tx:0,ty:-.2,tz:-3.75,th:PI-.3,ph:.5,w:5.4,h:5.2}};
VIEW.both={tx:0,ty:.3,tz:1.2,th:.25,ph:.72,w:4.8,h:4.4};
const workV=(s,th=.3,w=2.7)=>({tx:1.2*s,ty:.25,tz:1.9,th:th*s,ph:.8,w,h:2.8});
const hipV=s=>({tx:.5,ty:.65,tz:.3*s,th:s>0?.62:PI-.62,ph:1.02,w:3,h:3.3}),shV=s=>({tx:-.55,ty:.7,tz:.3*s,th:s>0?-.5:PI+.5,ph:1,w:2.9,h:3.3});
function placeCam(dt){if(goal){const a=1-Math.exp(-dt*3.2);for(const k in goal)cam[k]+=(goal[k]-cam[k])*a}
const r=cam.r,sp=Math.sin(cam.ph);camera.position.set(cam.tx+r*sp*Math.sin(cam.th),cam.ty+r*Math.cos(cam.ph),cam.tz+r*sp*Math.cos(cam.th));camera.lookAt(cam.tx,cam.ty,cam.tz)}
function size(){W=cv.clientWidth;H=cv.clientHeight;renderer.setSize(W,H,false);const a=W/H;camera.aspect=a;const side=SIDE.matches,cd=$('card');cardW=side?cd.offsetWidth+cd.offsetLeft*2:0;cardH=side?0:cd.offsetHeight+20;availW=side?clamp((W-cardW)/W,.3,1):1;camera.setViewOffset(W,H,-cardW/2,side?-22:cardH*.46,W,H);camera.updateProjectionMatrix()}
const ro=new ResizeObserver(size);ro.observe(document.body);ro.observe($('card'));
/* ---------- pointer control ---------- */
const ptr=new Map();let pin=0,moved=0,downT=0,lastTap=0;
const pd=()=>{const a=[...ptr.values()];return Math.hypot(a[0].x-a[1].x,a[0].y-a[1].y)};
cv.addEventListener('pointerdown',e=>{cv.setPointerCapture(e.pointerId);ptr.set(e.pointerId,{x:e.clientX,y:e.clientY});if(ptr.size===1){moved=0;downT=performance.now()}else pin=pd();$('hint').style.opacity=0});
cv.addEventListener('pointermove',e=>{const p=ptr.get(e.pointerId);if(!p)return;const dx=e.clientX-p.x,dy=e.clientY-p.y;p.x=e.clientX;p.y=e.clientY;
if(ptr.size===1){moved+=Math.abs(dx)+Math.abs(dy);if(moved>6){goal=null;cam.th-=dx*.0065;cam.ph=clamp(cam.ph-dy*.005,.12,1.5)}}
else if(ptr.size===2){goal=null;moved=99;const d=pd();cam.r=clamp(cam.r*pin/d,1.5,18);pin=d;const k=cam.r*.0009;cam.tx-=dx*k*Math.cos(cam.th);cam.tz+=dx*k*Math.sin(cam.th);cam.ty=clamp(cam.ty+dy*k,-.3,2.5)}});
const up=e=>{if(!ptr.delete(e.pointerId))return;if(ptr.size===0&&moved<8&&performance.now()-downT<400){const now=performance.now();if(now-lastTap<320&&!awaiting)fly(STEPS[si].cam);else tap(e.clientX,e.clientY);lastTap=now}};
cv.addEventListener('pointerup',up);cv.addEventListener('pointercancel',e=>ptr.delete(e.pointerId));
cv.addEventListener('wheel',e=>{e.preventDefault();goal=null;cam.r=clamp(cam.r*Math.exp(e.deltaY*.0012),1.5,18)},{passive:false});
/* ---------- labels ---------- */
const kneeW=s=>leg[s].kneeM.getWorldPosition(new V3);
const LBL=[['hip',1,'Hip joint',()=>HIP(1)],['hip',-1,'Hip joint',()=>HIP(-1)],['knee',1,'Knee joint',()=>kneeW(1)],['knee',-1,'Knee joint',()=>kneeW(-1)],['shoulder',1,'Shoulder joint',()=>SH(1)],['shoulder',-1,'Shoulder joint',()=>SH(-1)],['keel',0,'Keel bone',()=>v(-.1,1.5,0)],['wishbone',0,'Wishbone',()=>v(-1.05,.72,0)]]
.map(a=>{const el=document.createElement('button');el.className='lb'+(a[1]?'':' bone');el.textContent=a[2];el.onclick=()=>focus(a[0],a[1]||1);$('labels').appendChild(el);return{id:a[0],s:a[1],pos:a[3],el}});
const FACT={hip:['Hip joint','Ball and socket. It sits deep, where the thigh meets the back. Push the leg down and out, and the ball comes out of the socket.'],
knee:['Knee joint','A hinge between the thigh and the drumstick. A thin line of fat marks it. Bend the leg and you can feel it move.'],
shoulder:['Shoulder joint','A small ball joint low on the side, near the neck end. Pull the wing away from the body and the joint opens.'],
keel:['Keel bone','This is not a joint. It is the flat bone between the two breasts. It guides the long breast cut.'],
wishbone:['Wishbone','A thin V at the neck end. Cut it out first and the breast comes off cleaner.']};
function focus(id,s=1){if(busy||awaiting)return;const p=LBL.find(l=>l.id===id&&(l.s===s||!l.s)).pos();setX(true);
fly({tx:p.x,ty:p.y-.1,tz:p.z*.6,th:id==='keel'?.35:id==='wishbone'?-1.25:(p.x>0?.7:-.6)*(s>0?1:-1)+(s>0?0:PI),ph:id==='keel'?.55:.98,w:1.9,h:2.1});
if(si)return say(FACT[id][1]);$('t').textContent=FACT[id][0];$('b').textContent=FACT[id][1];$('fig').innerHTML=FIG[{hip:'ball',knee:'hinge',shoulder:'ball',keel:'keel'}[id]]||'';$('tip').textContent='';picked=id;chips()}
const pv=new V3;
function placeLabels(){const st=STEPS[si],show=labelsOn&&!awaiting;for(const l of LBL){let on=show&&(picked?l.id===picked:st.lab.includes(l.id));
if(on){pv.copy(l.pos());if(l.s&&(camera.position.z-cam.tz)*l.s<-.4)on=false;else{pv.project(camera);const x=(pv.x*.5+.5)*W,y=(-pv.y*.5+.5)*H;if(pv.z>1||y>H-cardH-6||y<56||x<cardW-30)on=false;else l.el.style.transform=`translate(${x+22|0}px,${y-15|0}px)`}}
l.el.style.display=on?'':'none'}}
/* ---------- the cuts ---------- */
const sgn=s=>a=>v(a[0],a[1],a[2]*s),qId=new Q();
const P_HIP=s=>[[-.3,1.12,.7],[.25,1.04,.68],[.7,.86,.66],[1.02,.58,.56]].map(sgn(s)),P_SH=s=>[[-.82,1.08,.56],[-.74,.82,.66],[-.66,.52,.74]].map(sgn(s)),P_KEEL=s=>[[-.98,1.26,.04],[-.5,1.46,.04],[.1,1.48,.04],[.6,1.36,.04],[.9,1.16,.04]].map(sgn(s));
function P_KNEE(s){const L=leg[s],kp=kneeW(s),q0=L.kg.getWorldQuaternion(new Q),d=L.D.clone().applyQuaternion(q0).setY(0).normalize(),n=v(-d.z,0,d.x);return[kp.clone().addScaledVector(n,.42).setY(.68),kp.clone().setY(.6),kp.clone().addScaledVector(n,-.42).setY(.5)]}
function P_THIGH(s){const a=leg[s].g.getWorldPosition(new V3),b=kneeW(s);return[a.clone().setY(.64),a.clone().lerp(b,.5).setY(.66),b.clone().setY(.64)]}
function P_SLICE(s){const p=lobe[s].g.position,out=[];for(let i=0;i<9;i++){const x=-.83+i*1.66/8,m=1-(x/BR.x)**2,zm=BR.z*Math.sqrt(m);out.push([.04,.5,.95].map(t=>{const z=t*zm;return v(p.x+x,p.y+BR.y*Math.sqrt(Math.max(0,m-(z/BR.z)**2))+.02,p.z+z*s)}))}return out}
const twoSides=fn=>()=>[fn(1),fn(-1)];
async function cutLeg(s,sp){const L=leg[s];fly(hipV(s));await wait(s>0?800:1100);
await knifeCut(P_HIP(s),1.5/sp);
await tw(.7/sp,k=>{L.g.rotation.x=s*.8*k},back);flash(L.hipM);say('Pop. The hip joint is open.');await wait(450/sp);
await knifeCut([[.52,.8,.7],[.7,.45,.58],[.86,.2,.5]].map(sgn(s)),.7/sp,1);cutLine.visible=false;
await moveTo(L.g,L.flat.p,L.flat.q,1.1/sp)}
async function splitKnee(s,sp){fly(workV(s));await wait(s>0?300:900);const L=leg[s],q0=L.kg.getWorldQuaternion(new Q),d=L.D.clone().applyQuaternion(q0).setY(0).normalize();
await knifeCut(P_KNEE(s),.9/sp,2);cutLine.visible=false;
const q=new Q().setFromAxisAngle(Y,Math.atan2(d.z,d.x)+(s>0?0:PI)).multiply(q0),c=L.D.clone().multiplyScalar(.5).applyQuaternion(q);
await moveTo(L.kg,v(.95*s-c.x,TY+.31,-5.25-c.z),q,1.1/sp)}
async function boneThigh(s,sp){fly(workV(s));await wait(s>0?300:900);const L=leg[s],a=L.g.getWorldPosition(new V3),b=kneeW(s),c=L.th.getWorldPosition(new V3),d=b.clone().sub(a).setY(0).normalize();
await knifeCut(P_THIGH(s),.8/sp,2);cutLine.visible=false;
await moveTo(L.fem,v(-2.2,.06,-.95+.16*s),new Q().setFromUnitVectors(Y,v(.25*s,0,1).normalize()),.9/sp,.9);
L.sl.position.set(c.x,.004,c.z);L.sl.rotation.set(0,Math.atan2(-d.z,d.x),0);
await chops(a.clone().setY(.42),b.clone().setY(.42),5,.9/sp);L.th.visible=false;L.kneeM.visible=false;L.sl.visible=true;
await fan(L.sl,.2,-1,.5/sp);await moveTo(L.sl,v(.95*s,TY,-4.3),qId,1/sp)}
async function cutWing(s,sp){const Wg=wing[s];fly(shV(s));await wait(s>0?800:1100);
await tw(.6/sp,k=>{Wg.g.rotation.x=s*.55*k},back);flash(Wg.shM);
await knifeCut(P_SH(s),.9/sp,2);cutLine.visible=false;
await moveTo(Wg.g,Wg.tray.p,Wg.tray.q,1.1/sp)}
async function cutBreast(s,sp){const B=lobe[s];fly({tx:0,ty:.9,tz:0,th:s>0?.32:PI-.32,ph:.66,w:3.4,h:3.6});await wait(s>0?700:1000);
await knifeCut(P_KEEL(s),1.6/sp,3);
await Promise.all([tw(.6/sp,k=>{B.g.rotation.x=s*.28*k;B.g.position.z=s*(.004+.12*k)}),knifeCut([[.8,1.02,.5],[0,.98,.72],[-.85,.98,.58]].map(sgn(s)),1.1/sp,3)]);cutLine.visible=false;
await moveTo(B.g,B.work,qId,1.2/sp,1)}
async function sliceBreast(s,sp){fly(workV(s,.85,3));await wait(s>0?300:900);const B=lobe[s],p=B.g.position;
await chops(v(p.x-.95,.3,p.z+.35*s),v(p.x+.95,.3,p.z+.35*s),10,1.5/sp);B.sl.position.copy(p);B.g.visible=false;B.sl.visible=true;
await fan(B.sl,.25,-1.05,.6/sp);await moveTo(B.sl,v(-.1,TY,s>0?-2.62:-3.1),qId,1.1/sp)}
const both=fn=>async()=>{await fn(1,1);await fn(-1,1.7)};
/* ---------- steps ---------- */
const STEPS=[
{t:'Find the six joints',b:'A turkey comes apart at six joints: two hips, two knees and two shoulders. A red ring marks each joint. Cut at the joint, not through bone.',tip:'Tap a name to go to that joint. Rest the bird for 20 to 30 minutes before you cut.',cam:VIEW.all,lab:['hip','knee','shoulder','keel'],tour:1},
{t:'Open the hip',find:'Hold the drumstick end and move the leg. The leg turns at one point, deep against the body. That point is the hip.',cut:'Cut the skin between the breast and the leg. Push the leg down flat until the joint pops. Cut through the gap.',tip:'If the knife stops, it is on bone. Move it 1 cm and try again.',
cam:hipV(1),lab:['hip'],hi:'leg',fig:'ball',sided:1,pre:twoSides(P_HIP),wig:()=>[1,-1].map(s=>({o:leg[s].g,ax:XA,amp:s*.3})),q:['hip joint',()=>[HIP(1),HIP(-1)]],act:both(cutLeg)},
{t:'Split the knee',find:'Put the leg skin side down and bend it. A thin line of fat goes across the bend. The knee is under that line.',cut:'Cut straight down on the fat line. The knife goes between the two bone ends.',tip:'Force is not necessary. If you must push hard, you are not in the joint.',
cam:workV(1),lab:['knee'],hi:'leg',fig:'hinge',pre:twoSides(P_KNEE),wig:()=>[1,-1].map(s=>({o:leg[s].kg,ax:leg[s].K.clone().cross(leg[s].D).normalize(),amp:-.32})),q:['knee joint',()=>[kneeW(1),kneeW(-1)]],act:both(splitKnee)},
{t:'Bone the thigh',find:'Feel the one bone that goes along the middle of the thigh.',cut:'Cut along each side of the bone and lift it out. Then slice the meat across the grain.',tip:'Slices across the grain are tender. Slices along the grain are stringy.',
cam:workV(1),lab:[],hi:'leg',fig:'bone',pre:twoSides(P_THIGH),act:both(boneThigh)},
{t:'Take off the wings',find:'Move the wing. It turns at a point low on the side of the breast, near the neck end. That point is the shoulder.',cut:'Pull the wing away from the body. The joint opens. Cut through the gap.',tip:'The shoulder is lower than most people think.',
cam:shV(1),lab:['shoulder'],hi:'wing',fig:'ball',sided:1,pre:twoSides(P_SH),wig:()=>[1,-1].map(s=>({o:wing[s].g,ax:XA,amp:s*.3})),q:['shoulder joint',()=>[SH(1),SH(-1)]],act:both(cutWing)},
{t:'Lift off the breast',find:'Feel the hard ridge along the top middle of the breast. That ridge is the keel bone.',cut:'Cut down along one side of the keel. Keep the blade flat against the bone, then follow the ribs outward. Use long strokes.',tip:'Do not slice the breast on the bird. Take it off in one piece first.',
cam:VIEW.top,lab:['keel','wishbone'],hi:'keel',fig:'keel',pre:twoSides(P_KEEL),q:['keel bone',()=>[v(-.6,1.42,0),v(-.1,1.48,0),v(.45,1.4,0)]],act:both(cutBreast)},
{t:'Slice across the grain',find:'Look at the lines in the meat. They go along the length of the breast. Those lines are the grain.',cut:'Put the breast skin side up. Slice across the lines, about ½ inch thick.',tip:'Use one long stroke for each slice. Do not saw.',
cam:workV(1,.85,3),lab:[],fig:'grain',pre:()=>[...P_SLICE(1),...P_SLICE(-1)],act:both(sliceBreast)},
{t:'Serve',b:'White meat goes in the middle. Dark meat, drumsticks and wings go around it. Keep the carcass for stock.',tip:'',cam:VIEW.tray,lab:[]}];
const BONE='#f4ead4',CUT='#ff4f6a',DSH=`fill="none" stroke="${CUT}" stroke-width="3.5" stroke-dasharray="6 5" stroke-linecap="round"`;
const FIG={
ball:`<svg viewBox="0 0 96 96" role="img" aria-label="Ball and socket joint. The knife goes between the ball and the socket."><path d="M40 20A28 28 0 0 0 40 76" fill="none" stroke="${BONE}" stroke-width="9" stroke-linecap="round"/><circle cx="60" cy="48" r="15" fill="${BONE}"/><rect x="66" y="42" width="30" height="12" fill="${BONE}"/><path d="M46 12Q26 48 46 84" ${DSH}/></svg>`,
hinge:`<svg viewBox="0 0 96 96" role="img" aria-label="Hinge joint. The knife goes between the two bone ends."><path d="M8 22L38 40M62 54L90 74" stroke="${BONE}" stroke-width="11" stroke-linecap="round"/><circle cx="39" cy="41" r="10" fill="${BONE}"/><circle cx="61" cy="53" r="10" fill="${BONE}"/><path d="M64 21L36 73" ${DSH}/></svg>`,
keel:`<svg viewBox="0 0 96 96" role="img" aria-label="Section through the breast. The knife goes down one side of the keel bone, then out along the ribs."><path d="M45 20Q16 26 8 74Q28 64 45 62ZM51 20Q80 26 88 74Q68 64 51 62Z" fill="#e7c7a2"/><path d="M48 14V62M48 62Q28 64 8 76M48 62Q68 64 88 76" fill="none" stroke="${BONE}" stroke-width="5" stroke-linecap="round"/><path d="M42 8V56Q26 59 10 68" ${DSH}/></svg>`,
bone:`<svg viewBox="0 0 96 96" role="img" aria-label="The thigh bone inside the meat. The knife goes along each side of the bone."><rect x="8" y="22" width="80" height="52" rx="24" fill="#c79a7c"/><path d="M26 48H70" stroke="${BONE}" stroke-width="9" stroke-linecap="round"/><circle cx="24" cy="48" r="8" fill="${BONE}"/><circle cx="72" cy="48" r="8" fill="${BONE}"/><path d="M16 35H80M16 61H80" ${DSH}/></svg>`,
grain:`<svg viewBox="0 0 96 96" role="img" aria-label="The cuts go across the lines of the meat."><rect x="8" y="26" width="80" height="44" rx="20" fill="#e7c7a2"/><path d="M18 38H78M14 48H82M18 58H78" stroke="#b98a62" stroke-width="2" stroke-linecap="round"/><path d="M30 18V78M48 18V78M66 18V78" ${DSH}/></svg>`};
let si=0,done=true,busy=false,quiz=false,awaiting=false,labelsOn=true,xGoal=0,xr=0,picked=null,userX=false;const snaps=[],scores=[];
const snap=()=>mov.map(o=>({o,par:o.parent,p:o.position.clone(),q:o.quaternion.clone(),vis:o.visible}));
const restore=s=>{unwig();s.forEach(a=>{a.par.add(a.o);a.o.position.copy(a.p);a.o.quaternion.copy(a.q);a.o.visible=a.vis});knife.visible=cutLine.visible=false};
const total=()=>scores.reduce((a,b)=>a+(b||0),0);
function setX(on){xGoal=on?1:0;$('bx').setAttribute('aria-pressed',on)}
let toastT;function say(m){const t=$('toast');t.textContent=m;t.classList.add('on');clearTimeout(toastT);toastT=setTimeout(()=>t.classList.remove('on'),1800+m.length*45)}
function chips(){$('chips').innerHTML=STEPS[si].tour?Object.keys(FACT).map(k=>`<button data-k="${k}" class="${picked===k?'on':''}">${FACT[k][0].replace(' joint','').replace(' bone','')}</button>`).join(''):''}
$('chips').onclick=e=>{const k=e.target.dataset&&e.target.dataset.k;if(k)focus(k)};
function draw(){const st=STEPS[si],last=si===STEPS.length-1;
$('bar').innerHTML=STEPS.map((_,i)=>`<span class="${i<=si?'on':''}"></span>`).join('');
$('k').textContent=si?(quiz&&st.q?'Quiz, ':'')+`step ${si} of ${STEPS.length-1}`.replace(/^s/,quiz&&st.q?'s':'S'):'Before you cut';
$('t').textContent=st.t;
if(st.find&&!awaiting)$('b').innerHTML=`<span><b>Find it</b>${st.find}</span><span><b>Cut</b>${st.cut}</span>`;
else $('b').textContent=awaiting?`Tap the place on the bird where the ${st.q[0]} is. X-ray is off. Turn the bird if you need to.`:last&&quiz?`You scored ${total()} of 12. ${total()>=10?'You know where the joints are.':total()>=6?'Good. Do it again and you will have it.':'Use X-ray, look again, then try once more.'} ${st.b}`:st.b;
$('fig').innerHTML=st.fig&&!awaiting?FIG[st.fig]:'';$('lg').style.visibility=awaiting?'hidden':'';
$('tip').textContent=awaiting?'':st.tip;chips();
$('back').hidden=si===0;$('back').disabled=busy;$('back').textContent=done&&st.act?'Replay':'Back';
const go=$('go'),alt=$('alt');go.disabled=busy;alt.disabled=busy;
go.textContent=busy?'Cutting':si===0?'Start carving':last?'Carve again':awaiting?'Show me':!done?'Make the cut':'Next';
alt.hidden=si!==0;alt.textContent='Play the quiz';
$('score').style.display=quiz?'block':'none';document.body.classList.toggle('quiz',quiz);$('score').textContent=`Score ${total()}`;
steam.visible=si<6&&!still;size()}
function enter(i,fwd){si=i;picked=null;const st=STEPS[i];if(fwd||!snaps[i])snaps[i]=snap();done=!st.act;awaiting=quiz&&!!st.q;if(awaiting){scores[i]=0;setX(false)}else if(!userX&&i>0)setX(!!st.q);const live=!done&&!awaiting;setGuides(live&&st.pre?st.pre():null,st.sided);setWig(live&&st.wig&&!still?st.wig():null);fly(st.cam);draw()}
async function run(){const st=STEPS[si];unwig();setGuides(null);awaiting=false;busy=true;draw();await st.act();busy=false;done=true;fly([0,VIEW.all,VIEW.both,VIEW.tray,VIEW.all,VIEW.both,VIEW.tray][si]);draw()}
$('go').onclick=()=>{if(busy)return;const last=si===STEPS.length-1;
if(si===0){quiz=false;enter(1,true)}else if(last){restore(snaps[1]);scores.length=0;enter(0,false)}else if(!done)run();else enter(si+1,true)};
$('alt').onclick=()=>{quiz=true;scores.length=0;userX=false;enter(1,true);say('Quiz on. Find each joint without X-ray.')};
$('back').onclick=()=>{if(busy)return;if(done&&STEPS[si].act||si===STEPS.length-1&&false){restore(snaps[si]);enter(si,false)}else{restore(snaps[si-1]||snaps[si]);enter(si-1,false)}};
$('bx').onclick=()=>{if(awaiting)return say('X-ray is off in the quiz. Tap your answer first.');userX=true;setX(!xGoal)};
$('bh').onclick=()=>{$('help').hidden=false};$('hx').onclick=()=>{$('help').hidden=true};$('help').onclick=e=>{if(e.target.id==='help')$('help').hidden=true};
const ray=new THREE.Raycaster();
function tap(x,y){if(!awaiting||busy)return;const st=STEPS[si];ray.setFromCamera({x:x/W*2-1,y:-(y/H)*2+1},camera);
const d=Math.min(...st.q[1]().map(p=>ray.ray.distanceToPoint(p))),cm=Math.round(d*15),pts=d<.17?3:d<.36?2:d<.6?1:0;scores[si]=pts;
say(pts===3?'Exactly on the joint. 3 points.':pts===2?`Close. About ${cm} cm off. 2 points.`:pts===1?`About ${cm} cm off. 1 point.`:`Missed by about ${cm} cm. Look at the red point.`);
setX(true);awaiting=false;busy=true;draw();st.q[1]().length<3&&marks.forEach(m=>flash(m));wait(1500).then(run)}
/* ---------- frame loop ---------- */
let last=performance.now(),tt=0,xPrev=-1,ts=1,slowN=0,slowT=0,pr=Math.min(devicePixelRatio||1,2);
function frame(now){const raw=(now-last)/1000,dt=Math.min(.05,raw)*ts;last=now;tt+=dt;
if(raw<.5){slowT+=raw;if(++slowN>=90){if(slowT/slowN>1/26&&pr>1){pr=Math.max(1,pr-.5);renderer.setPixelRatio(pr);size()}slowN=slowT=0}}
for(const t of[...tweens]){t.t+=dt;const k=Math.min(1,t.t/t.d);t.fn(t.ease(k));if(k>=1){tweens.delete(t);t.res()}}
xr+=(xGoal-xr)*(1-Math.exp(-dt*5));if(Math.abs(xr-xPrev)>.002){xPrev=xr;const tr=xr>.02;
for(const m of flesh){if(m.transparent!==tr){m.transparent=tr;m.needsUpdate=true}m.opacity=1-.64*xr;m.depthWrite=xr<.45}
skinMat.clearcoat=.75*(1-xr);boneMat.emissiveIntensity=.04+.2*xr;boneMat.color.copy(B0).lerp(B1,xr)}
const st=STEPS[si],side=camera.position.z-cam.tz;
for(const m of marks){const u=m.userData,tg=!awaiting&&st.lab.includes(u.id)&&(!picked||picked===u.id);let o=m.visible&&!awaiting?(tg?1:xr*.32):0;
if((u.id!=='knee'||si<2)&&side*u.s<-.4)o*=.3;m.material.opacity=o;m.scale.setScalar(.34*u.k);
const f=still?.35:(tt*.8+(u.s>0?0:.5))%1;u.p.visible=m.visible;u.p.material.opacity=tg?o*(1-f)*.85:0;u.p.scale.setScalar(.34*(1+f*1.2)*u.k)}
const hi=awaiting?'':st.hi;for(const[m,k]of BM){const on=hi===k;m.color.copy(B0).lerp(GOLD,on?xr:0);m.emissive.copy(on?HI:LO);m.emissiveIntensity=.04+xr*(on?.45+(still?0:.2*Math.sin(tt*4)):.3)}
guideMat.opacity=still?.95:.8+.2*Math.sin(tt*4);for(const g of guides.children){const far=g.userData.s&&side*g.userData.s<-.4;if(g.userData.edge)g.visible=!far;else g.material=far?guideFar:guideMat}
if(wigs&&!busy){const a=.5-.5*Math.cos(tt*2.6);for(const w of wigs)w.o.quaternion.copy(w.q0).multiply(qT.setFromAxisAngle(w.ax,w.amp*a))}
if(steam.visible)for(const s of steam.children){const u=(tt*.16+s.userData.ph)%1;s.position.set(s.userData.x+Math.sin(tt+s.userData.ph*9)*.15,1.4+u*2,s.userData.z);s.scale.setScalar(.5+u*1.3);s.material.opacity=Math.sin(u*PI)*.085*(1-xr)}
placeCam(dt);placeLabels();renderer.render(scene,camera);requestAnimationFrame(frame)}
size();enter(0,true);cam.th=1.5;cam.r=fitR(3.8,4.2)*1.3;
setTimeout(()=>{if(!userX&&si===0)setX(true)},2300);setTimeout(()=>$('hint').style.opacity=0,7000);
requestAnimationFrame(frame);
window.__t={STEPS,cam,get pr(){return pr},get xr(){return xr},leg,wing,lobe,get busy(){return busy},get si(){return si},set ts(v){ts=v}};
}
index.html43 lines
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Carve the Turkey: find the six joints in 3D</title>
<meta name="description" content="A free 3D carving lesson: turn a roasted turkey, see the six joints through the skin, and follow seven cuts from the hip to the sliced breast.">
<link rel="icon" href="../../favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="./turkey.css">
</head><body>
<canvas id="c" aria-label="3D roasted turkey. Drag to turn, pinch to zoom."></canvas>
<div id="vig"></div>
<div id="labels"></div>
<header>
<div class="mark"><a class="back" href="../">← Animations</a>Carve <i>the turkey</i></div>
<div class="tog"><span id="score"></span><button id="bx" aria-pressed="false">X-ray</button><button id="bh">Help</button></div>
</header>
<p id="hint">Drag to turn. Pinch or scroll to zoom.</p>
<div id="toast" role="status"></div>
<section id="card">
<div id="bar"></div>
<div id="kr"><p id="k"></p><p id="lg"><span><svg viewBox="0 0 30 30" aria-hidden="true"><circle cx="15" cy="15" r="9" fill="none" stroke="#fff" stroke-width="6"/><circle cx="15" cy="15" r="9" fill="none" stroke="#ff3358" stroke-width="3.5"/><circle cx="15" cy="15" r="2.6" fill="#fff"/></svg>Joint</span><span><svg viewBox="0 0 30 30" aria-hidden="true"><path d="M3 21Q15 5 27 13" fill="none" stroke="#fff6dd" stroke-width="3" stroke-dasharray="5 3.5" stroke-linecap="round"/></svg>Knife path</span></p></div>
<h1 id="t">Carve the turkey</h1>
<div id="scroll"><div id="body"><div id="fig"></div><p id="b">The 3D model is loading.</p></div>
<div id="chips"></div>
<p id="tip"></p></div>
<div class="row"><button id="back" class="ghost" hidden>Back</button><button id="alt" class="ghost" hidden></button><button id="go" class="pri">Start carving</button></div>
</section>
<div id="help" hidden><div class="sheet" role="dialog" aria-label="Help">
<h2>How to read the model</h2>
<ul>
<li><svg viewBox="0 0 30 30" aria-hidden="true"><circle cx="15" cy="15" r="9" fill="none" stroke="#fff" stroke-width="6"/><circle cx="15" cy="15" r="9" fill="none" stroke="#ff3358" stroke-width="3.5"/><circle cx="15" cy="15" r="2.6" fill="#fff"/></svg>A red ring marks a joint. The knife goes through it.</li>
<li><svg viewBox="0 0 30 30" aria-hidden="true"><path d="M3 21Q15 5 27 13" fill="none" stroke="#fff6dd" stroke-width="3" stroke-dasharray="5 3.5" stroke-linecap="round"/></svg>A dashed white line shows the knife path.</li>
<li><svg viewBox="0 0 30 30" aria-hidden="true"><path d="M5 24H26M5 24L20 7" fill="none" stroke="#f7ecdb" stroke-width="3" stroke-linecap="round"/><path d="M20 23A15 15 0 0 0 15.5 13.5" fill="none" stroke="#e9ab45" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="1 4.5"/></svg>A part that moves shows you where it bends.</li>
<li><svg viewBox="0 0 30 30" aria-hidden="true"><path d="M7 22L23 8" stroke="#e9ab45" stroke-width="5" stroke-linecap="round"/><circle cx="7" cy="22" r="4.6" fill="#e9ab45"/><circle cx="23" cy="8" r="4.6" fill="#e9ab45"/></svg>In X-ray, the gold bones are the bones for this step.</li>
</ul>
<p>Drag to turn the bird. Pinch or scroll to zoom. Tap two times to reset the view. Tap a label to go to that joint. Tap Replay to see a cut again.</p>
<p><a href="../../cases/carve-the-turkey/">How it was made</a> · <a href="../">All animations</a></p>
<button class="pri" id="hx">Got it</button>
</div></div>
<div id="fail"><p>This page needs WebGL to show the 3D turkey. Open it in a current browser.</p></div>
<script src="../vendor/three-r128.min.js"></script>
<script src="./turkey.js"></script>
</body></html>
turkey.css80 lines
@font-face{font-family:Fraunces;font-style:normal;font-weight:600;font-display:swap;src:url(./fonts/fraunces-latin-600-normal.woff2) format("woff2")}
@font-face{font-family:Fraunces;font-style:italic;font-weight:500;font-display:swap;src:url(./fonts/fraunces-latin-500-italic.woff2) format("woff2")}
@font-face{font-family:Figtree;font-style:normal;font-weight:300 900;font-display:swap;src:url(./fonts/figtree-latin-wght-normal.woff2) format("woff2")}
/* VOICE: a calm kitchen lesson at the table, warm and exact.
IDEA: an anatomy chart for the carving board; the bird turns to glass and shows its joints.
PICTURE: one roasted turkey on a walnut board, full screen, to turn and zoom.
COLOUR AND TYPE: espresso ground, cream ink, roast gold, cranberry for joints; Fraunces + Figtree.
LAYOUT: the scene fills the screen; one step card at the bottom; two switches at the top. */
:root{color-scheme:dark;--bg:#170d08;--ink:#f7ecdb;--dim:#cdb89c;--gold:#e9ab45;--cran:#ff4f6a;--panel:rgba(28,16,10,.78);--line:rgba(247,236,219,.16)}
*{box-sizing:border-box;min-width:0}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.5 Figtree,system-ui,sans-serif;overflow:hidden;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
#c{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}
#vig{position:fixed;inset:0;pointer-events:none;background:radial-gradient(120% 90% at 50% 38%,transparent 45%,rgba(10,5,3,.7) 100%)}
#labels{position:fixed;inset:0;pointer-events:none;overflow:hidden}
.lb{position:absolute;left:0;top:0;display:flex;align-items:center;gap:6px;padding:5px 10px 5px 7px;border-radius:99px;background:rgba(20,11,7,.82);border:1px solid var(--line);font-size:13px;font-weight:600;white-space:nowrap;color:var(--ink);pointer-events:auto;cursor:pointer;will-change:transform;font-family:inherit}
.lb::before{content:"";width:9px;height:9px;border-radius:50%;background:var(--cran);box-shadow:0 0 0 3px rgba(255,79,106,.25)}
.lb.bone::before{background:var(--gold);box-shadow:0 0 0 3px rgba(233,171,69,.25)}
header{position:fixed;left:0;right:0;top:0;display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px max(14px,3vw);pointer-events:none}
.mark{font:600 22px/1 Fraunces,Georgia,serif;letter-spacing:-.01em;text-shadow:0 2px 12px #000;white-space:nowrap}
@media(max-width:480px){.quiz .mark i{display:none}}
.back{display:block;width:max-content;margin-bottom:6px;font:600 13px/1 Figtree,system-ui,sans-serif;letter-spacing:0;color:var(--dim);text-decoration:none;pointer-events:auto}
.back:hover,.sheet a:hover{color:var(--ink)}
.sheet a{color:var(--gold)}
.mark i{font-weight:500;color:var(--gold)}
.tog{display:flex;gap:8px;pointer-events:auto}
button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation}
button:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
.tog button{min-height:40px;padding:0 14px;border-radius:99px;background:var(--panel);border:1px solid var(--line);font-size:14px;font-weight:600;white-space:nowrap;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
.tog button[aria-pressed=true]{background:var(--ink);color:#20120a;border-color:var(--ink)}
#score{display:none;align-self:center;font-weight:600;font-size:14px;color:var(--gold);white-space:nowrap}
#card{position:fixed;left:50%;bottom:max(10px,env(safe-area-inset-bottom));transform:translateX(-50%);width:min(520px,calc(100% - 20px));padding:14px 16px 14px;border-radius:20px;background:var(--panel);border:1px solid var(--line);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);box-shadow:0 18px 50px rgba(0,0,0,.55)}
#card{display:flex;flex-direction:column;max-height:calc(100% - 236px)}
#scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
@media(min-width:900px){#card{left:28px;bottom:28px;transform:none;width:430px;padding:20px 22px;max-height:calc(100% - 100px)}}
#bar{display:flex;gap:4px;margin-bottom:10px}
#bar span{flex:1;height:3px;border-radius:2px;background:var(--line)}
#bar span.on{background:var(--gold)}
#kr{display:flex;justify-content:space-between;align-items:center;gap:8px}
#k{margin:0;font-size:13px;font-weight:600;color:var(--gold);white-space:nowrap}
#lg{margin:0;display:flex;gap:11px;font-size:13px;color:var(--dim);white-space:nowrap}
#lg svg{width:17px;height:17px;margin-right:4px;vertical-align:-4px}
#body{display:flow-root}
#b span{display:block}#b span+span{margin-top:5px}
#b b{color:var(--gold);font-weight:600;margin-right:7px}
#fig{float:right;width:76px;height:76px;margin:4px 0 4px 12px;border-radius:14px;background:rgba(0,0,0,.3);border:1px solid var(--line)}
#fig:empty{display:none}
#fig svg{display:block;width:100%;height:100%}
#help{position:fixed;inset:0;display:grid;place-items:center;padding:16px;background:rgba(10,5,3,.7);z-index:5}
#help[hidden]{display:none}
.sheet{width:min(440px,100%);max-height:100%;overflow-y:auto;padding:20px;border-radius:20px;background:#24140b;border:1px solid var(--line);box-shadow:0 18px 50px rgba(0,0,0,.6)}
.sheet h2{margin:0 0 12px;font:600 25px/1.1 Fraunces,Georgia,serif}
.sheet ul{list-style:none;margin:0;padding:0;display:grid;gap:11px}
.sheet li{display:flex;gap:12px;align-items:center;font-size:15.5px;line-height:1.35}
.sheet li svg{flex:none;width:32px;height:32px}
.sheet p{margin:13px 0 0;font-size:14.5px;color:var(--dim);line-height:1.45}
.sheet .pri{width:100%;min-height:46px;border-radius:13px;font-weight:600;font-size:15.5px;margin-top:15px}
h1{margin:2px 0 6px;font:600 clamp(25px,6.4vw,32px)/1.08 Fraunces,Georgia,serif;letter-spacing:-.015em;text-wrap:balance}
#b{margin:0;color:var(--ink);font-size:15.5px;line-height:1.45}
#tip{margin:8px 0 0;font-size:14px;color:var(--dim);line-height:1.4}
#tip:empty,#chips:empty{display:none}
#chips{display:flex;gap:7px;margin:10px 0 0;padding:0 0 2px;overflow-x:auto;scrollbar-width:none}
#chips::-webkit-scrollbar{display:none}
#chips button{flex:none;min-height:38px;padding:0 13px;border-radius:99px;background:transparent;border:1px solid var(--line);font-size:14px;font-weight:600}
#chips button.on{border-color:var(--cran);color:#fff;background:rgba(255,79,106,.16)}
.row{display:flex;gap:8px;margin-top:12px}
.row button{min-height:46px;border-radius:13px;font-weight:600;font-size:15.5px;padding:0 16px}
.ghost{background:transparent;border:1px solid var(--line)}
.pri{flex:1;background:var(--gold);color:#22130a}
.row button:disabled{opacity:.45;cursor:default}
.row button[hidden]{display:none}
#toast{position:fixed;left:50%;top:68px;transform:translate(-50%,-8px);padding:9px 16px;border-radius:18px;line-height:1.35;width:max-content;background:var(--ink);color:#22130a;font-weight:600;font-size:14.5px;opacity:0;transition:opacity .25s,transform .25s;pointer-events:none;max-width:calc(100% - 28px);text-align:center}
#toast.on{opacity:1;transform:translate(-50%,0)}
#hint{position:fixed;left:50%;top:64px;transform:translateX(-50%);margin:0;padding:6px 13px;border-radius:99px;background:rgba(20,11,7,.6);font-size:13px;color:var(--dim);pointer-events:none;transition:opacity .6s;white-space:nowrap}
#fail{position:fixed;inset:0;display:none;place-items:center;padding:30px;text-align:center}
@media(max-width:899px) and (max-height:640px){h1{font-size:22px;margin-bottom:4px}#b{font-size:14.5px;line-height:1.4}#tip,#fig{display:none}.row{margin-top:9px}.row button{min-height:44px}#card{padding:12px 14px}}
@media(max-width:899px) and (max-height:520px) and (min-width:560px){#card{left:10px;bottom:10px;transform:none;width:min(330px,46vw);max-height:calc(100% - 74px)}#chips{margin-top:8px}h1{font-size:21px}.sheet{width:min(680px,100%);padding:16px 18px}.sheet h2{font-size:21px;margin-bottom:8px}.sheet ul{grid-template-columns:1fr 1fr;gap:8px 16px}.sheet li{font-size:14.5px}.sheet p{margin-top:9px;font-size:14px}.sheet .pri{margin-top:10px;min-height:44px}#toast{left:auto;right:12px;transform:translate(0,-8px);max-width:44vw}#toast.on{transform:none}#hint{left:auto;right:12px;transform:none}}
@media(max-width:360px){.mark{font-size:19px}.tog{gap:6px}.tog button{padding:0 11px}#lg{gap:8px}}
@media(prefers-reduced-motion:reduce){#toast{transition:none}}
Need an interactive piece for your business or audience?
A product explainer, a training walkthrough, a simulation people can play with. This one is free to take. I can build yours for a fixed price agreed up front, and the first call is free.