{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ray-marched-aluminium-publish-key-on-a-blue-lit-plinth-that-strikes-a-lightbox-model-of-the-page-from-draft-to-live","type":"registry:block","title":"Ray Marched Aluminium Publish Key on a Blue Lit Plinth That Strikes a Lightbox Model of the Page from Draft to Live","description":"Free React and WebGL publish toggle. One heavy aluminium key on a blue lit plinth sends light down a floor channel and strikes a lightbox page from draft to live.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/ray-marched-aluminium-publish-key-on-a-blue-lit-plinth-that-strikes-a-lightbox-model-of-the-page-from-draft-to-live.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\n\n/** The page that the model shows once it is live. Change the words here. */\nconst SITE = {\n  brand: \"Slow Kiln\",\n  nav: [\"Shop\", \"Studio\", \"Visit\"],\n  headline: [\"Thrown by hand,\", \"fired slow.\"],\n  sub: \"Small batch stoneware from a harbour studio, glazed in quiet colours and fired once a week.\",\n  cta: \"Shop the batch\",\n  foot: \"Whitby, Yorkshire\",\n};\nconst PHOTO = {\n  src: \"https://images.pexels.com/photos/8479191/pexels-photo-8479191.jpeg?auto=compress&cs=tinysrgb&w=900\",\n  alt: \"Pale crackle glazed ceramic vase lit from one side against a black background\",\n  tone: \"#17191c\",\n};\n/** The two states, as the words shown beside the key. */\nconst STATES = {\n  draft: { word: \"Draft\", line: \"Only you can see this page.\", action: \"Publish\" },\n  live: { word: \"Live\", line: \"Anyone with the address can visit.\", action: \"Back to draft\" },\n};\n\nconst BLUE = \"#4F98FB\";\nconst INK = \"#0B0D12\";\nconst PAPER = \"#F6F4EF\";\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\n/** Seconds the self-playing demo holds the live page, and the draft, before pressing the key again. */\nconst HOLD_LIVE = 6.5;\nconst HOLD_DRAFT = 2.3;\n/** How far down the key stays once the page is live, as a share of its full travel. */\nconst LATCH = 0.46;\n/** Lowest and highest render scale (canvas pixels per CSS pixel). The loop steps down when frames run slow. */\nconst MIN_SCALE = 0.6001;\nconst MAX_SCALE = 1.5001;\n\n/* ---------- canvas drawings, used as textures ---------- */\n\ntype Ctx = CanvasRenderingContext2D;\nconst setFont = (c: Ctx, weight: number, size: number, track = 0) => {\n  c.font = `${weight} ${size}px ${FONT}`;\n  (c as unknown as { letterSpacing: string }).letterSpacing = `${(track * size).toFixed(2)}px`;\n};\nfunction wrap(c: Ctx, text: string, maxW: number): string[] {\n  const out: string[] = [];\n  let line = \"\";\n  for (const word of text.split(\" \")) {\n    const next = line ? line + \" \" + word : word;\n    if (line && c.measureText(next).width > maxW) {\n      out.push(line);\n      line = word;\n    } else line = next;\n  }\n  out.push(line);\n  return out;\n}\nfunction pill(c: Ctx, x: number, y: number, w: number, h: number, r: number) {\n  c.beginPath();\n  c.moveTo(x + r, y);\n  c.arcTo(x + w, y, x + w, y + h, r);\n  c.arcTo(x + w, y + h, x, y + h, r);\n  c.arcTo(x, y + h, x, y, r);\n  c.arcTo(x, y, x + w, y, r);\n  c.closePath();\n}\n\n/** The published page, as printed on the film inside the lightbox. 2048 x 1536. */\nfunction drawLive(c: Ctx, img: HTMLImageElement | null) {\n  c.fillStyle = PAPER;\n  c.fillRect(0, 0, 2048, 1536);\n  c.textBaseline = \"alphabetic\";\n  // menu bar\n  c.fillStyle = INK;\n  pill(c, 84, 76, 1880, 132, 66);\n  c.fill();\n  c.fillStyle = \"#fff\";\n  setFont(c, 800, 58, -0.02);\n  c.fillText(SITE.brand, 148, 163);\n  setFont(c, 500, 44, 0);\n  let x = 1900;\n  for (const item of [...SITE.nav].reverse()) {\n    x -= c.measureText(item).width;\n    c.fillText(item, x, 158);\n    x -= 70;\n  }\n  // photograph\n  const px = 1296, py = 290, pw = 668, ph = 1010;\n  c.save();\n  pill(c, px, py, pw, ph, 40);\n  c.clip();\n  c.fillStyle = PHOTO.tone;\n  c.fillRect(px, py, pw, ph);\n  if (img && img.naturalWidth) {\n    const s = Math.max(pw / img.naturalWidth, ph / img.naturalHeight);\n    const w = img.naturalWidth * s, h = img.naturalHeight * s;\n    try {\n      c.filter = \"grayscale(1) contrast(1.08) brightness(1.12)\";\n    } catch {\n      /* colour is fine too */\n    }\n    c.drawImage(img, px + (pw - w) / 2, py + (ph - h) / 2, w, h);\n    c.filter = \"none\";\n  } else {\n    const g = c.createRadialGradient(px + 300, py + 600, 20, px + 300, py + 600, 520);\n    g.addColorStop(0, \"#c9ccd0\");\n    g.addColorStop(0.45, \"#5d6066\");\n    g.addColorStop(1, PHOTO.tone);\n    c.fillStyle = g;\n    c.fillRect(px, py, pw, ph);\n  }\n  c.restore();\n  // headline\n  c.fillStyle = INK;\n  let size = 176;\n  for (; size > 80; size -= 4) {\n    setFont(c, 800, size, -0.05);\n    if (Math.max(...SITE.headline.map((l) => c.measureText(l).width)) < 1130) break;\n  }\n  SITE.headline.forEach((l, i) => c.fillText(l, 100, 470 + size * 0.36 + i * size * 0.95));\n  // small print\n  c.fillStyle = \"#3d4149\";\n  setFont(c, 500, 50, -0.012);\n  wrap(c, SITE.sub, 980).slice(0, 3).forEach((l, i) => c.fillText(l, 106, 880 + i * 68));\n  // button\n  c.fillStyle = BLUE;\n  pill(c, 104, 1126, 560, 150, 75);\n  c.fill();\n  c.fillStyle = \"#fff\";\n  setFont(c, 700, 56, -0.015);\n  const lw = c.measureText(SITE.cta).width;\n  const sx = 104 + (560 - lw - 74) / 2;\n  c.fillText(SITE.cta, sx, 1220);\n  c.lineWidth = 7;\n  c.lineCap = \"round\";\n  c.lineJoin = \"round\";\n  c.strokeStyle = \"#fff\";\n  const ax = sx + lw + 28;\n  c.beginPath();\n  c.moveTo(ax, 1201);\n  c.lineTo(ax + 44, 1201);\n  c.moveTo(ax + 26, 1183);\n  c.lineTo(ax + 44, 1201);\n  c.lineTo(ax + 26, 1219);\n  c.stroke();\n  // foot\n  c.fillStyle = \"rgba(11,13,18,0.16)\";\n  c.fillRect(104, 1404, 1860, 3);\n  c.fillStyle = \"#7d8088\";\n  setFont(c, 600, 26, 0.14);\n  c.fillText(SITE.foot.toUpperCase(), 104, 1462);\n  const right = SITE.brand.toUpperCase();\n  c.fillText(right, 1964 - c.measureText(right).width, 1462);\n}\n\n/** The same page before it is published: a pencil plan of blocks on dark film. 1024 x 768. */\nfunction drawDraft(c: Ctx) {\n  c.fillStyle = \"#23262c\";\n  c.fillRect(0, 0, 1024, 768);\n  const line = \"#7c818b\";\n  const fill = \"#343841\";\n  c.strokeStyle = line;\n  c.lineWidth = 2.5;\n  c.setLineDash([10, 9]);\n  c.fillStyle = fill;\n  pill(c, 42, 38, 940, 66, 33);\n  c.fill();\n  c.stroke();\n  pill(c, 648, 145, 334, 505, 20);\n  c.fill();\n  c.stroke();\n  c.beginPath();\n  c.moveTo(660, 157);\n  c.lineTo(970, 638);\n  c.moveTo(970, 157);\n  c.lineTo(660, 638);\n  c.stroke();\n  pill(c, 52, 563, 280, 75, 37.5);\n  c.fill();\n  c.stroke();\n  c.setLineDash([]);\n  c.fillStyle = \"#5b606a\";\n  pill(c, 52, 222, 520, 62, 10);\n  c.fill();\n  pill(c, 52, 304, 400, 62, 10);\n  c.fill();\n  c.fillStyle = \"#454a54\";\n  for (let i = 0; i < 3; i++) {\n    pill(c, 53, 432 + i * 34, [470, 490, 300][i], 14, 7);\n    c.fill();\n  }\n  c.fillStyle = \"#4a4f59\";\n  pill(c, 72, 62, 110, 18, 9);\n  c.fill();\n  for (let i = 0; i < 3; i++) {\n    pill(c, 720 + i * 82, 64, 58, 14, 7);\n    c.fill();\n  }\n  c.fillStyle = line;\n  c.fillRect(52, 702, 930, 1.5);\n  c.textBaseline = \"alphabetic\";\n  setFont(c, 600, 15, 0.2);\n  c.fillText(\"DRAFT\", 52, 734);\n  const t = \"NOT PUBLISHED\";\n  c.fillText(t, 982 - c.measureText(t).width, 734);\n}\n\n/** Plan view of the key from above, 1.3 units across: red is the white paint in the engraving, green is the arrow cut through the cap. */\nfunction drawMarks(c: Ctx) {\n  const S = 2048, u = S / 1.3;\n  c.fillStyle = \"#000\";\n  c.fillRect(0, 0, S, S);\n  c.translate(S / 2, S / 2);\n  c.textBaseline = \"middle\";\n  c.fillStyle = \"#f00\";\n  setFont(c, 700, 0.052 * u, 0.2);\n  const z = 0.533 * u;\n  const d = \"DRAFT\";\n  c.fillText(d, -0.125 * u - c.measureText(d).width, z);\n  c.fillText(\"LIVE\", 0.135 * u, z);\n  setFont(c, 600, 0.036 * u, 0.34);\n  const p = \"PUBLISH\";\n  c.fillText(p, -c.measureText(p).width / 2 + 0.006 * u, -z);\n  // arrow\n  c.strokeStyle = \"#0f0\";\n  c.lineWidth = 0.05 * u;\n  c.lineCap = \"round\";\n  c.lineJoin = \"round\";\n  c.beginPath();\n  c.moveTo(0, 0.15 * u);\n  c.lineTo(0, -0.15 * u);\n  c.moveTo(-0.125 * u, -0.03 * u);\n  c.lineTo(0, -0.155 * u);\n  c.lineTo(0.125 * u, -0.03 * u);\n  c.stroke();\n}\n\n/* ---------- shaders ---------- */\n\nconst VERT = `#version 300 es\nin vec2 a; out vec2 vUv;\nvoid main(){ vUv = a * 0.5 + 0.5; gl_Position = vec4(a, 0.0, 1.0); }`;\n\nconst SCENE = `#version 300 es\nprecision highp float;\nin vec2 vUv; out vec4 o;\nuniform vec2 uRes;\nuniform vec3 uCam, uTarget;\nuniform float uFov, uTime;\nuniform vec4 uPos;    // key x, z and model x, z on the floor\nuniform float uYaw;   // turn of the model\nuniform float uPress; // travel of the key, 0 up to 1 on its stop\nuniform float uGlow;  // blue light under the key\nuniform float uInk;   // how far the printed page has replaced the plan, bottom to top\nuniform float uLit;   // lamps inside the lightbox\nuniform vec4 uSeg;    // the light channel in the floor: from x, z to x, z\nuniform vec4 uChan;   // pulse position, pulse strength, how far the channel is filled, light under the model\nuniform vec4 uPip;    // the two indicator lamps on the collar, then radius and strength of the ring on the floor\nuniform sampler2D uLive, uDraft, uMarks;\n\nconst vec3 BLUE = vec3(0.078, 0.314, 0.965);\nconst vec3 ALU = vec3(0.91, 0.918, 0.925);\nconst vec3 KEY = vec3(-0.21, 0.86, 0.465);\nconst vec3 KEYC = vec3(1.0, 0.975, 0.94);\nconst float PT = 0.38, CT = 0.50, MS = 0.84;\n\nfloat gCy, gSy, gCl, gSl, gPix, gDist;\nvec3 gPageC, gPageN, gKeyC;\n\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), 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 n1(float x){ float i = floor(x), f = fract(x); f = f * f * (3.0 - 2.0 * f); return mix(h21(vec2(i, 3.7)), h21(vec2(i + 1.0, 3.7)), f); }\n\nfloat rb2(vec2 p, vec2 h, float r){ vec2 d = abs(p) - h + r; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r; }\nfloat ext(float d2, float y, float h, float bev){ vec2 w = vec2(d2, abs(y) - h) + bev; return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - bev; }\n\nvec3 toKey(vec3 p){ return p - vec3(uPos.x, 0.0, uPos.y); }\nvec3 toBase(vec3 p){ p -= vec3(uPos.z, 0.0, uPos.w); p.xz = vec2(gCy * p.x - gSy * p.z, gSy * p.x + gCy * p.z); return p / MS; }\nvec3 toBox(vec3 q){ q.y -= 0.11; q.yz = vec2(gCl * q.y - gSl * q.z, gSl * q.y + gCl * q.z); return q; }\nvec3 dirBox(vec3 d){ d.xz = vec2(gCy * d.x - gSy * d.z, gSy * d.x + gCy * d.z); d.yz = vec2(gCl * d.y - gSl * d.z, gSl * d.y + gCl * d.z); return d; }\nvec3 boxToWorld(vec3 q){\n  q.yz = vec2(gCl * q.y + gSl * q.z, -gSl * q.y + gCl * q.z); q.y += 0.11;\n  q.xz = vec2(gCy * q.x + gSy * q.z, -gSy * q.x + gCy * q.z);\n  return q * MS + vec3(uPos.z, 0.0, uPos.w);\n}\n\nfloat capTop(){ return CT + 0.19 - uPress * 0.15; }\nfloat sdPlinth(vec3 p){\n  float body = ext(rb2(p.xz, vec2(0.8), 0.15), p.y - 0.215, 0.165, 0.03);\n  float foot = ext(rb2(p.xz, vec2(0.72), 0.09), p.y - 0.03, 0.03, 0.0);\n  return min(body, foot);\n}\nfloat sdCollar(vec3 p){\n  float d2 = rb2(p.xz, vec2(0.62), 0.17);\n  float d = max(d2, abs(p.y - (PT + CT) * 0.5) - (CT - PT) * 0.5);\n  d = max(d, (d2 + p.y - CT + 0.03) * 0.7071);\n  float w2 = rb2(p.xz, vec2(0.47), 0.13) - clamp(p.y - (CT - 0.02), 0.0, 0.03);\n  return max(d, -max(w2, PT + 0.03 - p.y));\n}\nfloat sdCap(vec3 p){\n  float top = capTop();\n  float d = ext(rb2(p.xz, vec2(0.42), 0.11), p.y - (top - 0.22), 0.22, 0.032);\n  return max(d, 2.3 - length(p - vec3(0.0, top + 2.3 - 0.03, 0.0)));\n}\nfloat sdBase(vec3 q){\n  float body = ext(rb2(q.xz - vec2(0.0, -0.04), vec2(1.2, 0.34), 0.07), q.y - 0.09, 0.05, 0.026);\n  float foot = ext(rb2(q.xz - vec2(0.0, -0.04), vec2(1.04, 0.18), 0.04), q.y - 0.02, 0.02, 0.0);\n  return min(body, foot);\n}\nfloat sdBox(vec3 r){\n  vec2 c = r.xy - vec2(0.0, 0.82);\n  return ext(rb2(c, vec2(1.07, 0.82), 0.075), r.z, 0.085, 0.028);\n}\n\nvec2 map(vec3 p){\n  vec2 r = vec2(1e5, 0.0);\n  vec3 k = toKey(p);\n  float bk = length(k - vec3(0.0, 0.3, 0.0)) - 1.3;\n  if (bk < 0.25){\n    r = vec2(sdPlinth(k), 1.0);\n    float d = sdCollar(k); if (d < r.x) r = vec2(d, 2.0);\n    d = sdCap(k); if (d < r.x) r = vec2(d, 3.0);\n  } else r.x = bk;\n  vec3 q = toBase(p);\n  float bp = (length(q - vec3(0.0, 0.85, -0.12)) - 1.6) * MS;\n  if (bp < 0.25){\n    float d = sdBase(q) * MS; if (d < r.x) r = vec2(d, 4.0);\n    d = sdBox(toBox(q)) * MS; if (d < r.x) r = vec2(d, 5.0);\n  } else if (bp < r.x) r = vec2(bp, 0.0);\n  return r;\n}\nvec3 normal(vec3 p){\n  vec2 e = vec2(1.0, -1.0) * 0.0011;\n  return normalize(e.xyy * map(p + e.xyy).x + e.yyx * map(p + e.yyx).x + e.yxy * map(p + e.yxy).x + e.xxx * map(p + e.xxx).x);\n}\nvec2 march(vec3 ro, vec3 rd, int steps, float far){\n  float t = 0.0; vec2 h = vec2(0.0);\n  for (int i = 0; i < 120; i++){\n    if (i >= steps) break;\n    h = map(ro + rd * t);\n    if (h.x < 0.0005 * (1.0 + t * 0.3) || t > far) break;\n    t += h.x * 0.9;\n  }\n  return vec2(t, (t > far || h.x > 0.02) ? 0.0 : h.y);\n}\nfloat shadow(vec3 ro, vec3 rd){\n  float res = 1.0, t = 0.02;\n  for (int i = 0; i < 26; i++){\n    vec2 m = map(ro + rd * t); float h = m.x;\n    if (m.y > 0.5) res = min(res, 5.5 * h / t);\n    t += clamp(h, 0.014, 0.3);\n    if (res < 0.004 || t > 5.0) break;\n  }\n  res = clamp(res, 0.0, 1.0);\n  return res * res * (3.0 - 2.0 * res);\n}\nfloat occ(vec3 p, vec3 n){\n  float o = 0.0, s = 1.0;\n  for (int i = 0; i < 5; i++){\n    float h = 0.012 + 0.1 * float(i) / 4.0;\n    o += (h - map(p + n * h).x) * s;\n    s *= 0.8;\n  }\n  return clamp(1.0 - 3.4 * o, 0.0, 1.0);\n}\n\n// The studio: softboxes as rectangles, with edges that soften as the surface that mirrors them gets rougher.\nfloat gGrade;\nfloat rectL(vec3 ro, vec3 rd, vec3 c, vec3 n, vec2 hs, float soft){\n  float dn = dot(rd, n); if (dn > -1e-4) return 0.0;\n  float t = dot(c - ro, n) / dn; if (t < 0.0) return 0.0;\n  vec3 q = ro + rd * t - c; float s = soft * t + 0.02;\n  vec3 u = normalize(cross(vec3(0.0, 1.0, 0.0), n)), v = cross(n, u);\n  vec2 d = abs(vec2(dot(q, u), dot(q, v))) - hs;\n  float cloth = 1.0 - 0.45 * clamp(length(vec2(dot(q, u), dot(q, v)) / hs), 0.0, 1.4);\n  gGrade = smoothstep(-hs.y - s, hs.y, dot(q, v));\n  return smoothstep(s, -s, d.x) * smoothstep(s, -s, d.y) * cloth;\n}\nvec3 env(vec3 ro, vec3 rd, float rough){\n  float soft = 0.03 + rough * 0.8;\n  vec3 c = mix(vec3(0.008, 0.009, 0.012), vec3(0.03, 0.033, 0.042), smoothstep(-0.1, 0.9, rd.y));\n  c += vec3(1.0, 0.975, 0.94) * 6.0 * rectL(ro, rd, vec3(-1.8, 7.8, 4.2), normalize(vec3(2.0, -7.4, -4.2)), vec2(3.2, 1.9), soft);\n  c += vec3(0.9, 0.94, 1.0) * 4.6 * rectL(ro, rd, vec3(8.0, 3.2, -2.6), normalize(vec3(-8.0, -2.6, 2.6)), vec2(0.8, 2.8), soft);\n  c += vec3(0.86, 0.92, 1.0) * 1.6 * rectL(ro, rd, vec3(-8.5, 2.4, -0.5), normalize(vec3(8.5, -1.8, 0.5)), vec2(1.3, 2.2), soft);\n  // the scrim behind the set is graded: bright along its top edge, nearly out at the bottom\n  float back = rectL(ro, rd, vec3(0.6, 5.8, -6.9), normalize(vec3(-0.3, -5.2, 6.9)), vec2(4.6, 1.9), soft);\n  c += vec3(0.92, 0.96, 1.0) * back * (0.14 + 2.0 * gGrade * gGrade);\n  c += vec3(0.3, 0.315, 0.345) * smoothstep(0.08, 1.0, rd.y) * (0.25 + 0.75 * smoothstep(0.7, -0.8, rd.z));\n  return c;\n}\nvec3 envF(vec3 ro, vec3 rd, float rough){\n  if (rd.y >= 0.0) return env(ro, rd, rough);\n  float t = -ro.y / rd.y;\n  float f = 0.06 + 0.94 * pow(1.0 - clamp(-rd.y, 0.0, 1.0), 5.0);\n  return vec3(0.006, 0.0065, 0.008) + f * env(ro + rd * t, vec3(rd.x, -rd.y, rd.z), rough + 0.04);\n}\nvec3 fres(vec3 f0, float c){ return f0 + (1.0 - f0) * pow(1.0 - clamp(c, 0.0, 1.0), 5.0); }\nvec3 aniso(vec3 p, vec3 rd, vec3 n, vec3 b, float spread, float rough){\n  vec3 c = vec3(0.0); float w = 0.0;\n  for (int i = -3; i <= 3; i++){ float f = float(i) / 3.0; float g = exp(-2.4 * f * f); c += g * envF(p, reflect(rd, normalize(n + b * f * spread)), rough); w += g; }\n  return c / w;\n}\n// White light thrown by the lit page onto whatever faces it.\nfloat pageLight(vec3 p, vec3 n){\n  vec3 l = gPageC - p; float d2 = dot(l, l); l *= inversesqrt(d2);\n  return uLit * 2.3 * max(dot(n, l), 0.0) * max(dot(gPageN, -l), 0.0) / (0.5 + d2 * 0.5);\n}\nfloat lodOf(float texels){ return clamp(log2(gDist * gPix * texels), 0.0, 7.0); }\n\nvec3 shade(vec3 p, vec3 n, float id, vec3 rd, bool hq){\n  float sh = 1.0, ao = 1.0;\n  if (hq){ sh = shadow(p + n * 0.006, KEY); ao = occ(p, n); }\n  vec3 keyL = KEYC * max(dot(n, KEY), 0.0) * sh * 1.5;\n  vec3 amb = vec3(0.07, 0.076, 0.09) * ao * (0.6 + 0.4 * n.y);\n  float pl = pageLight(p, n);\n  vec3 r = reflect(rd, n);\n  float nv = max(dot(n, -rd), 0.0);\n  float so = 0.35 + 0.65 * ao;\n  vec3 col;\n  if (id < 1.5 || (id > 3.5 && id < 4.5)){\n    // plinth and base: bead-blasted black anodising\n    vec3 l = id < 1.5 ? toKey(p) : toBase(p);\n    float g = n2(l.xz * 60.0 + l.y * 41.0);\n    float f = 0.045 + 0.955 * pow(1.0 - nv, 5.0);\n    vec2 cell = floor(l.xz * 41.0); float hs = h21(cell + id);\n    vec2 cp = (cell + 0.2 + 0.6 * vec2(h21(cell + 3.1), h21(cell + 7.7))) / 41.0;\n    float dust = step(id, 1.5) * step(0.985, hs) * smoothstep(0.003 + 0.004 * h21(cell + 1.3), 0.0, length(l.xz - cp)) * step(0.9, n.y);\n    float smear = n2(l.xz * 3.1 + 7.0) * n2(l.xz * 7.3);\n    col = (vec3(0.016, 0.017, 0.021) * (0.94 + 0.12 * g) + dust * 0.4) * (keyL + amb + pl) + envF(p, r, 0.16 + 0.03 * g + 0.14 * smear) * f * so;\n    // light from underneath bounces off the floor and up the sides\n    col += BLUE * (id < 1.5 ? uGlow : uChan.w) * 0.16 * exp(-max(l.y - 0.05, 0.0) * 13.0) * (1.0 - abs(n.y));\n    if (l.y < (id < 1.5 ? 0.0505 : 0.0405)) col = BLUE * (id < 1.5 ? uGlow : uChan.w) * 3.5 + vec3(1.0) * (id < 1.5 ? uGlow : uChan.w) * 0.4;\n    return col;\n  }\n  if (id < 2.5){\n    vec3 k = toKey(p);\n    float w2 = rb2(k.xz, vec2(0.47), 0.13);\n    float hgt = k.y - (PT + 0.03);\n    if (w2 < 0.006 && hgt < 0.006) return (BLUE * 5.5 + 0.12) * uGlow; // the diffuser at the bottom of the gap\n    if (w2 < 0.04 && n.y < 0.6){\n      // wall of the well, washed by the light below it\n      col = fres(ALU, nv) * envF(p, r, 0.22) * so;\n      return col * 0.5 + BLUE * 1.5 * uGlow * exp(-max(hgt, 0.0) * 17.0) * ALU;\n    }\n    if (n.y > 0.9){\n      // top face, brushed front to back, with paint-filled engraving and two lamps\n      vec3 nn = normalize(n + vec3(1.0, 0.0, 0.0) * ((n1(k.x * 520.0) - 0.5) * 0.05 + (n1(k.x * 130.0 + 5.0) - 0.5) * 0.03));\n      col = fres(ALU, nv) * (aniso(p, rd, nn, vec3(0.0, 0.0, 1.0), 0.34, 0.1) * so * (0.86 + 0.14 * n1(k.x * 260.0 + 9.0)) + 0.07 * (keyL + pl));\n      float ink = textureLod(uMarks, k.xz / 1.3 + 0.5, lodOf(1575.0)).r;\n      col = mix(col, vec3(0.012, 0.013, 0.016) * (keyL + amb) + envF(p, r, 0.3) * 0.04, ink * 0.96);\n      vec2 pd = vec2(abs(k.x) - 0.066, k.z - 0.533);\n      float pip = smoothstep(0.019, 0.015, length(pd));\n      float lev = k.x < 0.0 ? uPip.x : uPip.y;\n      vec3 lamp = k.x < 0.0 ? vec3(0.8, 0.83, 0.9) * 1.3 : BLUE * 7.0 + 0.12;\n      col = mix(col, vec3(0.01) + lamp * lev, pip);\n      col += (k.x < 0.0 ? vec3(0.05) : BLUE * 0.5) * lev * exp(-length(pd) * 26.0) * (1.0 - pip);\n      // four socket screws hold the collar down\n      float sd = length(abs(k.xz) - 0.506);\n      if (sd < 0.04){\n        vec2 hx = abs(k.xz - sign(k.xz) * 0.506);\n        float hex = max(hx.x * 0.866 + hx.y * 0.5, hx.y) - 0.014;\n        vec3 head = fres(ALU, nv) * envF(p, reflect(rd, normalize(n + vec3(k.x, 0.0, k.z) * 0.0 + vec3(hx.x, 0.0, hx.y) * 2.5 * sign(k.x))), 0.05) * so;\n        col = mix(col, head * 0.9, smoothstep(0.03, 0.028, sd));\n        col *= 1.0 - 0.75 * smoothstep(0.036, 0.031, sd) * smoothstep(0.026, 0.03, sd);\n        col = mix(col, vec3(0.004), smoothstep(0.002, -0.001, hex));\n      }\n      // light creeping over the lip of the well\n      col += BLUE * uGlow * 0.5 * exp(-max(w2 - 0.03, 0.0) * 34.0);\n      return col;\n    }\n    if (abs(n.y) < 0.25){\n      vec3 nn = normalize(n + vec3(0.0, 1.0, 0.0) * (n1(k.y * 700.0) - 0.5) * 0.05);\n      return fres(ALU, nv) * (aniso(p, rd, nn, vec3(0.0, 1.0, 0.0), 0.3, 0.1) * so + 0.07 * (keyL + pl));\n    }\n    return fres(ALU, nv) * (envF(p, r, 0.035) * so + 0.05 * (keyL + pl)); // diamond-cut chamfers\n  }\n  if (id < 3.5){\n    vec3 k = toKey(p);\n    float rr = length(k.xz); vec3 rdir = vec3(k.x, 0.0, k.z) / max(rr, 1e-4);\n    float dish = smoothstep(0.372, 0.36, rr) * step(0.55, n.y);\n    if (n.y > 0.55){\n      // the dish is faced on a lathe, the flat round it is brushed straight\n      vec3 bit = mix(vec3(0.0, 0.0, 1.0), rdir, dish);\n      vec3 gr = mix(vec3(1.0, 0.0, 0.0) * ((n1(k.x * 430.0) - 0.5) * 0.035 + (n1(k.x * 90.0 + 2.0) - 0.5) * 0.02), rdir * ((n1(rr * 420.0) - 0.5) * 0.05 + (n1(rr * 95.0 + 4.0) - 0.5) * 0.03), dish);\n      vec3 nn = normalize(n + gr);\n      col = fres(ALU, nv) * (aniso(p, rd, nn, bit, mix(0.2, 0.36, dish), mix(0.09, 0.05, dish)) * so * (0.88 + 0.12 * n1(rr * 180.0 + 1.0)) + 0.05 * (keyL + pl + amb));\n      // the cutter leaves a bright lip where the dish meets the flat\n      float lip = smoothstep(0.012, 0.0, abs(rr - 0.366));\n      col = mix(col, fres(ALU, nv) * envF(p, reflect(rd, normalize(n - rdir * 0.55)), 0.04), lip * 0.85);\n    } else col = fres(ALU, nv) * (envF(p, r, 0.05) * so + 0.05 * (keyL + pl + amb));\n    float hgt = k.y - (PT + 0.03);\n    if (n.y > 0.55){\n      // the arrow is a light pipe let into the metal: brightest down its middle, with a dark cut edge\n      float ar = textureLod(uMarks, k.xz / 1.3 + 0.5, lodOf(1575.0)).g;\n      float soft = textureLod(uMarks, k.xz / 1.3 + 0.5, 4.6).g;\n      float core = smoothstep(0.45, 0.95, soft);\n      col *= 1.0 - 0.6 * smoothstep(0.02, 0.4, soft) * (1.0 - ar);\n      vec3 lens = vec3(0.2, 0.26, 0.4) * (keyL + amb) * 0.3 + BLUE * (0.45 + 1.1 * uGlow + 3.4 * uGlow * core) + vec3(1.0) * 1.7 * uGlow * core * core;\n      col += BLUE * uGlow * 0.55 * soft * (1.0 - ar);\n      col = mix(col, lens, ar);\n    } else {\n      col += BLUE * 1.5 * uGlow * exp(-max(hgt, 0.0) * 12.0) * smoothstep(0.5, -0.2, n.y) * ALU;\n    }\n    return col;\n  }\n  // the lightbox\n  vec3 q = toBox(toBase(p)), nq = dirBox(n);\n  vec2 c = q.xy - vec2(0.0, 0.82);\n  float fd = rb2(c, vec2(1.0, 0.75), 0.03), aa = gDist * gPix * 1.2;\n  float film = smoothstep(aa, -aa, fd) * step(0.07, q.z);\n  vec3 filmC = vec3(0.0);\n  if (film > 0.0){\n    float vt = (c.y + 0.75) / 1.5;\n    vec2 uv = vec2(c.x * 0.5 + 0.5, 1.0 - vt);\n    float lv = smoothstep(0.0, 0.012, uInk * 1.06 - vt);\n    vec3 live = pow(textureLod(uLive, uv, lodOf(1024.0)).rgb, vec3(2.2));\n    vec3 draft = pow(textureLod(uDraft, uv, lodOf(512.0)).rgb, vec3(2.2));\n    vec3 alb = mix(draft, live * 0.42, lv);\n    float f = 0.04 + 0.96 * pow(1.0 - nv, 5.0);\n    col = alb * (keyL * 0.8 + amb * 1.4) + envF(p, r, 0.05) * f;\n    // opal acrylic over edge lamps: a touch brighter toward the frame, and never perfectly even\n    float even = 0.9 + 0.1 * smoothstep(0.45, 0.0, min(1.0 - abs(c.x), 0.75 - abs(c.y))) + 0.02 * n2(c * 3.0);\n    col += live * lv * uLit * 2.1 * even;\n    if (uInk > 0.002 && uInk < 0.998){\n      float d = uInk * 1.06 - vt;\n      col += (BLUE * 6.0 + 1.4) * exp(-abs(d) * 130.0) + BLUE * 0.9 * exp(-max(d, 0.0) * 9.0) * step(0.0, d);\n    }\n    if (film > 0.999) return col;\n    filmC = col;\n  }\n  // frame: dark titanium grey, satin, with a polished edge\n  float edge = 1.0 - smoothstep(0.8, 0.97, max(abs(nq.z), max(abs(nq.x), abs(nq.y))));\n  vec3 bw = normalize(boxToWorld(vec3(1.0, 0.0, 0.0)) - boxToWorld(vec3(0.0)));\n  vec3 nn = normalize(n + bw * (n1(q.x * 150.0) - 0.5) * 0.03 * (1.0 - edge));\n  col = fres(ALU, nv) * (mix(aniso(p, rd, nn, normalize(cross(n, bw)), 0.3, 0.1), envF(p, r, 0.09), edge) * so + 0.07 * (keyL + pl));\n  // the rebate round the film catches the page's own light\n  // a black gasket holds the film in the frame, and catches a little of the page's light\n  float gasket = smoothstep(0.016 + aa, 0.016 - aa, fd) * step(0.07, q.z);\n  col = mix(col, vec3(0.006, 0.0065, 0.008) + vec3(0.9, 0.92, 1.0) * uLit * 0.07 * smoothstep(0.016, 0.0, fd), gasket);\n  return mix(col, filmC, film);\n}\n\nvec3 backdrop(vec3 rd){\n  return mix(vec3(0.03, 0.034, 0.045), vec3(0.0035, 0.004, 0.0055), smoothstep(0.0, 0.42, rd.y));\n}\n\nvec3 floorShade(vec3 p, vec3 rd, float t){\n  vec3 n = normalize(vec3((n2(p.xz * 0.9) - 0.5) * 0.004, 1.0, (n2(p.zx * 0.9 + 5.0) - 0.5) * 0.004));\n  float near = step(t, 26.0);\n  float sh = 1.0, ao = 1.0;\n  vec3 k = toKey(p), q = toBase(p);\n  float dK = rb2(k.xz, vec2(0.8), 0.15), dP = rb2(q.xz - vec2(0.0, -0.04), vec2(1.2, 0.34), 0.07) * MS;\n  if (near > 0.5){\n    sh = shadow(p + vec3(0.0, 0.006, 0.0), KEY);\n    ao = clamp(0.25 + 0.75 * min(smoothstep(-0.06, 0.5, dK), smoothstep(-0.06, 0.4, dP)), 0.0, 1.0);\n  }\n  vec2 cc = p.xz - 0.5 * (uPos.xy + uPos.zw);\n  float pool = 1.0 / (1.0 + dot(cc, cc) * 0.055); pool *= pool;\n  vec3 alb = vec3(0.05, 0.052, 0.06) * (0.9 + 0.2 * n2(p.xz * 2.2));\n  // dust on the floor that catches the key light\n  vec2 cell = floor(p.xz * 23.0); float hs = h21(cell);\n  vec2 cp = (cell + 0.2 + 0.6 * vec2(h21(cell + 3.1), h21(cell + 7.7))) / 23.0;\n  alb += step(0.993, hs) * smoothstep(0.004 + 0.006 * h21(cell + 1.3), 0.0, length(p.xz - cp)) * 0.3;\n  vec3 col = alb * (KEYC * KEY.y * sh * pool * 1.5 + vec3(0.05) * ao + pageLight(p, n) * ao);\n  // the mirror\n  vec3 rr = reflect(rd, n);\n  float f = 0.055 + 0.945 * pow(1.0 - max(dot(n, -rd), 0.0), 5.0);\n  vec3 rc = env(p, rr, 0.3) * 0.2 * (0.4 + 0.6 * ao);\n  if (near > 0.5){\n    vec3 rp = p + vec3(0.0, 0.004, 0.0);\n    vec2 rh = march(rp, rr, 56, 12.0);\n    if (rh.y > 0.5){\n      vec3 hp = rp + rr * rh.x;\n      gDist = t + rh.x;\n      rc = shade(hp, normal(hp), rh.y, rr, false) * exp(-rh.x * 0.7);\n    }\n  }\n  col += rc * f * (0.9 + 0.1 * n2(p.xz * 1.3 + 3.0));\n  // blue light leaking from under the plinth, and under the model once the channel is lit\n  float oK = max(dK, 0.0), oP = max(dP, 0.0);\n  col += BLUE * uGlow * (0.34 * exp(-oK * 11.0) + 0.06 * exp(-oK * 2.6)) * step(0.0, dK + 0.1);\n  col += BLUE * uChan.w * (0.26 * exp(-oP * 11.0) + 0.04 * exp(-oP * 2.6)) * step(0.0, dP + 0.1);\n  // the thump when the key lands: a ring of light running out across the floor\n  col += BLUE * uPip.w * (0.5 * exp(-pow((oK - uPip.z) * 8.0, 2.0)) + 0.07 * exp(-pow((oK - uPip.z) * 2.6, 2.0))) * step(0.0, dK);\n  // the channel let into the floor\n  vec2 a = uSeg.xy, b = uSeg.zw, ab = b - a;\n  float s = clamp(dot(p.xz - a, ab) / dot(ab, ab), 0.0, 1.0);\n  float d = length(p.xz - a - ab * s);\n  float core = smoothstep(0.02, 0.011, d);\n  float level = smoothstep(0.0, 0.03, uChan.z - s) * (0.75 + 0.25 * sin(s * 40.0 - uTime * 2.4)) + uChan.y * exp(-pow((s - uChan.x) * 6.5, 2.0)) * 3.0;\n  col = mix(col, vec3(0.004), core * 0.85);\n  col += (BLUE * (0.035 + 4.5 * level) + vec3(1.0) * level * 0.9) * core + BLUE * level * 0.22 * exp(-d * 13.0);\n  return mix(col, backdrop(vec3(rd.x, 0.0, rd.z)), smoothstep(8.0, 30.0, t));\n}\n\nvec3 aces(vec3 x){ return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); }\n\nvoid main(){\n  gCy = cos(uYaw); gSy = sin(uYaw); gCl = cos(0.2); gSl = sin(0.2);\n  gPageC = boxToWorld(vec3(0.0, 0.82, 0.09));\n  gPageN = normalize(boxToWorld(vec3(0.0, 0.82, 1.08)) - gPageC);\n  gKeyC = vec3(uPos.x, PT + 0.06, uPos.y);\n  gPix = 2.0 * tan(uFov * 0.5) / uRes.y;\n  vec2 uv = (gl_FragCoord.xy - 0.5 * uRes) / uRes.y;\n  vec3 fw = normalize(uTarget - uCam), rgt = normalize(cross(fw, vec3(0.0, 1.0, 0.0))), up = cross(rgt, fw);\n  vec3 rd = normalize(fw + (uv.x * rgt + uv.y * up) * 2.0 * tan(uFov * 0.5));\n  vec3 ro = uCam;\n  float tf = rd.y < -1e-4 ? -ro.y / rd.y : 1e5;\n  vec2 hit = march(ro, rd, 120, min(tf, 40.0));\n  float t; vec3 col;\n  if (hit.y > 0.5 && hit.x < tf){\n    t = hit.x; vec3 p = ro + rd * t; gDist = t;\n    col = shade(p, normal(p), hit.y, rd, true);\n  } else if (tf < 1e4){\n    t = tf; col = floorShade(ro + rd * tf, rd, tf);\n  } else { t = 40.0; col = backdrop(rd); }\n  // light in the air above the key and in front of the page\n  float tc = clamp(dot(gKeyC - ro, rd), 0.0, t);\n  float dm = length(ro + rd * tc - gKeyC);\n  col += BLUE * uGlow * 0.006 / (0.1 + dm * dm * 2.2);\n  vec3 pc = gPageC + gPageN * 0.5;\n  tc = clamp(dot(pc - ro, rd), 0.0, t);\n  dm = length(ro + rd * tc - pc);\n  col += vec3(0.85, 0.9, 1.0) * uLit * 0.01 / (0.25 + dm * dm);\n  float mx = max(col.r, max(col.g, col.b));\n  col = mix(col * (aces(vec3(mx)).r / max(mx, 0.0001)), aces(col), 0.14);\n  col = pow(col, vec3(1.0 / 2.2));\n  o = vec4(col, clamp(t / 24.0, 0.0, 1.0));\n}`;\n\nconst POST = `#version 300 es\nprecision highp float;\nin vec2 vUv; out vec4 o;\nuniform sampler2D uSrc;\nuniform vec2 uRes;\nuniform float uFocus, uTime;\nfloat hash(vec2 p){ return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }\nvoid main(){\n  vec4 c0 = texture(uSrc, vUv);\n  float z = c0.a * 24.0;\n  {\n    vec2 e = 1.0 / uRes; vec3 L = vec3(0.299, 0.587, 0.114);\n    float nw = dot(textureLod(uSrc, vUv + vec2(-e.x, -e.y), 0.0).rgb, L), ne = dot(textureLod(uSrc, vUv + vec2(e.x, -e.y), 0.0).rgb, L);\n    float sw = dot(textureLod(uSrc, vUv + vec2(-e.x, e.y), 0.0).rgb, L), se = dot(textureLod(uSrc, vUv + e, 0.0).rgb, L), lm = dot(c0.rgb, L);\n    float lo = min(lm, min(min(nw, ne), min(sw, se))), hi = max(lm, max(max(nw, ne), max(sw, se)));\n    vec2 dir = vec2(-((nw + ne) - (sw + se)), (nw + sw) - (ne + se));\n    float rcp = 1.0 / (min(abs(dir.x), abs(dir.y)) + max((nw + ne + sw + se) * 0.03125, 0.0078));\n    dir = clamp(dir * rcp, -8.0, 8.0) * e;\n    vec3 a = 0.5 * (textureLod(uSrc, vUv + dir * (1.0 / 3.0 - 0.5), 0.0).rgb + textureLod(uSrc, vUv + dir * (2.0 / 3.0 - 0.5), 0.0).rgb);\n    vec3 b = a * 0.5 + 0.25 * (textureLod(uSrc, vUv - dir * 0.5, 0.0).rgb + textureLod(uSrc, vUv + dir * 0.5, 0.0).rgb);\n    float lb = dot(b, L);\n    c0.rgb = (lb < lo || lb > hi) ? a : b;\n  }\n  float px = uRes.y / 720.0;\n  float coc = clamp(abs(z - uFocus) / max(z, 0.1) * (z < uFocus ? 7.0 : 5.0) - 0.9, 0.0, 6.0) * px;\n  vec3 acc = c0.rgb; float ws = 1.0;\n  float j = hash(gl_FragCoord.xy) * 6.283;\n  float lod = log2(max(coc / 3.0, 1.0));\n  for (int i = 0; i < 14; i++){\n    float fi = (float(i) + 0.5) / 14.0;\n    float a = float(i) * 2.39996 + j;\n    vec2 off = vec2(cos(a), sin(a)) * sqrt(fi) * coc / uRes;\n    vec4 s = textureLod(uSrc, vUv + off, lod);\n    float w = 1.0 + 5.0 * pow(max(s.r, max(s.g, s.b)), 6.0);\n    acc += s.rgb * w; ws += w;\n  }\n  vec3 col = acc / ws;\n  vec3 bl = textureLod(uSrc, vUv, 3.0).rgb * 0.35 + textureLod(uSrc, vUv, 4.5).rgb * 0.35 + textureLod(uSrc, vUv, 6.0).rgb * 0.3;\n  col += bl * bl * 0.11;\n  vec2 v = vUv - 0.5;\n  col *= 1.0 - dot(v, v) * 0.8;\n  col = mix(col, col * col * (3.0 - 2.0 * col), 0.3);\n  float g = hash(gl_FragCoord.xy + fract(uTime) * 91.7) - 0.5;\n  col += g * 0.026 * (1.0 - 0.5 * col);\n  o = vec4(col, 1.0);\n}`;\n\n/* ---------- small motion helpers ---------- */\n\ntype Spring = { x: number; v: number; t: number; k: number; c: number };\nconst spring = (x: number, k: number, c: number): Spring => ({ x, v: 0, t: x, k, c });\nconst stepSpring = (s: Spring, dt: number) => {\n  s.v += (-s.k * (s.x - s.t) - s.c * s.v) * dt;\n  s.x += s.v * dt;\n};\n\nexport default function PublishKeyLightboxPage() {\n  const reduce = useReducedMotion();\n  const [live, setLive] = useState(true);\n  const [ready, setReady] = useState(false);\n  const rootRef = useRef<HTMLElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const hitRef = useRef<HTMLDivElement>(null);\n  // The render loop owns the scene. React talks to it through this handle.\n  const api = useRef<{ toggle: () => void; hold: (down: boolean) => void } | null>(null);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const canvas = canvasRef.current;\n    if (!root || !canvas) return;\n    const gl = canvas.getContext(\"webgl2\", { antialias: false, alpha: false, powerPreference: \"high-performance\" });\n    if (!gl) return;\n\n    const compile = (type: number, src: string) => {\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      return s;\n    };\n    const link = (fs: string) => {\n      const p = gl.createProgram()!;\n      gl.attachShader(p, compile(gl.VERTEX_SHADER, VERT));\n      gl.attachShader(p, compile(gl.FRAGMENT_SHADER, fs));\n      gl.bindAttribLocation(p, 0, \"a\");\n      gl.linkProgram(p);\n      if (!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(p) || \"link\");\n      return p;\n    };\n    let scene: WebGLProgram;\n    let post: WebGLProgram;\n    try {\n      scene = link(SCENE);\n      post = link(POST);\n    } catch (e) {\n      console.error(e);\n      return;\n    }\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    const su = Object.fromEntries([\"uRes\", \"uCam\", \"uTarget\", \"uFov\", \"uTime\", \"uPos\", \"uYaw\", \"uPress\", \"uGlow\", \"uInk\", \"uLit\", \"uSeg\", \"uChan\", \"uPip\", \"uLive\", \"uDraft\", \"uMarks\"].map((n) => [n, U(scene, n)]));\n    const pu = Object.fromEntries([\"uSrc\", \"uRes\", \"uFocus\", \"uTime\"].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);\n    gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n\n    const aniso = gl.getExtension(\"EXT_texture_filter_anisotropic\");\n    const makeTex = () => {\n      const t = gl.createTexture()!;\n      gl.bindTexture(gl.TEXTURE_2D, t);\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      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      if (aniso) gl.texParameterf(gl.TEXTURE_2D, aniso.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(8, gl.getParameter(aniso.MAX_TEXTURE_MAX_ANISOTROPY_EXT)));\n      return t;\n    };\n    const upload = (t: WebGLTexture, src: HTMLCanvasElement) => {\n      gl.bindTexture(gl.TEXTURE_2D, t);\n      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, src);\n      gl.generateMipmap(gl.TEXTURE_2D);\n    };\n    const mk = (w: number, h: number) => {\n      const c = document.createElement(\"canvas\");\n      c.width = w;\n      c.height = h;\n      return [c, c.getContext(\"2d\")!] as const;\n    };\n    const liveTex = makeTex();\n    const draftTex = makeTex();\n    const marksTex = makeTex();\n    let dirty = true;\n    const paintLive = (img: HTMLImageElement | null) => {\n      const [cv, cx] = mk(2048, 1536);\n      drawLive(cx, img);\n      try {\n        upload(liveTex, cv);\n      } catch {\n        // a photograph that may not be read back: print the page with the plain study instead\n        const [c2, x2] = mk(2048, 1536);\n        drawLive(x2, null);\n        upload(liveTex, c2);\n      }\n      dirty = true;\n    };\n    paintLive(null);\n    {\n      const [cv, cx] = mk(1024, 768);\n      drawDraft(cx);\n      upload(draftTex, cv);\n      const [mv, mx] = mk(2048, 2048);\n      drawMarks(mx);\n      upload(marksTex, mv);\n    }\n    const photo = new Image();\n    photo.crossOrigin = \"anonymous\";\n    photo.decoding = \"async\";\n    photo.onload = () => paintLive(photo);\n    photo.src = PHOTO.src;\n\n    // the moving parts\n    const press = spring(LATCH, 420, 22);\n    const glow = spring(1, 200, 20);\n    const lit = spring(1, 150, 13);\n    const push = spring(0, 60, 9);\n    const under = spring(1, 60, 14);\n    const pip = spring(1, 90, 16);\n    const ink = { x: 1, t: 1, rate: 2 };\n    const fill = { x: 1, t: 1, rate: 2 };\n    const pulse = { x: 2, on: false };\n    const ring = { r: 0, s: 0 };\n    const cam = { ax: 0, ay: 0, tx: 0, ty: 0 };\n    let isLive = true;\n    let held = false;\n    let flicker: { at: number; v: number }[] = [];\n    let demo = !reduce;\n    let clock = 0;\n    let time = 0;\n    let idleAt = 4.2;\n    let wake = Infinity;\n    let cues: { at: number; fn: () => void }[] = [];\n    const at = (delay: number, fn: () => void) => {\n      cues.push({ at: clock + delay, fn });\n      cues.sort((a, b) => a.at - b.at);\n    };\n\n    const settle = (on: boolean) => {\n      cues = [];\n      flicker = [];\n      const set = (s: Spring, v: number) => ((s.x = s.t = v), (s.v = 0));\n      set(press, on ? LATCH : 0);\n      set(glow, on ? 1 : 0.42);\n      set(lit, on ? 1 : 0);\n      set(under, on ? 1 : 0);\n      set(pip, on ? 1 : 0);\n      ink.x = ink.t = fill.x = fill.t = on ? 1 : 0;\n      pulse.on = false;\n      ring.s = 0;\n      dirty = true;\n    };\n    /** The key has reached its stop: run what follows from it. */\n    const strike = (on: boolean) => {\n      isLive = on;\n      cues = [];\n      flicker = [];\n      push.v += 2.2;\n      ring.r = 0;\n      ring.s = on ? 1 : 0.45;\n      if (on) {\n        glow.t = 2.6;\n        pip.t = 1;\n        pulse.x = 0;\n        pulse.on = true;\n        fill.t = 1;\n        fill.rate = 1 / 0.5;\n        at(0.1, () => {\n          press.k = 520;\n          press.c = 17;\n          press.t = held ? 1 : LATCH;\n        });\n        at(0.22, () => (glow.t = 1));\n        at(0.5, () => {\n          under.t = 1;\n          ink.t = 1;\n          ink.rate = 1 / 0.5;\n        });\n        at(1.04, () => {\n          // the lamps catch, drop out, catch again and hold\n          flicker = [\n            { at: clock, v: 0.7 },\n            { at: clock + 0.05, v: 0.04 },\n            { at: clock + 0.13, v: 0.95 },\n            { at: clock + 0.18, v: 0.16 },\n            { at: clock + 0.25, v: 1.25 },\n          ];\n          setLive(true);\n        });\n        at(1.32, () => {\n          flicker = [];\n          lit.t = 1;\n        });\n      } else {\n        glow.t = 0.42;\n        pip.t = 0;\n        lit.k = 520;\n        lit.c = 46;\n        lit.t = 0;\n        setLive(false);\n        at(0.09, () => {\n          press.k = 300;\n          press.c = 13;\n          press.t = held ? 1 : 0;\n        });\n        at(0.12, () => {\n          ink.t = 0;\n          ink.rate = 1 / 0.38;\n          fill.t = 0;\n          fill.rate = 1 / 0.45;\n          under.t = 0;\n        });\n        at(0.7, () => {\n          lit.k = 150;\n          lit.c = 13;\n        });\n      }\n    };\n    const toggle = () => {\n      const next = !isLive;\n      if (reduce) {\n        isLive = next;\n        setLive(next);\n        settle(next);\n        return;\n      }\n      press.k = 620;\n      press.c = 30;\n      press.t = 1;\n      cues = [];\n      at(0.11, () => strike(next));\n    };\n    const quiet = () => {\n      demo = false;\n      idleAt = Infinity;\n      wake = clock + 14;\n    };\n    api.current = {\n      toggle: () => {\n        quiet();\n        toggle();\n        kick();\n      },\n      hold: (down) => {\n        if (reduce) {\n          if (!down) {\n            isLive = !isLive;\n            setLive(isLive);\n            settle(isLive);\n            kick();\n          }\n          return;\n        }\n        quiet();\n        held = down;\n        if (down) {\n          press.k = 620;\n          press.c = 30;\n          press.t = 1;\n        } else strike(!isLive);\n        kick();\n      },\n    };\n\n    // render target\n    const fbo = gl.createFramebuffer();\n    const fbTex = gl.createTexture()!;\n    gl.bindTexture(gl.TEXTURE_2D, fbTex);\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    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    let scale = Math.min(MAX_SCALE, Math.max(1, window.devicePixelRatio || 1));\n    let cssW = 1;\n    let cssH = 1;\n    let phone = false;\n    let bw = 0;\n    let bh = 0;\n    const resize = () => {\n      const r = canvas.getBoundingClientRect();\n      cssW = Math.max(1, r.width);\n      cssH = Math.max(1, r.height);\n      phone = cssW < 768;\n      // never more than about 1.9 million pixels through the ray marcher\n      const s = Math.min(scale, Math.sqrt(1.9e6 / (cssW * cssH)));\n      const w = Math.round(cssW * s);\n      const h = Math.round(cssH * s);\n      if (w !== bw || h !== bh) {\n        bw = w;\n        bh = h;\n        canvas.width = w;\n        canvas.height = h;\n        gl.bindTexture(gl.TEXTURE_2D, fbTex);\n        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n        gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fbTex, 0);\n      }\n      dirty = true;\n    };\n    resize();\n\n    let hitKey = \"\";\n    const draw = () => {\n      const wide = cssW / cssH;\n      // where things stand, and where the camera is\n      const key = phone ? [0.25, 1.35] : [-0.1, 0.9];\n      const model = phone ? [-0.1, -1.45] : [2.1, -1.15];\n      const yaw = phone ? 0.1 : -0.34;\n      const tgt = phone ? [0.05, 0.85, -0.1] : [0.2, 0.62, 0.1];\n      const az = (phone ? 0.12 : -0.2) + cam.ax * 0.1 + Math.sin(time * 0.21) * 0.018;\n      const el = (phone ? 0.5 : 0.4) - cam.ay * 0.05 + Math.sin(time * 0.29 + 1) * 0.007;\n      const fov = phone ? 0.5 : 0.4;\n      const dist = (phone ? 12.0 : 7.6 * Math.max(1, 1.6 / wide)) * (1 - 0.012 * push.x);\n      const camPos = [tgt[0] + dist * Math.sin(az) * Math.cos(el), tgt[1] + dist * Math.sin(el), tgt[2] + dist * Math.cos(az) * Math.cos(el)];\n      // the channel runs from the edge of the plinth to the edge of the model's base\n      const dx = model[0] - key[0];\n      const dz = model[1] - key[1];\n      const len = Math.hypot(dx, dz);\n      const ux = dx / len;\n      const uz = dz / len;\n      const seg = [key[0] + ux * 0.76, key[1] + uz * 0.76, model[0] - ux * 0.42, model[1] - uz * 0.42];\n      const breathe = reduce ? 0 : 1;\n      const rest = 1 - Math.min(1, pip.x);\n\n      gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n      gl.viewport(0, 0, bw, bh);\n      gl.useProgram(scene);\n      gl.uniform2f(su.uRes, bw, bh);\n      gl.uniform3f(su.uCam, camPos[0], camPos[1], camPos[2]);\n      gl.uniform3f(su.uTarget, tgt[0], tgt[1], tgt[2]);\n      gl.uniform1f(su.uFov, fov);\n      gl.uniform1f(su.uTime, time);\n      gl.uniform4f(su.uPos, key[0], key[1], model[0], model[1]);\n      gl.uniform1f(su.uYaw, yaw);\n      gl.uniform1f(su.uPress, Math.max(-0.12, Math.min(1.06, press.x)));\n      gl.uniform1f(su.uGlow, Math.max(0, glow.x) * (1 + (0.04 + 0.3 * rest) * Math.sin(time * 1.9) * breathe));\n      gl.uniform1f(su.uInk, ink.x);\n      gl.uniform1f(su.uLit, Math.max(0, lit.x) * (1 + 0.012 * Math.sin(time * 9.0) * breathe));\n      gl.uniform4f(su.uSeg, seg[0], seg[1], seg[2], seg[3]);\n      gl.uniform4f(su.uChan, pulse.x, pulse.on ? 1 : 0, fill.x * 1.04, Math.max(0, under.x));\n      gl.uniform4f(su.uPip, rest, Math.max(0, pip.x), ring.r, ring.s);\n      gl.activeTexture(gl.TEXTURE0);\n      gl.bindTexture(gl.TEXTURE_2D, liveTex);\n      gl.uniform1i(su.uLive, 0);\n      gl.activeTexture(gl.TEXTURE1);\n      gl.bindTexture(gl.TEXTURE_2D, draftTex);\n      gl.uniform1i(su.uDraft, 1);\n      gl.activeTexture(gl.TEXTURE2);\n      gl.bindTexture(gl.TEXTURE_2D, marksTex);\n      gl.uniform1i(su.uMarks, 2);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.viewport(0, 0, bw, bh);\n      gl.useProgram(post);\n      gl.activeTexture(gl.TEXTURE0);\n      gl.bindTexture(gl.TEXTURE_2D, fbTex);\n      gl.generateMipmap(gl.TEXTURE_2D);\n      gl.uniform1i(pu.uSrc, 0);\n      gl.uniform2f(pu.uRes, bw, bh);\n      const f = [key[0] + 0.5 * ux - camPos[0], 0.7 - camPos[1], key[1] + 0.5 * uz - camPos[2]];\n      gl.uniform1f(pu.uFocus, Math.hypot(f[0], f[1], f[2]));\n      gl.uniform1f(pu.uTime, reduce ? 0 : time);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n      // keep the pointer target over the key\n      const hit = hitRef.current;\n      if (hit) {\n        const fw = [tgt[0] - camPos[0], tgt[1] - camPos[1], tgt[2] - camPos[2]];\n        const fl = Math.hypot(fw[0], fw[1], fw[2]);\n        fw[0] /= fl; fw[1] /= fl; fw[2] /= fl;\n        const rg = [-fw[2], 0, fw[0]];\n        const rl = Math.hypot(rg[0], rg[2]);\n        rg[0] /= rl; rg[2] /= rl;\n        const up = [rg[1] * fw[2] - rg[2] * fw[1], rg[2] * fw[0] - rg[0] * fw[2], rg[0] * fw[1] - rg[1] * fw[0]];\n        const v = [key[0] - camPos[0], 0.55 - camPos[1], key[1] - camPos[2]];\n        const depth = v[0] * fw[0] + v[1] * fw[1] + v[2] * fw[2];\n        const k = cssH / (depth * 2 * Math.tan(fov / 2));\n        const x = cssW / 2 + (v[0] * rg[0] + v[2] * rg[2]) * k;\n        const y = cssH / 2 - (v[0] * up[0] + v[1] * up[1] + v[2] * up[2]) * k;\n        const next = `${Math.round(x)}|${Math.round(y)}|${Math.round(1.5 * k)}`;\n        if (next !== hitKey) {\n          hitKey = next;\n          hit.style.left = `${x}px`;\n          hit.style.top = `${y}px`;\n          hit.style.width = `${1.5 * k}px`;\n          hit.style.height = `${1.15 * k}px`;\n        }\n      }\n    };\n\n    let raf = 0;\n    let last = 0;\n    let onScreen = true;\n    let slow = 0;\n    let first = true;\n    const frame = (now: number) => {\n      raf = 0;\n      const raw = last ? (now - last) / 1000 : 0.016;\n      last = now;\n      const dt = Math.min(raw, 0.1);\n      if (reduce) {\n        if (dirty) {\n          dirty = false;\n          draw();\n        }\n      } else {\n        clock += dt;\n        time += dt;\n        while (cues.length && cues[0].at <= clock) cues.shift()!.fn();\n        if (clock > wake) {\n          wake = Infinity;\n          demo = true;\n          idleAt = clock + 1.5;\n        }\n        if (demo && clock > idleAt) {\n          toggle();\n          idleAt = clock + (isLive ? HOLD_DRAFT : HOLD_LIVE + 1.4);\n        }\n        for (let n = 0; n < 4; n++) {\n          const h = dt / 4;\n          stepSpring(press, h);\n          stepSpring(glow, h);\n          stepSpring(lit, h);\n          stepSpring(push, h);\n          stepSpring(under, h);\n          stepSpring(pip, h);\n        }\n        // the key lands on a rubber stop\n        if (press.x > 1.04) {\n          press.x = 1.04;\n          press.v *= -0.3;\n        }\n        if (flicker.length) {\n          let v = lit.x;\n          for (const f of flicker) if (clock >= f.at) v = f.v;\n          lit.x = v;\n          lit.v = 0;\n        }\n        ink.x += Math.sign(ink.t - ink.x) * Math.min(Math.abs(ink.t - ink.x), dt * ink.rate);\n        fill.x += Math.sign(fill.t - fill.x) * Math.min(Math.abs(fill.t - fill.x), dt * fill.rate);\n        if (ring.s > 0.001) {\n          ring.r += dt * (3.4 - ring.r * 0.9);\n          ring.s *= Math.exp(-dt * 3.6);\n        } else ring.s = 0;\n        if (pulse.on) {\n          pulse.x += dt / 0.5;\n          if (pulse.x > 1.5) pulse.on = false;\n        }\n        const kc = 1 - Math.exp(-dt * 3.2);\n        cam.ax += (cam.tx - cam.ax) * kc;\n        cam.ay += (cam.ty - cam.ay) * kc;\n        draw();\n        // step the resolution down if this machine cannot hold the frame rate\n        if (raw > 0.03) slow++;\n        else slow = Math.max(0, slow - 1);\n        if (slow > 24 && scale > MIN_SCALE) {\n          scale = Math.max(MIN_SCALE, scale * 0.84);\n          slow = 0;\n          resize();\n        }\n      }\n      if (first) {\n        first = false;\n        setReady(true);\n      }\n      if (onScreen && !document.hidden && (!reduce || dirty)) raf = requestAnimationFrame(frame);\n    };\n    function kick() {\n      if (!raf && onScreen && !document.hidden) {\n        last = 0;\n        raf = requestAnimationFrame(frame);\n      }\n    }\n    const io = new IntersectionObserver(([e]) => {\n      onScreen = e.isIntersecting;\n      kick();\n    });\n    io.observe(root);\n    const ro = new ResizeObserver(() => {\n      resize();\n      kick();\n    });\n    ro.observe(canvas);\n    const onVis = () => kick();\n    document.addEventListener(\"visibilitychange\", onVis);\n    const onMove = (e: PointerEvent) => {\n      if (reduce) return;\n      const r = root.getBoundingClientRect();\n      cam.tx = Math.max(-1, Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1));\n      cam.ty = Math.max(-1, Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1));\n    };\n    const onLeave = () => {\n      cam.tx = 0;\n      cam.ty = 0;\n    };\n    root.addEventListener(\"pointermove\", onMove);\n    root.addEventListener(\"pointerleave\", onLeave);\n    const onLost = (e: Event) => {\n      e.preventDefault();\n      setReady(false);\n      cancelAnimationFrame(raf);\n      api.current = null;\n    };\n    canvas.addEventListener(\"webglcontextlost\", onLost);\n    const photoKick = () => kick();\n    photo.addEventListener(\"load\", photoKick);\n    kick();\n\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      ro.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVis);\n      root.removeEventListener(\"pointermove\", onMove);\n      root.removeEventListener(\"pointerleave\", onLeave);\n      canvas.removeEventListener(\"webglcontextlost\", onLost);\n      photo.removeEventListener(\"load\", photoKick);\n      photo.onload = null;\n      api.current = null;\n      [liveTex, draftTex, marksTex, fbTex].forEach((t) => gl.deleteTexture(t));\n      gl.deleteFramebuffer(fbo);\n      gl.deleteBuffer(quad);\n      gl.deleteProgram(scene);\n      gl.deleteProgram(post);\n    };\n  }, [reduce]);\n\n  const press = () => {\n    if (api.current) api.current.toggle();\n    else setLive((v) => !v);\n  };\n  const state = live ? STATES.live : STATES.draft;\n  const ease = [0.2, 0.9, 0.2, 1] as const;\n\n  return (\n    <section ref={rootRef} className=\"relative isolate h-[680px] w-full overflow-hidden md:h-[740px]\" style={{ backgroundColor: INK, fontFamily: FONT }}>\n      <style>{`\n        @keyframes publish-key-lightbox-page-breathe { 0%, 100% { opacity: .7 } 50% { opacity: 1 } }\n        .publish-key-lightbox-page-glow { animation: publish-key-lightbox-page-breathe 3.3s ease-in-out infinite }\n        @media (prefers-reduced-motion: reduce) { .publish-key-lightbox-page-glow { animation: none } }\n      `}</style>\n\n      {/* The still: the same picture built from elements. Shown before the renderer starts and wherever it cannot run. */}\n      <div className={`absolute inset-0 transition-opacity duration-700 ${ready ? \"opacity-0\" : \"opacity-100\"}`} style={{ background: \"radial-gradient(80% 60% at 62% 60%, #1b1e26 0%, #0f1117 48%, #0B0D12 100%)\" }}>\n        {/* the model of the page */}\n        <div className=\"absolute left-1/2 top-[29%] w-[250px] -translate-x-1/2 md:left-[72%] md:top-[15%] md:w-[400px]\" style={{ perspective: \"1400px\" }}>\n          <div className=\"relative rounded-[18px] p-[9px] transition-shadow duration-500\" style={{ aspectRatio: \"4 / 3.08\", transform: \"rotateY(-17deg) rotateX(7deg)\", background: \"linear-gradient(160deg, #5b5f68 0%, #2a2d34 30%, #17191e 100%)\", boxShadow: live ? \"0 0 0 1px rgba(255,255,255,0.08) inset, 0 50px 80px -30px rgba(0,0,0,0.9), 0 0 120px 10px rgba(226,234,255,0.22)\" : \"0 0 0 1px rgba(255,255,255,0.08) inset, 0 50px 80px -30px rgba(0,0,0,0.9)\" }}>\n            {live ? (\n              <div className=\"relative h-full w-full overflow-hidden rounded-[10px]\" style={{ backgroundColor: PAPER, boxShadow: \"inset 0 0 30px rgba(255,255,255,0.9)\" }}>\n                <div className=\"absolute inset-x-[4%] top-[5%] flex h-[9%] items-center justify-between rounded-full px-[4%] text-white\" style={{ backgroundColor: INK }}>\n                  <span className=\"text-[10px] font-extrabold tracking-tight md:text-[11px]\">{SITE.brand}</span>\n                  <span className=\"flex gap-2.5 text-[8px] font-medium text-white/85 md:text-[9px]\">\n                    {SITE.nav.map((n) => (\n                      <span key={n}>{n}</span>\n                    ))}\n                  </span>\n                </div>\n                <h3 className=\"absolute left-[5%] top-[27%] w-[58%] text-[15px] font-extrabold leading-[0.95] tracking-[-0.05em] md:text-[23px]\" style={{ color: INK }}>\n                  {SITE.headline.map((l) => (\n                    <span key={l} className=\"block whitespace-nowrap\">\n                      {l}\n                    </span>\n                  ))}\n                </h3>\n                <p className=\"absolute left-[5%] top-[50%] w-[52%] text-[6.5px] font-medium leading-snug text-slate-600 md:top-[54%] md:w-[50%] md:text-[9px]\">{SITE.sub}</p>\n                <div className=\"absolute right-[4%] top-[19%] h-[66%] w-[33%] overflow-hidden rounded-[8px]\" style={{ backgroundColor: PHOTO.tone }}>\n                  <img src={PHOTO.src} alt={PHOTO.alt} width={334} height={505} className=\"h-full w-full object-cover grayscale\" />\n                </div>\n                <div className=\"absolute left-[5%] top-[73.5%] flex h-[10%] w-[28%] items-center justify-center rounded-full text-[6.5px] font-bold text-white md:text-[9px]\" style={{ backgroundColor: BLUE }}>\n                  {SITE.cta}\n                </div>\n                <div className=\"absolute inset-x-[5%] bottom-[4%] flex justify-between border-t border-slate-900/15 pt-[1.5%] text-[6px] font-semibold uppercase tracking-[0.14em] text-slate-500\">\n                  <span>{SITE.foot}</span>\n                  <span>{SITE.brand}</span>\n                </div>\n              </div>\n            ) : (\n              <div className=\"relative h-full w-full overflow-hidden rounded-[10px] bg-[#23262c]\">\n                <div className=\"absolute inset-x-[4%] top-[5%] h-[9%] rounded-full border border-dashed border-[#7c818b] bg-[#343841]\" />\n                <div className=\"absolute left-[5%] top-[29%] h-[8%] w-[50%] rounded bg-[#5b606a]\" />\n                <div className=\"absolute left-[5%] top-[40%] h-[8%] w-[39%] rounded bg-[#5b606a]\" />\n                <div className=\"absolute left-[5%] top-[56%] h-[2%] w-[46%] rounded bg-[#454a54]\" />\n                <div className=\"absolute left-[5%] top-[61%] h-[2%] w-[48%] rounded bg-[#454a54]\" />\n                <div className=\"absolute right-[4%] top-[19%] h-[66%] w-[33%] rounded-[8px] border border-dashed border-[#7c818b] bg-[#343841]\" />\n                <div className=\"absolute left-[5%] top-[73.5%] h-[10%] w-[28%] rounded-full border border-dashed border-[#7c818b] bg-[#343841]\" />\n                <div className=\"absolute inset-x-[5%] bottom-[4%] flex justify-between border-t border-[#7c818b]/60 pt-[1.5%] text-[6px] font-semibold uppercase tracking-[0.2em] text-[#7c818b]\">\n                  <span>Draft</span>\n                  <span>Not published</span>\n                </div>\n              </div>\n            )}\n          </div>\n        </div>\n        {/* the key on its plinth, seen from above the front edge */}\n        <div className=\"absolute bottom-[15%] left-1/2 h-[150px] w-[200px] -translate-x-1/2 md:bottom-[13%] md:left-[49%] md:h-[230px] md:w-[300px]\" style={{ perspective: \"900px\" }} aria-hidden=\"true\">\n          <div className=\"absolute inset-x-0 bottom-0 h-[34%] rounded-b-[14px]\" style={{ background: \"linear-gradient(180deg, #17191e 0%, #0b0c10 100%)\", boxShadow: `0 16px 46px -2px rgba(79,152,251,${live ? 0.75 : 0.35}), 0 2px 0 0 rgba(79,152,251,${live ? 0.95 : 0.5})` }} />\n          <div className=\"absolute inset-x-0 top-0 h-[76%] rounded-[26px]\" style={{ transform: \"rotateX(58deg)\", transformOrigin: \"50% 100%\", background: \"linear-gradient(180deg, #23262d 0%, #15171c 100%)\", boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.12)\" }}>\n            <div className=\"absolute inset-[14%] rounded-[30px]\" style={{ background: \"linear-gradient(100deg, #8d9299 0%, #e9ecef 30%, #a9aeb5 62%, #dfe2e6 100%)\", boxShadow: \"inset 0 0 0 2px rgba(255,255,255,0.55), 0 6px 14px rgba(0,0,0,0.6)\" }}>\n              <div className=\"publish-key-lightbox-page-glow absolute inset-[12%] rounded-[22px]\" style={{ backgroundColor: BLUE, boxShadow: `0 0 26px 6px rgba(79,152,251,${live ? 0.95 : 0.5}), inset 0 0 12px #fff` }} />\n              <div className=\"absolute inset-[16.5%] flex items-center justify-center rounded-[18px] transition-transform duration-300\" style={{ transform: live ? \"translateY(-4px)\" : \"translateY(-12px)\", background: \"radial-gradient(90% 90% at 40% 30%, #f4f5f6 0%, #c3c7cc 55%, #8f949b 100%)\", boxShadow: \"0 12px 0 -1px #6d7279, 0 16px 16px rgba(0,0,0,0.55), inset 0 2px 0 rgba(255,255,255,0.9)\" }}>\n                <svg viewBox=\"0 0 24 24\" className=\"h-[42%] w-[42%]\" fill=\"none\" stroke={BLUE} strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" style={{ filter: \"drop-shadow(0 0 5px rgba(79,152,251,0.9))\" }}>\n                  <path d=\"M12 20V5M5.5 11 12 4.5 18.5 11\" />\n                </svg>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n\n      <canvas ref={canvasRef} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full transition-opacity duration-700 ${ready ? \"opacity-100\" : \"opacity-0\"}`} />\n\n      {/* Pointer target laid over the key in the picture. The named button below does the same job for keyboards and screen readers. */}\n      <div\n        ref={hitRef}\n        aria-hidden=\"true\"\n        className={`absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer touch-manipulation select-none rounded-[32%] ${ready ? \"\" : \"hidden\"}`}\n        onPointerDown={(e) => {\n          e.currentTarget.setPointerCapture(e.pointerId);\n          api.current?.hold(true);\n        }}\n        onPointerUp={() => api.current?.hold(false)}\n        onPointerCancel={() => api.current?.hold(false)}\n      />\n\n      <p className=\"pointer-events-none absolute left-5 top-5 text-[10px] font-semibold uppercase tracking-[0.22em] text-white/45 md:left-10 md:top-9 md:text-[11px]\">\n        One key <span className=\"mx-1.5 text-white/25\">/</span> Draft to live\n      </p>\n\n      <div className=\"pointer-events-none absolute left-5 top-12 md:left-10 md:top-20 lg:bottom-12 lg:top-auto\">\n        <p className=\"flex items-center gap-2.5 text-[10px] font-semibold uppercase tracking-[0.22em] text-white/50 md:text-[11px]\">\n          <span className=\"relative flex h-2 w-2\">\n            <span className=\"absolute inset-0 rounded-full transition-colors duration-300\" style={{ backgroundColor: live ? BLUE : \"rgba(255,255,255,0.3)\", boxShadow: live ? \"0 0 10px 2px rgba(79,152,251,0.9)\" : \"none\" }} />\n          </span>\n          {SITE.brand} <span className=\"text-white/25\">/</span> Status\n        </p>\n        <div className=\"relative mt-1 h-[84px] w-[300px] overflow-hidden md:mt-2 md:h-[112px] md:w-[320px] lg:h-[150px] lg:w-[400px]\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            <motion.h2\n              key={state.word}\n              initial={reduce ? { opacity: 0 } : { y: \"62%\", opacity: 0 }}\n              animate={{ y: \"0%\", opacity: 1 }}\n              exit={reduce ? { opacity: 0 } : { y: \"-46%\", opacity: 0 }}\n              transition={reduce ? { duration: 0.01 } : { y: { type: \"spring\", stiffness: 240, damping: 21 }, opacity: { duration: 0.3, ease } }}\n              className=\"absolute left-0 top-0 text-[84px] font-extrabold leading-[1] tracking-[-0.06em] text-white md:text-[112px] lg:text-[150px]\"\n            >\n              {state.word}\n            </motion.h2>\n          </AnimatePresence>\n        </div>\n        <p className=\"mt-1 text-[14px] font-medium tracking-tight text-white/60 md:mt-3 md:text-[17px]\">{state.line}</p>\n      </div>\n\n      <div className=\"absolute inset-x-5 bottom-5 flex items-center justify-between gap-4 md:inset-x-auto md:bottom-12 md:right-10 md:flex-col md:items-end md:gap-3\">\n        <span className=\"text-[10px] font-semibold uppercase tracking-[0.22em] text-white/40 md:text-[11px]\">Press the key</span>\n        <button\n          type=\"button\"\n          onClick={press}\n          aria-pressed={live}\n          aria-label={live ? \"Published. Press to take the page back to draft\" : \"Draft. Press to publish the page\"}\n          className=\"flex h-12 items-center gap-2.5 rounded-full pl-5 pr-6 text-[15px] font-bold tracking-tight transition-[transform,background-color,color,box-shadow] duration-300 hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-[#0B0D12] active:scale-95 motion-reduce:transition-none\"\n          style={live ? { backgroundColor: \"rgba(255,255,255,0.08)\", color: \"#fff\", boxShadow: \"inset 0 0 0 1px rgba(255,255,255,0.16)\" } : { backgroundColor: BLUE, color: INK, boxShadow: \"0 0 28px -2px rgba(79,152,251,0.8), inset 0 1px 0 rgba(255,255,255,0.4)\" }}\n        >\n          <svg viewBox=\"0 0 20 20\" className={`h-5 w-5 transition-transform duration-300 motion-reduce:transition-none ${live ? \"rotate-180\" : \"\"}`} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M10 16V4M5 9l5-5 5 5\" />\n          </svg>\n          {state.action}\n        </button>\n      </div>\n      <p className=\"sr-only\" aria-live=\"polite\">\n        {SITE.brand} is {live ? \"live\" : \"a draft\"}. {state.line}\n      </p>\n    </section>\n  );\n}\n"}]}
