{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"framed-portrait-testimonials-in-webgl-with-a-leaning-two-sided-frame-that-swings-on-its-corner-and-claps-back-onto-a-sunlit-wall","type":"registry:block","title":"Framed Portrait Testimonials in WebGL with a Leaning Two-Sided Frame That Swings on Its Corner and Claps Back onto a Sunlit Wall","description":"Free testimonial section in raw WebGL: a framed portrait leans on a sunlit wall beside a huge quote, and swings round like a door to show the next speaker.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/framed-portrait-testimonials-in-webgl-with-a-leaning-two-sided-frame-that-swings-on-its-corner-and-claps-back-onto-a-sunlit-wall.tsx","type":"registry:component","content":"import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The speakers, in order. `focus` is the crop centre of the photo (0 to 1), `tone` shows until the photo arrives. */\nconst voices = [\n  {\n    quote: \"My regulars found the new shop before I had finished my coffee.\",\n    name: \"Rosalía Méndez\",\n    role: \"Owner, Casa Méndez Bakery\",\n    src: \"https://images.pexels.com/photos/15672675/pexels-photo-15672675.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    alt: \"Older woman with silver hair and round glasses resting her chin on her folded hands in front of a bright yellow wall\",\n    focus: [0.5, 0.52],\n    tone: \"#e2b10c\",\n  },\n  {\n    quote: \"They asked what we wanted to stop doing. Nobody had asked us that.\",\n    name: \"Kwabena Asante\",\n    role: \"Founder, Ridgeline Roasters\",\n    src: \"https://images.pexels.com/photos/15689960/pexels-photo-15689960.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    alt: \"Man in a white striped shirt leaning toward the camera against a deep red backdrop\",\n    focus: [0.5, 0.4],\n    tone: \"#b3301c\",\n  },\n  {\n    quote: \"We briefed them on a napkin. They built exactly the napkin.\",\n    name: \"Amara Diallo\",\n    role: \"Studio director, Fold and Thread\",\n    src: \"https://images.pexels.com/photos/33276169/pexels-photo-33276169.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    alt: \"Woman in a white vest looking over her shoulder with one hand raised, against a teal backdrop\",\n    focus: [0.55, 0.42],\n    tone: \"#4f8f88\",\n  },\n  {\n    quote: \"Launch day was quiet. I have never been so glad to be bored.\",\n    name: \"Theo Marlowe\",\n    role: \"Head of product, Pinewater\",\n    src: \"https://images.pexels.com/photos/8801041/pexels-photo-8801041.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    alt: \"Smiling man with short curly hair in a pale pink T-shirt against a dusty pink backdrop\",\n    focus: [0.5, 0.42],\n    tone: \"#c98f9a\",\n  },\n];\n\n/** Where the sun sits for each speaker: direction toward it, colour, strength, how much leaf shade, and where the window light lands. */\nconst suns = [\n  { dir: [0.5, 0.56, 0.66], col: [1.0, 0.92, 0.8], power: 1.0, leaf: 0.6, aim: [0.5, 1.02] },\n  { dir: [0.78, 0.36, 0.52], col: [1.0, 0.8, 0.58], power: 1.12, leaf: 0.95, aim: [0.3, 0.7] },\n  { dir: [0.3, 0.78, 0.55], col: [1.0, 0.96, 0.88], power: 0.96, leaf: 0.0, aim: [0.62, 0.86] },\n  { dir: [0.66, 0.5, 0.56], col: [1.0, 0.86, 0.7], power: 1.06, leaf: 0.7, aim: [0.4, 1.12] },\n];\n\nconst N = voices.length;\nconst MASTHEAD = \"Oriel\"; // the wordmark in the top corner\nconst KICKER = \"In their words\"; // small label above the quote\nconst HOLD_MS = 5600; // rest between automatic turns\nconst SWING = 10; // pull of the frame toward its new side\nconst SWING_DRAG = 4.2; // lower lets the frame arrive faster and clap harder\nconst BOUNCE = 0.36; // how much speed survives each knock against the wall\nconst SERIF = '\"New York\", ui-serif, \"Iowan Old Style\", \"Palatino Linotype\", Palatino, Georgia, serif';\nconst GROTESK = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\nconst INK = \"#3d0f0b\";\n\n// The frame, in metres. It stands on the floor and leans back until its top edge meets the wall.\nconst FW = 1.0;\nconst FH = 1.32;\nconst FD = 0.026; // half its thickness\nconst FM = 0.055; // width of the moulding\nconst ZG = 0.015; // the glass sits this far from the middle of the frame\nconst LEAN = 0.16; // resting lean, in radians\nconst Z0 = FH * Math.sin(LEAN) + FD * Math.cos(LEAN);\nconst CAM_Z = 5.6;\nconst TEX_W = 728;\nconst TEX_H = 984;\n\nconst mod = (a: number, n: number) => ((a % n) + n) % n;\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst smooth = (a: number, b: number, v: number) => {\n  const t = clamp((v - a) / (b - a), 0, 1);\n  return t * t * (3 - 2 * t);\n};\nconst f = (v: number) => v.toFixed(4);\n\nconst VS = `#version 300 es\nprecision highp float;\nlayout(location = 0) in vec3 aPos;\nlayout(location = 1) in vec3 aNor;\nlayout(location = 2) in vec2 aUv;\nlayout(location = 3) in float aMat;\nuniform vec3 uC, uU, uV, uN, uCam, uRt, uUp, uFw;\nuniform float uTan, uAspect;\nout vec3 vW; out vec3 vL; out vec3 vNor; out vec2 vUv; out float vMat;\nvoid main() {\n  bool fr = aMat > 2.5;\n  vW = fr ? uC + uU * aPos.x + uV * aPos.y + uN * aPos.z : aPos;\n  vNor = fr ? uU * aNor.x + uV * aNor.y + uN * aNor.z : aNor;\n  vL = aPos; vUv = aUv; vMat = aMat;\n  vec3 d = vW - uCam;\n  float z = dot(d, uFw);\n  gl_Position = vec4(dot(d, uRt) / (uTan * uAspect), dot(d, uUp) / uTan, (z * 60.2 - 24.0) / 59.8, z);\n}`;\n\nconst FS = `#version 300 es\nprecision highp float;\nprecision highp sampler2DArray;\nconst vec3 BC = vec3(${f(FW / 2)}, ${f(FH / 2)}, 0.0);\nconst vec3 BH = vec3(${f(FW / 2)}, ${f(FH / 2)}, ${f(FD)});\nconst float M = ${f(FM)};\nconst vec3 WALLC = vec3(0.84, 0.34, 0.14);\nconst vec3 AMB = vec3(0.5, 0.49, 0.53);\nconst vec3 TILE = vec3(0.42, 0.13, 0.065);\nconst vec3 WOOD = vec3(0.085, 0.034, 0.014);\nuniform vec3 uC, uU, uV, uN, uCam, uFw;\nuniform vec3 uL, uLu, uLv, uLT, uSun;\nuniform float uLeaf, uTime, uFocus, uAperture;\nuniform float uLayer[2];\nuniform sampler2DArray uTex;\nin vec3 vW; in vec3 vL; in vec3 vNor; in vec2 vUv; in float vMat;\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 sbox(vec2 p, vec2 h, float s) { vec2 d = smoothstep(h + s, h - s, abs(p)); return d.x * d.y; }\nfloat sdRect(vec2 p, vec2 h) { vec2 q = abs(p) - h; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0); }\n\nvec3 toLocal(vec3 p) { vec3 d = p - uC; return vec3(dot(d, uU), dot(d, uV), dot(d, uN)); }\nvec3 dirLocal(vec3 v) { return vec3(dot(v, uU), dot(v, uV), dot(v, uN)); }\nfloat sdFrame(vec3 l) { vec3 q = abs(l - BC) - BH; return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0); }\n\n// Does a ray meet the frame? Returns the distance, and the local point it lands on.\nfloat hitFrame(vec3 ro, vec3 rd, out vec3 lp, out vec3 ln) {\n  vec3 o = toLocal(ro) - BC, d = dirLocal(rd);\n  vec3 inv = 1.0 / (d + vec3(1e-6));\n  vec3 t1 = (-BH - o) * inv, t2 = (BH - o) * inv;\n  vec3 tn = min(t1, t2), tf = max(t1, t2);\n  float a = max(tn.x, max(tn.y, tn.z)), b = min(tf.x, min(tf.y, tf.z));\n  if (a > b || a < 1e-3) return -1.0;\n  lp = o + d * a + BC;\n  ln = tn.x > tn.y && tn.x > tn.z ? vec3(-sign(d.x), 0, 0) : tn.y > tn.z ? vec3(0, -sign(d.y), 0) : vec3(0, 0, -sign(d.z));\n  return a;\n}\n\n// Soft shadow of the frame, walked toward the sun through its distance field.\nfloat frameShadow(vec3 P, int steps) {\n  vec3 o = toLocal(P), d = dirLocal(uL);\n  float res = 1.0, t = 0.015;\n  for (int i = 0; i < steps; i++) {\n    float h = sdFrame(o + d * t);\n    res = min(res, 11.0 * h / t);\n    if (res < 0.003 || t > 3.5) break;\n    t += clamp(h, 0.012, 0.5);\n  }\n  res = clamp(res, 0.0, 1.0);\n  return res * res * (3.0 - 2.0 * res);\n}\n\n// Shade from a branch outside: pointed leaves scattered in clumps, one per cell of a grid.\nfloat leaves(vec2 q, float salt) {\n  vec2 id = floor(q);\n  float sh = 0.0;\n  for (int j = -1; j <= 1; j++) for (int i = -1; i <= 1; i++) {\n    vec2 c = id + vec2(float(i), float(j));\n    float h = hash(c + salt);\n    if (h + 0.75 * vnoise(c * 0.33 + salt) < 0.86) continue;\n    vec2 ctr = c + 0.5 + (vec2(hash(c + salt + 1.3), hash(c + salt + 2.9)) - 0.5) * 0.9;\n    float a = 2.2 + (hash(c + salt + 4.1) - 0.5) * 2.4;\n    vec2 d = q - ctr;\n    d = vec2(d.x * cos(a) + d.y * sin(a), -d.x * sin(a) + d.y * cos(a));\n    float size = 0.42 + 0.3 * h;\n    float r = length(vec2(d.x, d.y * 2.5)) / size + abs(d.x) / size * 0.35;\n    sh = max(sh, smoothstep(1.0, 0.72, r));\n  }\n  return sh;\n}\n\n// The window the sun comes through: panes, glazing bars and a branch outside.\nfloat gobo(vec3 P, bool fine) {\n  vec3 d = P - uLT;\n  vec2 g = vec2(dot(d, uLu), dot(d, uLv));\n  float w = sbox(g, vec2(1.7, 1.12), 0.06);\n  float bars = (1.0 - 0.9 * smoothstep(0.034, 0.012, abs(abs(g.x) - 0.57))) * (1.0 - 0.9 * smoothstep(0.034, 0.012, abs(g.y - 0.64)));\n  vec2 sway = 0.035 * vec2(sin(uTime * 0.7 + g.y * 2.6), cos(uTime * 0.53 + g.x * 2.1));\n  float leaf = fine ? 1.0 - 0.92 * max(leaves(g * 3.1 + sway * 2.0, 0.0), leaves(g * 4.6 - sway * 3.0 + 5.0, 7.0)) : 0.45 + 0.55 * smoothstep(0.35, 0.65, vnoise(g * 5.0 + 3.0));\n  float where = smoothstep(-0.5, 0.9, g.y * 0.9 - g.x * 0.5);\n  return w * bars * mix(1.0, leaf, uLeaf * where);\n}\n\n// What polished things see when they look back into the room.\nvec3 room(vec3 rd, float soft) {\n  vec3 c = mix(vec3(0.34, 0.2, 0.13), vec3(0.95, 0.9, 0.84), smoothstep(-0.05, 0.55, rd.y));\n  if (rd.y < 0.0) c = mix(c, TILE * 0.8, smoothstep(0.0, -0.12, rd.y));\n  float fwd = dot(rd, uL);\n  if (fwd > 0.0) {\n    vec2 a = vec2(dot(rd, uLu), dot(rd, uLv)) / fwd;\n    float win = sbox(a, vec2(0.3, 0.42), mix(0.012, 0.22, soft));\n    win *= 1.0 - smoothstep(0.016, 0.006, abs(a.x)) * 0.9 * (1.0 - soft);\n    win *= 1.0 - smoothstep(0.016, 0.006, abs(a.y - 0.2)) * 0.9 * (1.0 - soft);\n    c += uSun * 9.0 * win * (1.0 - 0.8 * soft);\n  }\n  // a pale ceiling panel whose slanted edge shows as the sheen on the glass\n  float pan = smoothstep(0.3, 0.325, rd.y + rd.x * 0.5 * sign(uL.x)) * smoothstep(0.8, 0.45, rd.y) * step(0.0, rd.z);\n  c += vec3(1.0, 0.95, 0.88) * 1.7 * pan;\n  return c;\n}\n\nvec3 wallLight(vec3 P, vec3 n, bool fine) {\n  float sh = frameShadow(P, fine ? 22 : 9);\n  float near = sdFrame(toLocal(P));\n  float ao = (1.0 - 0.32 * exp(-P.y / 0.16)) * mix(0.5, 1.0, smoothstep(0.0, 0.2, near));\n  vec3 bounce = TILE * uSun * max(uL.y, 0.0) * 1.3 * exp(-P.y / 0.55);\n  return uSun * max(dot(n, uL), 0.0) * gobo(P, fine) * sh + AMB * ao + bounce;\n}\nvec3 wallCol(vec3 P, bool fine) {\n  float cloud = fbm(P.xy * 1.15 + 4.0);\n  vec3 alb = WALLC * (0.86 + 0.26 * cloud);\n  vec3 n = vec3(0, 0, 1);\n  if (fine) {\n    // trowel marks: a height field, tilted into a normal so raking sun picks it out\n    vec2 q = P.xy * vec2(7.0, 5.0);\n    float e = 0.02;\n    float h0 = fbm(q) + 0.35 * fbm(q * 5.0), hx = fbm(q + vec2(e, 0)) + 0.35 * fbm(q * 5.0 + vec2(e * 5.0, 0)), hy = fbm(q + vec2(0, e)) + 0.35 * fbm(q * 5.0 + vec2(0, e * 5.0));\n    n = normalize(vec3(-(hx - h0) / e * 0.028, -(hy - h0) / e * 0.028, 1.0));\n    alb *= 0.95 + 0.1 * h0;\n  }\n  return alb * wallLight(P, n, fine);\n}\n\n// The picture side of the frame: glass over a bevelled mount over the print.\nvec3 faceCol(vec3 l, vec3 P, vec3 Nw, float flip, int idx, vec3 V, bool fine) {\n  vec2 p = vec2(flip > 0.0 ? l.x : ${f(FW)} - l.x, l.y);\n  vec2 uv = (p - M) / (vec2(${f(FW)}, ${f(FH)}) - 2.0 * M);\n  vec3 alb = textureLod(uTex, vec3(uv, uLayer[idx]), fine ? 0.0 : 2.5).rgb;\n  vec3 Ll = vec3(dot(uL, uU) * flip, dot(uL, uV), dot(uL, Nw));\n  float ndl = max(Ll.z, 0.0);\n  vec2 off = Ll.xy / max(Ll.z, 0.3);\n  vec2 pc = vec2(${f(FW / 2)}, 0.675), ph = vec2(0.35, 0.495);\n  float dWin = sdRect(p - pc, ph);\n  float lip = 1.0 - smoothstep(-0.007, 0.001, sdRect(p + off * 0.009 - BC.xy, BH.xy - M));\n  float edge = -sdRect(p - BC.xy, BH.xy - M);\n  float ao = 1.0 - 0.3 * exp(-edge / 0.012);\n  float lit = ndl * lip;\n  float aa = max(fwidth(dWin), 1e-4);\n  float inPrint = 1.0 - smoothstep(-aa, 0.0, dWin);\n  float onBevel = smoothstep(-aa, 0.0, dWin) * (1.0 - smoothstep(0.005 - aa, 0.005, dWin));\n  float printLit = lit * (1.0 - smoothstep(-0.0035, 0.0005, sdRect(p + off * 0.003 - pc, ph)));\n  float printAo = ao * (1.0 - 0.25 * exp(min(dWin, 0.0) / 0.004));\n  // the cut edge of the mount, at forty-five degrees, showing its white core\n  vec2 q = abs(p - pc) - ph;\n  vec2 g = q.x > q.y ? vec2(sign(p.x - pc.x), 0.0) : vec2(0.0, sign(p.y - pc.y));\n  float bevLit = max(dot(normalize(vec3(-g * 0.72, 0.7)), Ll), 0.0) * lip;\n  vec3 matAlb = alb * (0.965 + 0.06 * vnoise(p * 1400.0));\n  alb = mix(mix(matAlb, vec3(0.96, 0.95, 0.91), onBevel), pow(alb, vec3(1.04)), inPrint);\n  lit = mix(mix(lit, bevLit, onBevel), printLit, inPrint);\n  ao = mix(ao, printAo, inPrint);\n  vec3 col = alb * (uSun * lit * gobo(P, fine) + AMB * ao + vec3(0.05, 0.03, 0.02));\n  if (!fine) return col;\n  float F = 0.045 + 0.955 * pow(1.0 - max(dot(Nw, V), 0.0), 5.0);\n  vec3 R = reflect(-V, Nw);\n  vec3 seen = R.z < -0.05 ? WALLC * (AMB + uSun * 0.5) : room(R, 0.0);\n  // faint wipe marks on the glass, only visible where it mirrors something bright\n  float wipe = 0.78 + 0.44 * fbm(p * vec2(5.0, 2.2) + 11.0);\n  return col * (1.0 - F) * 0.985 + seen * F * wipe;\n}\n\nvec3 woodCol(vec2 uv, vec3 P, vec3 Nw, vec3 V) {\n  float fig = fbm(vec2(uv.x * 2.2, uv.y * 70.0 + 3.0 * vnoise(uv * vec2(1.5, 9.0))));\n  float pore = vnoise(vec2(uv.x * 38.0, uv.y * 420.0));\n  vec3 alb = mix(WOOD, WOOD * vec3(1.25, 0.9, 0.7), vnoise(uv * vec2(0.9, 30.0))) * (0.4 + 1.25 * fig) * (0.8 + 0.4 * pore);\n  // the mitre: a hairline where two lengths of moulding meet at each corner\n  vec2 lc = min(vL.xy, vec2(${f(FW)}, ${f(FH)}) - vL.xy);\n  alb *= 1.0 - 0.6 * smoothstep(0.0016, 0.0004, abs(lc.x - lc.y)) * step(abs(vL.z), ${f(FD)} + 0.01);\n  float g = gobo(P, true);\n  float ao = 0.55 + 0.45 * smoothstep(0.0, 0.12, P.y);\n  vec3 col = alb * (uSun * max(dot(Nw, uL), 0.0) * g + AMB * ao);\n  float F = 0.05 + 0.95 * pow(1.0 - max(dot(Nw, V), 0.0), 5.0);\n  vec3 R = reflect(-V, Nw);\n  col += (R.z < -0.1 ? WALLC * 0.7 : room(R, 1.0)) * F * 0.75;\n  col += uSun * g * pow(max(dot(Nw, normalize(uL + V)), 0.0), 60.0) * 0.5 * (0.75 + 0.25 * fig);\n  return col;\n}\n\nvec3 tonemap(vec3 x) { x *= 0.8; return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); }\nvec4 pack(vec3 col, float depth) {\n  float coc = clamp(uAperture * (1.0 - uFocus / max(depth, 0.05)), -1.0, 1.0);\n  return vec4(pow(tonemap(col), vec3(1.0 / 2.2)), 0.5 + 0.5 * coc);\n}\n\nvoid main() {\n  vec3 V = normalize(uCam - vW);\n  float depth = dot(vW - uCam, uFw);\n  vec3 col;\n  if (vMat < 0.5) {\n    col = wallCol(vW, true);\n  } else if (vMat < 1.5) {\n    // waxed terracotta tiles, each one laid a hair out of level\n    vec2 tc = vW.xz / 0.3 + vec2(0.5, 0.18);\n    vec2 id = floor(tc), fr = fract(tc);\n    float e = min(min(fr.x, 1.0 - fr.x), min(fr.y, 1.0 - fr.y)) * 0.3;\n    float px = max(fwidth(tc.x), fwidth(tc.y)) * 0.3;\n    float grout = smoothstep(0.0045 + px, 0.0025, e) / (1.0 + px * 60.0);\n    float tone = hash(id);\n    float blot = fbm(vW.xz * 7.0 + id * 3.0);\n    vec3 alb = TILE * (0.72 + 0.5 * tone) * (0.8 + 0.4 * blot);\n    alb = mix(alb, vec3(0.34, 0.22, 0.16), grout);\n    vec3 n = normalize(vec3((hash(id + 3.7) - 0.5) * 0.016, 1.0, (hash(id + 9.1) - 0.5) * 0.016));\n    float rough = mix(0.012 + 0.05 * blot * blot, 0.5, grout);\n    float seed = ign(gl_FragCoord.xy);\n    vec3 refl = vec3(0.0);\n    float far = 0.0;\n    for (int k = 0; k < 5; k++) {\n      float a = 6.2832 * fract(seed + float(k) * 0.618034);\n      float r = sqrt((float(k) + 0.5) / 5.0);\n      vec3 R = reflect(-V, normalize(n + vec3(cos(a), 0.0, sin(a)) * r * rough));\n      vec3 lp, ln;\n      float t = hitFrame(vW, R, lp, ln);\n      if (t > 0.0) {\n        vec3 Nw = uU * ln.x + uV * ln.y + uN * ln.z;\n        vec3 Ph = vW + R * t;\n        bool open = abs(ln.z) > 0.5 && sdRect(lp.xy - BC.xy, BH.xy - M) < 0.0;\n        refl += open ? faceCol(lp, Ph, Nw, ln.z, ln.z > 0.0 ? 0 : 1, -R, false) : WOOD * (uSun * max(dot(Nw, uL), 0.0) + AMB);\n        far += t;\n      } else if (R.z < -1e-3) {\n        float tw = -vW.z / R.z;\n        refl += wallCol(vW + R * tw, false);\n        far += tw;\n      } else { refl += room(R, 0.3); far += 6.0; }\n    }\n    refl /= 5.0; far /= 5.0;\n    float near = sdFrame(toLocal(vW));\n    float ao = (1.0 - 0.45 * exp(-vW.z / 0.1)) * mix(0.35, 1.0, smoothstep(0.0, 0.14, near));\n    vec3 dif = uSun * max(dot(n, uL), 0.0) * gobo(vW, true) * frameShadow(vW, 22) + AMB * ao;\n    float F = 0.05 + 0.95 * pow(1.0 - clamp(dot(V, n), 0.0, 1.0), 5.0);\n    F *= 1.0 - grout;\n    col = alb * dif * (1.0 - F) + refl * F * (0.5 + 0.5 * ao);\n    depth += far * clamp(F * 2.0, 0.0, 1.0) * (1.0 - smoothstep(0.02, 0.08, rough));\n  } else if (vMat < 2.5) {\n    // skirting board, painted the wall colour in a harder gloss\n    vec3 n = normalize(vNor);\n    float ao = 0.55 + 0.45 * smoothstep(0.0, 0.07, vW.y);\n    col = WALLC * 0.93 * (uSun * max(dot(n, uL), 0.0) * gobo(vW, true) * frameShadow(vW, 16) + AMB * ao + TILE * uSun * 0.5);\n    float F = 0.04 + 0.96 * pow(1.0 - max(dot(n, V), 0.0), 5.0);\n    col += room(reflect(-V, n), 1.0) * F * 0.25;\n  } else if (vMat < 3.5) {\n    col = woodCol(vUv, vW, normalize(vNor), V);\n  } else {\n    float flip = vMat < 4.5 ? 1.0 : -1.0;\n    col = faceCol(vL, vW, normalize(vNor), flip, vMat < 4.5 ? 0 : 1, V, true);\n  }\n  o = pack(col, depth);\n}`;\n\nconst VS_FULL = `#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;\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 coc0 = abs(c0.a * 2.0 - 1.0);\n  vec3 lin0 = pow(c0.rgb, vec3(2.2));\n  vec3 acc = lin0; float wsum = 1.0; float spread = coc0;\n  float rot = 6.2832 * ign(gl_FragCoord.xy);\n  for (int k = 1; k < 44; k++) {\n    float r = k < 32 ? sqrt(float(k) / 32.0) * uMaxR : sqrt(float(k - 31) / 12.0) * min(uMaxR, 3.0);\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;\n    float cs = abs(sc);\n    if (sc > c0.a * 2.0 - 1.0) cs = min(cs, coc0 * 1.6 + 0.02);\n    float w = smoothstep(r - 1.0, r + 1.0, cs * uMaxR);\n    acc += pow(s.rgb, vec3(2.2)) * w; wsum += w; spread = max(spread, cs * step(0.5, w));\n  }\n  o = vec4(pow(acc / wsum, vec3(1.0 / 2.2)), spread);\n}`;\n\nconst FS_OUT = `#version 300 es\nprecision highp float;\nuniform sampler2D uScene;\nuniform vec2 uPx;\nuniform float 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 c = texture(uScene, vUv);\n  float r = clamp(c.a * 4.0, 0.0, 1.0) * 1.5;\n  vec3 col = c.rgb * 4.0;\n  for (int k = 0; k < 8; k++) {\n    float a = float(k) * 0.7854;\n    col += texture(uScene, vUv + vec2(cos(a), sin(a)) * r * (k % 2 == 0 ? 1.0 : 1.9) * uPx).rgb;\n  }\n  col /= 12.0;\n  vec2 q = vUv - 0.5;\n  col *= 1.0 - 0.42 * dot(q, q);\n  col += (ign(gl_FragCoord.xy + fract(uTime) * 61.0) - 0.5) * 0.022;\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/** Wall, floor, skirting, then the frame: a mitred moulding swept from a rounded profile, and a pane on each side. */\nfunction sceneMesh() {\n  const out: number[] = [];\n  const quad = (p: number[][], n: number[][], uv: number[][], mat: number) => {\n    for (const i of [0, 1, 2, 0, 2, 3]) out.push(...p[i], ...n[i], ...uv[i], mat);\n  };\n  const flat = (p: number[][], n: number[], mat: number) => quad(p, [n, n, n, n], [[0, 0], [0, 0], [0, 0], [0, 0]], mat);\n  flat([[-40, 0, 0], [40, 0, 0], [40, 14, 0], [-40, 14, 0]], [0, 0, 1], 0);\n  flat([[-40, 0, 0], [40, 0, 0], [40, 0, 30], [-40, 0, 30]], [0, 1, 0], 1);\n  const st = 0.014, sh = 0.085;\n  flat([[-40, 0, st], [40, 0, st], [40, sh - 0.004, st], [-40, sh - 0.004, st]], [0, 0, 1], 2);\n  quad([[-40, sh - 0.004, st], [40, sh - 0.004, st], [40, sh, st - 0.004], [-40, sh, st - 0.004]], [[0, 0, 1], [0, 0, 1], [0, 1, 0], [0, 1, 0]], [[0, 0], [0, 0], [0, 0], [0, 0]], 2);\n  flat([[-40, sh, st - 0.004], [40, sh, st - 0.004], [40, sh, 0], [-40, sh, 0]], [0, 1, 0], 2);\n\n  // half of the moulding's cross-section: [inset from the outer edge, height, normal]\n  const half: number[][] = [[0, 0, -1, 0]];\n  const r1 = 0.007, r2 = 0.004;\n  for (let i = 0; i <= 6; i++) {\n    const a = Math.PI - (i / 6) * (Math.PI / 2);\n    half.push([r1 + r1 * Math.cos(a), FD - r1 + r1 * Math.sin(a), Math.cos(a), Math.sin(a)]);\n  }\n  for (let i = 0; i <= 5; i++) {\n    const a = Math.PI / 2 - (i / 5) * (Math.PI / 2);\n    half.push([FM - r2 + r2 * Math.cos(a), FD - r2 + r2 * Math.sin(a), Math.cos(a), Math.sin(a)]);\n  }\n  half.push([FM, ZG - 0.001, 1, 0]);\n  const prof = [...half.slice(1).reverse().map(([t, z, nt, nz]) => [t, -z, nt, -nz]), ...half];\n  let arc = 0;\n  const arcs = prof.map((p, i) => (i ? (arc += Math.hypot(p[0] - prof[i - 1][0], p[1] - prof[i - 1][1])) : 0));\n  const corner = (k: number, t: number) => [[t, t], [FW - t, t], [FW - t, FH - t], [t, FH - t]][k % 4];\n  const inward = [[0, 1], [-1, 0], [0, -1], [1, 0]];\n  for (let k = 0; k < 4; k++) {\n    for (let i = 0; i < prof.length - 1; i++) {\n      const [a, b] = [prof[i], prof[i + 1]];\n      const pts = [[k, a], [k + 1, a], [k + 1, b], [k, b]] as const;\n      const along = (c: number[]) => (k % 2 === 0 ? c[0] : c[1]) + k * 3.3;\n      quad(\n        pts.map(([kk, p]) => [...corner(kk, p[0]), p[1]]),\n        pts.map(([, p]) => [inward[k][0] * p[2], inward[k][1] * p[2], p[3]]),\n        pts.map(([kk, p]) => [along(corner(kk, p[0])), arcs[p === a ? i : i + 1]]),\n        3,\n      );\n    }\n  }\n  const e = FM - 0.002;\n  const zero = [[0, 0], [0, 0], [0, 0], [0, 0]];\n  quad([[e, e, ZG], [FW - e, e, ZG], [FW - e, FH - e, ZG], [e, FH - e, ZG]], Array(4).fill([0, 0, 1]), zero, 4);\n  quad([[e, e, -ZG], [FW - e, e, -ZG], [FW - e, FH - e, -ZG], [e, FH - e, -ZG]], Array(4).fill([0, 0, -1]), zero, 5);\n  return new Float32Array(out);\n}\n\n/** One sheet per speaker: the mount, the print cropped into its window, and a pencilled caption underneath. */\nfunction paintSheet(ctx: CanvasRenderingContext2D, v: (typeof voices)[number], index: number, img: HTMLImageElement | null) {\n  ctx.fillStyle = \"#efe9dc\";\n  ctx.fillRect(0, 0, TEX_W, TEX_H);\n  const [x, y, w, h] = [84, 84, 560, 792];\n  ctx.fillStyle = v.tone;\n  ctx.fillRect(x, y, w, h);\n  if (img) {\n    const s = Math.max(w / img.naturalWidth, h / img.naturalHeight);\n    const iw = img.naturalWidth * s, ih = img.naturalHeight * s;\n    ctx.save();\n    ctx.beginPath();\n    ctx.rect(x, y, w, h);\n    ctx.clip();\n    ctx.drawImage(img, x + clamp(w / 2 - v.focus[0] * iw, w - iw, 0), y + clamp(h / 2 - v.focus[1] * ih, h - ih, 0), iw, ih);\n    ctx.restore();\n  }\n  ctx.fillStyle = \"rgba(60, 48, 42, 0.82)\";\n  ctx.textBaseline = \"alphabetic\";\n  ctx.font = `italic 23px ${SERIF}`;\n  ctx.textAlign = \"left\";\n  ctx.fillText(v.name, x + 2, y + h + 44);\n  ctx.textAlign = \"right\";\n  ctx.fillText(`${index + 1} / ${N}`, x + w - 2, y + h + 44);\n}\n\ntype Sim = {\n  index: number; side: number; yaw: number; yawV: number; lean: number; leanV: number; rock: number; rockV: number;\n  queue: number; textIn: boolean; textSide: number; kick: number; kickV: number;\n  px: number; py: number; cx: number; cy: number; panX: number; sideMix: number;\n  sun: number[]; paused: boolean; nextAuto: number; dirty: boolean; narrow: boolean;\n};\n\nfunction QuoteBody({ v, narrow }: { v: (typeof voices)[number]; narrow: boolean }) {\n  return (\n    <figure className=\"m-0 flex h-full flex-col\" style={{ color: INK }}>\n      <p className=\"flex items-center gap-3 font-semibold uppercase\" style={{ fontFamily: GROTESK, fontSize: narrow ? 10.5 : 12, letterSpacing: \"0.26em\" }}>\n        <span aria-hidden=\"true\" className=\"inline-block h-px w-8 bg-current\" />\n        {KICKER}\n      </p>\n      <blockquote className=\"m-0 mt-5\" style={{ fontFamily: SERIF, fontSize: narrow ? 40 : 72, lineHeight: 0.98, letterSpacing: \"-0.035em\", fontWeight: 500, textWrap: \"balance\" } as React.CSSProperties}>\n        <span aria-hidden=\"true\" className=\"absolute\" style={{ transform: \"translateX(-0.46em)\" }}>\n          “\n        </span>\n        {v.quote}”\n      </blockquote>\n      <figcaption className={narrow ? \"mt-5\" : \"mt-9\"} style={{ fontFamily: GROTESK }}>\n        <span className=\"block font-semibold\" style={{ fontSize: narrow ? 15 : 19, letterSpacing: \"-0.01em\" }}>\n          {v.name}\n        </span>\n        <span className=\"mt-1 block font-medium uppercase\" style={{ fontSize: narrow ? 10 : 11.5, letterSpacing: \"0.2em\" }}>\n          {v.role}\n        </span>\n      </figcaption>\n    </figure>\n  );\n}\n\nexport default function LeaningFrameTestimonials() {\n  const reduce = useReducedMotion();\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const plateRef = useRef<HTMLDivElement>(null);\n  const [shown, setShown] = useState(0);\n  const [ink, setInk] = useState(true);\n  const [narrow, setNarrow] = useState(false);\n  const [mode, setMode] = useState<\"pending\" | \"gl\" | \"still\">(\"pending\");\n  const sim = useRef<Sim>({\n    index: 0, side: 0, yaw: 0, yawV: 0, lean: LEAN, leanV: 0, rock: 0, rockV: 0,\n    queue: 0, textIn: true, textSide: 0, kick: 0, kickV: 0,\n    px: 0, py: 0, cx: 0, cy: 0, panX: 0, sideMix: 0,\n    sun: [], paused: false, nextAuto: 0, dirty: true, narrow: false,\n  });\n\n  const step = useCallback((dir: number) => {\n    const s = sim.current;\n    s.queue = clamp(s.queue + dir, -2, 2);\n    s.nextAuto = performance.now() + HOLD_MS * 1.6;\n    s.dirty = true;\n    if (mode === \"still\") {\n      s.queue = 0;\n      setShown((i) => mod(i + dir, N));\n    }\n  }, [mode]);\n\n  // tall, narrow stages put the quote on the wall above the frame instead of beside it\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    if (!wrap) return;\n    const measure = () => {\n      const isNarrow = wrap.clientWidth / wrap.clientHeight < 1.12;\n      sim.current.narrow = isNarrow;\n      sim.current.dirty = true;\n      setNarrow(isNarrow);\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(wrap);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const canvas = canvasRef.current;\n    const plate = plateRef.current;\n    if (!wrap || !canvas || !plate) 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 prog: WebGLProgram, progLens: WebGLProgram, progOut: WebGLProgram;\n    try {\n      prog = program(gl, VS, FS);\n      progLens = program(gl, VS_FULL, FS_LENS);\n      progOut = program(gl, VS_FULL, FS_OUT);\n    } catch {\n      setMode(\"still\");\n      return;\n    }\n    setMode(\"gl\");\n\n    // one sRGB layer per speaker, so the light maths happens in linear colour\n    const tex = gl.createTexture();\n    gl.activeTexture(gl.TEXTURE0);\n    gl.bindTexture(gl.TEXTURE_2D_ARRAY, tex);\n    gl.texStorage3D(gl.TEXTURE_2D_ARRAY, Math.floor(Math.log2(TEX_H)) + 1, gl.SRGB8_ALPHA8, TEX_W, TEX_H, N);\n    gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n    gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n    gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n    const aniso = gl.getExtension(\"EXT_texture_filter_anisotropic\");\n    if (aniso) gl.texParameterf(gl.TEXTURE_2D_ARRAY, aniso.TEXTURE_MAX_ANISOTROPY_EXT, 8);\n    const scratch = document.createElement(\"canvas\");\n    scratch.width = TEX_W;\n    scratch.height = TEX_H;\n    const sctx = scratch.getContext(\"2d\")!;\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n    const upload = (layer: number) => {\n      gl.activeTexture(gl.TEXTURE0);\n      gl.bindTexture(gl.TEXTURE_2D_ARRAY, tex);\n      gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, layer, TEX_W, TEX_H, 1, gl.RGBA, gl.UNSIGNED_BYTE, scratch);\n      gl.generateMipmap(gl.TEXTURE_2D_ARRAY);\n      s.dirty = true;\n    };\n    let alive = true;\n    voices.forEach((v, i) => {\n      paintSheet(sctx, v, i, null);\n      upload(i);\n      const img = new Image();\n      img.crossOrigin = \"anonymous\";\n      img.onload = () => {\n        if (!alive) return;\n        paintSheet(sctx, v, i, img);\n        upload(i);\n      };\n      img.src = v.src;\n    });\n\n    const mesh = sceneMesh();\n    const vao = gl.createVertexArray();\n    gl.bindVertexArray(vao);\n    gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());\n    gl.bufferData(gl.ARRAY_BUFFER, mesh, gl.STATIC_DRAW);\n    [3, 3, 2, 1].reduce((off, size, loc) => {\n      gl.enableVertexAttribArray(loc);\n      gl.vertexAttribPointer(loc, size, gl.FLOAT, false, 36, off);\n      return off + size * 4;\n    }, 0);\n    gl.bindVertexArray(null);\n    const emptyVao = gl.createVertexArray();\n\n    const msFbo = gl.createFramebuffer();\n    const msColor = gl.createRenderbuffer();\n    const msDepth = gl.createRenderbuffer();\n    const resFbo = gl.createFramebuffer();\n    const resTex = gl.createTexture();\n    const lensFbo = gl.createFramebuffer();\n    const lensTex = gl.createTexture();\n    let W = 0, H = 0, cw = 1, ch = 1, scale = Math.min(window.devicePixelRatio || 1, 1.5);\n    const samples = Math.min(4, gl.getParameter(gl.MAX_SAMPLES));\n    const resize = () => {\n      cw = wrap.clientWidth;\n      ch = wrap.clientHeight;\n      let k = scale;\n      if (cw * ch * k * k > 1.5e6) k = Math.sqrt(1.5e6 / (cw * ch));\n      const w = Math.max(2, Math.round(cw * k)), h = Math.max(2, Math.round(ch * k));\n      s.dirty = true;\n      if (w === W && h === H) return;\n      W = w;\n      H = h;\n      canvas.width = W;\n      canvas.height = H;\n      gl.bindRenderbuffer(gl.RENDERBUFFER, msColor);\n      gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.RGBA8, W, H);\n      gl.bindRenderbuffer(gl.RENDERBUFFER, msDepth);\n      gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT24, W, H);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, msFbo);\n      gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msColor);\n      gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, msDepth);\n      for (const [unit, t, fb] of [[gl.TEXTURE2, resTex, resFbo], [gl.TEXTURE3, lensTex, lensFbo]] as const) {\n        gl.activeTexture(unit);\n        gl.bindTexture(gl.TEXTURE_2D, t);\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, fb);\n        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, t, 0);\n      }\n    };\n    resize();\n    const ro = new ResizeObserver(resize);\n    ro.observe(wrap);\n\n    const locs = new Map<string, WebGLUniformLocation | null>();\n    const U = (p: WebGLProgram, n: string) => {\n      const key = (p === prog ? \"a\" : p === progLens ? \"b\" : \"c\") + n;\n      if (!locs.has(key)) locs.set(key, gl.getUniformLocation(p, n));\n      return locs.get(key)!;\n    };\n    const layers = new Float32Array([0, 1]);\n    /** The eight numbers that describe a sun: direction, colour times power, leaf shade, aim. Mirrored when the frame changes side. */\n    const sunFor = (i: number, side: number) => {\n      const p = suns[i % suns.length];\n      const m = side ? 1 : -1;\n      return [m * p.dir[0], p.dir[1], p.dir[2], p.col[0] * p.power, p.col[1] * p.power, p.col[2] * p.power, p.leaf, -m * p.aim[0], p.aim[1]];\n    };\n    s.sun = sunFor(0, 0);\n\n    const draw = (t: number) => {\n      // where the frame is: swung about its hinge corner, rocked onto that corner, leaning back toward the wall\n      const cy = Math.cos(s.yaw), sy = Math.sin(s.yaw), cr = Math.cos(s.rock), sr = Math.sin(s.rock), cl = Math.cos(s.lean), sl = Math.sin(s.lean);\n      const tilt = (v: number[]) => [v[0], v[1] * cl + v[2] * sl, -v[1] * sl + v[2] * cl];\n      const u0 = [cy, 0, sy], n0 = [-sy, 0, cy];\n      const Uv = tilt([u0[0] * cr, sr, u0[2] * cr]);\n      const Vv = tilt([-u0[0] * sr, cr, -u0[2] * sr]);\n      const Nv = tilt(n0);\n      let low = 0;\n      for (const x of [0, FW]) for (const z of [-FD, FD]) low = Math.min(low, Uv[1] * x + Nv[1] * z);\n      const C = [0, -low + 0.001, Z0];\n\n      const aspect = cw / ch;\n      const mix = s.sideMix; // 0 frame on the right, 1 on the left\n      const fc = 0.5 - mix;\n      const needW = s.narrow ? 0.68 : 1.7, needH = s.narrow ? 1.5 : 0.93;\n      const TAN = Math.max(needW / aspect, needH) / CAM_Z;\n      const lookY = s.narrow ? 1.16 : 0.71;\n      const centre = s.narrow ? fc : (mix - 0.5) * 0.5;\n      const drift = reduce ? 0 : 1;\n      const cam = [centre + s.cx * 0.34 + drift * 0.05 * Math.sin(t * 0.27), 0.98 - s.cy * 0.1 + drift * 0.015 * Math.sin(t * 0.21 + 1) + s.kick, CAM_Z];\n      let fw = [centre * 0.9 - cam[0], lookY - cam[1], -cam[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      const 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\n      const L = s.sun.slice(0, 3);\n      const ll = Math.hypot(L[0], L[1], L[2]);\n      for (let i = 0; i < 3; i++) L[i] /= ll;\n      let Lu = [L[2], 0, -L[0]];\n      const lul = Math.hypot(Lu[0], Lu[2]);\n      Lu = Lu.map((v) => v / lul);\n      const Lv = [L[1] * Lu[2] - L[2] * Lu[1], L[2] * Lu[0] - L[0] * Lu[2], L[0] * Lu[1] - L[1] * Lu[0]];\n\n      gl.bindFramebuffer(gl.FRAMEBUFFER, msFbo);\n      gl.viewport(0, 0, W, H);\n      gl.enable(gl.DEPTH_TEST);\n      gl.depthMask(true);\n      gl.clearColor(0.9, 0.7, 0.5, 0.5);\n      gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n      gl.useProgram(prog);\n      gl.uniform3fv(U(prog, \"uC\"), C);\n      gl.uniform3fv(U(prog, \"uU\"), Uv);\n      gl.uniform3fv(U(prog, \"uV\"), Vv);\n      gl.uniform3fv(U(prog, \"uN\"), Nv);\n      gl.uniform3fv(U(prog, \"uCam\"), cam);\n      gl.uniform3fv(U(prog, \"uRt\"), rt);\n      gl.uniform3fv(U(prog, \"uUp\"), up);\n      gl.uniform3fv(U(prog, \"uFw\"), fw);\n      gl.uniform1f(U(prog, \"uTan\"), TAN);\n      gl.uniform1f(U(prog, \"uAspect\"), W / H);\n      gl.uniform3fv(U(prog, \"uL\"), L);\n      gl.uniform3fv(U(prog, \"uLu\"), Lu);\n      gl.uniform3fv(U(prog, \"uLv\"), Lv);\n      gl.uniform3f(U(prog, \"uLT\"), s.sun[7], s.sun[8], 0);\n      gl.uniform3f(U(prog, \"uSun\"), s.sun[3], s.sun[4], s.sun[5]);\n      gl.uniform1f(U(prog, \"uLeaf\"), s.sun[6]);\n      gl.uniform1f(U(prog, \"uTime\"), reduce ? 0 : t);\n      gl.uniform1f(U(prog, \"uFocus\"), CAM_Z - 0.1);\n      gl.uniform1f(U(prog, \"uAperture\"), 1.5);\n      gl.uniform1fv(U(prog, \"uLayer[0]\"), layers);\n      gl.uniform1i(U(prog, \"uTex\"), 0);\n      gl.bindVertexArray(vao);\n      gl.drawArrays(gl.TRIANGLES, 0, mesh.length / 9);\n\n      gl.bindFramebuffer(gl.READ_FRAMEBUFFER, msFbo);\n      gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, resFbo);\n      gl.blitFramebuffer(0, 0, W, H, 0, 0, W, H, gl.COLOR_BUFFER_BIT, gl.NEAREST);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, lensFbo);\n      gl.disable(gl.DEPTH_TEST);\n      gl.useProgram(progLens);\n      gl.uniform1i(U(progLens, \"uScene\"), 2);\n      gl.uniform2f(U(progLens, \"uPx\"), 1 / W, 1 / H);\n      gl.uniform1f(U(progLens, \"uMaxR\"), H * 0.011);\n      gl.bindVertexArray(emptyVao);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.useProgram(progOut);\n      gl.uniform1i(U(progOut, \"uScene\"), 3);\n      gl.uniform2f(U(progOut, \"uPx\"), 1 / W, 1 / H);\n      gl.uniform1f(U(progOut, \"uTime\"), reduce ? 0 : t);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n      // lay the quote on the wall: the same camera, written as a CSS matrix\n      const dw = s.narrow ? 380 : 600;\n      const ww = s.narrow ? 1.16 : 1.36;\n      const tfc = 0.5 - s.textSide;\n      const ox = s.narrow ? tfc - ww / 2 : s.textSide ? 0.22 : -1.55;\n      const oy = s.narrow ? 2.43 : 1.36;\n      const k = ww / dw;\n      const proj = (p: number[]) => {\n        const d = [p[0] - cam[0], p[1] - cam[1], p[2] - cam[2]];\n        const xv = d[0] * rt[0] + d[1] * rt[1] + d[2] * rt[2], yv = d[0] * up[0] + d[1] * up[1] + d[2] * up[2], zv = d[0] * fw[0] + d[1] * fw[1] + d[2] * fw[2];\n        return [cw * 0.5 * (xv / (TAN * aspect) + zv), ch * 0.5 * (zv - yv / TAN), zv];\n      };\n      const h0 = proj([ox, oy, 0]), hx = proj([ox + k, oy, 0]), hy = proj([ox, oy - k, 0]);\n      const m = [hx[0] - h0[0], hx[1] - h0[1], hx[2] - h0[2], hy[0] - h0[0], hy[1] - h0[1], hy[2] - h0[2], h0[0], h0[1], h0[2]].map((v) => v / h0[2]);\n      plate.style.transform = `matrix3d(${m[0]},${m[1]},0,${m[2]},${m[3]},${m[4]},0,${m[5]},0,0,1,0,${m[6]},${m[7]},0,${m[8]})`;\n    };\n\n    /** One small step of the swing, the fall back against the wall, and the rock on the hinge corner. */\n    const physics = (dt: number) => {\n      const goal = s.side ? Math.PI : 0;\n      let away = Math.abs(goal - s.yaw);\n      if (s.queue !== 0 && away < 0.9 && Math.abs(s.yawV) < 2.4) {\n        const dir = Math.sign(s.queue);\n        s.queue -= dir;\n        s.index = mod(s.index + dir, N);\n        s.side = 1 - s.side;\n        layers[s.side] = s.index; // the hidden side gets the next print\n        s.textIn = false;\n        setInk(false);\n        return;\n      }\n      s.yawV += (SWING * (goal - s.yaw) - SWING_DRAG * s.yawV) * dt;\n      s.yaw += s.yawV * dt;\n      if ((goal === 0 && s.yaw < 0) || (goal > 0 && s.yaw > Math.PI)) {\n        s.yaw = goal;\n        s.yawV *= -0.18;\n      }\n      away = Math.abs(goal - s.yaw);\n      if (!s.textIn && away < 1.15) {\n        s.textIn = true;\n        s.textSide = s.side;\n        setShown(s.index);\n        setInk(true);\n      }\n      // upright while it travels; near home it topples back, slowly at first, and knocks against the wall\n      const fall = 1 - smooth(0.1, 0.75, away);\n      s.leanV += (fall * 34 * Math.sin(s.lean + 0.05) + (1 - fall) * (-95 * s.lean - 15 * s.leanV)) * dt;\n      s.lean += s.leanV * dt;\n      if (s.lean > LEAN) {\n        s.lean = LEAN;\n        if (s.leanV > 0.22) {\n          s.kickV -= s.leanV * 0.012;\n          s.leanV *= -BOUNCE;\n        } else s.leanV = 0;\n      }\n      const lift = 0.05 * smooth(0.25, 0.9, away);\n      s.rockV += (170 * (lift - s.rock) - 11 * s.rockV) * dt;\n      s.rock += s.rockV * dt;\n      if (s.rock < 0) {\n        s.rock = 0;\n        s.rockV *= -0.3;\n      }\n      s.kickV += (-420 * s.kick - 26 * s.kickV) * dt;\n      s.kick += s.kickV * dt;\n    };\n\n    let raf = 0, visible = true, last = performance.now(), slow = 0, frames = 0;\n    s.nextAuto = last + HOLD_MS * 0.75;\n    const tick = (now: number) => {\n      const real = now - last;\n      const dt = Math.min(0.05, real / 1000);\n      last = now;\n      if (!s.paused && !document.hidden && now > s.nextAuto && s.queue === 0) {\n        s.queue = 1;\n        s.nextAuto = now + HOLD_MS;\n      }\n      if (reduce) {\n        if (s.queue !== 0) {\n          s.index = mod(s.index + Math.sign(s.queue), N);\n          s.queue = 0;\n          s.side = 1 - s.side;\n          layers[s.side] = s.index;\n          s.textSide = s.side;\n          setShown(s.index);\n          s.dirty = true;\n        }\n        s.yaw = s.side ? Math.PI : 0;\n        s.lean = LEAN;\n        s.sideMix = s.side;\n        s.sun = sunFor(s.index, s.side);\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        s.cx += (s.px - s.cx) * Math.min(1, dt * 3);\n        s.cy += (s.py - s.cy) * Math.min(1, dt * 3);\n        s.sideMix += (s.yaw / Math.PI - s.sideMix) * Math.min(1, dt * 3.4);\n        const want = sunFor(s.index, s.side);\n        for (let i = 0; i < want.length; i++) s.sun[i] += (want[i] - s.sun[i]) * Math.min(1, dt * 2.6);\n      }\n      if (!reduce || s.dirty) {\n        draw(now / 1000);\n        s.dirty = false;\n        // measure, do not guess: if the machine cannot hold the frame rate, render fewer pixels\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.85;\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    raf = requestAnimationFrame(tick);\n\n    const move = (e: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      s.px = clamp(((e.clientX - r.left) / r.width) * 2 - 1, -1, 1);\n      s.py = clamp(((e.clientY - r.top) / r.height) * 2 - 1, -1, 1);\n      s.dirty = true;\n    };\n    const leave = () => {\n      s.px = 0;\n      s.py = 0;\n    };\n    wrap.addEventListener(\"pointermove\", move);\n    wrap.addEventListener(\"pointerleave\", leave);\n\n    return () => {\n      alive = false;\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      wrap.removeEventListener(\"pointermove\", move);\n      wrap.removeEventListener(\"pointerleave\", leave);\n      gl.getExtension(\"WEBGL_lose_context\")?.loseContext();\n    };\n  }, [reduce]);\n\n  const onKey = (e: React.KeyboardEvent) => {\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") {\n      e.preventDefault();\n      step(1);\n    } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      step(-1);\n    }\n  };\n  const pause = (v: boolean) => () => {\n    sim.current.paused = v;\n    if (!v) sim.current.nextAuto = performance.now() + HOLD_MS;\n  };\n  const v = voices[shown];\n  const btn = \"grid h-11 w-11 place-items-center rounded-full border border-[#3d0f0b]/25 bg-[#fff3e2]/70 text-[#3d0f0b] backdrop-blur-sm transition hover:bg-[#fff3e2] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3d0f0b]\";\n  const label = \"text-[10px] font-semibold uppercase tracking-[0.26em] sm:text-[11px]\";\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#e9a568]\" onFocus={pause(true)} onBlur={pause(false)} onPointerEnter={pause(true)} onPointerLeave={pause(false)}>\n      <style>{`@keyframes leaning-frame-testimonials-ink { from { opacity: 0; transform: translateY(14px); filter: blur(5px); } to { opacity: 1; transform: none; filter: blur(0); } } .leaning-frame-testimonials-ink { animation: leaning-frame-testimonials-ink 620ms cubic-bezier(0.2, 0.7, 0.2, 1) both; } @keyframes leaning-frame-testimonials-sun { from { transform: translateX(-3%); } to { transform: translateX(3%); } } .leaning-frame-testimonials-sun { animation: leaning-frame-testimonials-sun 9s ease-in-out infinite alternate; } @media (prefers-reduced-motion: reduce) { .leaning-frame-testimonials-ink, .leaning-frame-testimonials-sun { animation: none; } }`}</style>\n      <div\n        ref={wrapRef}\n        role=\"group\"\n        aria-roledescription=\"carousel\"\n        aria-label=\"Client testimonials. A framed portrait leans on a sunlit wall beside each quote. Use the left and right arrow keys to turn the frame to the next speaker.\"\n        tabIndex={0}\n        onKeyDown={onKey}\n        className=\"relative h-[720px] w-full select-none outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#3d0f0b]/70 sm:h-[780px]\"\n      >\n        <canvas ref={canvasRef} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full ${mode === \"still\" ? \"hidden\" : \"\"}`} />\n\n        {/* the quote, painted on the wall: real text, multiplied into the picture so sun and shade fall across it */}\n        <div\n          ref={plateRef}\n          aria-live=\"polite\"\n          className={`absolute left-0 top-0 origin-top-left ${mode === \"gl\" ? \"\" : \"hidden\"}`}\n          style={{ width: narrow ? 380 : 600, mixBlendMode: \"multiply\", willChange: \"transform\" }}\n        >\n          <div className=\"transition-opacity duration-200 motion-reduce:transition-none\" style={{ opacity: ink ? 1 : 0 }}>\n            <div key={shown} className=\"leaning-frame-testimonials-ink\">\n              <QuoteBody v={v} narrow={narrow} />\n              <span className=\"sr-only\">Portrait: {v.alt}</span>\n            </div>\n          </div>\n        </div>\n\n        {/* the same room built from plain boxes and one image, for browsers without WebGL 2 */}\n        {mode === \"still\" && (\n          <div className=\"absolute inset-0\" style={{ background: \"linear-gradient(105deg, #f4b97c 0%, #f1b071 38%, #d99358 100%)\" }}>\n            <div aria-hidden=\"true\" className=\"leaning-frame-testimonials-sun absolute inset-y-0 -left-[10%] w-[120%]\" style={{ background: \"linear-gradient(118deg, transparent 12%, rgba(255,236,200,0.5) 12.4%, rgba(255,236,200,0.5) 58%, transparent 58.6%)\" }} />\n            <div aria-hidden=\"true\" className=\"absolute inset-x-0 bottom-0 h-[13%]\" style={{ background: \"linear-gradient(180deg, #7a2a17 0%, #a3472a 100%)\", boxShadow: \"inset 0 10px 14px -8px rgba(40,10,0,0.6)\" }} />\n            <div className=\"absolute inset-x-0 bottom-[10%] top-[11%] mx-auto flex max-w-6xl flex-col items-center gap-6 px-6 sm:flex-row sm:items-end sm:gap-14 sm:px-12\">\n              <div aria-live=\"polite\" className=\"order-1 w-full max-w-[600px] sm:w-[54%] sm:pb-24\">\n                <QuoteBody v={v} narrow={narrow} />\n              </div>\n              <div className=\"order-2 h-[52%] shrink-0 sm:h-full\" style={{ aspectRatio: \"100 / 132\", padding: \"1.6%\", background: \"linear-gradient(135deg, #5a2f18, #2e1509 60%, #4a2512)\", boxShadow: \"22px 18px 30px -6px rgba(70,25,5,0.45), 2px 0 0 rgba(255,255,255,0.08) inset\" }}>\n                <div className=\"h-full w-full\" style={{ background: \"#efe9dc\", padding: \"10.5% 11% 13.5%\", boxShadow: \"inset 0 0 0 1px rgba(0,0,0,0.25), inset 3px 4px 6px rgba(0,0,0,0.25)\" }}>\n                  <img src={v.src} alt={v.alt} width={900} height={1350} className=\"h-full w-full object-cover\" style={{ background: v.tone, objectPosition: `${v.focus[0] * 100}% ${v.focus[1] * 100}%`, boxShadow: \"0 0 0 2px #fbf8f1, inset 0 0 0 1px rgba(0,0,0,0.3)\" }} />\n                </div>\n              </div>\n            </div>\n          </div>\n        )}\n\n        <div className=\"pointer-events-none absolute inset-x-0 top-0 flex items-baseline justify-between p-5 sm:p-9\" style={{ color: INK }}>\n          <p className=\"text-[26px] italic leading-none sm:text-[30px]\" style={{ fontFamily: SERIF, letterSpacing: \"-0.03em\" }}>\n            {MASTHEAD}\n          </p>\n          <p className={`${label} opacity-80`} style={{ fontFamily: GROTESK }}>\n            <span className=\"hidden sm:inline\">Arrow keys turn the frame</span>\n          </p>\n        </div>\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-between gap-4 p-5 sm:p-9\">\n          <p className={`${label} rounded-full bg-[#fff3e2]/85 px-4 py-2.5`} style={{ fontFamily: GROTESK, color: INK }}>\n            <span className=\"tabular-nums\">{String(shown + 1).padStart(2, \"0\")}</span>\n            <span className=\"mx-2 opacity-50\">/</span>\n            <span className=\"tabular-nums\">{String(N).padStart(2, \"0\")}</span>\n          </p>\n          <div className=\"pointer-events-auto flex gap-2\">\n            <button type=\"button\" onClick={() => step(-1)} aria-label=\"Previous testimonial\" className={btn}>\n              <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                <path d=\"M12 4l-6 6 6 6\" />\n              </svg>\n            </button>\n            <button type=\"button\" onClick={() => step(1)} aria-label=\"Next testimonial\" className={btn}>\n              <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                <path d=\"M8 4l6 6-6 6\" />\n              </svg>\n            </button>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
