{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"glazed-stoneware-jar-pricing-in-webgl-where-the-chosen-jar-rocks-forward-on-a-pastel-shelf-and-fills-with-honey","type":"registry:block","title":"Glazed Stoneware Jar Pricing in WebGL Where the Chosen Jar Rocks Forward on a Pastel Shelf and Fills with Honey","description":"Free React pricing section in raw WebGL: three glazed stoneware jars on a mint shelf in window light; the chosen jar rocks forward and fills with honey.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/glazed-stoneware-jar-pricing-in-webgl-where-the-chosen-jar-rocks-forward-on-a-pastel-shelf-and-fills-with-honey.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { motion, useReducedMotion } from \"framer-motion\";\n\n/** The product and its three plans. These are example prices: change them to your own. */\nconst product = { name: \"Larkspur\", line: \"Recipe costing for small kitchens\" };\nconst plans = [\n  {\n    name: \"Taster\",\n    price: 9,\n    pitch: \"One menu, costed to the gram.\",\n    features: [\"1 kitchen, 60 recipes\", \"Supplier price lists\", \"Allergen labels to print\"],\n    radius: 0.34, // jar radius in metres\n    height: 0.8,\n    glaze: [0.62, 0.5, 0.3], // speckled oatmeal, linear RGB\n    slip: [0.16, 0.09, 0.06], // the paint used for the lettering\n  },\n  {\n    name: \"Kitchen\",\n    price: 24,\n    pitch: \"Every dish, every margin, every week.\",\n    features: [\"3 kitchens, unlimited recipes\", \"Stock counts on a phone\", \"Waste log and weekly margin\", \"Prep lists by station\"],\n    radius: 0.42,\n    height: 1.0,\n    glaze: [0.78, 0.24, 0.11], // apricot\n    slip: [0.93, 0.88, 0.78],\n  },\n  {\n    name: \"Larder\",\n    price: 58,\n    pitch: \"A group of sites on one price book.\",\n    features: [\"Up to 12 sites\", \"Central ordering and transfers\", \"Menu engineering reports\", \"A named onboarding cook\"],\n    radius: 0.5,\n    height: 1.24,\n    glaze: [0.025, 0.06, 0.24], // cobalt\n    slip: [0.93, 0.88, 0.78],\n  },\n];\n\nconst GAP = 0.36; // shelf between neighbouring jars\nconst ROCK = 0.3; // how far forward the chosen jar rocks, in radians\nconst BOUNCE = 0.32; // how much speed survives when a jar lands back on its foot\nconst FILL_SECONDS = 1.5; // how long the honey takes to fill a jar\nconst DEMO = true; // plays through the plans by itself until somebody touches it\nconst SERIF = '\"Iowan Old Style\", \"Palatino Linotype\", Palatino, \"Book Antiqua\", Georgia, serif';\nconst GROTESK = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\nconst INK = \"#2a1c19\";\nconst WALL = \"#ecd3cb\";\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst XS = (() => {\n  const total = plans.reduce((a, p) => a + p.radius * 2, 0) + GAP * (plans.length - 1);\n  let x = -total / 2;\n  return plans.map((p) => {\n    const c = x + p.radius;\n    x += p.radius * 2 + GAP;\n    return c;\n  });\n})();\nconst SUN_DIR = (() => {\n  const v = [-0.6, 0.66, 0.46];\n  const l = Math.hypot(v[0], v[1], v[2]);\n  return v.map((x) => x / l);\n})();\nconst SHELF_FRONT = 0.92;\nconst WALL_Z = -0.86;\n\nconst GLSL = `#version 300 es\nprecision highp float;\nconst vec3 L = vec3(${SUN_DIR.map((v) => v.toFixed(4)).join(\", \")});\nconst vec3 SUN = vec3(1.0, 0.9, 0.76) * 3.4;\nconst vec3 SKY = vec3(0.86, 0.84, 0.88) * 0.6;\nconst float FRONT = ${SHELF_FRONT.toFixed(2)};\nconst float WZ = ${WALL_Z.toFixed(2)};\nuniform vec4 uJ[3];      // x, z, radius, height\nuniform vec2 uCS[3];     // cos and sin of the rock angle\nuniform vec3 uPiv[3];    // the edge of the foot the jar is rocking on\nuniform float uOff[3];   // which edge: +radius front, -radius back\nuniform float uLv[3];    // world height of the honey\nuniform float uSl[3];    // slosh tilt of the honey\nuniform vec3 uGl[3];     // glaze colour\nuniform vec3 uSp[3];     // slip colour\nuniform vec4 uStream;    // x, z, radius, bottom\nuniform sampler2D uTex;\nuniform vec3 uCam, uRt, uUp, uFw;\nuniform float uTan, uAspect, uFocus, uAperture, uTime;\nuniform vec2 uShift;\nin vec2 vUv;\nout vec4 o;\n\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\nfloat hash(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }\nfloat vnoise(vec2 p) {\n  vec2 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * 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);\n}\nfloat fbm(vec2 p) { return 0.5 * vnoise(p) + 0.25 * vnoise(p * 2.1 + 7.3) + 0.125 * vnoise(p * 4.3 + 1.7) + 0.0625 * vnoise(p * 8.9); }\nfloat smax(float a, float b, float k) { float h = clamp(0.5 - 0.5 * (b - a) / k, 0.0, 1.0); return mix(b, a, h) + k * h * (1.0 - h); }\n\nvec3 toJ(vec3 p, int i) {\n  vec3 d = p - uPiv[i];\n  vec2 r = uCS[i];\n  return vec3(d.x, d.y * r.x + d.z * r.y, -d.y * r.y + d.z * r.x + uOff[i]);\n}\nvec3 dirW(vec3 d, int i) { vec2 r = uCS[i]; return vec3(d.x, d.y * r.x - d.z * r.y, d.y * r.y + d.z * r.x); }\n\n// the turned profile: a full belly, a soft shoulder, a wide neck and a rolled lip\nfloat prof(float y, float R, float H) {\n  float t = clamp(y / H, 0.0, 1.0);\n  float body = R * (0.88 + 0.12 * sin(3.14159 * clamp(t / 0.82, 0.0, 1.0) * 0.86 + 0.3));\n  float r = mix(body, R * 0.8, smoothstep(0.7, 0.9, t));\n  r += R * 0.045 * smoothstep(0.93, 0.995, t);\n  r -= R * 0.07 * (1.0 - smoothstep(0.0, 0.06, t));\n  return r;\n}\nfloat wall(float R) { return 0.03 + 0.02 * R; }\nfloat jarD(vec3 q, float R, float H) {\n  float rho = length(q.xz), pr = prof(q.y, R, H), th = wall(R);\n  float outer = smax((rho - pr) * 0.85, max(-q.y, q.y - H), 0.02);\n  float inner = smax((rho - (pr - th)) * 0.85, th * 1.8 - q.y, 0.03);\n  return smax(outer, -inner, 0.01);\n}\nfloat cavD(vec3 q, float R, float H) {\n  float rho = length(q.xz), pr = prof(q.y, R, H), th = wall(R) + 0.004;\n  return smax((rho - (pr - th)) * 0.85, th * 1.8 - q.y, 0.03);\n}\n\n// id: 0..2 jars, 3..5 honey, 6 the pouring thread\nvec2 map(vec3 p, bool honey) {\n  vec2 res = vec2(1e9, -1.0);\n  for (int i = 0; i < 3; i++) {\n    vec4 J = uJ[i];\n    vec3 q = toJ(p, i);\n    float bound = length(max(vec2(length(q.xz) - J.z * 1.01, abs(q.y - J.w * 0.5) - J.w * 0.51), 0.0)) * 0.85;\n    if (bound > 0.3) { if (bound < res.x) res = vec2(bound, -1.0); continue; }\n    float d = jarD(q, J.z, J.w);\n    if (d < res.x) res = vec2(d, float(i));\n    if (honey && uLv[i] > -1.0) {\n      vec3 n = vec3(0.0, cos(uSl[i]), sin(uSl[i]));\n      float h = max(cavD(q, J.z, J.w), dot(p - vec3(J.x, uLv[i], J.y), n));\n      if (h < res.x) res = vec2(h, float(3 + i));\n    }\n  }\n  if (honey && uStream.z > 0.0) {\n    float wob = 0.012 * sin(p.y * 5.0 - uTime * 3.0);\n    float rr = uStream.z * (1.0 + 0.18 * sin(p.y * 11.0 - uTime * 14.0)) * (0.7 + 0.3 * smoothstep(uStream.w, uStream.w + 0.4, p.y));\n    float d = max(length(p.xz - uStream.xy - vec2(wob, 0.0)) - rr, uStream.w - 0.02 - p.y);\n    if (d < res.x) res = vec2(d, 6.0);\n  }\n  return res;\n}\nvec3 nrm(vec3 p, bool honey) {\n  vec2 e = vec2(0.0007, -0.0007);\n  return normalize(e.xyy * map(p + e.xyy, honey).x + e.yyx * map(p + e.yyx, honey).x + e.yxy * map(p + e.yxy, honey).x + e.xxx * map(p + e.xxx, honey).x);\n}\nfloat shadow(vec3 p) {\n  float s = 1.0, t = 0.02;\n  for (int k = 0; k < 30; k++) {\n    float h = map(p + L * t, true).x;\n    s = min(s, 9.0 * h / t);\n    t += clamp(h, 0.015, 0.25);\n    if (s < 0.01 || t > 4.0) break;\n  }\n  return clamp(s, 0.0, 1.0);\n}\nfloat ao(vec3 p, vec3 n) {\n  float a = 0.0, w = 1.0;\n  for (int k = 1; k <= 5; k++) {\n    float h = 0.016 * float(k * k);\n    a += w * (h - map(p + n * h, true).x);\n    w *= 0.62;\n  }\n  return clamp(1.0 - 2.6 * a, 0.0, 1.0);\n}\n\n// the sun comes through a tall casement to the left of the shelf: two leaves, glazing bars, and a plant on the sill\nfloat casement(vec3 p) {\n  vec3 a = normalize(cross(L, vec3(0.0, 1.0, 0.0))), b = cross(a, L);\n  vec2 w = vec2(dot(p, a), dot(p, b)) - vec2(-0.2, -0.1);\n  float pen = 0.02 + 0.03 * clamp(dot(p, -L) + 2.0, 0.0, 4.0);\n  vec2 e = vec2(2.25, 1.6) - abs(w);\n  float m = smoothstep(-pen, pen, e.x) * smoothstep(-pen, pen, e.y);\n  vec2 g = abs(fract(w / vec2(1.15, 0.78) + 0.5) - 0.5) * vec2(1.15, 0.78);\n  m *= smoothstep(0.02, 0.02 + pen, g.x) * smoothstep(0.014, 0.014 + pen, g.y);\n  // leaves of the sill plant breaking up the light at one corner\n  float leaf = smoothstep(0.6, 0.66, fbm(w * 3.4 + vec2(sin(uTime * 0.5) * 0.08, 0.0))) * smoothstep(0.0, 1.2, -w.y - 0.3 + w.x * 0.4);\n  return m * (1.0 - 0.7 * leaf);\n}\n\nvec3 env(vec3 r) {\n  vec3 c = mix(vec3(0.62, 0.5, 0.48), vec3(0.95, 0.84, 0.82), smoothstep(-0.3, 0.6, r.y)) * 0.7;\n  c = mix(c, vec3(0.6, 0.7, 0.66) * 0.6, smoothstep(0.05, -0.2, r.y));\n  // the window: bright panes with a cross bar, on the left\n  vec3 wd = normalize(vec3(-0.75, 0.42, 0.52));\n  float d = dot(r, wd);\n  if (d > 0.0) {\n    vec3 a = normalize(cross(wd, vec3(0.0, 1.0, 0.0))), b = cross(a, wd);\n    vec2 q = vec2(dot(r, a), dot(r, b)) / d;\n    float pane = smoothstep(0.04, 0.0, max(abs(q.x) - 0.38, abs(q.y) - 0.6));\n    pane *= smoothstep(0.0, 0.02, abs(q.x)) * smoothstep(0.0, 0.02, abs(q.y - 0.1));\n    c += vec3(1.0, 0.97, 0.92) * 9.0 * pane;\n  }\n  // a soft second window behind the camera\n  c += vec3(0.9, 0.94, 1.0) * 1.4 * smoothstep(0.7, 0.95, dot(r, normalize(vec3(0.3, 0.3, 1.0))));\n  return c;\n}\n\nvec3 shelfAlb(vec3 p) {\n  // painted pine: a pale mint coat with the grain telegraphing through\n  float g = fbm(vec2(p.x * 1.2, p.z * 22.0 + 4.0 * fbm(p.xz * 0.8)));\n  vec3 a = vec3(0.4, 0.62, 0.5) * (0.93 + 0.1 * g);\n  return a * (0.97 + 0.05 * vnoise(p.xz * 180.0));\n}\nvec3 wallAlb(vec3 p) {\n  float f = fbm(p.xy * 1.4 + 3.0);\n  vec3 a = mix(vec3(0.78, 0.47, 0.42), vec3(0.86, 0.58, 0.52), f);\n  return a * (0.97 + 0.05 * vnoise(p.xy * 60.0));\n}\n\nvec3 shadeJar(int i, vec3 p, vec3 rd, vec3 n, float jit) {\n  vec4 J = uJ[i];\n  vec3 q = toJ(p, i);\n  float R = J.z, H = J.w;\n  float t = q.y / H, ang = atan(q.x, q.z);\n  float rho = length(q.xz);\n  bool inside = rho < prof(q.y, R, H) - wall(R) * 0.5 && q.y < H * 0.985;\n  vec2 s = vec2(ang * R, q.y);\n  vec3 glaze = uGl[i];\n  // glaze pools darker where it runs thick: just above the drip line and around the shoulder\n  float drip = H * 0.075 + 0.014 * sin(s.x * 26.0 + float(i)) + 0.02 * (vnoise(vec2(s.x * 9.0, 1.0)) - 0.5);\n  float pool = smoothstep(0.05, 0.0, abs(q.y - drip - 0.02)) * 0.4 + smoothstep(0.08, 0.0, abs(t - 0.8)) * 0.2;\n  vec3 alb = glaze * (1.0 - pool * 0.55) * (0.92 + 0.12 * fbm(s * 7.0 + float(i) * 3.0));\n  // iron speckle from the clay body\n  float sp = smoothstep(0.9, 0.93, vnoise(s * 140.0 + float(i) * 11.0)) * 0.8 + smoothstep(0.94, 0.96, vnoise(s * 60.0 + 5.0)) * 0.6;\n  alb = mix(alb, vec3(0.12, 0.07, 0.04), sp * (i == 0 ? 0.75 : 0.35));\n  float gloss = 1.0;\n  float raw = 1.0 - smoothstep(-0.004, 0.004, q.y - drip);\n  if (raw > 0.0) {\n    vec3 clay = vec3(0.74, 0.6, 0.47) * (0.85 + 0.25 * vnoise(s * 60.0));\n    alb = mix(alb, clay, raw);\n    gloss = 1.0 - raw * 0.92;\n  }\n  // the plan is painted in white slip on the front of the belly\n  if (!inside) {\n    float u = ang / 2.1 + 0.5;\n    float v = (t - 0.3) / 0.42;\n    if (u > 0.0 && u < 1.0 && v > 0.0 && v < 1.0) {\n      float m = texture(uTex, vec2(u, (float(i) + v) / 3.0)).r;\n      alb = mix(alb, uSp[i], m * 0.96);\n      gloss *= 1.0 - 0.3 * m;\n    }\n  } else {\n    alb *= 0.8;\n  }\n  // a slow ripple from the throwing lines catches the reflections\n  vec3 nb = normalize(n + dirW(vec3(0.0, 1.0, 0.0), i) * (vnoise(vec2(s.y * 26.0, ang * 0.5)) - 0.5) * 0.05);\n  float sh = shadow(p + n * 0.01) * casement(p);\n  float oc = ao(p, n);\n  float ndl = max(dot(nb, L), 0.0);\n  vec3 col = alb * (SUN * ndl * sh + SKY * oc * (0.55 + 0.45 * nb.y) + vec3(0.6, 0.78, 0.7) * 0.18 * oc * max(-nb.y, 0.0) + vec3(0.95, 0.75, 0.7) * 0.14 * oc * max(-nb.z, 0.0));\n  // glaze: a clear coat over the colour\n  float F = (0.04 + 0.96 * pow(1.0 - clamp(dot(-rd, nb), 0.0, 1.0), 5.0)) * gloss;\n  vec3 Rf = reflect(rd, nb);\n  vec3 refl = env(Rf) * mix(0.35, 1.0, oc);\n  refl += SUN * sh * (24.0 * pow(max(dot(Rf, L), 0.0), 600.0) + 0.6 * pow(max(dot(Rf, L), 0.0), 40.0));\n  col = mix(col, refl, F * (inside ? 0.5 : 1.0));\n  col += SUN * sh * gloss * 0.04 * pow(max(dot(Rf, L), 0.0), 8.0);\n  return col;\n}\n\nvec3 shadeHoney(vec3 p, vec3 rd, vec3 n, float jit) {\n  float sh = shadow(p + n * 0.01) * casement(p);\n  float oc = 0.45 + 0.55 * ao(p, n);\n  vec3 deep = vec3(0.5, 0.2, 0.025), thin = vec3(1.0, 0.62, 0.14);\n  // light that enters the honey comes back out amber; the lit edge glows\n  float tr = sh * (0.4 + 0.6 * max(dot(n, L), 0.0));\n  vec3 col = deep * SKY * oc * 1.3 + thin * thin * SUN * tr * 0.45 + deep * SUN * sh * 0.25 + thin * deep * 0.5;\n  float F = 0.04 + 0.96 * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0);\n  vec3 R = reflect(rd, n);\n  vec3 refl = env(R) * mix(0.3, 1.0, oc) + SUN * sh * 30.0 * pow(max(dot(R, L), 0.0), 900.0);\n  return mix(col, refl, F);\n}\n\nvec3 shadeShelf(vec3 p, vec3 rd, vec3 n) {\n  vec3 alb = n.z > 0.5 ? shelfAlb(p.zyx * vec3(1.0, 1.0, 1.0)) * 0.95 : shelfAlb(p);\n  float sh = shadow(p + n * 0.003) * casement(p);\n  float oc = ao(p, n);\n  // the honey jars throw a little colour onto the paint beside them\n  vec3 bleed = vec3(0.0);\n  for (int i = 0; i < 3; i++) {\n    vec3 d = vec3(uJ[i].x, uJ[i].w * 0.35, uJ[i].y) - p;\n    bleed += uGl[i] * uGl[i] * uJ[i].z * 0.18 / (dot(d, d) + 0.08);\n  }\n  vec3 col = alb * (SUN * max(dot(n, L), 0.0) * sh + SKY * oc + bleed * SUN * 0.06 * oc);\n  float F = 0.03 + 0.5 * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0);\n  col += SUN * sh * 0.05 * pow(max(dot(reflect(rd, n), L), 0.0), 30.0);\n  // soft satin reflection of whatever stands on the shelf\n  if (n.y > 0.5) {\n    vec3 R = reflect(rd, n);\n    float t = 0.02;\n    for (int k = 0; k < 18; k++) {\n      vec2 h = map(p + R * t, false);\n      if (h.x < 0.004) { col = mix(col, uGl[int(h.y)] * SKY * 0.9, 0.22 * exp(-t * 2.5)); break; }\n      t += h.x;\n      if (t > 1.2) break;\n    }\n  }\n  return col * (1.0 - 0.0 * F);\n}\n\nvec3 shadeWall(vec3 p) {\n  vec3 n = vec3(0.0, 0.0, 1.0);\n  vec3 alb = wallAlb(p);\n  float sh = shadow(p + n * 0.003) * casement(p);\n  // under the shelf the board blocks the sun\n  if (p.y < 0.0) {\n    float k = -p.y / L.y;\n    float z = p.z + L.z * k;\n    sh *= smoothstep(FRONT + 0.02, FRONT - 0.06, z) < 0.5 ? 1.0 : 0.0;\n  }\n  float oc = ao(p, n) * (0.55 + 0.45 * smoothstep(0.0, 0.5, abs(p.y)));\n  return alb * (SUN * max(dot(n, L), 0.0) * sh + SKY * oc * 0.95 + vec3(0.6, 0.78, 0.7) * 0.1 * smoothstep(0.6, 0.0, p.y) * step(0.0, p.y));\n}\n\nvec3 tonemap(vec3 x) { x *= 0.55; return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); }\n\nvoid main() {\n  vec2 ndc = vUv * 2.0 - 1.0 - uShift;\n  vec3 rd = normalize(uFw + uRt * (ndc.x * uTan * uAspect) + uUp * (ndc.y * uTan));\n  float jit = ign(gl_FragCoord.xy);\n  // the set: shelf top, shelf front edge, then the wall\n  float tp = 1e9; int pid = -1; vec3 pn = vec3(0.0);\n  if (rd.y < 0.0) { float t = -uCam.y / rd.y; vec3 h = uCam + rd * t; if (h.z < FRONT && h.z > WZ) { tp = t; pid = 0; pn = vec3(0.0, 1.0, 0.0); } }\n  if (rd.z < 0.0) {\n    float t = (FRONT - uCam.z) / rd.z; vec3 h = uCam + rd * t;\n    if (t < tp && h.y < 0.0 && h.y > -0.11) { tp = t; pid = 1; pn = vec3(0.0, 0.0, 1.0); }\n    t = (WZ - uCam.z) / rd.z;\n    if (t < tp) { tp = t; pid = 2; pn = vec3(0.0, 0.0, 1.0); }\n  }\n  // the jars\n  float t = 0.0; float id = -1.0;\n  float tmax = min(tp, 30.0);\n  t = max(0.0, (uCam.z - 1.6) / max(-rd.z, 0.05));\n  for (int k = 0; k < 110; k++) {\n    vec2 h = map(uCam + rd * t, true);\n    if (h.x < 0.0006 * t) { id = h.y; break; }\n    t += h.x;\n    if (t > tmax) break;\n  }\n  vec3 col;\n  float depth;\n  if (id >= 0.0 && t < tmax) {\n    vec3 p = uCam + rd * t;\n    vec3 n = nrm(p, true);\n    int k = int(id + 0.5);\n    col = k < 3 ? shadeJar(k, p, rd, n, jit) : shadeHoney(p, rd, n, jit);\n    depth = t;\n  } else {\n    vec3 p = uCam + rd * tp;\n    col = pid == 2 ? shadeWall(p) : shadeShelf(p, rd, pn);\n    if (pid == 1) col *= 0.82;\n    depth = tp;\n  }\n  // light in the air near the window\n  col += vec3(1.0, 0.9, 0.78) * 0.035 * smoothstep(0.4, -1.0, dot(rd, vec3(1.0, 0.0, 0.0)));\n  float z = depth * dot(rd, uFw);\n  float coc = clamp(uAperture * (1.0 - uFocus / max(z, 0.05)), -1.0, 1.0);\n  o = vec4(pow(tonemap(col), vec3(1.0 / 2.2)), 0.5 + 0.5 * coc);\n}`;\n\nconst VS = `#version 300 es\nout vec2 vUv;\nvoid main() { vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)); vUv = p; gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0); }`;\n\nconst FS_LENS = `#version 300 es\nprecision highp float;\nuniform sampler2D uScene;\nuniform vec2 uPx;\nuniform float uMaxR, uTime;\nin vec2 vUv;\nout vec4 o;\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\nvoid main() {\n  vec4 c0 = texture(uScene, vUv);\n  float s0 = c0.a * 2.0 - 1.0, coc0 = abs(s0);\n  vec3 acc = c0.rgb; float wsum = 1.0;\n  float rot = 6.2832 * ign(gl_FragCoord.xy);\n  for (int k = 1; k < 20; k++) {\n    float r = sqrt(float(k) / 20.0) * uMaxR;\n    float a = float(k) * 2.39996 + rot;\n    vec4 s = texture(uScene, vUv + vec2(cos(a), sin(a)) * r * uPx);\n    float sc = s.a * 2.0 - 1.0, cs = abs(sc);\n    if (sc > s0) cs = min(cs, coc0 * 1.6 + 0.02);\n    float w = smoothstep(r - 1.0, r + 1.0, cs * uMaxR);\n    acc += s.rgb * w; wsum += w;\n  }\n  vec3 col = acc / wsum;\n  // smooth the stair-steps along the jar silhouettes where the lens has not already softened them\n  const vec3 LU = vec3(0.299, 0.587, 0.114);\n  vec3 cNW = texture(uScene, vUv + vec2(-1.0, -1.0) * uPx).rgb, cNE = texture(uScene, vUv + vec2(1.0, -1.0) * uPx).rgb;\n  vec3 cSW = texture(uScene, vUv + vec2(-1.0, 1.0) * uPx).rgb, cSE = texture(uScene, vUv + vec2(1.0, 1.0) * uPx).rgb;\n  float lNW = dot(cNW, LU), lNE = dot(cNE, LU), lSW = dot(cSW, LU), lSE = dot(cSE, LU), lM = dot(c0.rgb, LU);\n  float lMin = min(lM, min(min(lNW, lNE), min(lSW, lSE))), lMax = max(lM, max(max(lNW, lNE), max(lSW, lSE)));\n  vec2 dir = vec2(-((lNW + lNE) - (lSW + lSE)), (lNW + lSW) - (lNE + lSE));\n  float rcp = 1.0 / (min(abs(dir.x), abs(dir.y)) + max((lNW + lNE + lSW + lSE) * 0.03125, 0.0078));\n  dir = clamp(dir * rcp, -8.0, 8.0) * uPx;\n  vec3 fa = 0.5 * (texture(uScene, vUv + dir * (1.0 / 3.0 - 0.5)).rgb + texture(uScene, vUv + dir * (2.0 / 3.0 - 0.5)).rgb);\n  vec3 fb = fa * 0.5 + 0.25 * (texture(uScene, vUv - dir * 0.5).rgb + texture(uScene, vUv + dir * 0.5).rgb);\n  float lB = dot(fb, LU);\n  vec3 fx = (lB < lMin || lB > lMax) ? fa : fb;\n  col = mix(fx, col, smoothstep(0.05, 0.3, coc0));\n  vec2 q = vUv - 0.5;\n  col *= 1.0 - 0.32 * dot(q, q);\n  col += (ign(gl_FragCoord.xy + fract(uTime) * 61.0) - 0.5) * 0.018;\n  o = vec4(col, 1.0);\n}`;\n\nfunction program(gl: WebGL2RenderingContext, vs: string, fs: string) {\n  const p = gl.createProgram()!;\n  for (const [type, src] of [[gl.VERTEX_SHADER, vs], [gl.FRAGMENT_SHADER, fs]] as const) {\n    const s = gl.createShader(type)!;\n    gl.shaderSource(s, src);\n    gl.compileShader(s);\n    if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s) || \"shader\");\n    gl.attachShader(p, s);\n  }\n  gl.linkProgram(p);\n  if (!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(p) || \"link\");\n  return p;\n}\n\n/** The slip painting on each jar: plan name, the example price and its label. One band per plan. */\nfunction artwork() {\n  const W = 1024, H = 512;\n  const cv = document.createElement(\"canvas\");\n  cv.width = W;\n  cv.height = H * plans.length;\n  const ctx = cv.getContext(\"2d\")!;\n  ctx.fillStyle = \"#000\";\n  ctx.fillRect(0, 0, cv.width, cv.height);\n  ctx.fillStyle = \"#fff\";\n  ctx.textAlign = \"center\";\n  const tracked = (s: string, y: number, font: string, gap: number) => {\n    ctx.font = font;\n    const w = [...s].map((c) => ctx.measureText(c).width + gap);\n    let x = W / 2 - (w.reduce((a, b) => a + b, 0) - gap) / 2;\n    ctx.textAlign = \"left\";\n    [...s].forEach((c, i) => {\n      ctx.fillText(c, x, y);\n      x += w[i];\n    });\n  };\n  plans.forEach((plan, i) => {\n    // the texture is flipped on upload, so plan 0 is drawn in the bottom band\n    const y0 = (plans.length - 1 - i) * H;\n    ctx.save();\n    ctx.translate(0, y0);\n    tracked(plan.name.toUpperCase(), 96, `600 64px ${GROTESK}`, 14);\n    ctx.fillRect(W / 2 - 150, 128, 300, 5);\n    tracked(`$${plan.price}`, 354, `italic 500 230px ${SERIF}`, -6);\n    tracked(\"A MONTH · EXAMPLE\", 452, `600 42px ${GROTESK}`, 8);\n    ctx.restore();\n  });\n  return cv;\n}\n\ntype Sim = {\n  a: number[]; om: number[]; fill: number[]; sl: number[]; vsl: number[]; pour: number; pourAt: number;\n  plan: number; dirty: boolean; touched: boolean;\n};\n\n/** The same shelf drawn with plain elements, for browsers without WebGL 2. */\nfunction Still({ plan }: { plan: number }) {\n  const hex = [\"#cdb37f\", \"#e27a4f\", \"#1f3f86\"];\n  return (\n    <div aria-hidden=\"true\" className=\"absolute inset-0 overflow-hidden\" style={{ background: `linear-gradient(180deg, ${WALL} 0%, #f3ddd5 60%, #b6d4c4 60%, #a9cbb9 74%, #7f9f8f 74%, #d8b9b0 77%, #c9a69c 100%)` }}>\n      <div className=\"absolute left-0 top-0 h-[60%] w-[55%]\" style={{ background: \"linear-gradient(115deg, rgba(255,247,232,0.75), rgba(255,247,232,0) 70%)\" }} />\n      {plans.map((p, i) => {\n        const lit = i === plan;\n        const w = p.radius * 26;\n        return (\n          <div key={p.name} className=\"absolute -translate-x-1/2\" style={{ left: `${[24, 50, 77][i]}%`, bottom: \"31%\", width: `${w}%`, aspectRatio: `${(p.radius * 2) / p.height}` }}>\n            <div className=\"absolute -bottom-[3%] left-[20%] h-[8%] w-[110%] rounded-[50%] bg-black/25 blur-md\" />\n            <div className=\"absolute inset-0 rounded-b-[22%] rounded-t-[38%]\" style={{ background: `radial-gradient(circle at 30% 34%, rgba(255,255,255,0.55), rgba(255,255,255,0) 18%), linear-gradient(90deg, ${hex[i]} 0%, ${hex[i]} 45%, rgba(0,0,0,0.35) 100%), ${hex[i]}`, backgroundBlendMode: \"screen, multiply, normal\", transform: lit ? \"rotate(-4deg)\" : \"none\", transformOrigin: \"50% 100%\" }}>\n              <div className=\"absolute inset-x-0 top-[34%] text-center text-[#f6efe2]\" style={{ fontFamily: GROTESK }}>\n                <div className=\"text-[8px] font-semibold uppercase tracking-[0.2em] sm:text-[11px]\">{p.name}</div>\n                <div className=\"text-[clamp(18px,4vw,48px)] italic leading-none\" style={{ fontFamily: SERIF }}>${p.price}</div>\n              </div>\n            </div>\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n\nexport default function GlazedJarPricing() {\n  const reduce = useReducedMotion();\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const [plan, setPlan] = useState(1);\n  const [mode, setMode] = useState<\"pending\" | \"gl\" | \"still\">(\"pending\");\n  const [marks, setMarks] = useState<number[]>([26, 50, 75]);\n  const [handled, setHandled] = useState(false);\n  const sim = useRef<Sim>({ a: [0, 0, 0], om: [0, 0, 0], fill: [0, 1, 0], sl: [0, 0, 0], vsl: [0, 0, 0], pour: 0, pourAt: -1, plan: 1, dirty: true, touched: false });\n\n  // choosing a plan: the jar rocks forward on its foot and honey pours in\n  useEffect(() => {\n    const s = sim.current;\n    if (s.plan !== plan) {\n      s.plan = plan;\n      const p = plans[plan];\n      const hc = p.height * 0.48, phi = Math.atan(p.radius / hc);\n      const K = (9.8 * Math.hypot(p.radius, hc)) / ((4 / 3) * (p.radius * p.radius + hc * hc));\n      s.om[plan] = Math.sqrt(2 * K * (Math.cos(phi - ROCK) - Math.cos(phi)) * 1.02);\n      s.pourAt = 0.32;\n    }\n    s.dirty = true;\n  }, [plan]);\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const canvas = canvasRef.current;\n    if (!wrap || !canvas) return;\n    const gl = canvas.getContext(\"webgl2\", { antialias: false, alpha: false, powerPreference: \"high-performance\" });\n    if (!gl) {\n      setMode(\"still\");\n      return;\n    }\n    const s = sim.current;\n    let pScene: WebGLProgram, pLens: WebGLProgram;\n    try {\n      pScene = program(gl, VS, GLSL);\n      pLens = program(gl, VS, FS_LENS);\n    } catch {\n      setMode(\"still\");\n      return;\n    }\n    setMode(\"gl\");\n\n    const art = gl.createTexture();\n    gl.activeTexture(gl.TEXTURE0);\n    gl.bindTexture(gl.TEXTURE_2D, art);\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, artwork());\n    gl.generateMipmap(gl.TEXTURE_2D);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n\n    const vao = gl.createVertexArray();\n    const fbo = gl.createFramebuffer();\n    const tex = gl.createTexture();\n    let W = 0, H = 0, scale = Math.min(window.devicePixelRatio || 1, 2), cssW = 1, cssH = 1;\n    const TAN = Math.tan((10 * Math.PI) / 180);\n    const cam = { pos: [0, 2, 10], rt: [1, 0, 0], up: [0, 1, 0], fw: [0, 0, -1], shift: [0, 0], focus: 8 };\n\n    const aim = (sx: number, sy: number) => {\n      const aspect = cssW / cssH;\n      const wide = aspect > 1.2;\n      const dist = Math.max(9.2, 1.85 / (TAN * aspect));\n      const el = 0.3;\n      const target = [0, 0.5, 0];\n      cam.pos = [target[0] + sx, target[1] + Math.sin(el) * dist + sy, target[2] + Math.cos(el) * dist];\n      let fw = [target[0] - cam.pos[0], target[1] - cam.pos[1], target[2] - cam.pos[2]];\n      const fl = Math.hypot(fw[0], fw[1], fw[2]);\n      fw = fw.map((v) => v / fl);\n      let rt = [-fw[2], 0, fw[0]];\n      const rl = Math.hypot(rt[0], rt[2]);\n      rt = rt.map((v) => v / rl);\n      cam.fw = fw;\n      cam.rt = rt;\n      cam.up = [rt[1] * fw[2] - rt[2] * fw[1], rt[2] * fw[0] - rt[0] * fw[2], rt[0] * fw[1] - rt[1] * fw[0]];\n      cam.shift = wide ? [0.08, -0.36] : [0, -0.48];\n      cam.focus = fl;\n      return aspect;\n    };\n    const project = (p: number[]) => {\n      const d = [p[0] - cam.pos[0], p[1] - cam.pos[1], p[2] - cam.pos[2]];\n      const z = d[0] * cam.fw[0] + d[1] * cam.fw[1] + d[2] * cam.fw[2];\n      const x = (d[0] * cam.rt[0] + d[1] * cam.rt[1] + d[2] * cam.rt[2]) / (z * TAN * (cssW / cssH)) + cam.shift[0];\n      const y = (d[0] * cam.up[0] + d[1] * cam.up[1] + d[2] * cam.up[2]) / (z * TAN) + cam.shift[1];\n      return [(x * 0.5 + 0.5) * cssW, (0.5 - y * 0.5) * cssH];\n    };\n\n    const resize = () => {\n      cssW = wrap.clientWidth;\n      cssH = wrap.clientHeight;\n      let k = scale;\n      if (cssW * cssH * k * k > 1.6e6) k = Math.sqrt(1.6e6 / (cssW * cssH));\n      const w = Math.max(2, Math.round(cssW * k)), h = Math.max(2, Math.round(cssH * k));\n      aim(0, 0);\n      setMarks(XS.map((x) => (project([x, 0, 0])[0] / cssW) * 100));\n      if (w === W && h === H) return;\n      W = w;\n      H = h;\n      canvas.width = W;\n      canvas.height = H;\n      gl.activeTexture(gl.TEXTURE1);\n      gl.bindTexture(gl.TEXTURE_2D, tex);\n      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n      gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);\n      s.dirty = true;\n    };\n    resize();\n    const ro = new ResizeObserver(resize);\n    ro.observe(wrap);\n\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    // where the honey sits, the edge each jar rocks on and where the thread of honey lands\n    const pose = (i: number) => {\n      const p = plans[i], a = s.a[i], sg = a >= 0 ? 1 : -1, c = Math.cos(a), sn = Math.sin(a);\n      const piv = [XS[i], 0, sg * p.radius];\n      const th = 0.03 + 0.02 * p.radius;\n      const yb = th * 1.8, yt = p.height * 0.9;\n      const y = yb + s.fill[i] * (yt - yb);\n      const level = s.fill[i] < 0.01 ? -5 : y * c + sg * p.radius * Math.abs(sn);\n      const mouthZ = p.height * sn + sg * p.radius * (1 - c);\n      return { piv, off: sg * p.radius, c, sn, level, mouthZ };\n    };\n    let pointer = [0, 0], view = [0, 0];\n\n    const draw = (t: number) => {\n      const aspect = aim(view[0], view[1]);\n      gl.bindVertexArray(vao);\n      gl.viewport(0, 0, W, H);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n      gl.useProgram(pScene);\n      const J: number[] = [], CS: number[] = [], PV: number[] = [], OF: number[] = [], LV: number[] = [], SL: number[] = [], GL: number[] = [], SP: number[] = [];\n      plans.forEach((p, i) => {\n        const q = pose(i);\n        J.push(XS[i], 0, p.radius, p.height);\n        CS.push(q.c, q.sn);\n        PV.push(...q.piv);\n        OF.push(q.off);\n        LV.push(q.level);\n        SL.push(s.sl[i]);\n        GL.push(...p.glaze);\n        SP.push(...p.slip);\n      });\n      gl.uniform4fv(U(pScene, \"uJ\"), J);\n      gl.uniform2fv(U(pScene, \"uCS\"), CS);\n      gl.uniform3fv(U(pScene, \"uPiv\"), PV);\n      gl.uniform1fv(U(pScene, \"uOff\"), OF);\n      gl.uniform1fv(U(pScene, \"uLv\"), LV);\n      gl.uniform1fv(U(pScene, \"uSl\"), SL);\n      gl.uniform3fv(U(pScene, \"uGl\"), GL);\n      gl.uniform3fv(U(pScene, \"uSp\"), SP);\n      const q = pose(s.plan);\n      gl.uniform4f(U(pScene, \"uStream\"), XS[s.plan], q.mouthZ, 0.022 * s.pour, Math.max(q.level, 0.05));\n      gl.uniform1i(U(pScene, \"uTex\"), 0);\n      gl.uniform3fv(U(pScene, \"uCam\"), cam.pos);\n      gl.uniform3fv(U(pScene, \"uRt\"), cam.rt);\n      gl.uniform3fv(U(pScene, \"uUp\"), cam.up);\n      gl.uniform3fv(U(pScene, \"uFw\"), cam.fw);\n      gl.uniform1f(U(pScene, \"uTan\"), TAN);\n      gl.uniform1f(U(pScene, \"uAspect\"), aspect);\n      gl.uniform2fv(U(pScene, \"uShift\"), cam.shift);\n      gl.uniform1f(U(pScene, \"uFocus\"), cam.focus);\n      gl.uniform1f(U(pScene, \"uAperture\"), 1.6);\n      gl.uniform1f(U(pScene, \"uTime\"), t);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.useProgram(pLens);\n      gl.uniform1i(U(pLens, \"uScene\"), 1);\n      gl.uniform2f(U(pLens, \"uPx\"), 1 / W, 1 / H);\n      gl.uniform1f(U(pLens, \"uMaxR\"), H * 0.007);\n      gl.uniform1f(U(pLens, \"uTime\"), reduce ? 0 : t);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n    };\n\n    // A jar on the edge of its foot is an upside-down pendulum: gravity pulls it back until it lands and rocks once the other way.\n    const physics = (dt: number) => {\n      plans.forEach((p, i) => {\n        const hc = p.height * 0.48, phi = Math.atan(p.radius / hc);\n        const K = (9.8 * Math.hypot(p.radius, hc)) / ((4 / 3) * (p.radius * p.radius + hc * hc));\n        const a0 = s.a[i];\n        const acc = a0 === 0 && s.om[i] === 0 ? 0 : -Math.sign(a0 || s.om[i]) * K * Math.sin(phi - Math.abs(a0));\n        const before = s.om[i];\n        s.om[i] += acc * dt;\n        let a = a0 + s.om[i] * dt;\n        if (a0 !== 0 && Math.sign(a) !== Math.sign(a0)) {\n          // landing on the foot: most of the speed goes into the shelf\n          const v = s.om[i] * BOUNCE;\n          a = 0;\n          s.om[i] = Math.abs(v) < 0.08 ? 0 : v;\n        }\n        s.a[i] = a;\n        // the honey lags behind the jar and slops back\n        const angAcc = (s.om[i] - before) / Math.max(dt, 1e-4);\n        s.vsl[i] += (-60 * s.sl[i] - 3.2 * s.vsl[i] - angAcc * 0.012) * dt;\n        s.sl[i] = clamp(s.sl[i] + s.vsl[i] * dt, -0.35, 0.35);\n        const want = i === s.plan ? 1 : 0;\n        if (want === 0) s.fill[i] = Math.max(0, s.fill[i] - dt * 0.9);\n      });\n      if (s.pourAt >= 0) {\n        s.pourAt -= dt;\n        if (s.pourAt < 0) s.pourAt = -1;\n      }\n      const filling = s.pourAt < 0 && s.fill[s.plan] < 1;\n      if (filling && s.pourAt === -1) s.fill[s.plan] = Math.min(1, s.fill[s.plan] + dt / FILL_SECONDS);\n      const target = s.pourAt === -1 && s.fill[s.plan] < 0.995 ? 1 : 0;\n      s.pour += (target - s.pour) * Math.min(1, dt * (target ? 9 : 3.5));\n      if (s.pour < 0.02 && !target) s.pour = 0;\n    };\n    const settle = () => {\n      plans.forEach((_, i) => {\n        s.a[i] = 0;\n        s.om[i] = 0;\n        s.sl[i] = s.vsl[i] = 0;\n        s.fill[i] = i === s.plan ? 1 : 0;\n      });\n      s.pour = 0;\n      s.pourAt = -1;\n    };\n    settle();\n\n    let raf = 0, visible = true, last = performance.now(), slow = 0, frames = 0;\n    const t0 = last;\n    let played = 0, demoAt = 4.0, step = 0;\n    const tick = (now: number) => {\n      const real = now - last;\n      const dt = clamp(real / 1000, 0, 0.05);\n      last = now;\n      const t = (now - t0) / 1000;\n      if (reduce) {\n        if (s.dirty) settle();\n      } else {\n        const sub = Math.max(1, Math.ceil(dt / 0.004));\n        for (let i = 0; i < sub; i++) physics(dt / sub);\n        played += dt;\n        view[0] += (pointer[0] * 0.35 + 0.12 * Math.sin(t * 0.21) - view[0]) * Math.min(1, dt * 3);\n        view[1] += (pointer[1] * 0.18 - view[1]) * Math.min(1, dt * 3);\n        if (DEMO && !s.touched && played > demoAt) {\n          const script = [2, 0, 1];\n          setPlan(script[step % script.length]);\n          step++;\n          demoAt = played + 3.6;\n        }\n      }\n      if (!reduce || s.dirty) {\n        draw(reduce ? 0 : t);\n        s.dirty = false;\n        if (!reduce && ++frames > 20) {\n          slow = slow * 0.92 + (real > 24 ? 1 : 0) * 0.08;\n          if (slow > 0.6 && scale > 0.5) {\n            scale *= 0.84;\n            slow = 0;\n            frames = 0;\n            resize();\n          }\n        }\n      }\n      if (visible) raf = requestAnimationFrame(tick);\n    };\n    const io = new IntersectionObserver(([e]) => {\n      const was = visible;\n      visible = e.isIntersecting;\n      if (visible && !was) {\n        last = performance.now();\n        frames = 0;\n        raf = requestAnimationFrame(tick);\n      }\n    });\n    io.observe(wrap);\n    const onVis = () => {\n      if (document.hidden) cancelAnimationFrame(raf);\n      else if (visible) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    };\n    document.addEventListener(\"visibilitychange\", onVis);\n    raf = requestAnimationFrame(tick);\n\n    // pressing a jar chooses its plan\n    const over = (e: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      const x = e.clientX - r.left, y = e.clientY - r.top;\n      for (let i = 0; i < plans.length; i++) {\n        const p = plans[i];\n        const a = project([XS[i] - p.radius, p.height, 0]), b = project([XS[i] + p.radius, 0, p.radius]);\n        if (x > a[0] - 6 && x < b[0] + 6 && y > a[1] - 6 && y < b[1] + 6) return i;\n      }\n      return -1;\n    };\n    const touch = () => {\n      s.touched = true;\n      setHandled(true);\n    };\n    const down = (e: PointerEvent) => {\n      touch();\n      const i = over(e);\n      if (i >= 0) setPlan(i);\n    };\n    const move = (e: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      pointer = [((e.clientX - r.left) / r.width - 0.5) * 2, ((e.clientY - r.top) / r.height - 0.5) * -2];\n      canvas.style.cursor = over(e) >= 0 ? \"pointer\" : \"\";\n    };\n    const leave = () => {\n      pointer = [0, 0];\n    };\n    const lost = (e: Event) => {\n      e.preventDefault();\n      setMode(\"still\");\n    };\n    canvas.addEventListener(\"pointerdown\", down);\n    canvas.addEventListener(\"pointermove\", move);\n    canvas.addEventListener(\"pointerleave\", leave);\n    canvas.addEventListener(\"webglcontextlost\", lost);\n    wrap.addEventListener(\"keydown\", touch);\n    wrap.addEventListener(\"focusin\", touch);\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(\"pointerleave\", leave);\n      canvas.removeEventListener(\"webglcontextlost\", lost);\n      wrap.removeEventListener(\"keydown\", touch);\n      wrap.removeEventListener(\"focusin\", touch);\n      gl.getExtension(\"WEBGL_lose_context\")?.loseContext();\n    };\n  }, [reduce]);\n\n  const chosen = plans[plan];\n  const check = (\n    <svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"mt-0.5 shrink-0\">\n      <path d=\"M4 10.5l4 4 8-9\" />\n    </svg>\n  );\n  const cta = (\n    <a\n      href=\"#\"\n      className=\"inline-flex h-11 items-center gap-3 rounded-full bg-[#2a1c19] pl-5 pr-4 text-[14px] font-semibold text-[#fbefe9] transition hover:bg-[#432c27] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#2a1c19] focus-visible:ring-offset-2 focus-visible:ring-offset-[#ecd3cb]\"\n    >\n      Start with {chosen.name}\n      <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <path d=\"M4 10h12M11 5l5 5-5 5\" />\n      </svg>\n    </a>\n  );\n\n  return (\n    <section className=\"relative overflow-hidden\" style={{ fontFamily: GROTESK, background: WALL, color: INK }}>\n      <div ref={wrapRef} className=\"relative h-[620px] w-full sm:h-[780px]\">\n        <canvas ref={canvasRef} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full touch-pan-y ${mode === \"still\" ? \"hidden\" : \"\"}`} />\n        {mode === \"still\" && <Still plan={plan} />}\n\n        <div className=\"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-4 p-5 sm:p-9\">\n          <p className=\"flex items-baseline gap-3\">\n            <span className=\"text-[22px] italic leading-none sm:text-[26px]\" style={{ fontFamily: SERIF, letterSpacing: \"-0.02em\" }}>\n              {product.name}\n            </span>\n            <span className=\"hidden text-[11px] font-semibold uppercase tracking-[0.24em] text-[#2a1c19]/75 sm:inline\">{product.line}</span>\n          </p>\n          <span className=\"rounded-full border border-[#2a1c19]/30 bg-[#fbefe9]/60 px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.18em] backdrop-blur-sm\">Example prices</span>\n        </div>\n\n        <div className=\"pointer-events-none absolute left-5 top-[70px] sm:left-9 sm:top-[104px]\" aria-live={handled ? \"polite\" : \"off\"}>\n          <p className=\"text-[11px] font-semibold uppercase tracking-[0.26em] text-[#2a1c19]/80\">\n            <span className=\"tabular-nums\">{`0${plan + 1}`}</span>\n            <span className=\"mx-2 text-[#2a1c19]/45\">/</span>\n            {chosen.name}\n          </p>\n          <h2 className=\"mt-1 flex items-start pb-1 font-semibold leading-[0.84]\" style={{ letterSpacing: \"-0.06em\" }}>\n            <span className=\"mr-1 mt-[0.12em] text-[34px] font-medium sm:text-[60px]\" style={{ letterSpacing: 0 }}>\n              $\n            </span>\n            <span className=\"overflow-hidden\">\n              <motion.span\n                key={plan}\n                initial={reduce ? false : { y: \"0.6em\", opacity: 0 }}\n                animate={{ y: 0, opacity: 1 }}\n                transition={{ type: \"spring\", stiffness: 240, damping: 22 }}\n                className=\"block text-[88px] tabular-nums sm:text-[160px]\"\n              >\n                {chosen.price}\n              </motion.span>\n            </span>\n            <span className=\"ml-3 mt-[0.6em] text-[11px] font-semibold uppercase leading-[1.5] tracking-[0.2em] text-[#2a1c19]/80 sm:ml-4 sm:mt-[1.4em] sm:text-[12px]\">\n              a month\n              <span className=\"block normal-case tracking-normal\" style={{ letterSpacing: \"0.01em\" }}>\n                example price\n              </span>\n            </span>\n          </h2>\n          <p className=\"mt-1 max-w-[19ch] text-[19px] italic leading-tight sm:mt-2 sm:max-w-none sm:text-[25px]\" style={{ fontFamily: SERIF, letterSpacing: \"-0.01em\" }}>\n            {chosen.pitch}\n          </p>\n        </div>\n\n        <div className=\"absolute right-9 top-[104px] hidden w-[262px] lg:block\">\n          <ul className=\"space-y-2 border-t border-[#2a1c19]/25 pt-3.5 text-[14px] leading-snug\">\n            {chosen.features.map((f) => (\n              <li key={f} className=\"flex gap-3\">\n                {check}\n                {f}\n              </li>\n            ))}\n          </ul>\n          <div className=\"mt-4\">{cta}</div>\n        </div>\n\n        <fieldset className=\"absolute inset-x-0 bottom-4 h-11 sm:bottom-6\">\n          <legend className=\"sr-only\">Plan</legend>\n          {plans.map((p, i) => (\n            <label\n              key={p.name}\n              htmlFor={`glazed-jar-pricing-plan-${i}`}\n              className=\"absolute top-0 -translate-x-1/2 cursor-pointer\"\n              style={{ left: `${mode === \"still\" ? [24, 50, 77][i] : marks[i]}%` }}\n            >\n              <input id={`glazed-jar-pricing-plan-${i}`} type=\"radio\" name=\"glazed-jar-pricing-plan\" value={p.name} checked={plan === i} onChange={() => setPlan(i)} className=\"peer sr-only\" />\n              <span className=\"flex h-11 items-center gap-2 whitespace-nowrap rounded-full border border-[#2a1c19]/15 bg-[#fbefe9]/90 pl-2.5 pr-3 text-[11px] font-semibold uppercase tracking-[0.08em] shadow-[0_6px_18px_rgba(60,30,20,0.18)] transition peer-checked:bg-[#2a1c19] peer-checked:text-[#fbefe9] peer-focus-visible:ring-2 peer-focus-visible:ring-[#2a1c19] peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-[#fbefe9] sm:gap-2.5 sm:pl-3.5 sm:pr-4 sm:text-[13px] sm:tracking-[0.14em]\">\n                <span className={`grid h-4 w-4 place-items-center rounded-full border-[1.5px] ${plan === i ? \"border-[#fbefe9]\" : \"border-[#2a1c19]/60\"}`}>\n                  <span className={`h-2 w-2 rounded-full bg-[#fbefe9] transition-transform ${plan === i ? \"scale-100\" : \"scale-0\"}`} />\n                </span>\n                {p.name}\n                <span className=\"hidden font-medium normal-case tracking-normal opacity-80 sm:inline\">${p.price}</span>\n              </span>\n            </label>\n          ))}\n        </fieldset>\n      </div>\n\n      <div className=\"border-t border-[#2a1c19]/15 px-5 pb-8 pt-6 lg:hidden\">\n        <ul className=\"space-y-2.5 text-[15px] leading-snug\">\n          {chosen.features.map((f) => (\n            <li key={f} className=\"flex gap-3\">\n              {check}\n              {f}\n            </li>\n          ))}\n        </ul>\n        <div className=\"mt-6\">{cta}</div>\n        <p className=\"mt-4 text-[13px] text-[#2a1c19]/80\">Prices shown are examples. Set your own in the plans list.</p>\n      </div>\n    </section>\n  );\n}\n"}]}
