{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ray-marched-fluted-stoneware-vase-product-card-on-a-paper-plinth-with-a-colourway-glaze-wipe-and-drag-to-turn","type":"registry:block","title":"Ray-Marched Fluted Stoneware Vase Product Card on a Paper Plinth with a Colourway Glaze Wipe and Drag to Turn","description":"Free React product card with a ray-marched ceramic vase on a paper plinth in daylight. Drag to turn it; each colourway washes up the glaze.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/ray-marched-fluted-stoneware-vase-product-card-on-a-paper-plinth-with-a-colourway-glaze-wipe-and-drag-to-turn.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The product. Change the words here. */\nconst PRODUCT = {\n  maker: \"Halde Ceramics\",\n  name: \"Ondine\",\n  kind: \"fluted vase\",\n  price: \"$148\",\n  blurb: \"Thrown by hand in grogged stoneware, then cut with twenty four flutes. The glaze runs thin on every ridge and pools deep in every groove, so the colour shifts as light moves round it.\",\n  facts: [\"34 cm tall\", \"Stoneware\", \"Raw clay foot\"],\n};\n\n/** Colourways: glaze, paper plinth, backdrop paper and the page tint around the stage. */\nconst COLOURWAYS = [\n  { name: \"Lagoon\", glaze: \"#1f7f80\", plinth: \"#e95a42\", backdrop: \"#fbd67a\", page: \"#fdeec4\" },\n  { name: \"Cobalt\", glaze: \"#0f3a8f\", plinth: \"#f2782a\", backdrop: \"#f8c0c2\", page: \"#fde3e3\" },\n  { name: \"Marigold\", glaze: \"#e08a12\", plinth: \"#3f63d2\", backdrop: \"#b2e3cf\", page: \"#dff3ea\" },\n  { name: \"Rose clay\", glaze: \"#c95c68\", plinth: \"#76a87d\", backdrop: \"#d4cbf4\", page: \"#ece8fb\" },\n];\n\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\nconst SERIF = '\"Iowan Old Style\", \"Palatino Linotype\", Palatino, \"Book Antiqua\", Georgia, serif';\n/** Seconds the glaze takes to wipe from one colourway to the next. */\nconst WIPE_SECONDS = 1.25;\n/** Self-playing demo: first change after this many seconds, then one every DEMO_EVERY. Stops on any input. */\nconst DEMO_FIRST = 4.2;\nconst DEMO_EVERY = 5.2;\n/** Idle turning speed (radians a second) and how quickly a flick slows down. */\nconst IDLE_SPIN = 0.32;\nconst FRICTION = 2.6;\n/** Render scale limits (canvas pixels per CSS pixel) and the pixel budget per frame. */\nconst MAX_SCALE = 1.5;\nconst MIN_SCALE = 0.75;\nconst PIXEL_BUDGET = 1_100_000;\n\nconst toLinear = (hex: string): [number, number, number] => {\n  const n = parseInt(hex.slice(1), 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((v) => Math.pow(v / 255, 2.2)) as [number, number, number];\n};\n\nconst VS = `attribute vec2 p;void main(){gl_Position=vec4(p,0.,1.);}`;\n\nconst FS = `precision highp float;\nuniform vec2 uRes;uniform float uRot,uWipe,uBob,uSeed;\nuniform vec3 uGA,uGB,uPA,uPB,uBA,uBB;\n#define BASE 0.46\n#define VH 1.42\n#define PR 0.74\nvec3 L;\nfloat hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}\nfloat vnoise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);\n return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y);}\nfloat prof(float t){return 0.17+0.3*exp(-pow((t-0.37)/0.26,2.))+0.085*pow(smoothstep(0.8,1.,t),2.);}\nvec3 vloc(vec3 p){float c=cos(uRot),s=sin(uRot);return vec3(c*p.x-s*p.z,p.y,s*p.x+c*p.z);}\nfloat fl(vec3 q,float t){float m=smoothstep(0.07,0.17,t)*(1.-smoothstep(0.7,0.8,t));\n return m*cos(24.*atan(q.z,q.x));}\nfloat vase(vec3 p){vec3 q=vloc(p);float h=q.y-BASE;float t=clamp(h/VH,0.,1.);\n float r=prof(t)+0.0085*fl(q,t);float rho=length(q.xz);\n float shell=abs(rho-r+0.012)-0.012;\n float lip=smoothstep(0.985,1.,t)*0.006;\n float d=max(shell+lip,max(-h,h-VH));\n d=min(d,max(rho-r,abs(h-0.05)-0.05));\n return d*0.62;}\nfloat rcyl(vec3 p,float r,float y0,float y1,float rb){vec2 d=vec2(length(p.xz)-r+rb,abs(p.y-(y0+y1)*0.5)-(y1-y0)*0.5+rb);\n return min(max(d.x,d.y),0.)+length(max(d,0.))-rb;}\nfloat plinth(vec3 p){return min(rcyl(p,PR-0.012,0.,BASE-0.05,0.02),rcyl(p,PR,BASE-0.115,BASE,0.012));}\nfloat map(vec3 p){return min(vase(p),plinth(p));}\nvec2 box(vec3 ro,vec3 rd){vec3 lo=vec3(-PR-0.02,-0.01,-PR-0.02),hi=vec3(PR+0.02,BASE+VH+0.02,PR+0.02);\n vec3 inv=1./rd;vec3 a=(lo-ro)*inv,b=(hi-ro)*inv;vec3 mn=min(a,b),mx=max(a,b);\n return vec2(max(max(mn.x,mn.y),mn.z),min(min(mx.x,mx.y),mx.z));}\nvec3 nrm(vec3 p){vec2 e=vec2(0.0012,-0.0012);\n return normalize(e.xyy*map(p+e.xyy)+e.yyx*map(p+e.yyx)+e.yxy*map(p+e.yxy)+e.xxx*map(p+e.xxx));}\nfloat shadow(vec3 ro,vec3 rd){vec2 b=box(ro,rd);if(b.x>b.y||b.y<0.)return 1.;\n float res=1.,t=max(b.x,0.015);\n for(int i=0;i<44;i++){float h=map(ro+rd*t);res=min(res,7.*h/t);t+=clamp(h,0.012,0.2);if(res<0.003||t>b.y)break;}\n return clamp(res,0.,1.);}\nfloat occl(vec3 p,vec3 n){float o=0.,s=1.;\n for(int i=1;i<=5;i++){float h=0.015+0.05*float(i*i)*0.5;o+=(h-map(p+n*h))*s;s*=0.72;}\n return clamp(1.-1.4*o,0.,1.);}\nfloat wipeK(vec3 p){float e=-0.25+uWipe*2.75+0.035*sin(atan(p.z,p.x)*3.+p.y*5.);return smoothstep(e+0.06,e-0.06,p.y);}\nvec3 SUN=vec3(1.,0.95,0.86)*2.25;\nfloat win(vec3 p){vec3 tx=normalize(cross(vec3(0,1,0),L)),ty=cross(L,tx);float u=dot(p,tx),v=dot(p,ty);\n float fr=smoothstep(3.6,2.6,abs(u-0.3))*smoothstep(3.4,2.4,abs(v));return mix(0.45,1.,fr);}\nvec3 SKY=vec3(0.78,0.82,0.92)*0.78;\nvec3 env(vec3 d,vec3 bg){\n vec3 col=mix(vec3(0.85,0.82,0.78),vec3(0.6,0.72,0.95),clamp(d.y*1.5,0.,1.))*0.8;\n vec3 tx=normalize(cross(vec3(0,1,0),L)),ty=cross(L,tx);float a=dot(d,L);\n if(a>0.){vec2 u=vec2(dot(d,tx),dot(d,ty))/a;\n  float w=smoothstep(0.56,0.5,abs(u.x))*smoothstep(0.8,0.74,abs(u.y));\n  w*=1.-0.9*smoothstep(0.022,0.01,abs(u.x))-0.9*smoothstep(0.022,0.01,abs(u.y-0.12));\n  col+=w*vec3(1.,0.97,0.9)*7.;}\n vec3 f=normalize(vec3(0.95,0.18,0.3));col+=smoothstep(0.9,0.95,dot(d,f))*vec3(1.)*1.6;\n col=mix(col,bg*(SUN*L.y+SKY)*0.75,smoothstep(0.06,-0.3,d.y));\n return col;}\nvec3 tone(vec3 x){x*=1.0;return clamp((x*(2.51*x+0.03))/(x*(2.43*x+0.59)+0.14),0.,1.);}\nvoid main(){\n L=normalize(vec3(-0.62,0.74,0.5));\n vec2 uv=(gl_FragCoord.xy-0.5*uRes)/min(uRes.y,uRes.x*1.18);\n vec3 ro=vec3(0.,1.5+uBob,5.1),ta=vec3(0.,0.97,0.);\n vec3 fw=normalize(ta-ro),rt=normalize(cross(fw,vec3(0,1,0))),up=cross(rt,fw);\n vec3 rd=normalize(fw*1.88+rt*uv.x+up*uv.y);\n float kw=smoothstep(0.3,0.95,uWipe);\n vec3 bgW=mix(uBA,uBB,kw);\n float flIl=SUN.x*L.y*0.92+SKY.x;\n vec3 col=bgW*vec3(flIl)*mix(1.,0.8,clamp(uv.y+0.2,0.,1.));\n float tHit=-1.;vec2 b=box(ro,rd);\n if(b.x<b.y&&b.y>0.){float t=max(b.x,0.);\n  for(int i=0;i<120;i++){float h=map(ro+rd*t);if(h<0.0007){tHit=t;break;}t+=h;if(t>b.y)break;}}\n float tf=rd.y<0.?-ro.y/rd.y:1e9;\n if(tHit>0.){vec3 p=ro+rd*tHit;vec3 n=nrm(p);float sh=shadow(p+n*0.003,L);float ao=occl(p,n);\n  float k=wipeK(p);float dif=max(dot(n,L),0.);\n  vec3 bgC=mix(uBA,uBB,k);\n  vec3 amb=SKY*(0.55+0.45*n.y)*ao+bgC*0.55*(0.5-0.5*n.y)*ao;\n  if(vase(p)<plinth(p)){\n   vec3 q=vloc(p);float h=q.y-BASE;float t=clamp(h/VH,0.,1.);float a=atan(q.z,q.x);float f=fl(q,t);\n   float line=0.085+0.012*sin(a*5.)+0.007*sin(a*13.+1.)-0.05*pow(max(sin(a*7.+1.3),0.),24.);\n   float gz=smoothstep(line-0.005,line+0.005,h);\n   bool inside=length(q.xz)<prof(t)-0.012;\n   vec3 g=mix(uGA,uGB,k)*0.8;\n   float thick=0.5+0.5*f;\n   vec3 ga=mix(g*mix(0.42,1.,thick),vec3(1.),0.1*thick)*mix(0.72,1.,smoothstep(line,line+0.09,h));\n   ga=mix(ga,mix(g,vec3(1.),0.25),smoothstep(0.96,1.,t)*0.6);\n   vec3 clay=vec3(0.74,0.6,0.47)*(0.9+0.2*vnoise(q.xz*60.+q.y*40.))*(1.-0.35*step(0.93,hash(floor(vec2(a*60.,h*200.)))));\n   vec3 alb=mix(clay,ga,gz);\n   vec3 c=alb*(SUN*dif*sh+amb);\n   c+=alb*g*0.25*SKY*pow(clamp(1.-abs(dot(n,rd)),0.,1.),2.)*gz;\n   float edge=exp(-pow((p.y-(-0.25+uWipe*2.75))/0.04,2.))*step(0.001,uWipe)*step(uWipe,0.999);\n   c*=1.+0.12*edge;\n   if(gz>0.01){float F=0.035+0.965*pow(1.-max(dot(n,-rd),0.),5.);\n    vec3 r=reflect(rd,n);vec3 e=env(r,bgC)*mix(0.35,1.,sh*0.5+0.5)*ao;\n    if(inside)e*=0.35;\n    c=mix(c,e,F*gz);vec3 hv=normalize(L-rd);c+=SUN*pow(max(dot(n,hv),0.),220.)*sh*1.4*gz;}\n   col=c;\n  }else{\n   vec3 pa=mix(uPA,uPB,k);float ang=atan(p.z,p.x);\n   float fib=0.96+0.04*vnoise(vec2(ang*260.,p.y*60.))+0.03*vnoise(p.xz*90.)-0.05*smoothstep(0.01,0.,abs(p.y-BASE+0.05))*step(n.y,0.5);\n   float seam=1.-0.12*smoothstep(0.012,0.,abs(ang-2.2))*step(p.y,BASE-0.02);\n   vec3 alb=pa*fib*seam*(n.y>0.6?1.04:1.);\n   col=alb*(SUN*dif*sh+amb);\n   col+=alb*0.12*SUN*pow(max(dot(n,normalize(L-rd)),0.),12.)*sh;\n  }\n }else if(tf<1e8){vec3 p=ro+rd*tf;float k=smoothstep(-1.+uWipe*11.+0.6,-1.+uWipe*11.-0.6,length(p.xz));\n  vec3 alb=mix(uBA,uBB,k)*(0.97+0.05*vnoise(p.xz*40.));\n  float d2=length(p.xz);float sh=shadow(p+vec3(0,0.002,0),L);float ao=d2<1.6?mix(0.3,1.,occl(p,vec3(0,1,0))):1.;\n  sh*=win(p);vec3 c=alb*(SUN*L.y*sh+SKY*ao)*0.92;\n  vec3 wall=mix(uBA,uBB,kw)*vec3(flIl)*mix(1.,0.8,clamp(uv.y+0.2,0.,1.));\n  col=mix(c,wall,smoothstep(6.,16.,tf));\n }\n col=tone(col);\n col=pow(col,vec3(1./2.2));\n vec2 sv=gl_FragCoord.xy/uRes-0.5;col*=1.-0.12*dot(sv,sv);\n col+=(hash(gl_FragCoord.xy+uSeed)-0.5)/180.;\n gl_FragColor=vec4(col,1.);\n}`;\n\ntype Gl = WebGLRenderingContext;\n\nfunction makeProgram(gl: Gl): WebGLProgram | null {\n  const sh = (type: number, src: string) => {\n    const s = gl.createShader(type);\n    if (!s) return null;\n    gl.shaderSource(s, src);\n    gl.compileShader(s);\n    if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) {\n      console.warn(gl.getShaderInfoLog(s));\n      return null;\n    }\n    return s;\n  };\n  const v = sh(gl.VERTEX_SHADER, VS);\n  const f = sh(gl.FRAGMENT_SHADER, FS);\n  const prog = gl.createProgram();\n  if (!v || !f || !prog) return null;\n  gl.attachShader(prog, v);\n  gl.attachShader(prog, f);\n  gl.linkProgram(prog);\n  return gl.getProgramParameter(prog, gl.LINK_STATUS) ? prog : null;\n}\n\nconst ease = (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);\n\n/** Still picture used when WebGL is missing: the same vase in flat SVG shading. */\nfunction StillVase({ way }: { way: (typeof COLOURWAYS)[number] }) {\n  return (\n    <svg viewBox=\"0 0 400 440\" preserveAspectRatio=\"xMidYMid slice\" className=\"absolute inset-0 h-full w-full\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id=\"god5-v\" x1=\"0\" x2=\"1\">\n          <stop offset=\"0\" stopColor=\"#fff\" stopOpacity=\".4\" />\n          <stop offset=\".28\" stopColor=\"#fff\" stopOpacity=\"0\" />\n          <stop offset=\".7\" stopColor=\"#000\" stopOpacity=\".2\" />\n          <stop offset=\"1\" stopColor=\"#000\" stopOpacity=\".42\" />\n        </linearGradient>\n        <linearGradient id=\"god5-h\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\".55\" stopColor=\"#000\" stopOpacity=\"0\" />\n          <stop offset=\"1\" stopColor=\"#000\" stopOpacity=\".3\" />\n        </linearGradient>\n        <pattern id=\"god5-f\" width=\"10\" height=\"10\" patternUnits=\"userSpaceOnUse\">\n          <rect width=\"10\" height=\"10\" fill=\"#000\" opacity=\".16\" />\n          <rect x=\"2\" width=\"5\" height=\"10\" fill=\"#fff\" opacity=\".16\" />\n        </pattern>\n        <filter id=\"god5-b\" x=\"-30%\" y=\"-30%\" width=\"160%\" height=\"160%\"><feGaussianBlur stdDeviation=\"8\" /></filter>\n        <clipPath id=\"god5-c\"><path d=\"M182 300 C150 268 120 222 132 180 C142 148 176 132 184 112 C188 101 184 95 176 90 L224 90 C216 95 212 101 216 112 C224 132 258 148 268 180 C280 222 250 268 218 300 Z\" /></clipPath>\n      </defs>\n      <rect width=\"400\" height=\"440\" fill={way.backdrop} />\n      <ellipse cx=\"262\" cy=\"372\" rx=\"150\" ry=\"20\" fill=\"#000\" opacity=\".16\" filter=\"url(#god5-b)\" />\n      <path d=\"M96 300 v60 a104 20 0 0 0 208 0 v-60z\" fill={way.plinth} />\n      <path d=\"M96 300 v60 a104 20 0 0 0 208 0 v-60z\" fill=\"url(#god5-v)\" />\n      <path d=\"M93 300 v16 a107 21 0 0 0 214 0 v-16z\" fill={way.plinth} />\n      <path d=\"M93 300 v16 a107 21 0 0 0 214 0 v-16z\" fill=\"url(#god5-v)\" />\n      <ellipse cx=\"200\" cy=\"300\" rx=\"107\" ry=\"21\" fill={way.plinth} />\n      <ellipse cx=\"200\" cy=\"300\" rx=\"107\" ry=\"21\" fill=\"#fff\" opacity=\".2\" />\n      <ellipse cx=\"232\" cy=\"301\" rx=\"56\" ry=\"9\" fill=\"#000\" opacity=\".18\" filter=\"url(#god5-b)\" />\n      <g clipPath=\"url(#god5-c)\">\n        <rect width=\"400\" height=\"440\" fill={way.glaze} />\n        <rect width=\"400\" height=\"440\" fill=\"url(#god5-f)\" />\n        <rect width=\"400\" height=\"440\" fill=\"url(#god5-v)\" />\n        <rect y=\"90\" width=\"400\" height=\"210\" fill=\"url(#god5-h)\" />\n        <rect x=\"150\" y=\"150\" width=\"9\" height=\"90\" rx=\"4.5\" fill=\"#fff\" opacity=\".55\" filter=\"url(#god5-b)\" />\n        <rect y=\"288\" width=\"400\" height=\"14\" fill=\"#cdb79c\" />\n      </g>\n      <ellipse cx=\"200\" cy=\"91\" rx=\"24\" ry=\"4.5\" fill=\"#000\" opacity=\".4\" />\n    </svg>\n  );\n}\n\nexport default function RayMarchedFlutedVaseProductCard() {\n  const reduce = useReducedMotion();\n  const [active, setActive] = useState(0);\n  const [bag, setBag] = useState(0);\n  const [glFailed, setGlFailed] = useState(false);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const stageRef = useRef<HTMLDivElement>(null);\n  const state = useRef({ rot: 0.35, vel: 0, from: 0, to: 0, wipe: 1, wipeStart: 0, lastInput: -1e9, demo: true, dirty: true });\n  const reduceRef = useRef(!!reduce);\n  reduceRef.current = !!reduce;\n\n  const choose = (i: number, fromUser: boolean) => {\n    const s = state.current;\n    if (fromUser) s.demo = false;\n    if (i === s.to) return;\n    s.from = s.to;\n    s.to = i;\n    s.wipe = reduceRef.current ? 1 : 0;\n    s.wipeStart = performance.now();\n    if (reduceRef.current) s.from = i;\n    s.dirty = true;\n    setActive(i);\n  };\n\n  useEffect(() => {\n    const canvas = canvasRef.current;\n    const stage = stageRef.current;\n    if (!canvas || !stage) return;\n    const gl = canvas.getContext(\"webgl\", { antialias: false, alpha: false, powerPreference: \"high-performance\" }) as Gl | null;\n    const prog = gl ? makeProgram(gl) : null;\n    if (!gl || !prog) {\n      setGlFailed(true);\n      return;\n    }\n    const buf = gl.createBuffer();\n    gl.bindBuffer(gl.ARRAY_BUFFER, buf);\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n    gl.useProgram(prog);\n    const loc = gl.getAttribLocation(prog, \"p\");\n    gl.enableVertexAttribArray(loc);\n    gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);\n    const u = (n: string) => gl.getUniformLocation(prog, n);\n    const U = { res: u(\"uRes\"), rot: u(\"uRot\"), wipe: u(\"uWipe\"), bob: u(\"uBob\"), seed: u(\"uSeed\"), ga: u(\"uGA\"), gb: u(\"uGB\"), pa: u(\"uPA\"), pb: u(\"uPB\"), ba: u(\"uBA\"), bb: u(\"uBB\") };\n    const lin = COLOURWAYS.map((c) => ({ g: toLinear(c.glaze), p: toLinear(c.plinth), b: toLinear(c.backdrop) }));\n\n    let scale = Math.min(window.devicePixelRatio || 1, MAX_SCALE);\n    let w = 0;\n    let h = 0;\n    const resize = () => {\n      const r = canvas.getBoundingClientRect();\n      const s = Math.min(scale, Math.sqrt(PIXEL_BUDGET / Math.max(1, r.width * r.height)));\n      w = Math.max(1, Math.round(r.width * s));\n      h = Math.max(1, Math.round(r.height * s));\n      canvas.width = w;\n      canvas.height = h;\n      gl.viewport(0, 0, w, h);\n      state.current.dirty = true;\n    };\n    resize();\n    const ro = new ResizeObserver(resize);\n    ro.observe(canvas);\n\n    let visible = true;\n    const io = new IntersectionObserver(([e]) => {\n      visible = e.isIntersecting;\n      if (visible) kick();\n    });\n    io.observe(stage);\n\n    let raf = 0;\n    let last = performance.now();\n    const t0 = last;\n    let slow = 0;\n    let frames = 0;\n    let fpsT = last;\n    let nextDemo = t0 + DEMO_FIRST * 1000;\n\n    const frame = (now: number) => {\n      raf = 0;\n      const s = state.current;\n      const dt = Math.min(0.05, (now - last) / 1000);\n      last = now;\n      const still = reduceRef.current;\n      if (!still) {\n        const idle = now - s.lastInput > 2500;\n        const target = idle ? IDLE_SPIN : 0;\n        s.vel += (target - s.vel) * (1 - Math.exp(-FRICTION * dt));\n        s.rot += s.vel * dt;\n        if (s.demo && now > nextDemo) {\n          nextDemo = now + DEMO_EVERY * 1000;\n          choose((s.to + 1) % COLOURWAYS.length, false);\n        }\n      }\n      if (s.wipe < 1) {\n        s.wipe = Math.min(1, (now - s.wipeStart) / (WIPE_SECONDS * 1000));\n        if (s.wipe >= 1) s.from = s.to;\n      }\n      const a = lin[s.from];\n      const b = lin[s.to];\n      gl.uniform2f(U.res, w, h);\n      gl.uniform1f(U.rot, s.rot);\n      gl.uniform1f(U.wipe, s.wipe >= 1 ? 0 : ease(s.wipe));\n      gl.uniform1f(U.bob, still ? 0 : Math.sin((now - t0) / 2600) * 0.035);\n      gl.uniform1f(U.seed, still ? 0 : (now % 997) / 9.7);\n      gl.uniform3fv(U.ga, s.wipe >= 1 ? b.g : a.g);\n      gl.uniform3fv(U.gb, b.g);\n      gl.uniform3fv(U.pa, s.wipe >= 1 ? b.p : a.p);\n      gl.uniform3fv(U.pb, b.p);\n      gl.uniform3fv(U.ba, s.wipe >= 1 ? b.b : a.b);\n      gl.uniform3fv(U.bb, b.b);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      s.dirty = false;\n\n      frames++;\n      if (now - fpsT > 1000) {\n        const fps = (frames * 1000) / (now - fpsT);\n        canvas.dataset.fps = fps.toFixed(1);\n        if (now - t0 > 5000 && fps < 40 && scale > MIN_SCALE && ++slow > 2) {\n          scale = Math.max(MIN_SCALE, scale * 0.82);\n          slow = 0;\n          resize();\n        }\n        frames = 0;\n        fpsT = now;\n      }\n      if (visible && !document.hidden && (!still || s.wipe < 1 || s.dirty)) raf = requestAnimationFrame(frame);\n    };\n    const kick = () => {\n      if (!raf) {\n        last = performance.now();\n        raf = requestAnimationFrame(frame);\n      }\n    };\n    (state.current as unknown as { kick: () => void }).kick = kick;\n    const onVis = () => !document.hidden && kick();\n    document.addEventListener(\"visibilitychange\", onVis);\n    kick();\n\n    // drag to turn\n    let dragging = false;\n    let lastX = 0;\n    let lastT = 0;\n    const down = (e: PointerEvent) => {\n      dragging = true;\n      lastX = e.clientX;\n      lastT = performance.now();\n      state.current.demo = false;\n      state.current.lastInput = lastT;\n      canvas.setPointerCapture(e.pointerId);\n      kick();\n    };\n    const move = (e: PointerEvent) => {\n      if (!dragging) return;\n      const now = performance.now();\n      const dx = e.clientX - lastX;\n      const s = state.current;\n      const da = (dx / Math.max(200, canvas.clientWidth)) * Math.PI * 1.6;\n      s.rot += da;\n      s.vel = da / Math.max(0.008, (now - lastT) / 1000);\n      s.lastInput = now;\n      lastX = e.clientX;\n      lastT = now;\n      s.dirty = true;\n      kick();\n    };\n    const up = () => {\n      dragging = false;\n      state.current.lastInput = performance.now();\n    };\n    canvas.addEventListener(\"pointerdown\", down);\n    canvas.addEventListener(\"pointermove\", move);\n    canvas.addEventListener(\"pointerup\", up);\n    canvas.addEventListener(\"pointercancel\", up);\n\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVis);\n      canvas.removeEventListener(\"pointerdown\", down);\n      canvas.removeEventListener(\"pointermove\", move);\n      canvas.removeEventListener(\"pointerup\", up);\n      canvas.removeEventListener(\"pointercancel\", up);\n      gl.deleteProgram(prog);\n      gl.deleteBuffer(buf);\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  const kickLoop = () => (state.current as unknown as { kick?: () => void }).kick?.();\n\n  const onKey = (e: React.KeyboardEvent) => {\n    const s = state.current;\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\") {\n      e.preventDefault();\n      s.demo = false;\n      s.rot += (e.key === \"ArrowLeft\" ? -1 : 1) * (Math.PI / 12);\n      s.vel = 0;\n      s.lastInput = performance.now();\n      s.dirty = true;\n      kickLoop();\n    }\n  };\n\n  const pick = (i: number) => {\n    choose(i, true);\n    kickLoop();\n  };\n\n  const onSwatchKey = (e: React.KeyboardEvent, i: number) => {\n    const n = COLOURWAYS.length;\n    let j = -1;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") j = (i + 1) % n;\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\") j = (i - 1 + n) % n;\n    if (j < 0) return;\n    e.preventDefault();\n    pick(j);\n    const el = document.getElementById(`god5-sw-${j}`);\n    el?.focus();\n  };\n\n  const addToBag = () => {\n    const s = state.current;\n    s.demo = false;\n    if (!reduceRef.current) s.vel = 5.5;\n    s.lastInput = performance.now() - 2600;\n    kickLoop();\n    setBag((b) => b + 1);\n  };\n\n  const way = COLOURWAYS[active];\n\n  return (\n    <section\n      className=\"relative w-full overflow-hidden px-4 py-10 sm:px-8 sm:py-14\"\n      style={{ backgroundColor: way.page, transition: reduce ? \"none\" : `background-color ${WIPE_SECONDS}s ease`, fontFamily: FONT, minHeight: 640 }}\n    >\n      <div className=\"mx-auto grid max-w-6xl items-stretch gap-5 lg:grid-cols-[1.35fr_1fr]\">\n        <div\n          ref={stageRef}\n          tabIndex={0}\n          role=\"group\"\n          aria-roledescription=\"3D viewer\"\n          aria-label={`${PRODUCT.name} ${PRODUCT.kind} in ${way.name}. Use the left and right arrow keys to turn it.`}\n          onKeyDown={onKey}\n          className=\"relative h-[440px] overflow-hidden rounded-[28px] lg:h-auto lg:min-h-[600px] outline-none focus-visible:ring-4 focus-visible:ring-black/40 sm:h-[560px]\"\n          style={{ backgroundColor: way.backdrop }}\n        >\n          {glFailed ? <StillVase way={way} /> : <canvas ref={canvasRef} className=\"absolute inset-0 h-full w-full cursor-grab touch-pan-y active:cursor-grabbing\" aria-hidden=\"true\" />}\n          <div className=\"pointer-events-none absolute bottom-4 left-4 flex items-center gap-2 rounded-full bg-white/80 px-3.5 py-2 text-[13px] font-medium text-neutral-800 backdrop-blur-sm\">\n            <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n              <path d=\"M4 12a8 4 0 0 0 16 0\" />\n              <path d=\"M17 9l3 3-3 3\" />\n              <path d=\"M7 15l-3-3\" />\n            </svg>\n            Drag to turn\n          </div>\n        </div>\n\n        <div className=\"flex flex-col rounded-[28px] bg-white p-6 sm:p-9\">\n          <div className=\"flex items-center justify-between\">\n            <p className=\"text-[13px] font-semibold uppercase tracking-[0.14em] text-neutral-600\">{PRODUCT.maker}</p>\n            <span className=\"relative inline-flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-900\" aria-label={`Bag, ${bag} item${bag === 1 ? \"\" : \"s\"}`} role=\"img\">\n              <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <path d=\"M5 8h14l-1 12H6L5 8z\" />\n                <path d=\"M9 8V6a3 3 0 0 1 6 0v2\" />\n              </svg>\n              {bag > 0 && (\n                <span key={bag} className=\"god5-pop absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-neutral-900 px-1 text-[11px] font-semibold text-white\">\n                  {bag}\n                </span>\n              )}\n            </span>\n          </div>\n\n          <h2 className=\"mt-6 text-[52px] font-semibold leading-[0.9] tracking-[-0.045em] text-neutral-950 sm:text-[72px]\">{PRODUCT.name}</h2>\n          <p className=\"mt-2 text-[24px] italic text-neutral-700 sm:text-[28px]\" style={{ fontFamily: SERIF }}>\n            {PRODUCT.kind}\n          </p>\n          <p className=\"mt-5 text-[30px] font-semibold tracking-[-0.03em] text-neutral-950 tabular-nums\">{PRODUCT.price}</p>\n          <p className=\"mt-4 max-w-md text-[15px] leading-relaxed text-neutral-600\">{PRODUCT.blurb}</p>\n\n          <div className=\"mt-7\">\n            <p id=\"god5-cw\" className=\"text-[13px] font-medium text-neutral-600\">\n              Colourway <span className=\"ml-1 font-semibold text-neutral-950\">{way.name}</span>\n            </p>\n            <div role=\"radiogroup\" aria-labelledby=\"god5-cw\" className=\"mt-3 flex gap-3\">\n              {COLOURWAYS.map((c, i) => (\n                <button\n                  key={c.name}\n                  id={`god5-sw-${i}`}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={i === active}\n                  aria-label={c.name}\n                  tabIndex={i === active ? 0 : -1}\n                  onClick={() => pick(i)}\n                  onKeyDown={(e) => onSwatchKey(e, i)}\n                  className={`relative h-12 w-12 rounded-full outline-none transition-transform duration-200 hover:scale-105 focus-visible:ring-2 focus-visible:ring-neutral-900 focus-visible:ring-offset-2 motion-reduce:transition-none ${i === active ? \"ring-2 ring-neutral-900 ring-offset-[3px]\" : \"\"}`}\n                  style={{ background: `radial-gradient(circle at 34% 30%, rgba(255,255,255,.55), rgba(255,255,255,0) 38%), linear-gradient(160deg, ${c.glaze}, ${c.glaze} 55%, rgba(0,0,0,.35) 140%), ${c.glaze}` }}\n                >\n                  <span className=\"absolute -bottom-0.5 -right-0.5 h-4 w-4 rounded-full border-2 border-white\" style={{ backgroundColor: c.plinth }} aria-hidden=\"true\" />\n                </button>\n              ))}\n            </div>\n          </div>\n\n          <ul className=\"mt-6 flex flex-wrap gap-2\">\n            {PRODUCT.facts.map((f) => (\n              <li key={f} className=\"rounded-full border border-neutral-200 px-3 py-1.5 text-[13px] text-neutral-700\">\n                {f}\n              </li>\n            ))}\n          </ul>\n\n          <div className=\"mt-auto pt-8\">\n            <button\n              type=\"button\"\n              onClick={addToBag}\n              className=\"god5-press flex h-14 w-full items-center justify-between rounded-full bg-neutral-950 pl-7 pr-2 text-[16px] font-semibold text-white outline-none transition-transform duration-150 active:scale-[0.98] focus-visible:ring-4 focus-visible:ring-neutral-400 motion-reduce:transition-none\"\n            >\n              <span>{bag > 0 ? \"Add another\" : \"Add to bag\"}</span>\n              <span className=\"flex h-10 items-center rounded-full px-4 text-[14px] text-neutral-950\" style={{ backgroundColor: way.page, transition: reduce ? \"none\" : `background-color ${WIPE_SECONDS}s ease` }}>\n                {PRODUCT.price}\n              </span>\n            </button>\n            <p className=\"mt-3 text-center text-[13px] text-neutral-600\" aria-live=\"polite\">\n              {bag > 0 ? `${bag} in your bag, ${way.name} glaze.` : \"Each one is thrown to order and varies a little.\"}\n            </p>\n          </div>\n        </div>\n      </div>\n      <style>{`\n@keyframes god5-pop-k { 0% { transform: scale(.2); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }\n.god5-pop { animation: god5-pop-k .45s cubic-bezier(.3,1.6,.5,1) both; }\n@media (prefers-reduced-motion: reduce) { .god5-pop { animation: none; } }\n`}</style>\n    </section>\n  );\n}\n"}]}
