{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"kpi-gauge-card-with-a-ray-marched-cream-enamel-dial-damped-red-needle-domed-glass-and-chrome-bezel-on-a-sunlit-desk","type":"registry:block","title":"KPI Gauge Card with a Ray-Marched Cream Enamel Dial, Damped Red Needle, Domed Glass and Chrome Bezel on a Sunlit Desk","description":"Free React KPI card beside a WebGL desk gauge: cream enamel dial, red needle that swings with real damping, domed glass, chrome bezel and window sunlight.","dependencies":[],"files":[{"path":"components/we-inc/kpi-gauge-card-with-a-ray-marched-cream-enamel-dial-damped-red-needle-domed-glass-and-chrome-bezel-on-a-sunlit-desk.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent } from \"react\";\n\n// Demo data: one reading per period. `value` is on the 0 to 100 scale printed on the dial.\nconst periods = [\n  { label: \"Today\", long: \"today\", value: 62, delta: -9, against: \"yesterday\" },\n  { label: \"Week\", long: \"this week\", value: 74, delta: 6, against: \"last week\" },\n  { label: \"Month\", long: \"this month\", value: 81, delta: 4, against: \"last month\" },\n  { label: \"Quarter\", long: \"this quarter\", value: 68, delta: -3, against: \"last quarter\" },\n];\nconst METRIC = \"On-time dispatch\";\nconst UNIT = \"%\";\nconst TARGET = 75; // the small brass mark on the dial\nconst START = 1; // the period it opens on\nconst ARC = 270; // degrees the printed scale covers\nconst ZETA = 0.3; // needle damping ratio: 1 stops dead, 0.15 rings for a while\nconst OMEGA = 7.2; // needle natural frequency (radians a second): higher is a stiffer movement\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif';\nconst SERIF = '\"Iowan Old Style\", \"Palatino Linotype\", Palatino, \"Book Antiqua\", Georgia, serif';\n\nconst rad = (d: number) => (d * Math.PI) / 180;\nconst valueAngle = (v: number) => rad(-ARC / 2 + (ARC * Math.max(-2, Math.min(102, v))) / 100);\n\nconst VERT = `ATTR vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;\nconst TONE = `\nvec3 tone(vec3 x){ x *= 0.9; vec3 a = x * (2.51 * x + 0.03); vec3 b = x * (2.43 * x + 0.59) + 0.14; return pow(clamp(a / b, 0.0, 1.0), vec3(1.0 / 2.2)); }\n`;\n\n// The photograph: an instrument lying on an oak desk in a shaft of afternoon sun from a window to the left.\nconst SCENE = `\nprecision highp float;\nuniform vec2 uRes; uniform vec4 uJit; uniform float uSeed; uniform float uAng; uniform float uTgtAng;\nuniform vec3 uCam; uniform vec3 uTgt; uniform float uFoc; uniform vec2 uShift; uniform float uFocus;\nuniform sampler2D uTex; uniform float uDirect; uniform float uSway;\nconst float RC = 1.56; const float HC = 0.30; const float RD = 1.30; const float YD = 0.215;\nconst float RT = 1.43; const float YT = 0.335; const float rt = 0.105;\nconst float GR = 4.9; const float GY = 0.47;\nconst float PI = 3.14159265;\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); }\nfloat fbm(vec2 p){ float s = 0.0; float a = 0.5; for (int i = 0; i < 4; i++) { s += a * n2(p); p = p * 2.03 + 7.1; a *= 0.5; } return s; }\n\nvec3 sunDir(){ return normalize(vec3(-0.66, 0.70, 0.30)); }\nconst vec3 SUN = vec3(1.0, 0.82, 0.6) * 3.4;\n\n// Frame of the needle: x across it, y along it from the arbor to the tip.\nvec2 nFrame(vec2 xz, float a){ float s = sin(a); float c = cos(a); return vec2(xz.x * c - xz.y * s, xz.x * s + xz.y * c); }\n\nfloat sdCase(vec3 p){\n  float r = length(p.xz);\n  vec2 q = vec2(r - (RC - 0.06), p.y - 0.15);\n  float body = length(max(abs(q) - vec2(0.0, 0.09), 0.0)) - 0.06;\n  body = min(body, max(r - RC + 0.02, max(p.y - 0.2, -p.y)));\n  float bez = length(vec2(r - RT, (p.y - YT) * 1.15)) - rt;\n  float lip = max(abs(r - (RD + 0.035)) - 0.035, max(p.y - (YD + 0.07), YD - 0.02 - p.y));\n  float d = min(min(body, bez), lip);\n  // the well the dial sits in\n  d = max(d, -max(r - RD, YD - p.y));\n  d = min(d, max(r - RD, max(p.y - YD, -p.y)));\n  return d;\n}\nfloat sdNeedle(vec3 p){\n  vec2 k = nFrame(p.xz, uAng);\n  float y = p.y - (YD + 0.052);\n  float along = clamp(k.y, -0.27, 1.13);\n  float w = mix(0.016, 0.0045, clamp((k.y + 0.05) / 1.18, 0.0, 1.0));\n  float blade = max(max(abs(k.x) - w, abs(k.y - 0.43) - 0.70), abs(y) - 0.006);\n  float tail = max(length(k - vec2(0.0, -0.22)) - 0.058, abs(y) - 0.008);\n  float arbor = max(length(p.xz) - 0.085, max(p.y - (YD + 0.068), YD - p.y));\n  float cap = length(vec3(p.x, (p.y - (YD + 0.07)) * 1.8, p.z)) - 0.05;\n  return min(min(blade, tail), min(arbor, cap)) + along * 0.0;\n}\nfloat map(vec3 p){ return min(sdCase(p), sdNeedle(p)); }\n\nvec2 bound(vec3 ro, vec3 rd){\n  float a = dot(rd.xz, rd.xz); float b = dot(ro.xz, rd.xz); float c = dot(ro.xz, ro.xz) - 1.6 * 1.6;\n  float h = b * b - a * c; if (h < 0.0 || a < 1e-6) return vec2(1.0, -1.0);\n  h = sqrt(h); float t0 = (-b - h) / a; float t1 = (-b + h) / a;\n  if (abs(rd.y) > 1e-5) { float ya = (0.0 - ro.y) / rd.y; float yb = (0.46 - ro.y) / rd.y; t0 = max(t0, min(ya, yb)); t1 = min(t1, max(ya, yb)); }\n  return vec2(max(t0, 0.0), t1);\n}\nfloat march(vec3 ro, vec3 rd, int n, float eps){\n  vec2 tb = bound(ro, rd); if (tb.x > tb.y) return -1.0;\n  float t = tb.x;\n  for (int i = 0; i < 96; i++) { if (i >= n) break; float d = map(ro + rd * t); if (d < eps) return t; t += d * 0.8; if (t > tb.y) break; }\n  return -1.0;\n}\nvec3 calcN(vec3 p){\n  vec2 e = vec2(0.0007, -0.0007);\n  return normalize(e.xyy * map(p + e.xyy) + e.yyx * map(p + e.yyx) + e.yxy * map(p + e.yxy) + e.xxx * map(p + e.xxx));\n}\nfloat calcAO(vec3 p, vec3 n){\n  float o = 0.0; float s = 1.0;\n  for (int i = 1; i <= 5; i++) { float h = 0.01 + 0.045 * float(i); o += (h - map(p + n * h)) * s; s *= 0.7; }\n  return clamp(1.0 - 2.2 * o, 0.0, 1.0);\n}\nfloat softShadow(vec3 ro, vec3 rd, float k){\n  float res = 1.0; float t = 0.008;\n  for (int i = 0; i < 28; i++) { float h = map(ro + rd * t); res = min(res, k * h / t); t += clamp(h, 0.01, 0.2); if (res < 0.005 || t > 3.0) break; }\n  return clamp(res, 0.0, 1.0);\n}\n// The window the sun comes through: glazing bars throw their shadow across the desk and the dial.\nfloat windowGobo(vec3 p, float soft){\n  vec3 L = sunDir(); float t = (-6.5 - p.x) / L.x; vec3 q = p + L * t;\n  vec2 w = vec2(q.z + 0.2 + uSway, q.y - 1.1);\n  float s = soft * t + 0.01;\n  float inside = smoothstep(-s, s, w.x + 4.6) * smoothstep(s, -s, w.x - 4.4) * smoothstep(-s, s, w.y) * smoothstep(s, -s, w.y - 9.0);\n  vec2 m = abs(fract(w / vec2(2.25, 3.1)) - 0.5) * vec2(2.25, 3.1);\n  float bars = smoothstep(0.07 - s, 0.07 + s, m.x) * smoothstep(0.06 - s, 0.06 + s, m.y);\n  return inside * bars;\n}\nvec3 oak(vec2 p){\n  float warp = fbm(p * vec2(0.25, 1.1)) * 1.6 + 0.4 * fbm(p * vec2(1.0, 6.0));\n  float ring = fract(p.y * 2.6 + warp * 1.8);\n  float grain = smoothstep(0.0, 0.12, ring) * smoothstep(1.0, 0.4, ring);\n  float fine = n2(p * vec2(1.5, 160.0));\n  float pore = smoothstep(0.7, 0.95, n2(p * vec2(4.0, 220.0)));\n  vec3 lite = vec3(0.33, 0.17, 0.08); vec3 dark = vec3(0.13, 0.06, 0.028);\n  vec3 c = mix(dark, lite, 0.3 + 0.55 * grain + 0.15 * fine);\n  c *= 0.85 + 0.3 * fbm(p * vec2(0.4, 2.0) + 3.0);\n  return c * (1.0 - 0.35 * pore);\n}\n// The room as a reflection sees it: warm plaster, the bright window left, the desk below.\nvec3 room(vec3 ro, vec3 rd, float rough){\n  if (rd.y < 0.0) {\n    float t = -ro.y / rd.y; vec3 gp = ro + rd * t;\n    float lit = windowGobo(gp, 0.006 + rough * 0.1) * max(sunDir().y, 0.0);\n    vec3 a = oak(gp.xz);\n    return a * (SUN * lit * 0.9 + vec3(0.55, 0.5, 0.45) * 0.42) * exp(-0.012 * t * t);\n  }\n  vec3 c = mix(vec3(0.2, 0.15, 0.11), vec3(0.06, 0.05, 0.045), smoothstep(0.05, 0.6, rd.y)) * 0.8;\n  // a tall sash window behind the desk, seen as directions: the crystal and the chrome both carry it\n  if (rd.z > 0.05) {\n    vec2 w = vec2(rd.x / rd.z + 0.73, rd.y / rd.z - 0.8);\n    float s = 0.004 + rough * 0.3;\n    float inside = smoothstep(-s, s, w.x) * smoothstep(s, -s, w.x - 0.36) * smoothstep(-s, s, w.y) * smoothstep(s, -s, w.y - 0.46);\n    vec2 m = abs(fract(w / vec2(0.18, 0.23)) - 0.5) * vec2(0.18, 0.23);\n    float bars = smoothstep(0.009 - s, 0.009 + s, m.x) * smoothstep(0.008 - s, 0.008 + s, m.y);\n    c = mix(c, mix(vec3(2.4, 2.2, 1.95), vec3(1.3, 1.6, 2.2), smoothstep(0.0, 0.46, w.y)) * 6.5 * (1.0 - 0.8 * smoothstep(0.08, 0.3, rough)), inside * bars);\n  }\n  // the window on the left wall\n  if (rd.x < -0.05) {\n    float t = (-6.5 - ro.x) / rd.x; vec3 q = ro + rd * t;\n    vec2 w = vec2(q.z + 0.2 + uSway, q.y - 1.1);\n    float s = 0.02 + rough * 0.6 * t * 0.15;\n    float inside = smoothstep(-s, s, w.x + 4.6) * smoothstep(s, -s, w.x - 4.4) * smoothstep(-s, s, w.y) * smoothstep(s, -s, w.y - 9.0);\n    vec2 m = abs(fract(w / vec2(2.25, 3.1)) - 0.5) * vec2(2.25, 3.1);\n    float bars = smoothstep(0.07 - s, 0.07 + s, m.x) * smoothstep(0.06 - s, 0.06 + s, m.y);\n    vec3 sky = mix(vec3(2.6, 2.4, 2.1), vec3(1.4, 1.7, 2.3), smoothstep(1.0, 8.0, q.y));\n    c = mix(c, sky * 1.8, inside * bars);\n    c = mix(c, vec3(0.86, 0.8, 0.7) * 0.9, inside * (1.0 - bars));\n  }\n  // sun on the far wall\n  c += vec3(1.0, 0.8, 0.55) * 0.5 * smoothstep(0.2, 0.9, rd.z) * smoothstep(0.1, 0.4, rd.y) * smoothstep(0.7, 0.2, rd.y);\n  return c;\n}\n\nstruct Mat { vec3 alb; vec3 f0; float rough; float kind; };\nMat getMat(vec3 p, inout vec3 n, out vec3 emi){\n  Mat m; m.alb = vec3(0.0); m.f0 = vec3(0.04); m.rough = 0.2; m.kind = 0.0; emi = vec3(0.0);\n  float r = length(p.xz);\n  if (sdNeedle(p) < sdCase(p) + 0.0005) {\n    vec2 k = nFrame(p.xz, uAng);\n    if (r < 0.088 && p.y > YD + 0.005) { m.f0 = vec3(0.9, 0.87, 0.8); m.rough = 0.08; m.kind = 2.0; return m; }\n    // red lacquer, a touch darker where the blade is pressed thin\n    m.alb = vec3(0.62, 0.035, 0.025) * (0.85 + 0.15 * smoothstep(1.1, 0.3, k.y)); m.f0 = vec3(0.05); m.rough = 0.18; m.kind = 1.0;\n    return m;\n  }\n  if (r < RD + 0.001 && p.y < YD + 0.004) {\n    // vitreous enamel dial: cream, very slightly orange-peeled, printed in black and red\n    vec2 uv = vec2(p.x, -p.z) / (2.0 * RD) + 0.5;\n    vec4 ink = texture2D(uTex, uv);\n    float peel = n2(p.xz * 70.0) - 0.5; float peel2 = n2(p.zx * 70.0 + 4.0) - 0.5;\n    n = normalize(n + vec3(peel, 0.0, peel2) * 0.012);\n    vec3 cream = vec3(0.80, 0.70, 0.50) * (0.97 + 0.06 * fbm(p.xz * 3.0));\n    cream *= 1.0 - 0.12 * smoothstep(0.95, 1.3, r);\n    m.alb = mix(cream, vec3(0.012, 0.011, 0.01), ink.r);\n    m.alb = mix(m.alb, vec3(0.55, 0.035, 0.02), ink.g);\n    m.alb = mix(m.alb, vec3(0.62, 0.45, 0.18), ink.b);\n    m.f0 = mix(vec3(0.045), vec3(0.75, 0.55, 0.25), ink.b); m.rough = mix(0.09, 0.3, max(ink.r, ink.g)); m.kind = 1.0;\n    return m;\n  }\n  float bezel = length(vec2(r - RT, (p.y - YT) * 1.15)) - rt;\n  if (bezel < 0.004 || (p.y > YD - 0.03 && r < RD + 0.08)) {\n    // polished chrome: the bezel and the inner lip\n    m.f0 = vec3(0.92, 0.9, 0.86); m.rough = 0.025; m.kind = 2.0;\n    return m;\n  }\n  // stove-enamelled black case\n  m.alb = vec3(0.012, 0.012, 0.013); m.f0 = vec3(0.05); m.rough = 0.22; m.kind = 1.0;\n  return m;\n}\nvec3 fres(vec3 f0, float c){ return f0 + (1.0 - f0) * pow(1.0 - clamp(c, 0.0, 1.0), 5.0); }\nvec3 direct(vec3 p, vec3 n, vec3 rd, Mat m, float sh, float ao){\n  vec3 L = sunDir();\n  float ndl = max(dot(n, L), 0.0);\n  vec3 h = normalize(L - rd); float a2 = max(m.rough * m.rough, 0.002);\n  float nh = max(dot(n, h), 0.0); float d = nh * nh * (a2 - 1.0) + 1.0; float D = a2 / (PI * d * d);\n  vec3 spec = fres(m.f0, max(dot(h, -rd), 0.0)) * min(D, 60.0) * 0.25;\n  vec3 c = SUN * sh * ndl * (m.alb + spec);\n  c += m.alb * (vec3(0.55, 0.5, 0.45) * 0.45 * (0.5 + 0.5 * n.y) + vec3(0.6, 0.45, 0.3) * 0.12 * max(-n.y, 0.0)) * ao;\n  return c;\n}\nvec3 shadeLite(vec3 p, vec3 n, vec3 rd){\n  vec3 emi; Mat m = getMat(p, n, emi);\n  float g = windowGobo(p, 0.008);\n  vec3 r = reflect(rd, n);\n  return direct(p, n, rd, m, g, 0.8) + fres(m.f0, dot(-rd, n)) * room(p, r, m.rough);\n}\nvec3 trace(vec3 p, vec3 r, float rough){\n  float t = march(p, r, 40, 0.0015);\n  if (t > 0.0) { vec3 hp = p + r * t; return shadeLite(hp, calcN(hp), r); }\n  return room(p, r, rough);\n}\nvec3 shadeObj(vec3 p, vec3 n, vec3 rd, vec2 rnd){\n  vec3 gn = n; vec3 emi;\n  Mat m = getMat(p, n, emi);\n  float ao = calcAO(p, gn);\n  float sh = softShadow(p + gn * 0.004, sunDir(), 14.0) * windowGobo(p, 0.008);\n  vec3 col = direct(p, n, rd, m, sh, ao);\n  vec3 r = reflect(rd, n);\n  vec3 jr = normalize(r + vec3(rnd.x, rnd.y, rnd.x * rnd.y) * m.rough * 0.6);\n  vec3 s = m.kind == 2.0 ? trace(p + gn * 0.004, jr, m.rough) : room(p, jr, m.rough + 0.05) * (0.3 + 0.7 * ao);\n  return col + fres(m.f0, dot(-rd, n)) * s * (0.5 + 0.5 * ao);\n}\nvec3 shadeDesk(vec3 gp, vec3 rd, vec2 rnd, float dist){\n  vec3 a = oak(gp.xz);\n  float near = step(length(gp.xz), 6.0);\n  float occ = 1.0; float sh = 1.0;\n  if (near > 0.5) {\n    occ = smoothstep(-0.03, 0.55, map(gp + vec3(0.0, 0.04, 0.0)));\n    occ = mix(occ, 1.0, 0.25);\n    sh = softShadow(gp + vec3(0.0, 0.002, 0.0), sunDir(), 9.0);\n  }\n  float g = windowGobo(gp, 0.006);\n  vec3 L = sunDir();\n  vec3 col = a * (SUN * g * sh * L.y + vec3(0.55, 0.5, 0.45) * 0.42 * occ);\n  // oiled finish: a soft sheen of the window and of the instrument\n  vec3 n = normalize(vec3((n2(gp.xz * 4.0) - 0.5) * 0.02, 1.0, (n2(gp.zx * 4.0) - 0.5) * 0.02));\n  vec3 r = normalize(reflect(rd, n) + vec3(rnd.x, 0.0, rnd.y) * 0.12);\n  float f = 0.04 + 0.96 * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0);\n  vec3 refl = near > 0.5 ? trace(gp + vec3(0.0, 0.002, 0.0), r, 0.25) : room(gp, r, 0.25);\n  col += f * refl * 0.55 * occ;\n  col *= mix(1.0, 0.25, smoothstep(9.0, 30.0, dist));\n  return col;\n}\n// The domed crystal: thin glass, so it only adds what it reflects and dims what it lets through.\nvec2 glassHit(vec3 ro, vec3 rd){\n  vec3 c = vec3(0.0, GY - GR, 0.0); vec3 oc = ro - c;\n  float b = dot(oc, rd); float h = b * b - dot(oc, oc) + GR * GR;\n  if (h < 0.0) return vec2(-1.0);\n  float t = -b - sqrt(h); vec3 p = ro + rd * t;\n  if (t < 0.0 || length(p.xz) > RD + 0.07) return vec2(-1.0);\n  return vec2(t, length(p.xz));\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 rt3 = normalize(cross(vec3(0.0, 1.0, 0.0), fw)); vec3 up = cross(fw, rt3);\n  vec3 rd = normalize(fw * uFoc + rt3 * uv.x + up * uv.y);\n  vec3 ro = uCam;\n  vec3 fp = ro + rd * (uFocus / dot(rd, fw));\n  ro += rt3 * 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 t = march(ro, rd, 96, 0.0003);\n  float tg = rd.y < 0.0 ? -ro.y / rd.y : 1e9;\n  vec3 col;\n  if (t > 0.0 && t < tg) { vec3 p = ro + rd * t; col = shadeObj(p, calcN(p), rd, rnd); }\n  else if (tg < 1e8) col = shadeDesk(ro + rd * tg, rd, rnd, tg);\n  else col = room(ro, rd, 0.0);\n  vec2 gh = glassHit(ro, rd);\n  if (gh.x > 0.0 && (t < 0.0 || gh.x < t)) {\n    vec3 gp = ro + rd * gh.x; vec3 gn = normalize(gp - vec3(0.0, GY - GR, 0.0));\n    float cs = clamp(dot(-rd, gn), 0.0, 1.0);\n    float F = 0.04 + 0.96 * pow(1.0 - cs, 5.0);\n    float edge = smoothstep(RD - 0.18, RD + 0.06, gh.y);\n    F = mix(F, 0.35, edge * 0.5);\n    vec3 gr = reflect(rd, gn);\n    vec3 refl = room(gp, normalize(gr + vec3(rnd.x, 0.0, rnd.y) * 0.01), 0.0);\n    // a faint film of dust and fingerprints, lit only where the window lands on it\n    float smudge = fbm(gp.xz * 2.2 + 11.0) * smoothstep(0.55, 0.85, fbm(gp.zx * 1.3));\n    col = col * (1.0 - F) * mix(vec3(1.0), vec3(0.93, 0.96, 0.95), edge) + F * refl + smudge * 0.04 * refl;\n  }\n  col = min(col, vec3(30.0));\n  if (uDirect > 0.5) col = tone(col);\n  outC = vec4(col, 1.0);\n}\n`;\n\nconst POST = `\nprecision highp float;\nuniform sampler2D uAcc; uniform vec2 uRes; uniform float uGrain; uniform vec2 uCentre;\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 = texture2D(uAcc, uv).rgb;\n  vec2 px = 1.0 / uRes;\n  vec3 nb = texture2D(uAcc, uv + vec2(px.x, 0.0)).rgb + texture2D(uAcc, uv - vec2(px.x, 0.0)).rgb + texture2D(uAcc, uv + vec2(0.0, px.y)).rgb + texture2D(uAcc, uv - vec2(0.0, px.y)).rgb;\n  c = max(c + (c - nb * 0.25) * 0.4, 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 = texture2D(uAcc, uv + vec2(cos(a), sin(a)) * r * 0.03 * vec2(uRes.y / uRes.x, 1.0)).rgb;\n    b += min(max(s - 1.4, 0.0), vec3(6.0)) * (1.0 - 0.6 * r);\n  }\n  c += b * vec3(0.011, 0.0095, 0.008);\n  vec2 q = (uv - uCentre) * vec2(uRes.x / uRes.y, 1.0);\n  c *= 1.0 - 0.3 * smoothstep(0.35, 1.25, length(q));\n  c = tone(c);\n  float g = h21(gl_FragCoord.xy + uGrain * 91.7) - 0.5;\n  c += g * 0.02 * (1.0 - 0.4 * c.g);\n  outC = vec4(c, 1.0);\n}\n`;\n\n// The dial printing as a flat plan: black ink in red, red ink in green, brass in blue.\nfunction dialArt() {\n  const S = 2048, RD = 1.3;\n  const cv = document.createElement(\"canvas\");\n  cv.width = S; cv.height = S;\n  const g = cv.getContext(\"2d\");\n  if (!g) return cv;\n  const px = S / (2 * RD);\n  g.fillStyle = \"#000\"; g.fillRect(0, 0, S, S);\n  g.translate(S / 2, S / 2);\n  g.textAlign = \"center\"; g.textBaseline = \"middle\";\n  const at = (v: number) => rad(-ARC / 2 + (ARC * v) / 100);\n  // red band below 40\n  g.strokeStyle = \"#0f0\"; g.lineWidth = 0.05 * px; g.lineCap = \"butt\";\n  g.beginPath(); g.arc(0, 0, 1.13 * px, at(0) - Math.PI / 2, at(40) - Math.PI / 2); g.stroke();\n  g.strokeStyle = \"#f00\"; g.lineWidth = 0.008 * px;\n  g.beginPath(); g.arc(0, 0, 1.2 * px, at(0) - Math.PI / 2, at(100) - Math.PI / 2); g.stroke();\n  for (let i = 0; i <= 100; i++) {\n    const major = i % 10 === 0, mid = i % 5 === 0;\n    if (!major && !mid && i % 1 !== 0) continue;\n    g.save(); g.rotate(at(i));\n    const len = major ? 0.17 : mid ? 0.11 : 0.06, w = major ? 0.022 : mid ? 0.013 : 0.007;\n    g.fillStyle = \"#f00\"; g.fillRect((-w * px) / 2, -1.2 * px, w * px, len * px);\n    if (major) {\n      g.font = `600 ${0.14 * px}px ${FONT}`;\n      g.translate(0, -0.9 * px); g.rotate(-at(i));\n      g.fillText(String(i), 0, 0);\n    }\n    g.restore();\n  }\n  // target mark in brass\n  g.save(); g.rotate(at(TARGET)); g.fillStyle = \"#00f\";\n  g.beginPath(); g.moveTo(0, -1.215 * px); g.lineTo(-0.05 * px, -1.295 * px); g.lineTo(0.05 * px, -1.295 * px); g.closePath(); g.fill(); g.restore();\n  g.fillStyle = \"#f00\";\n  g.font = `600 ${0.075 * px}px ${FONT}`;\n  const track = (text: string, y: number, sp: number) => {\n    const chars = text.split(\"\"); const widths = chars.map((c) => g.measureText(c).width);\n    const total = widths.reduce((a, b) => a + b, 0) + sp * px * (chars.length - 1);\n    let x = -total / 2;\n    chars.forEach((c, k) => { g.fillText(c, x + widths[k] / 2, y * px); x += widths[k] + sp * px; });\n  };\n  track(METRIC.toUpperCase(), 0.42, 0.022);\n  g.font = `500 ${0.2 * px}px ${SERIF}`; g.fillText(UNIT, 0, -0.42 * px);\n  g.font = `italic 500 ${0.075 * px}px ${SERIF}`;\n  g.fillText(\"Harrow & Peel\", 0, 0.56 * px);\n  return cv;\n}\n\n// No WebGL or reduced motion on a software renderer: the same instrument as an SVG still.\nfunction Still({ value }: { value: number }) {\n  const deg = -ARC / 2 + (ARC * value) / 100;\n  const ticks = Array.from({ length: 21 }, (_, i) => i * 5);\n  return (\n    <div aria-hidden=\"true\" className=\"absolute left-1/2 top-[34%] w-[340px] -translate-x-1/2 -translate-y-1/2 sm:w-[420px] lg:left-[68%] lg:top-1/2 lg:w-[520px]\">\n      <div className=\"absolute inset-x-[-10%] bottom-[-12%] top-[30%] rounded-full bg-black/30 blur-2xl\" style={{ transform: \"translate(14%, 6%) scaleY(0.5)\" }} />\n      <svg viewBox=\"-160 -160 320 320\" className=\"relative w-full\" style={{ transform: \"perspective(900px) rotateX(36deg)\" }}>\n        <defs>\n          <radialGradient id=\"kpi-gauge-still-cream\" cx=\"40%\" cy=\"35%\" r=\"75%\"><stop offset=\"0\" stopColor=\"#f3e7cc\" /><stop offset=\"0.8\" stopColor=\"#e3d2ad\" /><stop offset=\"1\" stopColor=\"#c9b48a\" /></radialGradient>\n          <linearGradient id=\"kpi-gauge-still-chrome\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stopColor=\"#ffffff\" /><stop offset=\"0.3\" stopColor=\"#8f9196\" /><stop offset=\"0.55\" stopColor=\"#f4f4f2\" /><stop offset=\"0.8\" stopColor=\"#4a4b50\" /><stop offset=\"1\" stopColor=\"#d9d9d6\" /></linearGradient>\n          <linearGradient id=\"kpi-gauge-still-glass\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stopColor=\"#fff\" stopOpacity=\"0.55\" /><stop offset=\"0.35\" stopColor=\"#fff\" stopOpacity=\"0.05\" /><stop offset=\"1\" stopColor=\"#fff\" stopOpacity=\"0\" /></linearGradient>\n        </defs>\n        <circle r=\"156\" fill=\"#141313\" />\n        <circle r=\"150\" fill=\"none\" stroke=\"url(#kpi-gauge-still-chrome)\" strokeWidth=\"14\" />\n        <circle r=\"134\" fill=\"url(#kpi-gauge-still-cream)\" />\n        <circle r=\"112\" fill=\"none\" stroke=\"#b3241a\" strokeWidth=\"5\" strokeDasharray=\"211 1000\" transform=\"rotate(-225)\" />\n        {ticks.map((v) => (\n          <g key={v} transform={`rotate(${-ARC / 2 + (ARC * v) / 100})`}>\n            <rect x={v % 10 ? -0.7 : -1.2} y={-124} width={v % 10 ? 1.4 : 2.4} height={v % 10 ? 9 : 16} fill=\"#141210\" />\n            {v % 10 === 0 && <text y={-96} transform={`rotate(${ARC / 2 - (ARC * v) / 100} 0 -96)`} textAnchor=\"middle\" dominantBaseline=\"middle\" fontSize=\"14\" fontWeight=\"600\" fill=\"#141210\" style={{ fontFamily: FONT }}>{v}</text>}\n          </g>\n        ))}\n        <text y=\"46\" textAnchor=\"middle\" fontSize=\"8\" letterSpacing=\"2\" fontWeight=\"600\" fill=\"#141210\" style={{ fontFamily: FONT }}>{METRIC.toUpperCase()}</text>\n        <g transform={`rotate(${deg})`}>\n          <path d=\"M-1.6 22 L-0.5 -118 L0.5 -118 L1.6 22 Z\" fill=\"#9c120c\" />\n          <circle cy=\"22\" r=\"6\" fill=\"#9c120c\" />\n        </g>\n        <circle r=\"9\" fill=\"#cfcfcb\" stroke=\"#6b6b68\" />\n        <ellipse cx=\"-40\" cy=\"-60\" rx=\"95\" ry=\"55\" fill=\"url(#kpi-gauge-still-glass)\" transform=\"rotate(-30)\" />\n      </svg>\n    </div>\n  );\n}\n\nexport default function KpiGaugeCardOnSunlitDesk() {\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const readout = useRef<HTMLSpanElement>(null);\n  const radios = useRef<(HTMLButtonElement | null)[]>([]);\n  const [period, setPeriod] = useState(START);\n  const [shown, setShown] = useState<\"wait\" | \"gl\" | \"still\">(\"wait\");\n  const api = useRef<{ go: (i: number, fromUser: boolean) => void } | null>(null);\n  const periodRef = useRef(START);\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 s = {\n      v: periods[START].value, vel: 0, target: periods[START].value, shown: periods[START].value,\n      px: 0, py: 0, sx: 0, sy: 0, count: 0, fresh: true, frame: 0, slow: 0, visible: true, raf: 0, last: 0, t0: 0,\n      touched: false, demoAt: 0, first: true, sway: 0,\n    };\n    const setReadout = (v: number) => { if (readout.current) readout.current.textContent = String(Math.round(v)); };\n\n    const opts = { antialias: false, alpha: false, powerPreference: \"high-performance\" as const };\n    const gl2 = cv.getContext(\"webgl2\", opts) as WebGL2RenderingContext | null;\n    const gl = (gl2 ?? cv.getContext(\"webgl\", opts)) as WebGLRenderingContext | null;\n    const fallback = () => {\n      setShown(\"still\");\n      api.current = { go: (i) => { periodRef.current = i; setPeriod(i); setReadout(periods[i].value); } };\n    };\n    if (!gl) { fallback(); return; }\n    const canAcc = !!gl2 && (!!gl2.getExtension(\"EXT_color_buffer_float\") || !!gl2.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 calm = reduce || software;\n\n    const head = gl2 ? \"#version 300 es\\n#define ATTR in\\n#define texture2D texture\\n\" : \"#define ATTR attribute\\n\";\n    const fhead = gl2 ? \"#version 300 es\\n#define texture2D texture\\nprecision highp float;\\nout vec4 outC;\\n\" : \"#define outC gl_FragColor\\n\";\n    const compile = (type: number, src: string) => {\n      const sh = gl.createShader(type);\n      if (!sh) return null;\n      gl.shaderSource(sh, src); gl.compileShader(sh);\n      if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) { console.warn(gl.getShaderInfoLog(sh)); return null; }\n      return sh;\n    };\n    const link = (frag: string) => {\n      const v = compile(gl.VERTEX_SHADER, head + VERT), f = compile(gl.FRAGMENT_SHADER, fhead + frag);\n      const 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)) { fallback(); return; }\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    const su = Object.fromEntries([\"uRes\", \"uJit\", \"uSeed\", \"uAng\", \"uTgtAng\", \"uCam\", \"uTgt\", \"uFoc\", \"uShift\", \"uFocus\", \"uTex\", \"uDirect\", \"uSway\"].map((n) => [n, U(scene, n)]));\n    const pu = post ? Object.fromEntries([\"uAcc\", \"uRes\", \"uGrain\", \"uCentre\"].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    const tex = gl.createTexture();\n    gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, tex);\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, dialArt());\n    gl.generateMipmap(gl.TEXTURE_2D);\n    const aniso = gl.getExtension(\"EXT_texture_filter_anisotropic\");\n    if (aniso) gl.texParameterf(gl.TEXTURE_2D, aniso.TEXTURE_MAX_ANISOTROPY_EXT, 8);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\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 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.5, window.devicePixelRatio || 1) * scale;\n      const k = Math.min(1, Math.sqrt(1.4e6 / (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 (gl2 && acc && fbo) {\n        gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, acc);\n        gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16F, W, H, 0, gl.RGBA, gl2.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    const draw = (alpha: number, sample: number) => {\n      const wide = cssW >= 1024, aspect = cssW / cssH;\n      const el = 0.98 - s.sy * 0.04, az = 0.12 + s.sx * 0.06, dist = 9.3;\n      const tgt = [0, 0.18, 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 foc = 2.35 * Math.min(1, aspect / 0.95);\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 ? Math.sqrt(halton(sample, 7)) * 0.05 : 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.uAng, valueAngle(s.v)); gl.uniform1f(su.uTgtAng, valueAngle(TARGET));\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);\n      gl.uniform2f(su.uShift, wide ? 0.2 * aspect : 0, wide ? 0.0 : 0.17);\n      gl.uniform1f(su.uFocus, Math.hypot(cam[0], cam[1] - 0.3, cam[2]));\n      gl.uniform1i(su.uTex, 0);\n      gl.uniform1f(su.uDirect, canAcc ? 0 : 1);\n      gl.uniform1f(su.uSway, s.sway);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      if (canAcc && post) {\n        gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n        gl.disable(gl.BLEND);\n        gl.useProgram(post);\n        gl.uniform1i(pu.uAcc, 1); gl.uniform2f(pu.uRes, W, H);\n        gl.uniform1f(pu.uGrain, calm ? 1 : s.frame % 64);\n        gl.uniform2f(pu.uCentre, wide ? 0.7 : 0.5, wide ? 0.5 : 0.66);\n        gl.drawArrays(gl.TRIANGLES, 0, 3);\n      }\n    };\n\n    const go = (i: number, fromUser: boolean) => {\n      const k = (i + periods.length) % periods.length;\n      if (fromUser) s.touched = true;\n      s.target = periods[k].value;\n      if (k !== periodRef.current) { periodRef.current = k; setPeriod(k); }\n      if (reduce) { s.v = s.target; s.vel = 0; s.shown = s.target; setReadout(s.target); s.count = 0; s.fresh = true; }\n      wake();\n    };\n    api.current = { go };\n\n    const frame = (now: number) => {\n      s.raf = 0;\n      if (!s.visible) 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; s.demoAt = now + 4200; }\n      // self-running demo: opens settled on a reading, holds, then steps through the periods until touched\n      if (!calm && !s.touched && now > s.demoAt) { go(periodRef.current + 1, false); s.demoAt = now + 3400; }\n\n      let moving = false;\n      if (!reduce) {\n        // a damped second-order movement, like a moving-coil meter: it overshoots, rings twice and settles\n        const steps = 4, h = dt / steps;\n        for (let i = 0; i < steps; i++) {\n          const acc2 = OMEGA * OMEGA * (s.target - s.v) - 2 * ZETA * OMEGA * s.vel;\n          s.vel += acc2 * h; s.v += s.vel * h;\n        }\n        if (Math.abs(s.vel) > 0.02 || Math.abs(s.target - s.v) > 0.01) moving = true; else { s.v = s.target; s.vel = 0; }\n        // the printed number eases in critically damped, so it never reads a value past the real one\n        const ds = s.target - s.shown;\n        if (Math.abs(ds) > 0.02) { s.shown += ds * (1 - Math.exp(-dt * 5)); setReadout(s.shown); } else if (s.shown !== s.target) { s.shown = s.target; setReadout(s.target); }\n      }\n      if (!calm) {\n        s.sx += (s.px - s.sx) * (1 - Math.exp(-dt * 2.5)); s.sy += (s.py - s.sy) * (1 - Math.exp(-dt * 2.5));\n        if (Math.abs(s.px - s.sx) + Math.abs(s.py - s.sy) > 0.002) moving = true;\n      }\n\n      if (s.fresh || !canAcc) { draw(1, 0); s.fresh = false; s.count = 1; }\n      else if (moving) { draw(Math.abs(s.vel) > 6 ? 0.55 : 0.2, 1 + (s.frame % 64)); s.count = 4; }\n      else if (s.count < 48) { s.count++; draw(1 / s.count, s.count); }\n      if (s.first) { s.first = false; setShown(\"gl\"); }\n\n      if (!calm && dtRaw > 0.026) s.slow++; else s.slow = Math.max(0, s.slow - 2);\n      if (s.slow > 45 && scale > 0.5) { scale *= 0.82; s.slow = 0; size(); }\n\n      if (moving || s.count < 48 || (!calm && !s.touched)) s.raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!s.raf && s.visible) { s.last = 0; s.raf = requestAnimationFrame(frame); } };\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 move = (e: PointerEvent) => {\n      const r = box.getBoundingClientRect();\n      s.px = ((e.clientX - r.left) / r.width) * 2 - 1; s.py = ((e.clientY - r.top) / r.height) * 2 - 1;\n      if (!calm) wake();\n    };\n    const leave = () => { s.px = 0; s.py = 0; };\n    box.addEventListener(\"pointermove\", move);\n    box.addEventListener(\"pointerleave\", leave);\n    const lost = (e: Event) => { e.preventDefault(); fallback(); };\n    cv.addEventListener(\"webglcontextlost\", lost);\n    wake();\n\n    return () => {\n      cancelAnimationFrame(s.raf); ro.disconnect(); io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      box.removeEventListener(\"pointermove\", move); box.removeEventListener(\"pointerleave\", leave);\n      cv.removeEventListener(\"webglcontextlost\", lost);\n      api.current = null;\n    };\n  }, []);\n\n  const pick = (i: number) => {\n    if (api.current) api.current.go(i, true); else { periodRef.current = i; setPeriod(i); }\n  };\n  const onKey = (e: ReactKeyboardEvent<HTMLButtonElement>, i: number) => {\n    let k = i;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") k = (i + 1) % periods.length;\n    else if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\") k = (i - 1 + periods.length) % periods.length;\n    else if (e.key === \"Home\") k = 0;\n    else if (e.key === \"End\") k = periods.length - 1;\n    else return;\n    e.preventDefault();\n    pick(k);\n    radios.current[k]?.focus();\n  };\n\n  const p = periods[period];\n  const up = p.delta >= 0;\n\n  return (\n    <section className=\"relative isolate overflow-hidden bg-[#2a1a10] text-[#1d140d]\" style={{ fontFamily: FONT }}>\n      <div ref={stage} className=\"relative mx-auto h-[760px] w-full max-w-[1600px]\" style={{ background: \"radial-gradient(80% 70% at 66% 45%, #a0683a 0%, #6b4223 55%, #3a2414 100%)\" }}>\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        {shown === \"still\" && (\n          <>\n            <div aria-hidden=\"true\" className=\"absolute inset-0\" style={{ background: \"repeating-linear-gradient(118deg, transparent 0 210px, rgba(30,12,2,0.35) 210px 226px), linear-gradient(28deg, transparent 0 55%, rgba(25,10,2,0.45) 55%)\" }} />\n            <Still value={p.value} />\n          </>\n        )}\n\n        <div className=\"pointer-events-none absolute inset-0 flex flex-col justify-end px-5 pb-7 sm:px-10 lg:justify-center lg:px-16 lg:pb-0\">\n          <div className=\"pointer-events-auto w-full max-w-[25rem] rounded-[28px] bg-[#f5ecdc]/[0.93] p-6 shadow-[0_30px_60px_-20px_rgba(30,14,4,0.6),0_2px_0_rgba(255,255,255,0.6)_inset] ring-1 ring-black/5 backdrop-blur-md sm:p-8\">\n            <div className=\"flex items-center justify-between gap-3\">\n              <h2 className=\"text-[13px] font-semibold uppercase tracking-[0.2em] text-[#5b4636]\">{METRIC}</h2>\n              <span className=\"rounded-full border border-[#7a5c45]/40 px-2.5 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[#5b4636]\">Demo data</span>\n            </div>\n            <p className=\"mt-5 flex items-start leading-none sm:mt-6\">\n              <span ref={readout} className=\"text-[104px] font-semibold tabular-nums tracking-[-0.06em] text-[#1d140d] sm:text-[132px]\" style={{ lineHeight: 0.82 }}>{p.value}</span>\n              <span className=\"ml-1 mt-2 text-[40px] text-[#5b4636] sm:text-[48px]\" style={{ fontFamily: SERIF }}>{UNIT}</span>\n            </p>\n            <p aria-live=\"polite\" className=\"mt-4 text-[18px] leading-snug text-[#4a3829] sm:text-[20px]\" style={{ fontFamily: SERIF }}>\n              <span className=\"sr-only\">{METRIC} {p.long}: {p.value} percent. </span>\n              <span className={`font-semibold not-italic ${up ? \"text-[#2f6b3a]\" : \"text-[#9c1f14]\"}`} style={{ fontFamily: FONT }}>{up ? \"Up\" : \"Down\"} {Math.abs(p.delta)} pts</span>{\" \"}\n              <span className=\"italic\">on {p.against}. Target {TARGET}{UNIT}.</span>\n            </p>\n            <div role=\"radiogroup\" aria-label=\"Period\" className=\"mt-6 grid grid-cols-4 gap-1 rounded-full bg-[#e4d6bf] p-1 sm:mt-7\">\n              {periods.map((pr, i) => (\n                <button\n                  key={pr.label}\n                  ref={(el) => { radios.current[i] = el; }}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={i === period}\n                  tabIndex={i === period ? 0 : -1}\n                  onClick={() => pick(i)}\n                  onKeyDown={(e) => onKey(e, i)}\n                  className={`h-11 rounded-full text-[13px] font-medium outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-[#9c1f14] focus-visible:ring-offset-2 focus-visible:ring-offset-[#e4d6bf] ${i === period ? \"bg-[#1d140d] text-[#f5ecdc]\" : \"text-[#4a3829] hover:bg-[#d6c5aa]\"}`}\n                >\n                  {pr.label}\n                </button>\n              ))}\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
