{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"glass-tube-border-feature-card-in-webgl-with-a-warm-bead-of-light-that-runs-the-edge-and-warms-the-sunlit-table","type":"registry:block","title":"Glass Tube Border Feature Card in WebGL with a Warm Bead of Light That Runs the Edge and Warms the Sunlit Table","description":"Free animated border card: a bead of warm light runs through a glass tube bent around a feature card on a sunlit oak table, faster under the pointer.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/glass-tube-border-feature-card-in-webgl-with-a-warm-bead-of-light-that-runs-the-edge-and-warms-the-sunlit-table.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The words on the card. Everything here is real page text laid onto the card face. */\nconst card = {\n  kicker: \"Version history\",\n  title: \"Every draft kept. None of them in the way.\",\n  body: \"Roll any page back to how it looked on a given morning, compare two versions side by side, and restore one section without touching the rest.\",\n  link: \"See how versions work\",\n  maker: \"Quillmark Studio\",\n};\n\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 = \"#2b1c12\";\n\nconst IDLE_SPEED = 0.075; // laps per second while nobody is near\nconst HOVER_SPEED = 0.46; // laps per second under the pointer\nconst SPEED_SPRING = 26; // how hard the bead is pulled to its new speed\nconst SPEED_DAMP = 6.5; // lower lets it overshoot more\nconst WARM_DECAY = 2.6; // seconds for the warmth on the table to fade to about a third\nconst DEMO_EVERY = 9000; // ms between automatic fast laps when nobody is interacting\nconst BINS = 24; // places around the edge that hold warmth\nconst GAP = 0.02; // air between the card's edge and the glass\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n\ntype Layout = { hx: number; hy: number; rc: number; th: number; yaw: number; tr: number; pad: number; narrow: boolean };\nconst WIDE: Layout = { hx: 0.82, hy: 0.5, rc: 0.09, th: 0.028, yaw: -0.2, tr: 0.03, pad: 0.13, narrow: false };\nconst TALL: Layout = { hx: 0.5, hy: 0.7, rc: 0.08, th: 0.028, yaw: -0.16, tr: 0.026, pad: 0.095, narrow: true };\n\n/** The centre line of the tube, a rounded rectangle on the card face. */\nconst tubePath = (l: Layout) => {\n  const ax = l.hx + GAP + l.tr, ay = l.hy + GAP + l.tr, pr = l.rc + GAP + l.tr;\n  const sx = ax - pr, sy = ay - pr, A = (pr * Math.PI) / 2;\n  const per = 4 * sx + 4 * sy + 4 * A;\n  /** A point on the line, s from 0 to 1, starting bottom centre and running anticlockwise as you face the card. */\n  const at = (s: number): [number, number] => {\n    let d = (((s % 1) + 1) % 1) * per;\n    const arc = (cx: number, cy: number, a0: number, len: number): [number, number] => {\n      const a = a0 + len / pr;\n      return [cx + pr * Math.cos(a), cy + pr * Math.sin(a)];\n    };\n    if (d < sx) return [d, -ay];\n    d -= sx;\n    if (d < A) return arc(sx, -sy, -Math.PI / 2, d);\n    d -= A;\n    if (d < 2 * sy) return [ax, -sy + d];\n    d -= 2 * sy;\n    if (d < A) return arc(sx, sy, 0, d);\n    d -= A;\n    if (d < 2 * sx) return [sx - d, ay];\n    d -= 2 * sx;\n    if (d < A) return arc(-sx, sy, Math.PI / 2, d);\n    d -= A;\n    if (d < 2 * sy) return [-ax, sy - d];\n    d -= 2 * sy;\n    if (d < A) return arc(-sx, -sy, Math.PI, d);\n    d -= A;\n    return [-sx + d, -ay];\n  };\n  return { ax, ay, pr, per, at, zt: 0, lift: 2 * l.tr + GAP };\n};\n\nconst VS = `#version 300 es\nvoid main() { vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)); gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0); }`;\n\nconst FS = `#version 300 es\nprecision highp float;\nuniform vec2 uRes;\nuniform vec3 uCam, uFw, uRt, uUp;\nuniform float uTan;\nuniform vec2 uHalf; uniform float uRc, uTh, uYaw, uLift;\nuniform vec2 uPA; uniform float uPR, uTr, uZt, uPer;\nuniform vec3 uBead, uTail; uniform float uBeadS, uBeadPow;\nuniform vec3 uWarmPos[${BINS}]; uniform float uWarm[${BINS}];\nuniform vec3 uL, uLu, uLv, uSun;\nuniform float uTime, uFocus, uAperture;\nout vec4 o;\nconst float WALLZ = -2.3;\nconst vec3 WARM = vec3(1.0, 0.5, 0.17);\nconst vec3 AMB = vec3(0.2, 0.21, 0.25);\nfloat hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }\nfloat vnoise(vec2 p) { vec2 i = floor(p), f = fract(p); f = f * f * (3.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); }\nfloat fbm(vec2 p) { return 0.5 * vnoise(p) + 0.25 * vnoise(p * 2.03 + 7.3) + 0.125 * vnoise(p * 4.1 + 1.7) + 0.0625 * vnoise(p * 8.3 + 3.1); }\nfloat sbox(vec2 p, vec2 h, float s) { vec2 d = smoothstep(h + s, h - s, abs(p)); return d.x * d.y; }\nfloat sdRR(vec2 p, vec2 b, float r) { vec2 q = abs(p) - b + r; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r; }\nvec3 toL(vec3 p) { float c = cos(uYaw), s = sin(uYaw); vec3 d = p - vec3(0.0, uHalf.y + uLift, 0.0); return vec3(c * d.x - s * d.z, d.y, s * d.x + c * d.z); }\nvec3 dirW(vec3 n) { float c = cos(uYaw), s = sin(uYaw); return vec3(c * n.x + s * n.z, n.y, -s * n.x + c * n.z); }\nfloat sdCard(vec3 q) { float e = 0.007; vec2 w = vec2(sdRR(q.xy, uHalf - e, uRc - e), abs(q.z) - uTh + e); return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - e; }\nfloat sdTube(vec3 q) { return length(vec2(sdRR(q.xy, uPA, uPR), q.z - uZt)) - uTr; }\nfloat sdBox(vec3 p, vec3 b) { vec3 q = abs(p) - b; return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0) - 0.002; }\n// brass clips: a sleeve round the glass and a tab that holds the card's edge\nfloat sdClip(vec3 q) {\n  vec3 a = vec3(abs(q.x), abs(q.y), q.z);\n  float cx = uHalf.x * 0.62;\n  float s1 = max(length(vec2(a.y - uPA.y, a.z)) - (uTr + 0.0045), abs(a.x - cx) - 0.012);\n  float t1 = sdBox(vec3(a.x - cx, a.y - (uHalf.y + uPA.y) * 0.5, a.z), vec3(0.009, (uPA.y - uHalf.y) * 0.5, uTh * 1.15));\n  float s2 = max(length(vec2(a.x - uPA.x, a.z)) - (uTr + 0.0045), abs(a.y) - 0.012);\n  float t2 = sdBox(vec3(a.x - (uHalf.x + uPA.x) * 0.5, a.y, a.z), vec3((uPA.x - uHalf.x) * 0.5, 0.009, uTh * 1.15));\n  return min(min(s1, t1), min(s2, t2));\n}\nvec2 mapL(vec3 q) { float a = sdCard(q), b = sdTube(q), c = sdClip(q); vec2 r = a < b ? vec2(a, 1.0) : vec2(b, 2.0); return c < r.x ? vec2(c, 3.0) : r; }\nvec3 normL(vec3 q, float id) {\n  vec2 e = vec2(0.0007, -0.0007);\n  if (id < 1.5) return normalize(e.xyy * sdCard(q + e.xyy) + e.yyx * sdCard(q + e.yyx) + e.yxy * sdCard(q + e.yxy) + e.xxx * sdCard(q + e.xxx));\n  if (id > 2.5) return normalize(e.xyy * sdClip(q + e.xyy) + e.yyx * sdClip(q + e.yyx) + e.yxy * sdClip(q + e.yxy) + e.xxx * sdClip(q + e.xxx));\n  return normalize(e.xyy * sdTube(q + e.xyy) + e.yyx * sdTube(q + e.yyx) + e.yxy * sdTube(q + e.yxy) + e.xxx * sdTube(q + e.xxx));\n}\n// where along the tube (0 to 1) a point on the card face sits\nfloat pathParam(vec2 p) {\n  float sx = uPA.x - uPR, sy = uPA.y - uPR, A = uPR * 1.5707963;\n  float c2 = sx + A, c3 = c2 + 2.0 * sy, c4 = c3 + A, c5 = c4 + 2.0 * sx, c6 = c5 + A, c7 = c6 + 2.0 * sy, c8 = c7 + A;\n  float d;\n  if (abs(p.x) <= sx) d = p.y < 0.0 ? (p.x >= 0.0 ? p.x : c8 + p.x + sx) : c4 + sx - p.x;\n  else if (abs(p.y) <= sy) d = p.x > 0.0 ? c2 + p.y + sy : c6 + sy - p.y;\n  else {\n    vec2 cc = vec2(sign(p.x) * sx, sign(p.y) * sy);\n    float a = atan(p.y - cc.y, p.x - cc.x);\n    if (p.x > 0.0 && p.y < 0.0) d = sx + uPR * (a + 1.5707963);\n    else if (p.x > 0.0) d = c3 + uPR * a;\n    else if (p.y > 0.0) d = c5 + uPR * (a - 1.5707963);\n    else d = c7 + uPR * ((a < 0.0 ? a + 6.2831853 : a) - 3.1415926);\n  }\n  return d / uPer;\n}\n// warmth stored around the edge, read at one place on the tube\nfloat warmAt(float s) {\n  float f = s * ${BINS}.0 - 0.5;\n  int i0 = int(floor(f)); float t = fract(f);\n  int a = (i0 + ${BINS}) % ${BINS}, b = (i0 + 1 + ${BINS}) % ${BINS};\n  return mix(uWarm[a], uWarm[b], t);\n}\nfloat gobo(vec3 P, bool fine) {\n  vec2 g = vec2(dot(P, uLu), dot(P, uLv));\n  float w = sbox(g - vec2(0.15, 0.25), vec2(2.6, 1.9), 0.25);\n  float bars = 1.0 - 0.94 * smoothstep(0.05, 0.02, abs(g.x + 1.42)) - 0.94 * smoothstep(0.05, 0.02, abs(g.y - 1.62));\n  float leaf = 1.0;\n  if (fine) {\n    vec2 q = g * 2.4 + vec2(0.04 * sin(uTime * 0.6 + g.y * 3.0), 0.03 * cos(uTime * 0.45 + g.x * 2.0));\n    float n = fbm(q * 1.6 + 2.0);\n    leaf = 1.0 - 0.85 * smoothstep(0.52, 0.66, n) * smoothstep(-0.2, -1.6, g.x + 0.4 * g.y);\n  }\n  return w * clamp(bars, 0.0, 1.0) * leaf;\n}\n// light that the sun gets past the card and through the glass tube (which throws a bright line in its shadow)\nfloat sunVis(vec3 P) {\n  vec3 o = toL(P);\n  vec3 d = toL(P + uL) - o;\n  float rc = 1.0, tm = 1.0, t = 0.006;\n  for (int i = 0; i < 96; i++) {\n    vec3 q = o + d * t;\n    float dc = sdCard(q), dt = sdTube(q);\n    rc = min(rc, 6.0 * dc / t);\n    tm = min(tm, dt);\n    if (rc < 0.002 || t > 3.5) break;\n    t += clamp(min(dc, dt), 0.005, 0.12);\n  }\n  rc = clamp(rc, 0.0, 1.0); rc = rc * rc * (3.0 - 2.0 * rc);\n  float c = clamp(-tm / uTr, 0.0, 1.0);\n  float glass = tm > 0.0 ? 1.0 - 0.25 * exp(-tm / 0.008) : mix(0.5, 0.75, smoothstep(0.0, 0.4, c)) + 1.1 * smoothstep(0.55, 0.95, c);\n  return rc * glass;\n}\nvec3 env(vec3 rd) {\n  vec3 c = mix(vec3(0.33, 0.22, 0.15), vec3(0.92, 0.85, 0.76), smoothstep(-0.15, 0.7, rd.y));\n  float f = dot(rd, uL);\n  if (f > 0.0) {\n    vec2 a = vec2(dot(rd, uLu), dot(rd, uLv)) / f;\n    float win = sbox(a - vec2(0.05, 0.1), vec2(0.42, 0.55), 0.03);\n    win *= 1.0 - 0.9 * smoothstep(0.02, 0.008, abs(a.x + 0.12));\n    win *= 1.0 - 0.9 * smoothstep(0.02, 0.008, abs(a.y - 0.25));\n    c += uSun * 5.5 * win;\n  }\n  if (rd.y < 0.0) c = mix(c, vec3(0.2, 0.11, 0.05), smoothstep(0.0, -0.2, rd.y));\n  return c;\n}\n// the bead and the warmth it has left behind, as light falling on a surface\nvec3 beadLight(vec3 P, vec3 n) {\n  vec3 Lb = uBead - P; float d2 = dot(Lb, Lb);\n  float k = max(dot(n, Lb * inversesqrt(d2)), 0.0) * 0.6 + 0.4 * max(dot(n, Lb * inversesqrt(d2)), -0.2);\n  vec3 acc = WARM * uBeadPow * 0.08 * max(k, 0.0) / (d2 + 0.006);\n  float w = 0.0;\n  for (int i = 0; i < ${BINS}; i++) {\n    vec3 L = uWarmPos[i] - P; float e2 = dot(L, L);\n    w += uWarm[i] * max(dot(n, L * inversesqrt(e2)) * 0.7 + 0.3, 0.0) / (e2 + 0.03);\n  }\n  return acc + WARM * w * 0.11;\n}\nvec3 wood(vec3 P, out float rough, out vec3 n) {\n  float z = P.z * 4.4;\n  float id = floor(z);\n  float fr = fract(z);\n  float tone = hash(vec2(id, 3.1));\n  float off = hash(vec2(id, 9.7)) * 40.0;\n  float warp = 0.6 * fbm(vec2(P.x * 1.2 + off, z * 3.0));\n  float grain = mix(0.5, fbm(vec2(P.x * 1.4 + off, (fr + warp) * 26.0)), clamp(1.4 - fwidth(z * 26.0) * 0.7, 0.0, 1.0));\n  float fine = mix(0.5, vnoise(vec2(P.x * 90.0, z * 60.0 + off)), clamp(1.0 - max(fwidth(P.x * 90.0), fwidth(z * 60.0)) * 0.9, 0.0, 1.0));\n  vec3 alb = mix(vec3(0.26, 0.12, 0.05), vec3(0.55, 0.3, 0.13), 0.3 + 0.5 * tone) * (0.55 + 0.75 * grain) * (0.9 + 0.12 * fine);\n  float px = fwidth(z);\n  float seam = smoothstep(0.012 + px, 0.003, min(fr, 1.0 - fr)) / (1.0 + px * 40.0);\n  alb *= 1.0 - 0.75 * seam;\n  float x = P.x * 0.9 + off;\n  float pj = fwidth(x * 0.3);\n  float fj = fract(x * 0.3);\n  float joint = smoothstep(0.0012 + pj, 0.0, min(fj, 1.0 - fj)) / (1.0 + pj * 200.0);\n  alb *= 1.0 - 0.6 * joint;\n  rough = mix(0.05 + 0.08 * fine, 0.5, seam);\n  n = normalize(vec3(0.015 * (grain - 0.5), 1.0, 0.0));\n  return alb;\n}\nvec3 plaster(vec3 P) {\n  vec3 alb = vec3(0.72, 0.52, 0.36) * (0.88 + 0.22 * fbm(P.xy * 2.2));\n  float sun = max(uL.z, 0.0) * gobo(P, false) * sunVis(P);\n  return alb * (uSun * sun + AMB * 0.9);\n}\nvec3 paper(vec3 q) {\n  float f = vnoise(q.xy * 900.0) * 0.5 + vnoise(q.xy * vec2(260.0, 1700.0)) * 0.5;\n  return vec3(0.84, 0.79, 0.7) * (0.97 + 0.05 * f) * (0.98 + 0.04 * fbm(q.xy * 6.0));\n}\nvec3 shadeCard(vec3 P, vec3 q, vec3 nl, vec3 V, bool fine) {\n  vec3 n = dirW(nl);\n  vec3 alb = paper(q);\n  if (abs(nl.z) < 0.7) alb *= vec3(0.9, 0.86, 0.8);\n  float near = sdTube(q);\n  float ao = mix(0.55, 1.0, smoothstep(0.0, 0.03, near)) * mix(0.6, 1.0, smoothstep(0.0, 0.12, P.y));\n  float vis = fine ? sunVis(P + n * 0.002) : 1.0;\n  vec3 col = alb * (uSun * max(dot(n, uL), 0.0) * gobo(P, fine) * vis + AMB * ao + beadLight(P, n) + vec3(0.12, 0.06, 0.03) * exp(-P.y / 0.18));\n  float F = 0.03 + 0.97 * pow(1.0 - max(dot(n, V), 0.0), 5.0);\n  col += env(reflect(-V, n)) * F * 0.18;\n  return col;\n}\nvec3 shadeBrass(vec3 P, vec3 nl, vec3 V) {\n  vec3 n = dirW(nl);\n  vec3 alb = vec3(0.86, 0.6, 0.28);\n  vec3 R = reflect(-V, n);\n  float F = pow(1.0 - max(dot(n, V), 0.0), 5.0);\n  vec3 spec = env(R) * 0.7 + uSun * 8.0 * pow(max(dot(R, uL), 0.0), 120.0);\n  return (alb + (1.0 - alb) * F) * spec * 0.75 + alb * (uSun * max(dot(n, uL), 0.0) * 0.12 + beadLight(P, n) * 0.6);\n}\nvec3 shadeTable(vec3 P, vec3 V, vec3 rd, bool fine, out float far) {\n  float rough; vec3 n;\n  vec3 alb = wood(P, rough, n);\n  vec3 q = toL(P);\n  float dc = sdCard(q);\n  float ao = mix(0.32, 1.0, smoothstep(0.0, 0.16, dc)) * mix(0.75, 1.0, smoothstep(0.0, 0.05, sdTube(q)));\n  ao *= mix(0.7, 1.0, smoothstep(0.0, 0.5, P.z - WALLZ));\n  vec3 dif = uSun * max(dot(n, uL), 0.0) * gobo(P, fine) * (fine ? sunVis(P) : 1.0) + AMB * ao + beadLight(P, n);\n  vec3 col = alb * dif;\n  far = 0.0;\n  if (!fine) return col;\n  // varnish: one glossy bounce, jittered by the roughness of the grain\n  float j = hash(gl_FragCoord.xy + fract(uTime) * 13.0);\n  vec3 nr = normalize(n + rough * 0.1 * vec3(cos(j * 6.283), 0.0, sin(j * 6.283)) * sqrt(fract(j * 7.13)));\n  vec3 R = reflect(rd, nr);\n  vec3 ro = P + R * 0.003;\n  vec3 refl = vec3(0.0);\n  float t = 0.0; bool hit = false; float id = 0.0;\n  for (int i = 0; i < 48; i++) {\n    vec2 h = mapL(toL(ro + R * t));\n    if (h.x < 0.001) { hit = true; id = h.y; break; }\n    t += h.x;\n    if (t > 3.0) break;\n  }\n  if (hit) {\n    vec3 H = ro + R * t, hq = toL(H);\n    vec3 hn = normL(hq, id);\n    if (id < 1.5) refl = shadeCard(H, hq, hn, -R, false);\n    else if (id > 2.5) refl = shadeBrass(H, hn, -R);\n    else refl = env(reflect(R, dirW(hn))) * 0.22 + WARM * uBeadPow * 0.6 * exp(-pow((pathParam(hq.xy) - uBeadS) * uPer, 2.0) / 0.004) + WARM * warmAt(pathParam(hq.xy)) * 0.5;\n    far = t;\n  } else if (R.z < 0.0) {\n    float tw = (WALLZ - ro.z) / R.z;\n    refl = plaster(ro + R * tw);\n    far = tw;\n  } else { refl = env(R); far = 5.0; }\n  float F = 0.04 + 0.96 * pow(1.0 - max(dot(nr, V), 0.0), 5.0);\n  F *= 0.85;\n  return col * (1.0 - F) + refl * F * ao;\n}\nvec3 shadeGlass(vec3 P, vec3 q, vec3 nl, vec3 rd) {\n  vec3 n = dirW(nl);\n  float cosT = max(dot(n, -rd), 0.0);\n  float F = 0.04 + 0.96 * pow(1.0 - cosT, 5.0);\n  vec3 R = reflect(rd, n);\n  vec3 refl = env(R) + uSun * 22.0 * pow(max(dot(R, uL), 0.0), 260.0) * sunVis(P + n * 0.01);\n  // seen through the glass: the tube bends what is behind it a little\n  vec3 td = normalize(mix(rd, refract(rd, n, 0.67), 0.9));\n  vec3 ro = P + td * (uTr * 2.0 * cosT + 0.004);\n  vec3 seen;\n  float t = 0.0; bool hit = false;\n  for (int i = 0; i < 28; i++) {\n    float d = sdCard(toL(ro + td * t));\n    if (d < 0.0008) { hit = true; break; }\n    t += d;\n    if (t > 1.0) break;\n  }\n  if (hit) { vec3 H = ro + td * t, hq = toL(H); seen = shadeCard(H, hq, normL(hq, 1.0), -td, false); }\n  else { float tp = td.y < 0.0 ? -ro.y / td.y : 1e9; if (tp < 1e8) { float f; seen = shadeTable(ro + td * tp, -td, td, false, f); } else seen = env(td); }\n  vec3 tint = vec3(0.9, 0.93, 0.9) * exp(-(1.0 / max(cosT, 0.12) - 1.0) * vec3(0.3, 0.14, 0.22));\n  // the bead's light runs along inside the glass wall, brightest at the silhouette\n  float s = pathParam(q.xy);\n  float ds = fract(s - uBeadS + 0.5) - 0.5;\n  float dm = ds * uPer;\n  float pipe = 0.6 + 2.2 * pow(1.0 - cosT, 2.0);\n  float behind = dm < 0.0 ? exp(dm / 0.16) : exp(-dm / 0.025);\n  vec3 glow = WARM * (uBeadPow * (8.0 * exp(-dm * dm / 0.0025) + 1.5 * behind) + 0.55 * warmAt(s)) * pipe;\n  // a hollow tube: near its silhouette the eye looks along the wall and sees the dim room bent round\n  float rim = smoothstep(0.8, 0.12, cosT);\n  vec3 wall = mix(seen * tint, vec3(0.1, 0.085, 0.06) * (0.5 + 0.5 * env(R).r), rim * 0.9);\n  // an inner wall highlight, offset from the outer one\n  float inner = smoothstep(0.62, 0.7, cosT) * smoothstep(0.8, 0.7, cosT) * 0.35;\n  return wall * (1.0 - F) + refl * F + glow + vec3(1.0, 0.95, 0.88) * inner * max(dot(n, uL), 0.0);\n}\nvec3 tonemap(vec3 x) { x *= 0.66; return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); }\nvoid main() {\n  vec2 uv = (gl_FragCoord.xy / uRes) * 2.0 - 1.0;\n  float aspect = uRes.x / uRes.y;\n  vec3 rd = normalize(uFw + uRt * uv.x * uTan * aspect + uUp * uv.y * uTan);\n  vec3 ro = uCam;\n  float tp = rd.y < 0.0 ? -ro.y / rd.y : 1e9;\n  float tw = rd.z < 0.0 ? (WALLZ - ro.z) / rd.z : 1e9;\n  float tMax = min(min(tp, tw), 12.0);\n  // march the card and the tube from just before their bounds\n  float t = max(0.0, length(ro - vec3(0.0, uHalf.y + uLift, 0.0)) - max(uHalf.x, uHalf.y) - 0.4);\n  float id = 0.0;\n  for (int i = 0; i < 140; i++) {\n    vec2 h = mapL(toL(ro + rd * t));\n    if (h.x < 0.0001 * t) { id = h.y; break; }\n    t += h.x * 0.8;\n    if (t > tMax) break;\n  }\n  vec3 col; float depth; vec3 V = -rd;\n  if (id > 0.5 && t < tMax) {\n    vec3 P = ro + rd * t, q = toL(P);\n    vec3 nl = normL(q, id);\n    col = id < 1.5 ? shadeCard(P, q, nl, V, true) : id > 2.5 ? shadeBrass(P, nl, V) : shadeGlass(P, q, nl, rd);\n    depth = t;\n  } else if (tp < tw) {\n    float far;\n    vec3 P = ro + rd * tp;\n    col = shadeTable(P, V, rd, true, far);\n    depth = tp;\n  } else {\n    col = plaster(ro + rd * tw);\n    depth = tw;\n  }\n  // the bead itself: a short hot streak, drawn wherever it is not hidden behind the card\n  vec3 ba = uBead - uTail, w0 = ro - uTail;\n  float bb = dot(rd, ba), cc = max(dot(ba, ba), 1e-8), dd = dot(rd, w0), ee = dot(ba, w0);\n  float den = cc - bb * bb;\n  float sg = den > 1e-9 ? clamp((ee - bb * dd) / den, 0.0, 1.0) : 1.0;\n  vec3 Q = uTail + ba * sg;\n  float bt = dot(Q - ro, rd);\n  float best = length(ro + rd * bt - Q);\n  if (bt < depth + uTr * 2.5) {\n    float hot = 0.55 + 0.45 * sg; // brightest at the head\n    float core = exp(-best * best / (0.0075 * 0.0075)) * hot;\n    float halo = exp(-best / 0.05);\n    col += vec3(1.0, 0.88, 0.7) * core * 16.0 * uBeadPow + WARM * halo * 0.7 * uBeadPow;\n  }\n  float coc = clamp(uAperture * (1.0 - uFocus / max(depth, 0.05)), -1.0, 1.0);\n  o = vec4(pow(tonemap(col), vec3(1.0 / 2.2)), 0.5 + 0.5 * coc);\n}`;\n\nconst FS_OUT = `#version 300 es\nprecision highp float;\nuniform sampler2D uScene; uniform vec2 uPx; uniform float uMaxR, uTime;\nout vec4 o;\nfloat hash(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }\nvoid main() {\n  vec2 uv = gl_FragCoord.xy * uPx;\n  vec4 c0 = texture(uScene, uv);\n  float r0 = abs(c0.a * 2.0 - 1.0) * uMaxR;\n  vec3 acc = c0.rgb; float wsum = 1.0;\n  if (r0 > 0.6) {\n    float rot = hash(gl_FragCoord.xy) * 6.2832;\n    for (int i = 1; i < 28; i++) {\n      float f = float(i);\n      float a = f * 2.39996 + rot, r = sqrt(f / 27.0) * r0;\n      vec2 off = vec2(cos(a), sin(a)) * r * uPx;\n      vec4 s = texture(uScene, uv + off);\n      float rs = abs(s.a * 2.0 - 1.0) * uMaxR;\n      float w = smoothstep(r - 1.0, r + 1.0, rs + 0.5);\n      acc += s.rgb * w; wsum += w;\n    }\n  }\n  vec3 col = acc / wsum;\n  vec2 v = uv - 0.5;\n  col *= 1.0 - 0.32 * dot(v, v) * 1.6;\n  col += (hash(gl_FragCoord.xy + fract(uTime * 7.0) * 91.0) - 0.5) * 0.028;\n  o = vec4(col, 1.0);\n}`;\n\nfunction compile(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 sh = gl.createShader(type)!;\n    gl.shaderSource(sh, src);\n    gl.compileShader(sh);\n    if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(sh) || \"shader\");\n    gl.attachShader(p, sh);\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\nfunction CardText({ narrow }: { narrow: boolean }) {\n  return (\n    <div className=\"flex h-full flex-col\" style={{ color: INK, fontFamily: GROTESK }}>\n      <p className=\"font-semibold uppercase\" style={{ fontSize: narrow ? 11 : 12, letterSpacing: \"0.24em\" }}>\n        {card.kicker}\n      </p>\n      <h2 className=\"font-normal\" style={{ textWrap: \"balance\", fontFamily: SERIF, fontSize: narrow ? 37 : 47, lineHeight: 1.02, letterSpacing: \"-0.022em\", marginTop: narrow ? 18 : 16, maxWidth: narrow ? 330 : 520 }}>\n        {card.title}\n      </h2>\n      <p style={{ fontSize: narrow ? 15 : 16, lineHeight: 1.5, marginTop: narrow ? 18 : 16, maxWidth: narrow ? 320 : 470, opacity: 0.86 }}>{card.body}</p>\n      <div className={`mt-auto flex gap-4 ${narrow ? \"flex-col items-start\" : \"items-center justify-between\"}`} style={{ paddingTop: 14 }}>\n        <a\n          href=\"#\"\n          className=\"inline-flex min-h-[40px] items-center gap-2 rounded-full font-semibold underline decoration-1 underline-offset-[5px] outline-none focus-visible:ring-2 focus-visible:ring-[#2b1c12] focus-visible:ring-offset-4 focus-visible:ring-offset-transparent\"\n          style={{ fontSize: narrow ? 15 : 16 }}\n        >\n          {card.link}\n          <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M4 10h11M11 5l5 5-5 5\" />\n          </svg>\n        </a>\n        <span className=\"uppercase\" style={{ fontSize: 10.5, letterSpacing: \"0.2em\", opacity: 0.7 }}>{card.maker}</span>\n      </div>\n    </div>\n  );\n}\n\nexport default function GlassTubeBorderFeatureCard() {\n  const reduce = useReducedMotion();\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const plateRef = useRef<HTMLDivElement>(null);\n  const [mode, setMode] = useState<\"wait\" | \"gl\" | \"still\">(\"wait\");\n  const [narrow, setNarrow] = useState(false);\n  const sim = useRef({ hot: false, lastTouch: -1e9, px: 0, py: 0, cx: 0, cy: 0, narrow: false, dirty: true });\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    if (!wrap) return;\n    const measure = () => {\n      const n = wrap.clientWidth < 640;\n      sim.current.narrow = n;\n      sim.current.dirty = true;\n      setNarrow(n);\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, canvas = canvasRef.current, 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    let prog: WebGLProgram, progOut: WebGLProgram;\n    try {\n      prog = compile(gl, VS, FS);\n      progOut = compile(gl, VS, FS_OUT);\n    } catch (err) {\n      console.warn(err);\n      setMode(\"still\");\n      return;\n    }\n    setMode(\"gl\");\n    const s = sim.current;\n    const vao = gl.createVertexArray();\n    const fbo = gl.createFramebuffer();\n    const tex = gl.createTexture();\n    let W = 0, H = 0, cw = 1, ch = 1;\n    let scale = Math.min(window.devicePixelRatio || 1, 1.5);\n    const resize = () => {\n      cw = wrap.clientWidth;\n      ch = wrap.clientHeight;\n      let k = scale;\n      if (cw * ch * k * k > 1.1e6) k = Math.sqrt(1.1e6 / (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.activeTexture(gl.TEXTURE0);\n      gl.bindTexture(gl.TEXTURE_2D, tex);\n      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_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, tex, 0);\n    };\n    resize();\n    const ro = new ResizeObserver(resize);\n    ro.observe(wrap);\n    const locs = new Map<string, WebGLUniformLocation | null>();\n    const U = (p: WebGLProgram, n: string) => {\n      const key = (p === prog ? \"a\" : \"b\") + n;\n      if (!locs.has(key)) locs.set(key, gl.getUniformLocation(p, n));\n      return locs.get(key)!;\n    };\n\n    // the sun: low, warm, from the front left\n    const Lraw = [-0.62, 0.5, 0.6];\n    const ll = Math.hypot(Lraw[0], Lraw[1], Lraw[2]);\n    const L = Lraw.map((v) => v / 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    // the bead's state\n    let bs = 0.36, v = IDLE_SPEED, vv = 0, heat = 0;\n    const warm = new Float32Array(BINS);\n    const warmPos = new Float32Array(BINS * 3);\n    const toWorld = (l: Layout, x: number, y: number, z: number) => {\n      const c = Math.cos(l.yaw), sn = Math.sin(l.yaw);\n      return [c * x + sn * z, y + l.hy + 2 * l.tr + GAP, -sn * x + c * z];\n    };\n    let lay = s.narrow ? TALL : WIDE;\n    let path = tubePath(lay);\n    const relayout = () => {\n      lay = s.narrow ? TALL : WIDE;\n      path = tubePath(lay);\n      for (let i = 0; i < BINS; i++) {\n        const [x, y] = path.at((i + 0.5) / BINS);\n        const p = toWorld(lay, x, y, path.zt);\n        warmPos.set(p, i * 3);\n      }\n    };\n    relayout();\n    let lastNarrow = s.narrow;\n\n    /** One step of the bead: a spring on its speed, and warmth laid down where it passes. */\n    const step = (dt: number, hot: boolean) => {\n      const target = hot ? HOVER_SPEED : IDLE_SPEED;\n      vv += (SPEED_SPRING * (target - v) - SPEED_DAMP * vv) * dt;\n      v += vv * dt;\n      heat += ((hot ? 1 : 0) - heat) * Math.min(1, dt * 2.2);\n      const prev = bs;\n      bs = (bs + Math.max(0.01, v) * dt) % 1;\n      const decay = Math.exp(-dt / WARM_DECAY);\n      for (let i = 0; i < BINS; i++) warm[i] *= decay;\n      // spread the deposit over the bins the bead crossed this step\n      const gain = (0.25 + 2.4 * heat) * Math.max(0, v) * dt * BINS * 0.9;\n      const a = prev * BINS - 0.5, b = a + Math.max(0.01, v) * dt * BINS;\n      for (let f = Math.floor(a); f <= Math.floor(b) + 1; f++) {\n        const i = ((f % BINS) + BINS) % BINS;\n        const cover = clamp(Math.min(b, f + 1.5) - Math.max(a, f - 0.5), 0, 1);\n        warm[i] = Math.min(1.5, warm[i] + gain * cover * 0.5);\n      }\n    };\n    // start already warm, as if the bead had just run a fast lap\n    // and finish that lap with the bead on the top run, where it shows best\n    const PARK = 0.47;\n    for (let i = 0; i < 240; i++) step(1 / 60, i < 170);\n    const travelled = bs - 0.36;\n    warm.fill(0);\n    bs = (((PARK - travelled) % 1) + 1) % 1;\n    v = IDLE_SPEED;\n    vv = 0;\n    heat = 0;\n    for (let i = 0; i < 240; i++) step(1 / 60, i < 170);\n\n    const draw = (t: number) => {\n      if (s.narrow !== lastNarrow) {\n        lastNarrow = s.narrow;\n        relayout();\n      }\n      const aspect = cw / ch;\n      const n = lay.narrow;\n      const look = n ? [0.02, 0.7, 0] : [0.04, 0.53, 0];\n      const dist = n ? 3.7 : 3.25;\n      const drift = reduce ? 0 : 1;\n      const cam = [\n        look[0] + (n ? 0.32 : 0.55) + s.cx * 0.22 + drift * 0.04 * Math.sin(t * 0.23),\n        look[1] + (n ? 0.62 : 0.5) - s.cy * 0.08 + drift * 0.012 * Math.sin(t * 0.31 + 1.3),\n        dist,\n      ];\n      let fw = [look[0] - cam[0], look[1] - cam[1], look[2] - cam[2]];\n      const fl = Math.hypot(fw[0], fw[1], fw[2]);\n      fw = fw.map((x) => x / fl);\n      let rt = [-fw[2], 0, fw[0]];\n      const rl = Math.hypot(rt[0], rt[2]);\n      rt = rt.map((x) => x / 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      const needW = n ? 0.86 : 1.7, needH = n ? 1.2 : 1.02;\n      const TAN = Math.max(needW / aspect, needH) / fl;\n\n      const [bx, by] = path.at(bs);\n      const bead = toWorld(lay, bx, by, path.zt);\n      const [tx, ty] = path.at(bs - Math.min(0.06, Math.max(0.004, v * 0.045)));\n      const tail = toWorld(lay, tx, ty, path.zt);\n      const pow = 0.85 + 0.55 * heat;\n\n      gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n      gl.viewport(0, 0, W, H);\n      gl.useProgram(prog);\n      gl.uniform2f(U(prog, \"uRes\"), W, H);\n      gl.uniform3fv(U(prog, \"uCam\"), cam);\n      gl.uniform3fv(U(prog, \"uFw\"), fw);\n      gl.uniform3fv(U(prog, \"uRt\"), rt);\n      gl.uniform3fv(U(prog, \"uUp\"), up);\n      gl.uniform1f(U(prog, \"uTan\"), TAN);\n      gl.uniform2f(U(prog, \"uHalf\"), lay.hx, lay.hy);\n      gl.uniform1f(U(prog, \"uRc\"), lay.rc);\n      gl.uniform1f(U(prog, \"uTh\"), lay.th);\n      gl.uniform1f(U(prog, \"uYaw\"), lay.yaw);\n      gl.uniform1f(U(prog, \"uLift\"), path.lift);\n      gl.uniform2f(U(prog, \"uPA\"), path.ax, path.ay);\n      gl.uniform1f(U(prog, \"uPR\"), path.pr);\n      gl.uniform1f(U(prog, \"uTr\"), lay.tr);\n      gl.uniform1f(U(prog, \"uZt\"), path.zt);\n      gl.uniform1f(U(prog, \"uPer\"), path.per);\n      gl.uniform3fv(U(prog, \"uBead\"), bead);\n      gl.uniform3fv(U(prog, \"uTail\"), tail);\n      gl.uniform1f(U(prog, \"uBeadS\"), bs);\n      gl.uniform1f(U(prog, \"uBeadPow\"), pow);\n      gl.uniform3fv(U(prog, \"uWarmPos[0]\"), warmPos);\n      gl.uniform1fv(U(prog, \"uWarm[0]\"), warm);\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, \"uSun\"), 2.5, 2.02, 1.5);\n      gl.uniform1f(U(prog, \"uTime\"), reduce ? 0 : t);\n      gl.uniform1f(U(prog, \"uFocus\"), fl);\n      gl.uniform1f(U(prog, \"uAperture\"), 1.1);\n      gl.bindVertexArray(vao);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.viewport(0, 0, W, H);\n      gl.useProgram(progOut);\n      gl.activeTexture(gl.TEXTURE0);\n      gl.bindTexture(gl.TEXTURE_2D, tex);\n      gl.uniform1i(U(progOut, \"uScene\"), 0);\n      gl.uniform2f(U(progOut, \"uPx\"), 1 / W, 1 / H);\n      gl.uniform1f(U(progOut, \"uMaxR\"), H * 0.009);\n      gl.uniform1f(U(progOut, \"uTime\"), reduce ? 0 : t);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n      // lay the text on the card face with the same camera, as a CSS projective matrix\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];\n        const yv = d[0] * up[0] + d[1] * up[1] + d[2] * up[2];\n        const zv = d[0] * fw[0] + d[1] * fw[1] + d[2] * fw[2];\n        return [cw * 0.5 * (1 + xv / (zv * TAN * aspect)), ch * 0.5 * (1 - yv / (zv * TAN))];\n      };\n      const ix = lay.hx - lay.pad, iy = lay.hy - lay.pad;\n      const z = lay.th + 0.0005;\n      const [x0, y0] = proj(toWorld(lay, -ix, iy, z));\n      const [x1, y1] = proj(toWorld(lay, ix, iy, z));\n      const [x2, y2] = proj(toWorld(lay, ix, -iy, z));\n      const [x3, y3] = proj(toWorld(lay, -ix, -iy, z));\n      const dx1 = x1 - x2, dx2 = x3 - x2, dx3 = x0 - x1 + x2 - x3;\n      const dy1 = y1 - y2, dy2 = y3 - y2, dy3 = y0 - y1 + y2 - y3;\n      const den = dx1 * dy2 - dx2 * dy1;\n      const g = (dx3 * dy2 - dx2 * dy3) / den, h = (dx1 * dy3 - dx3 * dy1) / den;\n      const a = x1 - x0 + g * x1, b = x3 - x0 + h * x3, d = y1 - y0 + g * y1, e = y3 - y0 + h * y3;\n      const pw = n ? 340 : 620, ph = Math.round((pw * iy) / ix);\n      plate.style.width = `${pw}px`;\n      plate.style.height = `${ph}px`;\n      plate.style.transform = `matrix3d(${a / pw},${d / pw},0,${g / pw},${b / ph},${e / ph},0,${h / ph},0,0,1,0,${x0},${y0},0,1)`;\n    };\n\n    let raf = 0, visible = true, last = performance.now(), slow = 0, frames = 0, fpsT = last, fpsN = 0;\n    const t0 = last;\n    const tick = (now: number) => {\n      const real = now - last;\n      const dt = Math.min(0.05, real / 1000);\n      last = now;\n      if (reduce) {\n        if (s.dirty) {\n          draw(0);\n          s.dirty = false;\n        }\n      } else {\n        // a demo lap now and then, when nobody is touching it; the first one is under way at load\n        const idle = now - s.lastTouch > 4000;\n        const since = now - t0;\n        const demo = idle && (since < 3200 || (since - 3200) % DEMO_EVERY > DEMO_EVERY - 2600);\n        const sub = Math.max(1, Math.ceil(dt / 0.008));\n        for (let i = 0; i < sub; i++) step(dt / sub, s.hot || demo);\n        s.cx += (s.px - s.cx) * Math.min(1, dt * 2.5);\n        s.cy += (s.py - s.cy) * Math.min(1, dt * 2.5);\n        draw((now - t0) / 1000);\n        fpsN++;\n        if (now - fpsT > 1000) {\n          wrap.dataset.fps = String(Math.round((fpsN * 1000) / (now - fpsT)));\n          fpsN = 0;\n          fpsT = now;\n        }\n        // measure, do not guess: render fewer pixels if this machine cannot keep up\n        if (++frames > 30) {\n          slow = slow * 0.92 + (real > 22 ? 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 && !document.hidden) raf = requestAnimationFrame(tick);\n      else raf = 0;\n    };\n    const restart = () => {\n      if (!raf && visible && !document.hidden) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    };\n    const io = new IntersectionObserver(([en]) => {\n      visible = en.isIntersecting;\n      restart();\n    });\n    io.observe(wrap);\n    document.addEventListener(\"visibilitychange\", restart);\n    raf = requestAnimationFrame(tick);\n    const move = (ev: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      s.px = clamp(((ev.clientX - r.left) / r.width) * 2 - 1, -1, 1);\n      s.py = clamp(((ev.clientY - r.top) / r.height) * 2 - 1, -1, 1);\n    };\n    const leave = () => {\n      s.px = 0;\n      s.py = 0;\n    };\n    wrap.addEventListener(\"pointermove\", move);\n    wrap.addEventListener(\"pointerleave\", leave);\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", restart);\n      wrap.removeEventListener(\"pointermove\", move);\n      wrap.removeEventListener(\"pointerleave\", leave);\n      gl.getExtension(\"WEBGL_lose_context\")?.loseContext();\n    };\n  }, [reduce]);\n\n  const heat = (on: boolean) => () => {\n    sim.current.hot = on;\n    sim.current.lastTouch = performance.now();\n  };\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#7a4a2a]\">\n      <div\n        ref={wrapRef}\n        className=\"relative h-[640px] w-full select-none sm:h-[680px]\"\n        onPointerDown={(e) => {\n          if (e.pointerType !== \"mouse\") {\n            sim.current.hot = !sim.current.hot;\n            sim.current.lastTouch = performance.now();\n          }\n        }}\n      >\n        <canvas ref={canvasRef} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full ${mode === \"still\" ? \"hidden\" : \"\"}`} />\n        {/* the card's words: real text, projected onto the card face and multiplied into the light */}\n        <div\n          ref={plateRef}\n          className={`absolute left-0 top-0 origin-top-left ${mode === \"gl\" ? \"\" : \"hidden\"}`}\n          style={{ mixBlendMode: \"multiply\", willChange: \"transform\" }}\n          onPointerEnter={heat(true)}\n          onPointerLeave={heat(false)}\n          onFocus={heat(true)}\n          onBlur={heat(false)}\n        >\n          <CardText narrow={narrow} />\n        </div>\n        {mode === \"still\" && <Still narrow={narrow} onHot={heat} />}\n      </div>\n    </section>\n  );\n}\n\n/** The same table and card for browsers without WebGL 2: a warm photograph-like composition in plain CSS. */\nfunction Still({ narrow, onHot }: { narrow: boolean; onHot: (on: boolean) => () => void }) {\n  return (\n    <div className=\"absolute inset-0\" style={{ background: \"linear-gradient(180deg, #b9875f 0%, #a5734d 34%, #6b3b1d 34.2%, #8a5229 60%, #5a2f14 100%)\" }}>\n      <div aria-hidden=\"true\" className=\"absolute inset-x-0 bottom-0 top-[34%]\" style={{ background: \"repeating-linear-gradient(180deg, rgba(0,0,0,0) 0 26px, rgba(30,10,0,0.45) 26px 28px), radial-gradient(60% 50% at 30% 30%, rgba(255,214,160,0.35), transparent 70%)\" }} />\n      <div className=\"absolute inset-0 grid place-items-center px-4\">\n        <div\n          className=\"relative w-full\"\n          style={{ maxWidth: narrow ? 360 : 700, aspectRatio: narrow ? \"1 / 1.38\" : \"1.64 / 1\", borderRadius: 22, background: \"#e9e1d2\", boxShadow: \"30px 26px 40px -10px rgba(40,15,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.06)\" }}\n          onPointerEnter={onHot(true)}\n          onPointerLeave={onHot(false)}\n        >\n          <div aria-hidden=\"true\" className=\"absolute inset-[6px] rounded-[18px]\" style={{ boxShadow: \"inset 0 0 0 7px rgba(255,255,255,0.35), inset 0 0 0 8px rgba(120,140,120,0.35), inset 0 0 14px 6px rgba(255,170,90,0.35)\" }} />\n          <style>{`@keyframes glass-tube-border-card-bead { 0% { left: 6%; } 100% { left: 92%; } } .glass-tube-border-card-bead { animation: glass-tube-border-card-bead 5s cubic-bezier(0.45, 0, 0.3, 1) infinite alternate; } @media (prefers-reduced-motion: reduce) { .glass-tube-border-card-bead { animation: none; } }`}</style>\n          <div aria-hidden=\"true\" className=\"glass-tube-border-card-bead absolute h-2 w-2 rounded-full\" style={{ top: 8, left: \"62%\", background: \"#fff3df\", boxShadow: \"0 0 8px 3px rgba(255,170,80,0.8), 0 0 30px 10px rgba(255,140,50,0.35)\" }} />\n          <div className=\"absolute\" style={{ inset: narrow ? \"8% 10%\" : \"12% 9%\" }}>\n            <CardText narrow={narrow} />\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}
