{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ray-marched-vinyl-balloon-letters-hero-on-a-sky-blue-paper-sweep-that-squash-under-the-pointer-and-wobble-back-in-daylight","type":"registry:block","title":"Ray-Marched Vinyl Balloon Letters Hero on a Sky Blue Paper Sweep That Squash Under the Pointer and Wobble Back in Daylight","description":"Free React hero: puffed vinyl balloon letters traced in a WebGL shader stand on a blue paper sweep in daylight and squash and wobble when pressed.","dependencies":[],"files":[{"path":"components/we-inc/ray-marched-vinyl-balloon-letters-hero-on-a-sky-blue-paper-sweep-that-squash-under-the-pointer-and-wobble-back-in-daylight.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// Everything a visitor would edit first.\nconst venue = {\n  name: \"Puffle Hall\",\n  where: \"Party rooms, Larkfield\",\n  word: \"PARTY\", // blown up as balloon letters, one colour each (up to 8 letters)\n  headline: [\"Throw the party.\", \"We blow up the rest.\"],\n  line: \"A private room with soft play, a cake table and a host who sets up before you arrive and clears away after you leave.\",\n  cta: \"Book a party room\",\n  second: \"See the rooms\",\n  hours: \"Open Thursday to Sunday\",\n};\n// One colour per letter, in linear light (0 to 1). They repeat if the word is longer.\nconst COLOURS = [\n  [1.0, 0.085, 0.06], // tomato\n  [1.0, 0.5, 0.012], // sunflower\n  [0.012, 0.42, 0.2], // mint green\n  [0.2, 0.09, 0.95], // violet\n  [1.0, 0.13, 0.4], // bubblegum\n];\nconst PAPER = [0.3, 0.62, 0.93]; // the sky blue paper sweep, linear light\nconst INFLATE = 1.25; // how fat the letters are blown: 1 is round tubes\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif';\nconst BALLOON_FONT = '\"Arial Rounded MT Bold\", \"Nunito\", \"Varela Round\", \"Inter Tight\", ui-sans-serif, system-ui, sans-serif';\nconst MAXL = 8;\nconst CAPW = 1.7; // height of a capital in world units\nconst v3 = (c: number[]) => `vec3(${c.map((n) => n.toFixed(4)).join(\", \")})`;\nconst css = (c: number[]) => `rgb(${c.map((n) => Math.round(255 * Math.pow(Math.min(1, n), 1 / 2.2))).join(\",\")})`;\n\nconst VERT = `#version 300 es\nin vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst TONE = `\nvec3 tone(vec3 x){ vec3 c = 1.0 - exp(-max(x, 0.0) * 0.8); c = mix(c, c * c * (3.0 - 2.0 * c), 0.35); return pow(c, vec3(1.0 / 2.2)); }\n`;\n\n// The photograph: balloon letters standing on one sheet of paper that curves up into a wall, in daylight.\nconst SCENE = `#version 300 es\nprecision highp float;\nout vec4 outC;\nuniform vec2 uRes; uniform vec4 uJit; uniform float uSeed; uniform float uDirect;\nuniform vec3 uCam; uniform vec3 uTgt; uniform float uFoc; uniform vec2 uShift; uniform float uFocus;\nuniform vec3 uSun; uniform sampler2D uF; uniform vec4 uFS; uniform int uN;\nuniform vec4 uL[${MAXL}]; uniform vec4 uD[${MAXL}]; uniform float uSplit[${MAXL}]; uniform vec3 uC[${MAXL}];\nuniform vec3 uBox0; uniform vec3 uBox1;\nconst float ZW = 3.4; const float RC = 1.5; const float TOP = 9.0;\nconst float K = ${INFLATE.toFixed(3)};\nconst vec3 PAPER = ${v3(PAPER)};\nconst vec3 SUNC = vec3(1.0, 0.93, 0.8);\nconst vec3 SKY = vec3(0.86, 0.93, 1.0);\n${TONE}\nfloat h21(vec2 p){ vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }\nfloat n2(vec2 x){ vec2 i = floor(x); vec2 f = fract(x); f = f * f * (3.0 - 2.0 * f);\n  return mix(mix(h21(i), h21(i + vec2(1.0, 0.0)), f.x), mix(h21(i + vec2(0.0, 1.0)), h21(i + vec2(1.0, 1.0)), f.x), f.y); }\n\n// The field: red is how far the skin is blown out at that point of the outline, green and blue its slope.\nvec4 fieldB(vec2 xy){\n  vec2 uv = (xy - uFS.xy) / uFS.zw;\n  if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) return vec4(-0.2, 0.0, 0.0, 0.0);\n  return texture(uF, uv);\n}\n// Smooth read (cubic B-spline) from sixteen exact texels: hardware filtering rounds its weights and would draw contour lines on the skin.\nvec4 fieldS(vec2 xy){\n  ivec2 ts = textureSize(uF, 0);\n  vec2 uv = (xy - uFS.xy) / uFS.zw;\n  if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) return vec4(-0.2, 0.0, 0.0, 0.0);\n  vec2 x = uv * vec2(ts) - 0.5; vec2 f = fract(x); ivec2 i0 = ivec2(floor(x));\n  vec2 f2 = f * f; vec2 f3 = f2 * f;\n  vec2 w0 = (1.0 - f) * (1.0 - f) * (1.0 - f) / 6.0; vec2 w1 = (3.0 * f3 - 6.0 * f2 + 4.0) / 6.0; vec2 w3 = f3 / 6.0; vec2 w2 = 1.0 - w0 - w1 - w3;\n  float wx[4] = float[4](w0.x, w1.x, w2.x, w3.x); float wy[4] = float[4](w0.y, w1.y, w2.y, w3.y);\n  vec4 acc = vec4(0.0);\n  for (int j = 0; j < 4; j++) for (int i = 0; i < 4; i++) {\n    ivec2 c = clamp(i0 + ivec2(i - 1, j - 1), ivec2(0), ts - 1);\n    acc += texelFetch(uF, c, 0) * wx[i] * wy[j];\n  }\n  return acc;\n}\nint letterOf(float x){ int k = 0; for (int i = 0; i < ${MAXL - 1}; i++) { if (i < uN - 1 && x > uSplit[i]) k = i + 1; } return k; }\n\n// Into one letter's own frame: turned on its spot, leaning on its foot, squashed down and out.\nstruct Loc { vec3 q; vec2 xy; float sx; float sy; int id; };\nLoc localTo(vec3 p, int id){\n  Loc l; l.id = id;\n  vec4 L = uL[l.id];\n  vec3 q = p - vec3(L.x, uD[id].w, 0.0);\n  float c = cos(L.y); float s = sin(L.y); q.xz = vec2(c * q.x - s * q.z, s * q.x + c * q.z);\n  c = cos(L.z); s = sin(L.z); q.xy = vec2(c * q.x + s * q.y, -s * q.x + c * q.y);\n  l.sy = 1.0 - L.w; l.sx = inversesqrt(l.sy);\n  q /= vec3(l.sx, l.sy, l.sx);\n  l.q = q; l.xy = vec2(q.x + L.x, q.y);\n  return l;\n}\nfloat dent(Loc l, out vec2 g){\n  vec4 D = uD[l.id]; vec2 d = l.xy - D.xy;\n  float e = D.z * exp(-dot(d, d) * 8.0);\n  g = -16.0 * d * e;\n  return e;\n}\n// A letter turned on its spot can reach over the line into its neighbour's share, so both are asked.\nint otherOf(vec3 p, int id){ int o = p.x > uL[id].x ? id + 1 : id - 1; return clamp(o, 0, uN - 1); }\nfloat bodyOf(vec3 p, int id){\n  Loc l = localTo(p, id);\n  vec4 f = fieldB(l.xy);\n  vec2 dg; float e = dent(l, dg);\n  float z = l.q.z - e;\n  float G = z * z - 2.0 * K * f.x;\n  vec3 gr = vec3(2.0 * z * -dg - 2.0 * K * f.yz, 2.0 * z);\n  float d = 0.5 * G / max(length(gr), 1e-3);\n  // the shared field holds every letter: outside this letter's own share there is nothing of it\n  float lo = id > 0 ? uSplit[id - 1] : -1e3; float hi = id < uN - 1 ? uSplit[id] : 1e3;\n  float past = max(lo - l.xy.x, l.xy.x - hi);\n  if (past > 0.0) d = max(d, length(vec2(past, max(abs(l.q.z) - 0.6, 0.0))) * 0.9);\n  return d * min(l.sx, l.sy);\n}\nfloat body(vec3 p){ int id = letterOf(p.x); int o = otherOf(p, id); float d = bodyOf(p, id); return o == id ? d : min(d, bodyOf(p, o)); }\nint nearest(vec3 p){ int id = letterOf(p.x); int o = otherOf(p, id); return o != id && bodyOf(p, o) < bodyOf(p, id) ? o : id; }\nvec3 normalAt(vec3 p, out Loc l, out float hh){\n  l = localTo(p, nearest(p));\n  vec4 f = fieldS(l.xy); hh = f.x;\n  vec2 dg; float e = dent(l, dg);\n  // put the point exactly on the skin before taking its slope, so the march's last step leaves no ripples\n  float z = l.q.z - e; z = sign(z) * sqrt(max(2.0 * K * f.x, 0.0));\n  vec3 g = vec3(-2.0 * z * dg - 2.0 * K * f.yz, 2.0 * z);\n  g /= vec3(l.sx, l.sy, l.sx);\n  vec4 L = uL[l.id];\n  float c = cos(L.z); float s = sin(L.z); g.xy = vec2(c * g.x - s * g.y, s * g.x + c * g.y);\n  c = cos(L.y); s = sin(L.y); g.xz = vec2(c * g.x + s * g.z, -s * g.x + c * g.z);\n  return normalize(g);\n}\nvec2 boxHit(vec3 ro, vec3 rd){\n  vec3 inv = 1.0 / rd; vec3 a = (uBox0 - ro) * inv; vec3 b = (uBox1 - ro) * inv;\n  vec3 lo = min(a, b); vec3 hi = max(a, b);\n  return vec2(max(max(lo.x, lo.y), max(lo.z, 0.0)), min(min(hi.x, hi.y), hi.z));\n}\nfloat march(vec3 ro, vec3 rd){\n  vec2 tb = boxHit(ro, rd); if (tb.x > tb.y) return -1.0;\n  float t = tb.x;\n  for (int i = 0; i < 110; i++) { float d = body(ro + rd * t); if (d < 0.00025 * t) return t; t += clamp(d * 0.9, 0.001, 0.3); if (t > tb.y) break; }\n  return -1.0;\n}\n// The shade a letter catches from its two neighbours (its own terminator is in the shading already).\nfloat shadowFrom(vec3 p, vec3 l, int id){\n  vec2 tb = boxHit(p, l); if (tb.x > tb.y) return 1.0;\n  int a = max(id - 1, 0); int b = min(id + 1, uN - 1);\n  float res = 1.0; float t = max(tb.x, 0.02);\n  for (int i = 0; i < 32; i++) {\n    vec3 q = p + l * t; float h = 1e3;\n    if (a != id) h = min(h, bodyOf(q, a)); if (b != id) h = min(h, bodyOf(q, b));\n    res = min(res, 9.0 * h / t); t += clamp(h, 0.02, 0.25); if (res < 0.003 || t > tb.y) break;\n  }\n  res = clamp(res, 0.0, 1.0); return res * res * (3.0 - 2.0 * res);\n}\n// t0 also sets how close to the start the soft edge is ignored, so a skin does not shade itself in stripes.\nfloat shadow(vec3 p, vec3 l, float t0){\n  vec2 tb = boxHit(p, l); if (tb.x > tb.y) return 1.0;\n  float res = 1.0; float t = max(tb.x, t0);\n  for (int i = 0; i < 40; i++) { float h = body(p + l * t); if (h < 0.0005) { res = 0.0; break; } if (t > 3.0 * t0) res = min(res, 9.0 * h / t); t += clamp(h, 0.02, 0.25); if (res < 0.003 || t > tb.y) break; }\n  res = clamp(res, 0.0, 1.0); return res * res * (3.0 - 2.0 * res);\n}\n\n// The daylight studio round the set: a big window camera left, a scrim overhead, a white bounce card right.\nvec3 env(vec3 rd){\n  float el = asin(clamp(rd.y, -1.0, 1.0)); float az = atan(rd.x, -rd.z);\n  vec3 c = mix(PAPER * 0.9, SKY * 1.1, smoothstep(-0.1, 0.6, rd.y));\n  vec2 w = abs(vec2(az + 0.75, el - 0.42)) - vec2(0.42, 0.3);\n  float bars = 0.25 + 0.75 * smoothstep(0.01, 0.022, abs(az + 0.75)) * smoothstep(0.01, 0.022, abs(el - 0.42));\n  c += vec3(1.0, 0.98, 0.94) * 9.0 * smoothstep(0.03, -0.03, max(w.x, w.y)) * bars;\n  vec2 w2 = abs(vec2(az - 0.95, el - 0.25)) - vec2(0.16, 0.5);\n  c += vec3(1.0) * 3.2 * smoothstep(0.05, -0.05, max(w2.x, w2.y));\n  c += vec3(1.0, 0.99, 0.97) * 2.4 * smoothstep(0.85, 1.25, el);\n  c += SUNC * 40.0 * smoothstep(0.9965, 0.9992, dot(rd, uSun));\n  return c;\n}\n\n// The sun comes through a tall window: its glazing bars throw soft lines across the set.\nfloat gobo(vec3 p){\n  vec3 a = normalize(cross(uSun, vec3(0.0, 1.0, 0.0))); vec3 b = cross(a, uSun);\n  vec2 w = vec2(dot(p, a), dot(p, b)) - vec2(-1.2, 1.4);\n  // the window: a big opening with one upright and one rail, soft because it is far away\n  vec2 o = abs(w) - vec2(6.5, 3.6);\n  float open = smoothstep(0.9, -0.9, max(o.x, o.y));\n  float bars = smoothstep(0.06, 0.3, abs(w.x - 0.9)) * smoothstep(0.05, 0.28, abs(w.y + 0.6));\n  return mix(0.5, 1.0, open * bars);\n}\nvec3 stage(vec3 ro, vec3 rd, float full, float jit){\n  float t = 1e9; vec3 n = vec3(0.0, 1.0, 0.0);\n  if (rd.y < 0.0) { float tf = -ro.y / rd.y; float z = ro.z + rd.z * tf; if (z < ZW - RC) t = tf; }\n  if (t > 1e8 && rd.z > 0.0) { float tw = (ZW - ro.z) / rd.z; float y = ro.y + rd.y * tw; if (y > TOP) return env(rd); if (y > RC) { t = tw; n = vec3(0.0, 0.0, -1.0); } }\n  if (t > 1e8) {\n    vec2 o = ro.yz - vec2(RC, ZW - RC); float a = dot(rd.yz, rd.yz); float b = dot(o, rd.yz); float h = b * b - a * (dot(o, o) - RC * RC);\n    if (h > 0.0 && a > 1e-7) { float tc = (-b + sqrt(h)) / a; vec2 pc = ro.yz + rd.yz * tc; if (tc > 0.0 && pc.x < RC + 0.02 && pc.y > ZW - RC - 0.02) { t = tc; vec2 nn = (vec2(RC, ZW - RC) - pc) / RC; n = vec3(0.0, nn.x, nn.y); } }\n  }\n  if (t > 1e8) return env(rd);\n  vec3 p = ro + rd * t;\n  vec2 pq = p.xz * (1.0 - n.z * n.z) + p.xy * n.z * n.z + vec2(p.y * 0.37, 0.0);\n  float tooth = 0.45 * (n2(pq * 140.0) - 0.5) + 0.3 * (n2(pq * 55.0 + 7.0) - 0.5); float mott = n2(pq * 1.3) - 0.5;\n  vec3 alb = PAPER * (1.0 + 0.06 * tooth + 0.05 * mott);\n  float ndl = max(dot(n, uSun), 0.0);\n  float dB = body(p + n * 0.02);\n  float vis = full > 0.5 && ndl > 0.0 ? shadow(p + n * 0.004, uSun, 0.015) : 0.4 + 0.6 * smoothstep(0.0, 0.6, dB);\n  float occ = 0.38 + 0.62 * smoothstep(0.0, 0.5, dB);\n  occ *= 1.0 - 0.45 * exp(-max(dB, 0.0) * 9.0);\n  // light thrown back off the coloured skins onto the paper\n  int id = letterOf(p.x);\n  vec3 bleed = uC[id] * exp(-max(dB, 0.0) * 5.5) * 0.55 * smoothstep(1.6, 0.0, p.y);\n  float wash = exp(-dot(p.xy - vec2(-0.6, 1.4), p.xy - vec2(-0.6, 1.4)) / 30.0);\n  vec3 fill = mix(PAPER * 1.5 + 0.06, SKY, 0.4 + 0.4 * n.y) * (0.75 + 0.5 * wash) * (1.0 - 0.35 * smoothstep(1.5, 6.0, p.y));\n  vec3 col = alb * (SUNC * 4.5 * ndl * vis * gobo(p) + fill * occ * 0.5 + bleed);\n  return col;\n}\n\nvec3 shadeLetter(vec3 p, vec3 rd, vec2 rnd, float jit){\n  Loc l; float hh; vec3 n = normalAt(p, l, hh);\n  vec3 C = uC[l.id];\n  // creases where the two sheets are welded together round the outline, and fine crinkles near it\n  float edge = exp(-max(hh, 0.0) * 260.0);\n  // pleats run in from the seam, across the outline, like a bag pulled tight round a shape\n  vec2 gd = normalize(fieldB(l.xy).yz + 1e-5); vec2 tg = vec2(-gd.y, gd.x);\n  float pl = n2(vec2(dot(l.xy, tg) * 46.0, dot(l.xy, gd) * 5.0));\n  float pleat = exp(-max(hh, 0.0) * 420.0);\n  vec3 wob = vec3(tg * (pl - 0.5) * 0.55 * pleat, 0.0) * 0.55;\n  n = normalize(n + wob);\n  float seam = smoothstep(0.022, 0.006, abs(l.q.z - 0.0)) * edge;\n  vec3 r = reflect(rd, n);\n  float nv = clamp(dot(-rd, n), 0.0, 1.0);\n  float ndl = dot(n, uSun);\n  float sh = ndl > 0.0 ? shadowFrom(p + n * 0.02, uSun, l.id) : 0.0;\n  // vinyl: colour that softly wraps round into the shade, and lets a little sun through where the skin is thin\n  float wrap = clamp((ndl + 0.35) / 1.35, 0.0, 1.0);\n  float ao = 0.45 + 0.55 * smoothstep(-0.05, 0.55, p.y) ;\n  vec3 sky = mix(PAPER * 1.6 + 0.08, SKY * 1.15, 0.5 + 0.5 * n.y);\n  vec3 alb = C * (1.0 - 0.35 * seam);\n  vec3 col = alb * (SUNC * 3.3 * wrap * mix(0.16, 1.0, sh * gobo(p)) + sky * ao * 0.3 + alb * sky * ao * 0.35);\n  col += C * 0.7 * SUNC * clamp(-ndl, 0.0, 1.0) * edge * 0.6;\n  // a hard clear skin on top: the windows of the studio slide across it\n  float rough = 0.02 + 0.06 * seam;\n  vec3 rr = normalize(r + vec3(rnd.x, rnd.y, rnd.x * 0.5) * rough);\n  float f = min(0.04 + 0.6 * pow(1.0 - nv, 5.0), 0.45);\n  vec3 refl = rr.y < -0.02 ? stage(p + n * 0.01, rr, 0.0, 0.0) : env(rr);\n  col = col * (1.0 - f) + refl * f * ao;\n  col += SUNC * 26.0 * pow(max(dot(r, uSun), 0.0), 900.0) * sh;\n  return col;\n}\n\nvoid main(){\n  vec2 fc = gl_FragCoord.xy + uJit.xy;\n  vec2 uv = (fc - 0.5 * uRes) / uRes.y - uShift;\n  vec3 fw = normalize(uTgt - uCam); vec3 rt = normalize(cross(vec3(0.0, 1.0, 0.0), fw)); vec3 up = cross(fw, rt);\n  vec3 rd = normalize(fw * uFoc + rt * uv.x + up * uv.y);\n  vec3 ro = uCam;\n  vec3 fp = ro + rd * (uFocus / dot(rd, fw));\n  ro += rt * uJit.z + up * uJit.w; rd = normalize(fp - ro);\n  float ign = fract(52.9829189 * fract(dot(gl_FragCoord.xy, vec2(0.06711056, 0.00583715))) + uSeed);\n  float ang = ign * 6.2831853; float rr = sqrt(fract(ign * 7.13 + uSeed * 3.7));\n  vec2 rnd = vec2(cos(ang), sin(ang)) * rr * step(0.001, uSeed);\n  float jit = uSeed > 0.001 ? ign : 0.5;\n  float t = march(ro, rd);\n  vec3 col = t > 0.0 ? shadeLetter(ro + rd * t, rd, rnd, jit) : stage(ro, rd, 1.0, jit);\n  col = min(col, vec3(16.0));\n  if (uDirect > 0.5) col = tone(col);\n  outC = vec4(col, 1.0);\n}\n`;\n\n// Developing the frame: a little bloom off the glints, the film curve, a soft vignette and grain.\nconst POST = `#version 300 es\nprecision highp float;\nout vec4 outC;\nuniform sampler2D uAcc; uniform vec2 uRes; uniform float uGrain;\n${TONE}\nfloat h21(vec2 p){ vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }\nvoid main(){\n  vec2 uv = gl_FragCoord.xy / uRes;\n  vec3 c = texture(uAcc, uv).rgb;\n  vec2 px = 1.0 / uRes;\n  vec3 nb = texture(uAcc, uv + vec2(px.x, 0.0)).rgb + texture(uAcc, uv - vec2(px.x, 0.0)).rgb + texture(uAcc, uv + vec2(0.0, px.y)).rgb + texture(uAcc, uv - vec2(0.0, px.y)).rgb;\n  c = max(c + (c - nb * 0.25) * 0.35, 0.0);\n  vec3 b = vec3(0.0);\n  for (int i = 0; i < 20; i++) {\n    float a = float(i) * 2.39996; float r = sqrt((float(i) + 0.5) / 20.0);\n    vec3 s = texture(uAcc, uv + vec2(cos(a), sin(a)) * r * 0.02 * vec2(uRes.y / uRes.x, 1.0)).rgb;\n    b += min(max(s - 3.0, 0.0), vec3(8.0)) * (1.0 - 0.6 * r);\n  }\n  c += b * 0.015;\n  vec2 q = (uv - vec2(0.5, 0.55)) * vec2(uRes.x / uRes.y, 1.0);\n  c *= 1.0 - 0.16 * smoothstep(0.4, 1.3, length(q));\n  c = tone(c);\n  float g = h21(gl_FragCoord.xy + uGrain * 91.7) - 0.5;\n  c += g * 0.018 * (1.0 - 0.4 * c.g);\n  outC = vec4(c, 1.0);\n}\n`;\n\ntype Baked = { data: Float32Array; tw: number; th: number; fs: [number, number, number, number]; mids: number[]; splits: number[]; halfW: number; capH: number };\n\n// Two pass chamfer distance (in pixels) to the nearest inked pixel.\nfunction chamfer(ink: Uint8Array, w: number, h: number) {\n  const d = new Float32Array(w * h);\n  for (let i = 0; i < d.length; i++) d[i] = ink[i] ? 0 : 1e9;\n  const a = 1, b = Math.SQRT2;\n  for (let y = 1; y < h - 1; y++)\n    for (let x = 1; x < w - 1; x++) {\n      const i = y * w + x; if (!d[i]) continue;\n      d[i] = Math.min(d[i], d[i - 1] + a, d[i - w] + a, d[i - w - 1] + b, d[i - w + 1] + b);\n    }\n  for (let y = h - 2; y > 0; y--)\n    for (let x = w - 2; x > 0; x--) {\n      const i = y * w + x; if (!d[i]) continue;\n      d[i] = Math.min(d[i], d[i + 1] + a, d[i + w] + a, d[i + w + 1] + b, d[i + w - 1] + b);\n    }\n  return d;\n}\n// Relax the membrane (laplacian of h is -1 inside the ink, 0 on the outline) in place.\nfunction relax(hf: Float32Array, ink: Uint8Array, w: number, h: number, c2: number, omega: number, rounds: number) {\n  for (let it = 0; it < rounds; it++)\n    for (let y = 1; y < h - 1; y++)\n      for (let x = 1; x < w - 1; x++) {\n        const i = y * w + x;\n        if (ink[i]) hf[i] += omega * ((hf[i - 1] + hf[i + 1] + hf[i - w] + hf[i + w] + c2) * 0.25 - hf[i]);\n      }\n}\nfunction down(ink: Uint8Array, w: number, h: number) {\n  const W = w >> 1, H = h >> 1, o = new Uint8Array(W * H);\n  for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) { const i = 2 * y * w + 2 * x; o[y * W + x] = ink[i] + ink[i + 1] + ink[i + w] + ink[i + w + 1] >= 2 ? 1 : 0; }\n  return o;\n}\nfunction up(src: Float32Array, W: number, H: number, ink: Uint8Array) {\n  const w = W * 2, h = H * 2, o = new Float32Array(w * h);\n  for (let y = 0; y < h; y++) {\n    const fy = Math.min(H - 1.001, Math.max(0, (y - 0.5) / 2)), y0 = fy | 0, ty = fy - y0;\n    for (let x = 0; x < w; x++) {\n      const i = y * w + x; if (!ink[i]) continue;\n      const fx = Math.min(W - 1.001, Math.max(0, (x - 0.5) / 2)), x0 = fx | 0, tx = fx - x0, a = y0 * W + x0;\n      o[i] = (src[a] * (1 - tx) + src[a + 1] * tx) * (1 - ty) + (src[a + W] * (1 - tx) + src[a + W + 1] * tx) * ty;\n    }\n  }\n  return o;\n}\n\n// Set the word in a round heavy face, then blow each letter up like a sealed balloon.\nfunction bake(word: string): Baked {\n  const TW = 2048, TH = 512;\n  const cv = document.createElement(\"canvas\");\n  cv.width = TW; cv.height = TH;\n  const g = cv.getContext(\"2d\", { willReadFrequently: true })!;\n  const chars = [...word.slice(0, MAXL)];\n  const px = 300;\n  g.font = `900 ${px}px ${BALLOON_FONT}`;\n  const m = g.measureText(\"H\");\n  const cap = m.actualBoundingBoxAscent || px * 0.72;\n  const gap = px * 0.11, fat = px * 0.05;\n  const ws = chars.map((c) => g.measureText(c).width);\n  const total = ws.reduce((a, b) => a + b, 0) + gap * (chars.length - 1) + fat * 2;\n  const k = Math.min((TH * 0.7) / cap, (TW * 0.92) / total);\n  const size = px * k, capPx = cap * k, gp = gap * k, ft = fat * k;\n  g.fillStyle = \"#000\"; g.fillRect(0, 0, TW, TH);\n  g.font = `900 ${size}px ${BALLOON_FONT}`;\n  g.fillStyle = \"#fff\"; g.strokeStyle = \"#fff\"; g.lineJoin = \"round\"; g.lineWidth = ft * 2; g.textBaseline = \"alphabetic\";\n  const baseY = TH * 0.86;\n  let x = (TW - (total * k - ft * 2)) / 2;\n  const midsPx: number[] = [];\n  chars.forEach((c, i) => {\n    g.fillText(c, x, baseY); g.strokeText(c, x, baseY);\n    midsPx.push(x + (ws[i] * k) / 2);\n    x += ws[i] * k + gp;\n  });\n  const px2 = g.getImageData(0, 0, TW, TH).data;\n  const ink = new Uint8Array(TW * TH);\n  for (let y = 0; y < TH; y++) { const src = (TH - 1 - y) * TW * 4; for (let xx = 0; xx < TW; xx++) ink[y * TW + xx] = px2[src + xx * 4] > 127 ? 1 : 0; }\n  for (let xx = 0; xx < TW; xx++) ink[xx] = ink[(TH - 1) * TW + xx] = 0;\n  for (let y = 0; y < TH; y++) ink[y * TW] = ink[y * TW + TW - 1] = 0;\n  const cell = CAPW / capPx; // world units per pixel\n  // coarse to fine: the slow, wide part of the answer is found on the small grid\n  const ink1 = down(ink, TW, TH), ink2 = down(ink1, TW >> 1, TH >> 1);\n  const h2 = new Float32Array((TW >> 2) * (TH >> 2));\n  relax(h2, ink2, TW >> 2, TH >> 2, (cell * 4) ** 2, 1.88, 260);\n  const h1 = up(h2, TW >> 2, TH >> 2, ink1);\n  relax(h1, ink1, TW >> 1, TH >> 1, (cell * 2) ** 2, 1.6, 40);\n  const h0 = up(h1, TW >> 1, TH >> 1, ink);\n  relax(h0, ink, TW, TH, cell * cell, 1.3, 10);\n  const dist = chamfer(ink, TW, TH);\n  const HC = 0.05;\n  let field = new Float32Array(TW * TH);\n  for (let i = 0; i < field.length; i++) {\n    if (ink[i]) field[i] = HC * (1 - Math.exp(-h0[i] / HC));\n    else { const d = Math.min(dist[i] * cell, 0.4); field[i] = -(0.06 * d + d * d * 0.5); }\n  }\n  // two light blurs take the stair steps off the outline\n  const tmp = new Float32Array(TW * TH);\n  for (let pass = 0; pass < 2; pass++) {\n    for (let y = 0; y < TH; y++) { const r = y * TW; tmp[r] = field[r]; tmp[r + TW - 1] = field[r + TW - 1]; for (let xx = 1; xx < TW - 1; xx++) tmp[r + xx] = (field[r + xx - 1] + field[r + xx] * 2 + field[r + xx + 1]) * 0.25; }\n    for (let y = 1; y < TH - 1; y++) { const r = y * TW; for (let xx = 0; xx < TW; xx++) field[r + xx] = (tmp[r + xx - TW] + tmp[r + xx] * 2 + tmp[r + xx + TW]) * 0.25; }\n  }\n  const data = new Float32Array(TW * TH * 4);\n  const inv = 0.5 / cell;\n  for (let y = 1; y < TH - 1; y++)\n    for (let xx = 1; xx < TW - 1; xx++) {\n      const i = y * TW + xx, o = i * 4;\n      data[o] = field[i]; data[o + 1] = (field[i + 1] - field[i - 1]) * inv; data[o + 2] = (field[i + TW] - field[i - TW]) * inv;\n    }\n  for (let xx = 0; xx < TW; xx++) { data[xx * 4] = -0.2; data[((TH - 1) * TW + xx) * 4] = -0.2; }\n  for (let y = 0; y < TH; y++) { data[y * TW * 4] = -0.2; data[(y * TW + TW - 1) * 4] = -0.2; }\n  field = new Float32Array(0);\n  // world frame: the outline's lowest point rests on the floor, the word centred on x = 0\n  let lowest = TH;\n  for (let y = 0; y < TH && lowest === TH; y++) for (let xx = 0; xx < TW; xx++) if (ink[y * TW + xx]) { lowest = y; break; }\n  const x0 = -(TW / 2) * cell, y0 = -lowest * cell + 0.01;\n  const mids = midsPx.map((m2) => x0 + m2 * cell);\n  const splits = mids.slice(1).map((m2, i) => (m2 + mids[i]) / 2);\n  return { data, tw: TW, th: TH, fs: [x0, y0, TW * cell, TH * cell], mids, splits, halfW: (total * k * cell) / 2, capH: CAPW };\n}\n\n// No WebGL 2 (or no motion wanted before the first frame): the same word as layered glossy type on the same paper.\nfunction Still() {\n  const tilt = [-4, 3, -2, 4, -3, 2, -3, 3];\n  return (\n    <div aria-hidden=\"true\" className=\"absolute inset-x-0 top-[190px] flex justify-center lg:top-[200px]\">\n      <div className=\"relative flex items-end gap-[0.05em] text-[23vw] leading-[0.9] lg:text-[min(15.5vw,220px)]\" style={{ fontFamily: BALLOON_FONT, fontWeight: 900 }}>\n        {[...venue.word.slice(0, MAXL)].map((c, i) => {\n          const col = css(COLOURS[i % COLOURS.length]);\n          return (\n            <span key={i} className=\"relative inline-block\" style={{ transform: `rotate(${tilt[i]}deg)` }}>\n              {/* the shadow thrown back and to the right on the paper */}\n              <span className=\"absolute bottom-[-0.04em] left-[0.18em] h-[0.16em] w-[0.9em] rounded-[50%] bg-[#2d6f9e]/35 blur-[8px]\" />\n              <span className=\"relative block\" style={{ color: col, textShadow: \"0 0.025em 0 rgba(0,0,0,0.16), 0 0.05em 0.04em rgba(0,0,0,0.12), -0.02em -0.015em 0.02em rgba(255,255,255,0.35)\" }}>{c}</span>\n              {/* gloss and shade over the colour */}\n              <span className=\"absolute inset-0 block\" style={{ backgroundImage: \"radial-gradient(ellipse 30% 14% at 34% 18%, rgba(255,255,255,0.95), rgba(255,255,255,0) 70%), linear-gradient(165deg, rgba(255,255,255,0.38) 0%, rgba(255,255,255,0) 34%, rgba(0,0,0,0) 62%, rgba(20,20,60,0.3) 100%)\", WebkitBackgroundClip: \"text\", backgroundClip: \"text\", WebkitTextFillColor: \"transparent\", color: \"transparent\" }}>{c}</span>\n            </span>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n\nexport default function RayMarchedVinylBalloonLettersHero() {\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const [shown, setShown] = useState<\"wait\" | \"gl\" | \"still\">(\"wait\");\n  const api = useRef<{ squeeze: (i: number) => void; wave: () => void } | null>(null);\n  const letters = [...venue.word.slice(0, MAXL)];\n\n  useEffect(() => {\n    const box = stage.current, cv = canvas.current;\n    if (!box || !cv) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const gl = cv.getContext(\"webgl2\", { antialias: false, alpha: false, powerPreference: \"high-performance\" }) as WebGL2RenderingContext | null;\n    if (!gl) { setShown(\"still\"); return; }\n    const canAcc = !!gl.getExtension(\"EXT_color_buffer_float\") || !!gl.getExtension(\"EXT_color_buffer_half_float\");\n    const info = gl.getExtension(\"WEBGL_debug_renderer_info\");\n    const renderer = info ? String(gl.getParameter(info.UNMASKED_RENDERER_WEBGL)) : \"\";\n    const software = /swiftshader|llvmpipe|software|basic render/i.test(renderer);\n    const still = reduce || software;\n\n    const compile = (type: number, src: string) => {\n      const sh = gl.createShader(type); if (!sh) return null;\n      gl.shaderSource(sh, src); gl.compileShader(sh);\n      return gl.getShaderParameter(sh, gl.COMPILE_STATUS) ? sh : null;\n    };\n    const link = (frag: string) => {\n      const v = compile(gl.VERTEX_SHADER, VERT), f = compile(gl.FRAGMENT_SHADER, frag), p = gl.createProgram();\n      if (!v || !f || !p) return null;\n      gl.attachShader(p, v); gl.attachShader(p, f); gl.bindAttribLocation(p, 0, \"aPos\"); gl.linkProgram(p);\n      return gl.getProgramParameter(p, gl.LINK_STATUS) ? p : null;\n    };\n    const scene = link(SCENE), post = canAcc ? link(POST) : null;\n    if (!scene || (canAcc && !post)) { setShown(\"still\"); return; }\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    const su = Object.fromEntries([\"uRes\", \"uJit\", \"uSeed\", \"uDirect\", \"uCam\", \"uTgt\", \"uFoc\", \"uShift\", \"uFocus\", \"uSun\", \"uF\", \"uFS\", \"uN\", \"uL\", \"uD\", \"uSplit\", \"uC\", \"uBox0\", \"uBox1\"].map((n) => [n, U(scene, n)]));\n    const pu = post ? Object.fromEntries([\"uAcc\", \"uRes\", \"uGrain\"].map((n) => [n, U(post, n)])) : {};\n\n    const quad = gl.createBuffer();\n    gl.bindBuffer(gl.ARRAY_BUFFER, quad);\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n    gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n\n    // full precision for the field when the device can filter it, otherwise half floats\n    const f32 = !!gl.getExtension(\"OES_texture_float_linear\");\n    let field = bake(venue.word);\n    const ftex = gl.createTexture();\n    const upload = () => {\n      gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, ftex);\n      gl.texImage2D(gl.TEXTURE_2D, 0, f32 ? gl.RGBA32F : gl.RGBA16F, field.tw, field.th, 0, gl.RGBA, gl.FLOAT, field.data);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_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    };\n    upload();\n    const n = field.mids.length;\n    // each letter's resting pose: a small turn and lean, as if dropped on the paper by hand\n    const restYaw = [0.16, -0.1, 0.12, -0.14, 0.08, -0.12, 0.1, -0.08];\n    const restLean = [0.035, -0.03, 0.02, -0.04, 0.03, -0.02, 0.03, -0.03];\n    const L = Array.from({ length: n }, (_, i) => ({ sq: 0, sv: 0, yaw: 0, yv: 0, held: 0, dx: field.mids[i], dy: 0.9, dent: 0, dentT: 0 }));\n\n    const acc = canAcc ? gl.createTexture() : null;\n    const fbo = canAcc ? gl.createFramebuffer() : null;\n    let W = 0, H = 0, scale = 1, cssW = 1, cssH = 1;\n    const s = { px: 0, py: 0, sx: 0, sy: 0, count: 0, fresh: true, frame: 0, slow: 0, visible: true, raf: 0, last: 0, t0: 0, touched: false, alive: true, first: true, demo: 0 as number, hover: -1, hx: 0, hy: 0 };\n    const size = () => {\n      const r = box.getBoundingClientRect();\n      cssW = Math.max(1, r.width); cssH = Math.max(1, r.height);\n      const dpr = Math.min(software ? 1 : 1.6, window.devicePixelRatio || 1) * scale;\n      const k = Math.min(1, Math.sqrt(1.7e6 / (cssW * cssH * dpr * dpr)));\n      const w = Math.max(2, Math.round(cssW * dpr * k)), h = Math.max(2, Math.round(cssH * dpr * k));\n      if (w === W && h === H) return;\n      W = w; H = h; cv.width = W; cv.height = H;\n      if (acc && fbo) {\n        gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, acc);\n        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16F, W, H, 0, gl.RGBA, gl.HALF_FLOAT, null);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_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, acc, 0);\n        gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      }\n      s.count = 0; s.fresh = true;\n    };\n    const halton = (i: number, b: number) => { let f = 1, r = 0; while (i > 0) { f /= b; r += f * (i % b); i = Math.floor(i / b); } return r; };\n\n    // The lens: where it stands and how it frames the word, for wide screens and for phones.\n    const lens = () => {\n      const wide = cssW >= 1024, aspect = cssW / cssH;\n      const dist = 9.5, el = (wide ? 0.2 : 0.24) - s.sy * 0.025, az = s.sx * 0.06;\n      const span = field.halfW * 2 + 0.6;\n      const foc = wide ? Math.min(2.6, (dist * aspect) / (span / 0.74)) : (dist * aspect) / (span / 0.94);\n      const tgt = [0, 0.95, 0];\n      const cam = [dist * Math.sin(az) * Math.cos(el), tgt[1] + dist * Math.sin(el), -dist * Math.cos(az) * Math.cos(el)];\n      const shift = wide ? 0.1 : 0.17 * Math.min(1, cssH / cssW / 1.6);\n      return { cam, tgt, foc, shift, dist };\n    };\n    const ray = (cx: number, cy: number) => {\n      const { cam, tgt, foc, shift } = lens();\n      const ux = (cx - 0.5 * cssW) / cssH, uy = (0.5 * cssH - cy) / cssH - shift;\n      const fw = [tgt[0] - cam[0], tgt[1] - cam[1], tgt[2] - cam[2]], fl = Math.hypot(...fw); fw.forEach((_, i) => (fw[i] /= fl));\n      const rt = [fw[2], 0, -fw[0]], rl = Math.hypot(...rt); rt.forEach((_, i) => (rt[i] /= rl));\n      const upv = [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      const d = [0, 1, 2].map((i) => fw[i] * foc + rt[i] * ux + upv[i] * uy);\n      // meet the plane the letters stand in\n      const t = -cam[2] / d[2];\n      return { x: cam[0] + d[0] * t, y: cam[1] + d[1] * t };\n    };\n    const pick = (cx: number, cy: number) => {\n      const p = ray(cx, cy);\n      if (p.y < -0.1 || p.y > CAPW * 1.15 || Math.abs(p.x) > field.halfW + 0.15) return null;\n      let id = 0; field.splits.forEach((sp, i) => { if (p.x > sp) id = i + 1; });\n      return { id, x: p.x, y: p.y };\n    };\n\n    const draw = (alpha: number, sample: number, focusBlur = true) => {\n      const { cam, tgt, foc, shift, dist } = lens();\n      const jx = sample ? halton(sample, 2) - 0.5 : 0, jy = sample ? halton(sample, 3) - 0.5 : 0;\n      const la = halton(sample, 5) * Math.PI * 2, lr = sample && focusBlur ? Math.sqrt(halton(sample, 7)) * 0.07 : 0;\n      gl.useProgram(scene);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, canAcc ? fbo : null);\n      gl.viewport(0, 0, W, H);\n      if (canAcc && alpha < 1) { gl.enable(gl.BLEND); gl.blendColor(0, 0, 0, alpha); gl.blendFunc(gl.CONSTANT_ALPHA, gl.ONE_MINUS_CONSTANT_ALPHA); } else gl.disable(gl.BLEND);\n      gl.uniform2f(su.uRes, W, H);\n      gl.uniform4f(su.uJit, canAcc ? jx : 0, canAcc ? jy : 0, canAcc ? Math.cos(la) * lr : 0, canAcc ? Math.sin(la) * lr : 0);\n      gl.uniform1f(su.uSeed, canAcc && sample ? (sample * 0.61803) % 1 || 0.5 : 0);\n      gl.uniform1f(su.uDirect, canAcc ? 0 : 1);\n      gl.uniform3f(su.uCam, cam[0], cam[1], cam[2]); gl.uniform3f(su.uTgt, tgt[0], tgt[1], tgt[2]);\n      gl.uniform1f(su.uFoc, foc); gl.uniform2f(su.uShift, 0, shift);\n      gl.uniform1f(su.uFocus, dist);\n      const sa = -0.62 + s.sx * 0.05, se = 0.78;\n      const sun = [Math.sin(sa) * Math.cos(se), Math.sin(se), -Math.cos(sa) * Math.cos(se) * 0.75], sl = Math.hypot(...sun);\n      gl.uniform3f(su.uSun, sun[0] / sl, sun[1] / sl, sun[2] / sl);\n      gl.uniform1i(su.uF, 0);\n      gl.uniform4f(su.uFS, ...field.fs);\n      gl.uniform1i(su.uN, n);\n      const Lv = new Float32Array(MAXL * 4), Dv = new Float32Array(MAXL * 4), Cv = new Float32Array(MAXL * 3), Sp = new Float32Array(MAXL);\n      L.forEach((l, i) => {\n        Lv.set([field.mids[i], restYaw[i % 8] + l.yaw, restLean[i % 8], Math.max(-0.2, Math.min(0.4, l.sq))], i * 4);\n        Dv.set([l.dx, l.dy, l.dent, Math.max(0, -l.sq) * 0.7], i * 4);\n        Cv.set(COLOURS[i % COLOURS.length], i * 3);\n      });\n      field.splits.forEach((v, i) => (Sp[i] = v));\n      gl.uniform4fv(su.uL, Lv); gl.uniform4fv(su.uD, Dv); gl.uniform3fv(su.uC, Cv); gl.uniform1fv(su.uSplit, Sp);\n      const z = Math.sqrt(2 * INFLATE * 0.05) + 0.5;\n      gl.uniform3f(su.uBox0, -field.halfW - 1.2, -0.05, -z); gl.uniform3f(su.uBox1, field.halfW + 1.2, CAPW * 1.7, z);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      if (canAcc && post) {\n        gl.bindFramebuffer(gl.FRAMEBUFFER, null); gl.disable(gl.BLEND);\n        gl.useProgram(post);\n        gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, acc);\n        gl.uniform1i(pu.uAcc, 1); gl.uniform2f(pu.uRes, W, H);\n        gl.uniform1f(pu.uGrain, still ? 1 : s.frame % 64);\n        gl.drawArrays(gl.TRIANGLES, 0, 3);\n      }\n    };\n\n    // a press: the letter sinks and spreads while held; on release it springs back past its mark and wobbles\n    const press = (i: number, x?: number, y?: number) => {\n      const l = L[i]; if (!l) return;\n      l.held = 1; l.dx = x ?? field.mids[i]; l.dy = y ?? CAPW * 0.55; l.dentT = 0.22;\n      wake();\n    };\n    const release = (i: number) => {\n      const l = L[i]; if (!l || !l.held) return;\n      l.held = 0; l.dentT = 0; l.yv += (i % 2 ? -1 : 1) * 2.4; wake();\n    };\n    const squeeze = (i: number, ms = 280) => { if (reduce) return; press(i); window.setTimeout(() => release(i), ms); };\n    const wave = () => { if (reduce) return; L.forEach((_, i) => window.setTimeout(() => squeeze(i, 240), i * 120)); };\n    api.current = { squeeze: (i) => { s.touched = true; squeeze(i); }, wave: () => { s.touched = true; wave(); } };\n\n    const frame = (now: number) => {\n      s.raf = 0;\n      if (!s.visible || !s.alive) return;\n      const dtRaw = s.last ? (now - s.last) / 1000 : 0.016;\n      const dt = Math.min(0.033, dtRaw);\n      s.last = now; s.frame++;\n      if (!s.t0) s.t0 = now;\n      let moving = false;\n      if (!reduce) {\n        for (const l of L) {\n          const want = l.held ? 0.24 : 0;\n          for (let k = 0; k < 4; k++) {\n            const h = dt / 4;\n            l.sv += ((l.held ? 260 : 210) * (want - l.sq) - (l.held ? 26 : 7.5) * l.sv) * h; l.sq += l.sv * h;\n            l.yv += (-120 * l.yaw - 6 * l.yv) * h; l.yaw += l.yv * h;\n          }\n          l.dent += (l.dentT - l.dent) * (1 - Math.exp(-dt * (l.dentT > l.dent ? 22 : 9)));\n          if (l.held || Math.abs(l.sq) + Math.abs(l.sv) * 0.05 + Math.abs(l.yaw) + Math.abs(l.yv) * 0.05 + Math.abs(l.dent - l.dentT) > 0.0006) moving = true;\n          else { l.sq = l.sv = l.yaw = l.yv = 0; l.dent = l.dentT; }\n        }\n        const ex = s.px - s.sx, ey = s.py - s.sy;\n        s.sx += ex * (1 - Math.exp(-dt * 3)); s.sy += ey * (1 - Math.exp(-dt * 3));\n        if (Math.abs(ex) + Math.abs(ey) > 0.003) moving = true;\n      }\n      const fast = L.some((l) => Math.abs(l.sv) > 0.4 || Math.abs(l.yv) > 0.4);\n      if (s.fresh || !canAcc) { draw(1, 0); s.fresh = false; s.count = 1; }\n      else if (moving) { draw(fast ? 0.6 : 0.4, 1 + (s.frame % 64), false); s.count = 4; }\n      else if (s.count < 40) { s.count++; draw(1 / s.count, s.count); }\n      if (s.first) { s.first = false; setShown(\"gl\"); }\n      if (!still && dtRaw > 0.03) s.slow++; else s.slow = Math.max(0, s.slow - 2);\n      if (s.slow > 40 && scale > 0.55) { scale *= 0.85; s.slow = 0; size(); }\n      if (moving || s.count < 40) s.raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!s.raf && s.visible && s.alive) { s.last = 0; s.raf = requestAnimationFrame(frame); } };\n\n    // it opens finished and still; a few seconds later a squeeze runs along the word, and again every few seconds until someone joins in\n    const demo = () => { if (!s.alive) return; if (!s.touched && s.visible && !still) wave(); s.demo = window.setTimeout(demo, 7600); };\n    if (!still) s.demo = window.setTimeout(demo, 3600);\n\n    size();\n    const ro = new ResizeObserver(() => { size(); wake(); });\n    ro.observe(box);\n    const io = new IntersectionObserver(([e]) => { s.visible = e.isIntersecting && !document.hidden; if (s.visible) wake(); }, { threshold: 0.05 });\n    io.observe(box);\n    const vis = () => { s.visible = !document.hidden; if (s.visible) wake(); };\n    document.addEventListener(\"visibilitychange\", vis);\n    const fontIn = () => !!document.fonts?.check(`900 40px ${BALLOON_FONT.split(\",\")[0]}`);\n    const hadFont = fontIn();\n    document.fonts?.ready.then(() => {\n      if (!s.alive || fontIn() === hadFont) return;\n      field = bake(venue.word); upload(); s.count = 0; s.fresh = true; wake();\n    });\n\n    let held = -1, pid = -1;\n    const local = (e: PointerEvent) => { const r = box.getBoundingClientRect(); return [e.clientX - r.left, e.clientY - r.top]; };\n    const down = (e: PointerEvent) => {\n      const [x, y] = local(e); const hitL = pick(x, y);\n      if (!hitL || reduce) return;\n      s.touched = true; held = hitL.id; pid = e.pointerId;\n      try { box.setPointerCapture(pid); } catch { /* pointer already gone */ }\n      press(hitL.id, hitL.x, hitL.y);\n    };\n    const move = (e: PointerEvent) => {\n      const [x, y] = local(e);\n      s.px = (x / cssW) * 2 - 1; s.py = (y / cssH) * 2 - 1;\n      const hitL = pick(x, y);\n      box.style.cursor = hitL ? \"pointer\" : \"\";\n      if (!reduce) {\n        // a hovering finger already presses a shallow dimple into the skin\n        L.forEach((l, i) => { if (!l.held) l.dentT = hitL && hitL.id === i ? 0.055 : 0; });\n        if (hitL && !L[hitL.id].held) { L[hitL.id].dx = hitL.x; L[hitL.id].dy = hitL.y; }\n        if (held >= 0 && hitL && hitL.id === held) { L[held].dx = hitL.x; L[held].dy = hitL.y; }\n      }\n      if (!still) wake();\n    };\n    const upFn = (e: PointerEvent) => { if (e.pointerId !== pid || held < 0) return; release(held); held = -1; };\n    const leave = () => { s.px = 0; s.py = 0; L.forEach((l) => { if (!l.held) l.dentT = 0; }); wake(); };\n    box.addEventListener(\"pointerdown\", down);\n    box.addEventListener(\"pointermove\", move);\n    box.addEventListener(\"pointerup\", upFn);\n    box.addEventListener(\"pointercancel\", upFn);\n    box.addEventListener(\"pointerleave\", leave);\n    const lost = (e: Event) => { e.preventDefault(); setShown(\"still\"); };\n    cv.addEventListener(\"webglcontextlost\", lost);\n    wake();\n\n    return () => {\n      s.alive = false;\n      cancelAnimationFrame(s.raf); window.clearTimeout(s.demo); ro.disconnect(); io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      box.removeEventListener(\"pointerdown\", down); box.removeEventListener(\"pointermove\", move);\n      box.removeEventListener(\"pointerup\", upFn); box.removeEventListener(\"pointercancel\", upFn);\n      box.removeEventListener(\"pointerleave\", leave); cv.removeEventListener(\"webglcontextlost\", lost);\n      api.current = null;\n    };\n  }, []);\n\n  return (\n    <section className=\"relative isolate overflow-hidden bg-[#a7d3f2] text-[#0b2442]\" style={{ fontFamily: FONT }}>\n      <style>{`\n        @keyframes balloon-hero-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }\n        .balloon-hero-rise { animation: balloon-hero-rise 760ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }\n        @media (prefers-reduced-motion: reduce) { .balloon-hero-rise { animation: none; } }\n      `}</style>\n      <div ref={stage} className=\"relative mx-auto h-[780px] w-full max-w-[1600px]\" style={{ background: \"linear-gradient(180deg, #8fc3e4 0%, #a6d3ef 38%, #c9e9f7 52%, #bfe3f5 70%, #aed7ef 100%)\", touchAction: \"pan-y\" }}>\n        {shown === \"still\" && <Still />}\n        <canvas ref={canvas} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full transition-opacity duration-700 motion-reduce:transition-none ${shown === \"gl\" ? \"opacity-100\" : \"opacity-0\"}`} />\n\n        <div className=\"pointer-events-none absolute inset-0 flex flex-col justify-between px-5 pb-7 pt-6 sm:px-10 lg:px-16 lg:pb-12 lg:pt-9\">\n          <div className=\"flex items-center justify-between text-[12px] font-semibold uppercase tracking-[0.26em]\">\n            <span className=\"flex items-center gap-2.5\">\n              <span aria-hidden=\"true\" className=\"h-3 w-3 rounded-full bg-[#ff3d2e] shadow-[inset_-2px_-2px_3px_rgba(0,0,0,0.25),inset_2px_2px_2px_rgba(255,255,255,0.6)]\" />\n              {venue.name}\n            </span>\n            <span className=\"hidden sm:inline\">{venue.where}</span>\n          </div>\n\n          <div className=\"balloon-hero-rise grid items-end gap-6 lg:grid-cols-[1.45fr_1fr] lg:gap-14\">\n            <h1 className=\"text-[40px] font-extrabold leading-[0.95] tracking-[-0.045em] sm:text-[58px] lg:text-[clamp(56px,5.6vw,80px)]\">\n              {venue.headline[0]}\n              <br />\n              <span className=\"text-[#c8241a]\">{venue.headline[1]}</span>\n            </h1>\n            <div className=\"flex flex-col items-start gap-5\">\n              <p className=\"max-w-[26rem] text-[16px] font-medium leading-[1.45] text-[#14335a] lg:text-[18px]\">{venue.line}</p>\n              <div className=\"flex flex-wrap items-center gap-3\">\n                <a href=\"#\" className=\"pointer-events-auto inline-flex h-[52px] items-center gap-3 whitespace-nowrap rounded-full bg-[#0b2442] pl-7 pr-6 text-[15px] font-semibold tracking-[-0.01em] text-white shadow-[0_1px_0_rgba(255,255,255,0.25)_inset,0_16px_30px_-14px_rgba(11,36,66,0.8)] outline-none transition-transform duration-200 hover:-translate-y-0.5 focus-visible:ring-2 focus-visible:ring-[#0b2442] focus-visible:ring-offset-2 focus-visible:ring-offset-[#b4daf4] active:translate-y-0 motion-reduce:transition-none\">\n                  {venue.cta}\n                  <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M4 10h12M11 5l5 5-5 5\" /></svg>\n                </a>\n                <a href=\"#\" className=\"pointer-events-auto inline-flex h-[52px] items-center rounded-full px-5 text-[15px] font-semibold text-[#0b2442] underline decoration-[#0b2442]/30 underline-offset-[6px] outline-none hover:decoration-[#0b2442] focus-visible:ring-2 focus-visible:ring-[#0b2442]\">{venue.second}</a>\n              </div>\n            </div>\n          </div>\n        </div>\n\n        {shown === \"gl\" && (\n          <div className=\"absolute left-1/2 top-[318px] flex -translate-x-1/2 items-center gap-0.5 rounded-full bg-white/45 p-1 backdrop-blur-sm sm:top-[420px] lg:left-auto lg:right-16 lg:top-[76px] lg:translate-x-0 motion-reduce:hidden\">\n            <span className=\"pl-3 pr-1.5 text-[11px] font-semibold uppercase tracking-[0.2em] text-[#0b2442]\">Squeeze</span>\n            {letters.map((c, i) => (\n              <button key={i} type=\"button\" aria-label={`Squeeze the letter ${c}`} onClick={() => api.current?.squeeze(i)} className=\"grid h-10 w-10 place-items-center rounded-full text-[13px] font-extrabold text-[#0b2442] outline-none transition-colors hover:bg-white/70 focus-visible:ring-2 focus-visible:ring-[#0b2442]\">\n                {c}\n              </button>\n            ))}\n          </div>\n        )}\n        <p className=\"sr-only\">{venue.hours}</p>\n      </div>\n    </section>\n  );\n}\n"}]}
