{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"velvet-tip-up-theatre-seat-picker-with-sprung-seats-that-fold-down-brass-number-plates-and-reserved-cards","type":"registry:block","title":"Velvet Tip-up Theatre Seat Picker with Sprung Seats That Fold Down, Brass Number Plates and Reserved Cards","description":"Seat picker drawn as rows of velvet tip-up chairs: press one and its seat folds down, with brass numbers and a running total. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/velvet-tip-up-theatre-seat-picker-with-sprung-seats-that-fold-down-brass-number-plates-and-reserved-cards.tsx","type":"registry:component","content":"import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n// Everything a visitor is likely to change sits here.\nconst SHOW = { title: \"The Long Goodnight\", when: \"Fri 21 Nov, 8.15 pm\" };\nconst ROWS = [\"D\", \"C\", \"B\", \"A\"]; // back row first; A is nearest the screen\nconst PRICE: Record<string, number> = { A: 16, B: 19, C: 22, D: 22 };\nconst CURRENCY = \"£\";\nconst RESERVED = [\"D2\", \"D3\", \"C6\", \"C7\", \"B1\", \"A4\", \"A5\"]; // seats with a card hung on them\nconst START = [\"A2\", \"A3\"]; // already folded down when the page loads\nconst DEMO = [\"B3\", \"B4\", \"A2\", \"A3\", \"C4\", \"C5\", \"B3\", \"B4\", \"A2\", \"A3\", \"C4\", \"C5\"]; // seats the idle demo presses, in order\nconst VELVET = [\"#cf2a3f\", \"#931424\", \"#4c0a13\"]; // light, mid, shadow\nconst BRASS = [\"#fff2c2\", \"#d6a94a\", \"#7d5a17\"];\n\nconst PITCH = 104, LP = 70, TP = 15, EYE = (31 * Math.PI) / 180; // seat spacing, pan length, pan thickness, how far above the seats you are looking from\nconst UP = 4, DOWN = 92, PEEK = 22; // pan angle from upright, in degrees\n\nconst geometry = (narrow: boolean) => {\n  const cols = narrow ? 5 : 7, W0 = narrow ? 600 : 1100, H0 = narrow ? 850 : 690, base = narrow ? 560 : 520;\n  const rows = ROWS.map((letter, i) => { const n = ROWS.length - 1 - i; return { letter, s: Math.pow(0.9, n), y: base - [0, 128, 243, 346][n] }; });\n  return { cols, W0, H0, rows, cx: W0 / 2 };\n};\ntype Geo = ReturnType<typeof geometry>;\nconst seatX = (g: Geo, s: number, col: number) => g.cx + (col - (g.cols + 1) / 2) * PITCH * s;\n\ntype Ctx = CanvasRenderingContext2D;\nconst rng = (seed: number) => () => {\n  seed |= 0; seed = (seed + 0x6d2b79f5) | 0;\n  let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);\n  t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n  return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n};\nconst rr = (c: Ctx, x: number, y: number, w: number, h: number, r: number | number[]) => {\n  const [a, b, d, e] = typeof r === \"number\" ? [r, r, r, r] : r;\n  c.beginPath(); c.moveTo(x + a, y); c.arcTo(x + w, y, x + w, y + h, b); c.arcTo(x + w, y + h, x, y + h, d); c.arcTo(x, y + h, x, y, e); c.arcTo(x, y, x + w, y, a); c.closePath();\n};\n\nexport default function VelvetSeatPicker() {\n  const reduce = useReducedMotion();\n  const stageRef = useRef<HTMLDivElement>(null);\n  const cvRef = useRef<HTMLCanvasElement>(null);\n  const [narrow, setNarrow] = useState(false);\n  const [chosen, setChosen] = useState<string[]>(START);\n  const live = useRef({ chosen: START, hover: \"\", touched: false });\n  const geo = useMemo(() => geometry(narrow), [narrow]);\n  live.current.chosen = chosen;\n\n  useEffect(() => {\n    const el = stageRef.current?.parentElement;\n    if (!el) return;\n    const ro = new ResizeObserver(() => setNarrow(el.clientWidth < 700));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const stage = stageRef.current, cv = cvRef.current;\n    if (!stage || !cv) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const g = geo, L = live.current;\n    let k = 1, raf = 0, visible = true, last = performance.now(), nextDemo = last + 3700, demoAt = 0;\n    const room = document.createElement(\"canvas\");\n    const rowCv = g.rows.map(() => document.createElement(\"canvas\"));\n    const noise = document.createElement(\"canvas\"); noise.width = noise.height = 128;\n    { const n = noise.getContext(\"2d\")!, r = rng(4); for (let i = 0; i < 5200; i++) { n.fillStyle = `rgba(${r() > 0.55 ? \"255,190,190\" : \"20,0,0\"},${0.04 + r() * 0.1})`; n.fillRect(r() * 128, r() * 128, 1, 1 + r()); } }\n    const pile = ctx.createPattern(noise, \"repeat\");\n    const reserved = new Set(RESERVED);\n    const phi = new Map<string, { a: number; v: number }>();\n    for (const row of g.rows) for (let c = 1; c <= g.cols; c++) { const id = row.letter + c; phi.set(id, { a: L.chosen.includes(id) ? DOWN : UP, v: 0 }); }\n\n    /** Fill the current path as velvet: a top-lit body, a pale bloom along both edges, then the pile. */\n    const velvet = (c: Ctx, path: () => void, x: number, y: number, w: number, h: number, dim = 0) => {\n      const gr = c.createLinearGradient(0, y, 0, y + h);\n      gr.addColorStop(0, VELVET[0]); gr.addColorStop(0.42, VELVET[1]); gr.addColorStop(1, VELVET[2]);\n      path(); c.fillStyle = gr; c.fill();\n      c.save(); path(); c.clip();\n      const e = c.createLinearGradient(x, 0, x + w, 0);\n      e.addColorStop(0, \"rgba(255,170,170,0.3)\"); e.addColorStop(0.16, \"rgba(255,170,170,0)\"); e.addColorStop(0.84, \"rgba(255,170,170,0)\"); e.addColorStop(1, \"rgba(255,170,170,0.2)\");\n      c.fillStyle = e; c.fillRect(x, y, w, h);\n      const t = c.createLinearGradient(0, y, 0, y + Math.min(h, 16)); t.addColorStop(0, \"rgba(255,200,200,0.32)\"); t.addColorStop(1, \"rgba(255,200,200,0)\");\n      c.fillStyle = t; c.fillRect(x, y, w, Math.min(h, 16));\n      if (pile) { c.fillStyle = pile; c.fillRect(x, y, w, h); }\n      if (dim) { c.fillStyle = `rgba(10,2,4,${dim})`; c.fillRect(x, y, w, h); }\n      c.restore();\n    };\n    const brass = (c: Ctx, x0: number, y0: number, x1: number, y1: number) => { const b = c.createLinearGradient(x0, y0, x1, y1); b.addColorStop(0, BRASS[0]); b.addColorStop(0.45, BRASS[1]); b.addColorStop(1, BRASS[2]); return b; };\n    const wood = (c: Ctx, x0: number, x1: number) => { const w = c.createLinearGradient(x0, 0, x1, 0); w.addColorStop(0, \"#2a140c\"); w.addColorStop(0.3, \"#6d3f24\"); w.addColorStop(0.55, \"#4a2816\"); w.addColorStop(1, \"#1c0d07\"); return w; };\n\n    const build = () => {\n      // The auditorium behind the seats.\n      room.width = cv.width; room.height = cv.height;\n      const b = room.getContext(\"2d\")!;\n      b.setTransform(k, 0, 0, k, 0, 0);\n      b.fillStyle = \"#130a0d\"; b.fillRect(0, 0, g.W0, g.H0);\n      const wl = b.createRadialGradient(g.cx, g.H0 * 0.34, 40, g.cx, g.H0 * 0.4, g.W0 * 0.62);\n      wl.addColorStop(0, \"#3b1c22\"); wl.addColorStop(0.55, \"#1e0f13\"); wl.addColorStop(1, \"#130a0d\");\n      b.fillStyle = wl; b.fillRect(0, 0, g.W0, g.H0);\n\n      // One layer per row: its carpeted step, standards, arm rests, end panels and seat backs.\n      g.rows.forEach((row, ri) => {\n        const cvs = rowCv[ri]; cvs.width = cv.width; cvs.height = cv.height;\n        const c = cvs.getContext(\"2d\")!; const r = rng(100 + ri);\n        c.setTransform(k, 0, 0, k, 0, 0);\n        const s = row.s, half = (g.cols * PITCH * s) / 2 + 46 * s, fy = row.y + 68 * s, next = g.rows[ri + 1];\n        const bottom = next ? next.y + 68 * next.s - 20 * next.s : g.H0;\n        // step: tread, brass nosing, riser\n        const tread = c.createLinearGradient(0, fy - 24 * s, 0, fy);\n        tread.addColorStop(0, \"#1c1216\"); tread.addColorStop(1, \"#33202a\");\n        c.fillStyle = tread; c.fillRect(g.cx - half - 60, fy - 24 * s, half * 2 + 120, 24 * s);\n        const riser = c.createLinearGradient(0, fy, 0, bottom); riser.addColorStop(0, \"#150c10\"); riser.addColorStop(1, \"#0c0608\");\n        c.fillStyle = riser; c.fillRect(g.cx - half - 60, fy, half * 2 + 120, Math.max(0, bottom - fy));\n        for (let i = 0; i < 500; i++) { c.fillStyle = `rgba(${r() > 0.5 ? \"255,200,210\" : \"0,0,0\"},${0.03 + r() * 0.05})`; c.fillRect(g.cx - half - 60 + r() * (half * 2 + 120), fy - 24 * s + r() * 24 * s, 1.2, 1); }\n        c.fillStyle = brass(c, 0, fy - 1, 0, fy + 3); c.fillRect(g.cx - half - 60, fy - 1, half * 2 + 120, 3 * s);\n        // fade the step out towards the walls\n        for (const dir of [-1, 1]) { const fx = g.cx + dir * (half + 60), fd = c.createLinearGradient(fx, 0, fx - dir * 90, 0); fd.addColorStop(0, \"#130a0d\"); fd.addColorStop(1, \"rgba(19,10,13,0)\"); c.fillStyle = fd; c.fillRect(Math.min(fx, fx - dir * 90), fy - 26 * s, 90, bottom - fy + 28 * s); }\n\n        const local = (x: number) => { c.setTransform(k * s, 0, 0, k * s, x * k, row.y * k); };\n        // cast iron standards and wooden arm rests between the seats\n        for (let i = 0; i <= g.cols; i++) {\n          local(g.cx + (i - g.cols / 2) * PITCH * s);\n          const ir = c.createLinearGradient(-5, 0, 5, 0); ir.addColorStop(0, \"#0d0b0c\"); ir.addColorStop(0.4, \"#3b3537\"); ir.addColorStop(1, \"#090708\");\n          c.fillStyle = ir; c.fillRect(-4.5, -28, 9, 96);\n          c.beginPath(); c.moveTo(-4.5, 56); c.lineTo(-13, 68); c.lineTo(13, 68); c.lineTo(4.5, 56); c.closePath(); c.fill();\n          c.save(); c.shadowColor = \"rgba(0,0,0,0.7)\"; c.shadowBlur = 5 * k; c.shadowOffsetY = 3 * k;\n          rr(c, -9, -44, 18, 17, 6); c.fillStyle = wood(c, -9, 9); c.fill(); c.restore();\n          c.fillStyle = \"rgba(255,210,170,0.3)\"; rr(c, -6, -42.5, 12, 2.4, 1.2); c.fill();\n        }\n        // aisle end panels with the row letter and a step light\n        for (const dir of [-1, 1]) {\n          local(g.cx + dir * ((g.cols * PITCH * s) / 2 + 24 * s));\n          c.save(); c.shadowColor = \"rgba(0,0,0,0.75)\"; c.shadowBlur = 12 * k; c.shadowOffsetY = 5 * k;\n          rr(c, -17, -72, 34, 140, [14, 14, 3, 3]); c.fillStyle = wood(c, -17, 17); c.fill(); c.restore();\n          c.save(); rr(c, -17, -72, 34, 140, [14, 14, 3, 3]); c.clip();\n          for (let i = 0; i < 40; i++) { c.fillStyle = `rgba(${r() > 0.5 ? \"255,200,150\" : \"0,0,0\"},${0.04 + r() * 0.07})`; c.fillRect(-17 + r() * 34, -72, 0.8, 140); }\n          const sh = c.createLinearGradient(0, -72, 0, -40); sh.addColorStop(0, \"rgba(255,220,190,0.28)\"); sh.addColorStop(1, \"rgba(255,220,190,0)\"); c.fillStyle = sh; c.fillRect(-17, -72, 34, 32);\n          c.restore();\n          c.strokeStyle = \"rgba(0,0,0,0.45)\"; c.lineWidth = 1.2; rr(c, -11.5, -64, 23, 124, [9, 9, 2, 2]); c.stroke();\n          c.strokeStyle = \"rgba(255,220,180,0.14)\"; rr(c, -10.5, -63, 23, 124, [9, 9, 2, 2]); c.stroke();\n          c.save(); c.shadowColor = \"rgba(0,0,0,0.6)\"; c.shadowBlur = 3 * k; c.shadowOffsetY = 1.5 * k;\n          c.beginPath(); c.arc(0, -40, 9.5, 0, Math.PI * 2); c.fillStyle = brass(c, -8, -48, 8, -32); c.fill(); c.restore();\n          c.strokeStyle = \"rgba(90,60,10,0.6)\"; c.lineWidth = 0.8; c.beginPath(); c.arc(0, -40, 7.4, 0, Math.PI * 2); c.stroke();\n          c.fillStyle = \"#3d2a08\"; c.font = \"700 11px Georgia, 'Times New Roman', serif\"; c.textAlign = \"center\"; c.textBaseline = \"middle\"; c.fillText(row.letter, 0, -39.4);\n          rr(c, -7, 44, 14, 5, 2); c.fillStyle = \"#ffe2a8\"; c.shadowColor = \"#ffb44a\"; c.shadowBlur = 10 * k; c.fill(); c.shadowColor = \"transparent\"; c.shadowBlur = 0;\n          c.globalCompositeOperation = \"lighter\";\n          c.save(); c.translate(0, 66); c.scale(1, 0.32);\n          const pool = c.createRadialGradient(0, 0, 2, 0, 0, 62); pool.addColorStop(0, \"rgba(255,180,90,0.34)\"); pool.addColorStop(1, \"rgba(255,180,90,0)\"); c.fillStyle = pool; c.beginPath(); c.arc(0, 0, 62, 0, Math.PI * 2); c.fill(); c.restore();\n          c.globalCompositeOperation = \"source-over\";\n        }\n        // seat backs\n        for (let col = 1; col <= g.cols; col++) {\n          const id = row.letter + col;\n          local(seatX(g, s, col));\n          const back = () => rr(c, -42, -112, 84, 122, [24, 24, 5, 5]);\n          c.save(); c.shadowColor = \"rgba(0,0,0,0.7)\"; c.shadowBlur = 14 * k; c.shadowOffsetY = 6 * k; back(); c.fillStyle = VELVET[2]; c.fill(); c.restore();\n          velvet(c, back, -42, -112, 84, 122);\n          // two stitched channels and the piping round the edge\n          for (const sx of [-14, 14]) {\n            const ch = c.createLinearGradient(sx - 5, 0, sx + 5, 0); ch.addColorStop(0, \"rgba(40,0,6,0)\"); ch.addColorStop(0.5, \"rgba(40,0,6,0.5)\"); ch.addColorStop(0.62, \"rgba(255,170,170,0.2)\"); ch.addColorStop(1, \"rgba(255,170,170,0)\");\n            c.fillStyle = ch; c.fillRect(sx - 5, -100, 10, 104);\n          }\n          c.strokeStyle = \"rgba(255,150,150,0.38)\"; c.lineWidth = 1.1; rr(c, -39, -109, 78, 116, [21, 21, 4, 4]); c.stroke();\n          c.strokeStyle = \"rgba(30,0,4,0.5)\"; rr(c, -37.6, -107.6, 75.2, 113.2, [20, 20, 3, 3]); c.stroke();\n          // the dark gap under the seat back\n          c.fillStyle = \"rgba(6,2,3,0.8)\"; c.fillRect(-40, 10, 80, 46);\n          if (reserved.has(id)) {\n            const tilt = (r() - 0.5) * 0.16;\n            c.strokeStyle = \"rgba(235,225,205,0.75)\"; c.lineWidth = 0.8; c.beginPath(); c.moveTo(-12, -112); c.lineTo(-13, -94); c.moveTo(12, -112); c.lineTo(13, -94); c.stroke();\n            c.save(); c.translate(0, -84); c.rotate(tilt);\n            c.shadowColor = \"rgba(0,0,0,0.6)\"; c.shadowBlur = 6 * k; c.shadowOffsetY = 3 * k;\n            rr(c, -24, -11, 48, 24, 2); const cd = c.createLinearGradient(0, -11, 0, 13); cd.addColorStop(0, \"#fbf5e6\"); cd.addColorStop(1, \"#dccfb3\"); c.fillStyle = cd; c.fill();\n            c.shadowColor = \"transparent\"; c.strokeStyle = \"rgba(120,20,30,0.7)\"; c.lineWidth = 0.7; c.strokeRect(-21, -8, 42, 18);\n            c.fillStyle = \"#7a1420\"; c.font = \"700 6.4px Georgia, 'Times New Roman', serif\"; c.textAlign = \"center\"; c.textBaseline = \"middle\"; c.fillText(\"RESERVED\", 0, 1.2);\n            c.restore();\n          }\n        }\n        // rows further back sit in a little more darkness\n        c.setTransform(k, 0, 0, k, 0, 0);\n        c.globalCompositeOperation = \"source-atop\"; c.fillStyle = `rgba(10,3,5,${(g.rows.length - 1 - ri) * 0.13})`; c.fillRect(0, 0, g.W0, g.H0); c.globalCompositeOperation = \"source-over\";\n      });\n    };\n\n    /** The hinged pan of one seat at angle `deg` from upright, drawn at the hinge. */\n    const pan = (id: string, deg: number, dim: number) => {\n      const a = (deg * Math.PI) / 180 + EYE, cs = Math.cos(a), sn = Math.sin(a), wide = 1 + 0.1 * Math.sin((deg * Math.PI) / 180);\n      const sb = -LP * cs, th = TP * sn;\n      ctx.save(); ctx.scale(wide, 1);\n      // shadow the pan throws on what is behind and below it\n      const drop = Math.max(0, Math.sin((deg * Math.PI) / 180));\n      if (drop > 0.05) { const sh = ctx.createLinearGradient(0, sb, 0, sb + 50); sh.addColorStop(0, `rgba(0,0,0,${0.85 * drop})`); sh.addColorStop(1, \"rgba(0,0,0,0)\"); ctx.fillStyle = sh; ctx.fillRect(-44, sb, 88, 50); }\n      if (cs > 0) {\n        // underside: a pressed steel pan with a brass number plate\n        const h = -sb;\n        // the cushion is a little larger than the pan, so a rim of velvet shows all round it\n        velvet(ctx, () => rr(ctx, -41, sb - th, 82, h + th + 2, [6, 6, 4, 4]), -41, sb - th, 82, h + th + 2, dim + 0.1);\n        const body = () => rr(ctx, -36, sb + 3, 72, h - 5, [6, 6, 3, 3]);\n        const st = ctx.createLinearGradient(0, sb, 0, 0); st.addColorStop(0, \"#4a3c40\"); st.addColorStop(0.2, \"#2a2023\"); st.addColorStop(1, \"#120c0e\");\n        ctx.save(); ctx.shadowColor = \"rgba(0,0,0,0.65)\"; ctx.shadowBlur = 8 * k; ctx.shadowOffsetY = 3 * k; body(); ctx.fillStyle = st; ctx.fill(); ctx.restore();\n        ctx.strokeStyle = \"rgba(255,255,255,0.1)\"; ctx.lineWidth = 1; rr(ctx, -31, sb + h * 0.12, 62, h * 0.76, 5); ctx.stroke();\n        ctx.strokeStyle = \"rgba(0,0,0,0.5)\"; rr(ctx, -30, sb + h * 0.12 + 1, 62, h * 0.76, 5); ctx.stroke();\n        ctx.save(); ctx.translate(0, sb + h * 0.5); ctx.scale(1, h / (LP * 0.92));\n        ctx.shadowColor = \"rgba(0,0,0,0.7)\"; ctx.shadowBlur = 3 * k; ctx.shadowOffsetY = 1.5 * k;\n        ctx.beginPath(); ctx.ellipse(0, 0, 15, 10, 0, 0, Math.PI * 2); ctx.fillStyle = brass(ctx, -12, -10, 12, 10); ctx.fill(); ctx.shadowColor = \"transparent\";\n        ctx.strokeStyle = \"rgba(90,60,10,0.55)\"; ctx.lineWidth = 0.8; ctx.beginPath(); ctx.ellipse(0, 0, 12.4, 7.6, 0, 0, Math.PI * 2); ctx.stroke();\n        ctx.fillStyle = \"#3d2a08\"; ctx.font = \"700 11px Georgia, 'Times New Roman', serif\"; ctx.textAlign = \"center\"; ctx.textBaseline = \"middle\"; ctx.fillText(id.slice(1), 0, 0.6);\n        ctx.fillStyle = \"#6a4a12\"; for (const dx of [-12.6, 12.6]) { ctx.beginPath(); ctx.arc(dx, 0, 0.9, 0, Math.PI * 2); ctx.fill(); }\n        ctx.restore();\n        // the rolled front edge of the cushion, seen end on\n        velvet(ctx, () => rr(ctx, -41, sb - th, 82, th + 2, [5, 5, 1, 1]), -41, sb - th, 82, th + 2, dim);\n      } else {\n        // cushion top, then its front edge\n        const top = -th, st = sb - th;\n        velvet(ctx, () => rr(ctx, -41, top, 82, st - top + 3, [4, 4, 2, 2]), -41, top, 82, st - top + 3, dim);\n        ctx.fillStyle = \"rgba(40,0,6,0.35)\"; ctx.fillRect(-38, top, 76, 3);\n        const fr = () => rr(ctx, -42, st, 84, sb - st, [3, 3, 7, 7]);\n        velvet(ctx, fr, -42, st, 84, sb - st, dim + 0.12);\n        ctx.strokeStyle = \"rgba(255,160,160,0.5)\"; ctx.lineWidth = 1.1; ctx.beginPath(); ctx.moveTo(-40, st + 0.8); ctx.lineTo(40, st + 0.8); ctx.stroke();\n      }\n      ctx.restore();\n    };\n\n    const draw = (now = 0) => {\n      const breathe = reduce ? 1 : 0.86 + 0.14 * Math.sin(now / 520); // the torch is hand held\n      ctx.setTransform(1, 0, 0, 1, 0, 0);\n      ctx.drawImage(room, 0, 0);\n      g.rows.forEach((row, ri) => {\n        ctx.setTransform(1, 0, 0, 1, 0, 0);\n        ctx.drawImage(rowCv[ri], 0, 0);\n        const dim = (g.rows.length - 1 - ri) * 0.13;\n        for (let col = 1; col <= g.cols; col++) {\n          const id = row.letter + col, p = phi.get(id)!;\n          ctx.setTransform(k * row.s, 0, 0, k * row.s, seatX(g, row.s, col) * k, row.y * k);\n          pan(id, p.a, dim);\n          const lit = Math.max(0, (p.a - UP) / (DOWN - UP));\n          if (lit > 0.02) {\n            // an usher's torch: chosen seats sit in a pool of warm light\n            ctx.globalCompositeOperation = \"lighter\";\n            const gl = ctx.createRadialGradient(0, -34, 6, 0, -34, 92); gl.addColorStop(0, `rgba(255,190,130,${(0.19 * Math.min(1, lit) * breathe).toFixed(3)})`); gl.addColorStop(1, \"rgba(255,190,130,0)\");\n            ctx.fillStyle = gl; ctx.fillRect(-50, -116, 100, 160);\n            ctx.globalCompositeOperation = \"source-over\";\n          }\n        }\n      });\n      // darkness gathering at the edges of the house\n      ctx.setTransform(k, 0, 0, k, 0, 0);\n      const vg = ctx.createRadialGradient(g.cx, g.H0 * 0.5, g.W0 * 0.3, g.cx, g.H0 * 0.5, g.W0 * 0.75);\n      vg.addColorStop(0, \"rgba(19,10,13,0)\"); vg.addColorStop(1, \"rgba(19,10,13,0.9)\");\n      ctx.fillStyle = vg; ctx.fillRect(0, 0, g.W0, g.H0);\n    };\n\n    const tick = (now: number) => {\n      const dt = Math.min(0.033, (now - last) / 1000); last = now;\n      if (!L.touched && now > nextDemo) {\n        const id = DEMO[demoAt % DEMO.length]; demoAt++;\n        if (phi.has(id) && !reserved.has(id)) setChosen((c) => (c.includes(id) ? c.filter((x) => x !== id) : [...c, id]));\n        nextDemo = now + (demoAt % 2 ? 620 : 2100);\n      }\n      phi.forEach((p, id) => {\n        const target = L.chosen.includes(id) ? DOWN : L.hover === id && !reserved.has(id) ? PEEK : UP;\n        // the pan is a sprung flap: it overshoots, and it knocks against its stops\n        for (let n = 0; n < 2; n++) {\n          p.v += (170 * (target - p.a) - 11 * p.v) * (dt / 2); p.a += p.v * (dt / 2);\n          if (p.a > DOWN + 3) { p.a = DOWN + 3; p.v = -p.v * 0.35; }\n          if (p.a < UP - 2) { p.a = UP - 2; p.v = -p.v * 0.35; }\n        }\n      });\n      draw(now);\n      if (visible && !document.hidden) raf = requestAnimationFrame(tick);\n    };\n\n    const size = () => {\n      const w = stage.clientWidth, dpr = Math.min(2, window.devicePixelRatio || 1);\n      k = (w / g.W0) * dpr;\n      cv.width = Math.round(w * dpr); cv.height = Math.round(((w * g.H0) / g.W0) * dpr);\n      build(); settle();\n    };\n    const settle = () => { if (reduce) { phi.forEach((p, id) => { p.a = L.chosen.includes(id) ? DOWN : UP; p.v = 0; }); } draw(); };\n    (L as { redraw?: () => void }).redraw = () => { if (reduce) settle(); };\n    size();\n    const ro = new ResizeObserver(size); ro.observe(stage);\n    const start = () => { cancelAnimationFrame(raf); if (!reduce && visible && !document.hidden) { last = performance.now(); raf = requestAnimationFrame(tick); } };\n    const io = new IntersectionObserver(([e]) => { visible = e.isIntersecting; start(); });\n    io.observe(stage);\n    document.addEventListener(\"visibilitychange\", start);\n    start();\n    return () => { cancelAnimationFrame(raf); ro.disconnect(); io.disconnect(); document.removeEventListener(\"visibilitychange\", start); (L as { redraw?: () => void }).redraw = undefined; };\n  }, [geo, reduce]);\n\n  // with reduced motion there is no loop, so repaint when the choice changes\n  useEffect(() => { (live.current as { redraw?: () => void }).redraw?.(); }, [chosen]);\n\n  const toggle = (id: string) => { live.current.touched = true; setChosen((c) => (c.includes(id) ? c.filter((x) => x !== id) : [...c, id])); };\n  const picked = [...chosen].sort();\n  const total = picked.reduce((sum, id) => sum + (PRICE[id[0]] || 0), 0);\n  const summary = picked.length ? `${picked.join(\", \")} / ${CURRENCY}${total}` : \"No seats chosen yet\";\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#130a0d]\">\n      <div ref={stageRef} className=\"relative mx-auto w-full max-w-[1240px]\" style={{ aspectRatio: `${geo.W0} / ${geo.H0}` }}>\n        <canvas ref={cvRef} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n        <div role=\"group\" aria-label={`Seat plan for ${SHOW.title}, ${SHOW.when}. Row A is nearest the screen.`}>\n          {geo.rows.map((row) =>\n            Array.from({ length: geo.cols }, (_, i) => {\n              const col = i + 1, id = row.letter + col, taken = RESERVED.includes(id), on = chosen.includes(id);\n              return (\n                <button\n                  key={id}\n                  type=\"button\"\n                  aria-pressed={on}\n                  aria-disabled={taken || undefined}\n                  aria-label={taken ? `Row ${row.letter} seat ${col}, reserved` : `Row ${row.letter} seat ${col}, ${CURRENCY}${PRICE[row.letter]}`}\n                  onClick={() => { if (!taken) toggle(id); }}\n                  onPointerEnter={() => { live.current.hover = id; }}\n                  onPointerLeave={() => { if (live.current.hover === id) live.current.hover = \"\"; }}\n                  className={`absolute rounded-t-[22%] rounded-b-md bg-transparent outline-none focus-visible:ring-2 focus-visible:ring-amber-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#130a0d] ${taken ? \"cursor-not-allowed\" : \"cursor-pointer\"}`}\n                  style={{\n                    left: `${((seatX(geo, row.s, col) - 42 * row.s) / geo.W0) * 100}%`,\n                    top: `${((row.y - 112 * row.s) / geo.H0) * 100}%`,\n                    width: `${((84 * row.s) / geo.W0) * 100}%`,\n                    height: `${((146 * row.s) / geo.H0) * 100}%`,\n                  }}\n                />\n              );\n            }),\n          )}\n        </div>\n        <p className=\"absolute bottom-[72px] left-5 right-5 font-mono text-[11px] uppercase leading-relaxed tracking-[0.18em] text-rose-100/80 sm:bottom-7 sm:left-8\">\n          <span className=\"block text-rose-100/70\">{SHOW.title} / {SHOW.when}</span>\n          <span aria-live=\"polite\" className=\"block font-semibold tabular-nums text-white\">{summary}</span>\n        </p>\n        <a href=\"#\" className=\"absolute bottom-4 left-5 right-5 inline-flex h-11 items-center justify-center gap-2 rounded-full bg-[#f3e3b4] px-5 text-[13px] font-semibold text-[#2a1206] transition hover:bg-[#fff0c4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#130a0d] sm:bottom-6 sm:left-auto sm:right-8\">\n          Hold these seats\n          <svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M4 10h12M11 5l5 5-5 5\" /></svg>\n        </a>\n      </div>\n    </section>\n  );\n}\n"}]}
