{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"brass-lift-floor-indicator-navigation-with-an-arrow-that-sweeps-an-enamel-dial-between-sections","type":"registry:component","title":"Brass Lift Floor Indicator Navigation with an Arrow That Sweeps an Enamel Dial Between Sections","description":"Section navigation drawn as an old lift indicator: a blued arrow sweeps an enamel scale from floor to floor. Copy the React code or the HTML version free.","dependencies":[],"files":[{"path":"components/we-inc/brass-lift-floor-indicator-navigation-with-an-arrow-that-sweeps-an-enamel-dial-between-sections.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent } from \"react\";\n\n// The floors, left to right across the dial. `mark` is engraved on the enamel, `name` under it.\nconst floors = [\n  { mark: \"G\", name: \"Lobby\", note: \"Front desk, post room and the way in from the street\" },\n  { mark: \"1\", name: \"Work\", note: \"Twelve recent buildings, drawn and photographed\" },\n  { mark: \"2\", name: \"Studio\", note: \"Nine architects, two model makers and a dog\" },\n  { mark: \"3\", name: \"Journal\", note: \"Site diaries and notes from the drawing board\" },\n  { mark: \"4\", name: \"Contact\", note: \"Ring the bell or write to the top floor\" },\n];\nconst SWEEP = 128; // degrees between the first floor and the last\nconst SPEED = 1.15; // how fast the car travels, in radians of needle per second\nconst LAMP = \"#ffab3d\"; // the direction lamps\nconst START = 2; // floor the car is waiting at when the page loads\nconst VW = 600, VH = 424; // drawing size in design pixels\nconst PX = 300, PY = 318; // the needle's pivot\nconst R = 246; // radius of the brass plate\n\nconst floorAngle = (i: number) => ((floors.length === 1 ? 0 : i / (floors.length - 1) - 0.5) * SWEEP * Math.PI) / 180;\n\nexport default function BrassLiftFloorIndicator() {\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const stage = useRef<HTMLDivElement>(null);\n  const tabs = useRef<(HTMLButtonElement | null)[]>([]);\n  const [floor, setFloor] = useState(START);\n  const floorRef = useRef(START);\n  const api = useRef<{ go: (i: number, fromUser: boolean) => void } | null>(null);\n\n  useEffect(() => {\n    const cv = canvas.current, wrap = stage.current;\n    if (!cv || !wrap) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const dpr = Math.min(2, window.devicePixelRatio || 1) * 1.2;\n    cv.width = VW * dpr; cv.height = VH * dpr;\n    const hasConic = typeof ctx.createConicGradient === \"function\";\n    let seed = 11;\n    const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n\n    // Brass runs from a red-brown shadow through gold to a pale straw highlight.\n    const brass = (v: number, a = 1) => { const t = Math.max(0, Math.min(1, v / 255)); return `rgba(${(52 + 203 * t) | 0},${(31 + 203 * Math.pow(t, 1.12)) | 0},${(6 + 160 * Math.pow(t, 1.7)) | 0},${a})`; };\n    const platePath = (c: CanvasRenderingContext2D, inset = 0) => {\n      c.beginPath(); c.arc(PX, PY, R - inset, Math.PI, Math.PI * 2);\n      c.lineTo(PX + R - inset, PY + 40 - inset); c.lineTo(PX - R + inset, PY + 40 - inset); c.closePath();\n    };\n    const band = (c: CanvasRenderingContext2D, r0: number, r1: number) => { c.beginPath(); c.arc(PX, PY, r1, Math.PI, Math.PI * 2); c.arc(PX, PY, r0, Math.PI * 2, Math.PI, true); c.closePath(); };\n\n    // Brushing: the plate was spun against an abrasive, so the grain is circles about the pivot. Drawn once.\n    const grain = document.createElement(\"canvas\");\n    grain.width = cv.width; grain.height = cv.height;\n    const gx = grain.getContext(\"2d\");\n    if (gx) {\n      gx.scale(dpr, dpr);\n      for (let r = 3; r < R + 44; r += 0.5) {\n        const v = rand(), from = Math.PI * (1 + rand() * 0.25), to = from + Math.PI * (0.3 + rand() * 0.9);\n        gx.beginPath(); gx.arc(PX, PY, r, r < R ? Math.PI * 0.9 : from, r < R ? Math.PI * 2.1 : to);\n        gx.lineWidth = 0.45 + rand() * 0.4;\n        gx.strokeStyle = v > 0.5 ? `rgba(255,244,205,${(v - 0.5) * 0.36})` : `rgba(40,20,0,${(0.5 - v) * 0.34})`;\n        gx.stroke();\n      }\n      // a few longer scratches from eighty years of polishing\n      for (let k = 0; k < 26; k++) {\n        const r = 20 + rand() * (R - 24), a0 = Math.PI * (1 + rand());\n        gx.beginPath(); gx.arc(PX, PY, r, a0, a0 + 0.1 + rand() * 0.5);\n        gx.lineWidth = 0.6; gx.strokeStyle = `rgba(255,248,220,${0.1 + rand() * 0.16})`; gx.stroke();\n      }\n    }\n    // Fine speckle baked into the enamel so it does not read as flat paint.\n    const fleck = document.createElement(\"canvas\");\n    fleck.width = cv.width; fleck.height = cv.height;\n    const fx = fleck.getContext(\"2d\");\n    if (fx) {\n      fx.scale(dpr, dpr);\n      for (let k = 0; k < 2600; k++) {\n        const r = 128 + rand() * 82, a = Math.PI * (1 + rand());\n        fx.fillStyle = rand() > 0.5 ? `rgba(120,96,60,${rand() * 0.1})` : `rgba(255,255,255,${rand() * 0.2})`;\n        fx.fillRect(PX + Math.cos(a) * r, PY + Math.sin(a) * r, 0.5 + rand() * 0.9, 0.5 + rand() * 0.9);\n      }\n    }\n\n    const s = { a: floorAngle(START), v: 0, target: floorAngle(START), light: 0, lightTo: 0, up: 0, down: 0, glow: floors.map((_, i) => (i === START ? 1 : 0)) };\n\n    const sheen = (shift: number, lo: number, hi: number) => {\n      if (!hasConic) { const g = ctx.createLinearGradient(PX - R, 0, PX + R, 0); g.addColorStop(0, brass(lo)); g.addColorStop(0.42 + shift * 0.2, brass(hi)); g.addColorStop(1, brass(lo)); return g; }\n      const g = ctx.createConicGradient(Math.PI + shift, PX, PY);\n      const mid = (lo + hi) / 2;\n      const stops: [number, number][] = [[0, lo + 6], [0.05, mid - 8], [0.1, lo - 6], [0.15, mid + 12], [0.185, hi - 18], [0.21, hi], [0.235, hi - 30], [0.27, mid + 2], [0.31, lo + 12], [0.35, mid - 14], [0.385, mid + 30], [0.41, mid - 4], [0.45, lo - 10], [0.5, lo + 4], [0.75, lo - 16], [1, lo + 6]];\n      for (const [p, v] of stops) g.addColorStop(p, brass(v));\n      return g;\n    };\n\n    const engrave = (text: string, x: number, y: number, ink: string) => {\n      ctx.fillStyle = \"rgba(255,246,214,0.55)\"; ctx.fillText(text, x + 0.5, y + 0.9);\n      ctx.fillStyle = ink; ctx.fillText(text, x, y);\n    };\n\n    const lamp = (x: number, upward: boolean, on: number) => {\n      // brass bezel, dark socket, glass triangle\n      ctx.save(); ctx.shadowColor = \"rgba(40,18,0,0.55)\"; ctx.shadowBlur = 5; ctx.shadowOffsetY = 2 * dpr;\n      ctx.beginPath(); ctx.arc(x, PY + 20, 14, 0, Math.PI * 2); ctx.fillStyle = brass(120); ctx.fill(); ctx.restore();\n      const bz = ctx.createLinearGradient(0, PY + 6, 0, PY + 34); bz.addColorStop(0, brass(250)); bz.addColorStop(0.5, brass(150)); bz.addColorStop(1, brass(70));\n      ctx.beginPath(); ctx.arc(x, PY + 20, 14, 0, Math.PI * 2); ctx.fillStyle = bz; ctx.fill();\n      ctx.beginPath(); ctx.arc(x, PY + 20, 10.5, 0, Math.PI * 2); ctx.fillStyle = \"#170d05\"; ctx.fill();\n      const d = upward ? -1 : 1, cy = PY + 20 + d * 1.2;\n      ctx.save();\n      ctx.beginPath(); ctx.moveTo(x, cy + d * 6.4); ctx.lineTo(x - 6.6, cy - d * 5); ctx.lineTo(x + 6.6, cy - d * 5); ctx.closePath();\n      ctx.shadowColor = LAMP; ctx.shadowBlur = 22 * on; ctx.globalAlpha = 0.2 + 0.8 * on; ctx.fillStyle = LAMP; ctx.fill();\n      ctx.shadowBlur = 0; ctx.globalAlpha = on; ctx.fillStyle = \"rgba(255,244,214,0.75)\";\n      ctx.beginPath(); ctx.moveTo(x, cy + d * 3.4); ctx.lineTo(x - 3.2, cy - d * 2.6); ctx.lineTo(x + 3.2, cy - d * 2.6); ctx.closePath(); ctx.fill();\n      ctx.restore();\n      ctx.beginPath(); ctx.ellipse(x - 3.5, PY + 14.5, 4.6, 2.2, -0.5, 0, Math.PI * 2); ctx.fillStyle = \"rgba(255,255,255,0.2)\"; ctx.fill();\n    };\n\n    const needle = () => {\n      const g = ctx.createLinearGradient(-11, 0, 11, 0);\n      g.addColorStop(0, \"#05070c\"); g.addColorStop(0.42, \"#1c2536\"); g.addColorStop(0.5, \"#5d6f8f\"); g.addColorStop(0.58, \"#1a2231\"); g.addColorStop(1, \"#04060a\");\n      ctx.fillStyle = g;\n      ctx.beginPath();\n      ctx.moveTo(0, -128);\n      ctx.bezierCurveTo(5, -116, 13.5, -100, 14, -88); ctx.lineTo(4, -95); ctx.lineTo(5.6, -20);\n      ctx.bezierCurveTo(5.8, 2, 5.2, 8, 3.6, 13);\n      ctx.lineTo(-3.6, 13);\n      ctx.bezierCurveTo(-5.2, 8, -5.8, 2, -5.6, -20); ctx.lineTo(-4, -95); ctx.lineTo(-14, -88);\n      ctx.bezierCurveTo(-13.5, -100, -5, -116, 0, -128);\n      ctx.closePath(); ctx.fill();\n    };\n\n    const draw = () => {\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      ctx.clearRect(0, 0, VW, VH);\n      const la = s.light;\n\n      // The plate's shadow on the stone: one wide and soft, one tight under its edge.\n      ctx.save(); ctx.shadowColor = \"rgba(64,44,20,0.42)\"; ctx.shadowBlur = 34 * dpr; ctx.shadowOffsetY = 18 * dpr; ctx.shadowOffsetX = -5 * la * dpr;\n      platePath(ctx, 6); ctx.fillStyle = \"#000\"; ctx.fill(); ctx.restore();\n      ctx.save(); ctx.shadowColor = \"rgba(40,24,6,0.6)\"; ctx.shadowBlur = 5 * dpr; ctx.shadowOffsetY = 3 * dpr;\n      platePath(ctx, 1); ctx.fillStyle = \"#000\"; ctx.fill(); ctx.restore();\n\n      // Brass plate: sheen, brushing, then the cast mouldings.\n      platePath(ctx); ctx.fillStyle = sheen(la * 0.22, 88, 252); ctx.fill();\n      ctx.save(); platePath(ctx); ctx.clip();\n      ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(grain, 0, 0); ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      const fall = ctx.createLinearGradient(0, PY - R, 0, PY + 40);\n      fall.addColorStop(0, \"rgba(255,246,210,0.2)\"); fall.addColorStop(0.4, \"rgba(255,246,210,0)\"); fall.addColorStop(1, \"rgba(48,22,0,0.3)\");\n      ctx.fillStyle = fall; ctx.fillRect(0, 0, VW, VH);\n      ctx.restore();\n      // outer bevel\n      const edge = ctx.createLinearGradient(0, PY - R, 0, PY + 40);\n      edge.addColorStop(0, \"rgba(255,250,226,0.95)\"); edge.addColorStop(0.5, \"rgba(255,240,190,0.25)\"); edge.addColorStop(1, \"rgba(50,24,0,0.75)\");\n      platePath(ctx, 1); ctx.lineWidth = 2; ctx.strokeStyle = edge; ctx.stroke();\n      // a raised bead running round the rim\n      for (const [inset, w, c0, c1] of [[9, 5, \"rgba(46,22,0,0.5)\", \"rgba(255,248,214,0.5)\"], [10.2, 2.4, \"rgba(255,250,224,0.85)\", \"rgba(70,36,0,0.6)\"]] as [number, number, string, string][]) {\n        const g = ctx.createLinearGradient(0, PY - R, 0, PY + 40); g.addColorStop(0, c0); g.addColorStop(1, c1);\n        platePath(ctx, inset); ctx.lineWidth = w; ctx.strokeStyle = g; ctx.stroke();\n      }\n\n      // Engraved sunburst in the centre of the plate.\n      ctx.save(); ctx.lineCap = \"round\";\n      for (let k = 1; k < 30; k++) {\n        const a = Math.PI + (k / 30) * Math.PI, long = k % 2 === 0, r0 = long ? 34 : 58, r1 = long ? 114 : 104;\n        const cos = Math.cos(a), sin = Math.sin(a);\n        ctx.lineWidth = long ? 1.2 : 0.8;\n        ctx.strokeStyle = \"rgba(255,246,210,0.5)\"; ctx.beginPath(); ctx.moveTo(PX + cos * r0 + 0.5, PY + sin * r0 + 0.9); ctx.lineTo(PX + cos * r1 + 0.5, PY + sin * r1 + 0.9); ctx.stroke();\n        ctx.strokeStyle = \"rgba(58,28,0,0.62)\"; ctx.beginPath(); ctx.moveTo(PX + cos * r0, PY + sin * r0); ctx.lineTo(PX + cos * r1, PY + sin * r1); ctx.stroke();\n      }\n      ctx.restore();\n\n      // The enamel band, let into the brass.\n      band(ctx, 126, 212); ctx.fillStyle = \"rgba(40,18,0,0.7)\"; ctx.fill();\n      const en = ctx.createRadialGradient(PX, PY, 128, PX, PY, 210);\n      en.addColorStop(0, \"#e2d6ba\"); en.addColorStop(0.12, \"#f1e8d2\"); en.addColorStop(0.6, \"#f8f1df\"); en.addColorStop(0.9, \"#efe5cc\"); en.addColorStop(1, \"#cfc19f\");\n      band(ctx, 128, 210); ctx.fillStyle = en; ctx.fill();\n      ctx.save(); band(ctx, 128, 210); ctx.clip();\n      ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(fleck, 0, 0); ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      // shadow the brass lip throws onto the enamel, and the gloss of the glaze\n      ctx.lineWidth = 7; ctx.strokeStyle = \"rgba(70,44,10,0.26)\"; ctx.beginPath(); ctx.arc(PX - la * 2, PY + 3.5, 211, Math.PI, Math.PI * 2); ctx.stroke();\n      if (hasConic) {\n        const gl = ctx.createConicGradient(Math.PI + la * 0.3, PX, PY);\n        gl.addColorStop(0, \"rgba(255,255,255,0)\"); gl.addColorStop(0.14, \"rgba(255,255,255,0)\"); gl.addColorStop(0.2, \"rgba(255,255,255,0.75)\"); gl.addColorStop(0.24, \"rgba(255,255,255,0.1)\"); gl.addColorStop(0.27, \"rgba(255,255,255,0.4)\"); gl.addColorStop(0.3, \"rgba(255,255,255,0)\"); gl.addColorStop(1, \"rgba(255,255,255,0)\");\n        ctx.lineWidth = 9; ctx.strokeStyle = gl; ctx.beginPath(); ctx.arc(PX, PY, 197, Math.PI, Math.PI * 2); ctx.stroke();\n      }\n      ctx.restore();\n      // brass fillets either side of the enamel\n      for (const r of [126.5, 211.5]) {\n        ctx.lineWidth = 2.6; ctx.strokeStyle = sheen(la * 0.22 + 0.4, 120, 255); ctx.beginPath(); ctx.arc(PX, PY, r, Math.PI, Math.PI * 2); ctx.stroke();\n        ctx.lineWidth = 0.7; ctx.strokeStyle = \"rgba(50,24,0,0.55)\"; ctx.beginPath(); ctx.arc(PX, PY, r + (r < 200 ? 1.5 : -1.5), Math.PI, Math.PI * 2); ctx.stroke();\n      }\n\n      // Scale: a minute track, then numerals and names fired into the glaze.\n      const half = (SWEEP / 2 + 9) * (Math.PI / 180);\n      for (let k = -40; k <= 40; k++) {\n        const ang = (k * 2 * Math.PI) / 180;\n        if (Math.abs(ang) > half) continue;\n        const sin = Math.sin(ang), cos = -Math.cos(ang);\n        const main = floors.some((_, i) => Math.abs(floorAngle(i) - ang) < 0.012), five = k % 4 === 0;\n        ctx.beginPath(); ctx.moveTo(PX + sin * 204.5, PY + cos * 204.5); ctx.lineTo(PX + sin * (main ? 191 : five ? 197 : 200), PY + cos * (main ? 191 : five ? 197 : 200));\n        ctx.lineWidth = main ? 2 : 0.9; ctx.strokeStyle = main ? \"#191512\" : \"rgba(25,21,18,0.6)\"; ctx.stroke();\n      }\n      ctx.lineWidth = 0.9; ctx.strokeStyle = \"rgba(25,21,18,0.75)\";\n      ctx.beginPath(); ctx.arc(PX, PY, 205, -Math.PI / 2 - half, -Math.PI / 2 + half); ctx.stroke();\n      ctx.beginPath(); ctx.arc(PX, PY, 134, -Math.PI / 2 - half, -Math.PI / 2 + half); ctx.stroke();\n      ctx.textAlign = \"center\"; ctx.textBaseline = \"middle\";\n      floors.forEach((f, i) => {\n        const ang = floorAngle(i), on = s.glow[i];\n        ctx.save(); ctx.translate(PX + Math.sin(ang) * 174, PY - Math.cos(ang) * 174); ctx.rotate(ang);\n        ctx.font = '700 34px Didot, \"Bodoni MT\", \"Bodoni 72\", Georgia, \"Times New Roman\", serif';\n        ctx.fillStyle = `rgb(${(25 + 138 * on) | 0},${(21 + 4 * on) | 0},${(18 - 2 * on) | 0})`;\n        ctx.fillText(f.mark, 0, 1);\n        ctx.font = \"700 7.2px ui-sans-serif, system-ui, -apple-system, Helvetica, Arial, sans-serif\";\n        ctx.fillStyle = `rgba(25,21,18,${0.62 + 0.38 * on})`;\n        const word = f.name.toUpperCase().split(\"\").join(\"  \");\n        ctx.fillText(word, 0, 27);\n        ctx.restore();\n      });\n\n      // The base bar: lamps, legend, screws.\n      lamp(PX - 196, true, s.up); lamp(PX + 196, false, s.down);\n      ctx.font = \"700 8px ui-sans-serif, system-ui, -apple-system, Helvetica, Arial, sans-serif\"; ctx.textBaseline = \"middle\";\n      ctx.textAlign = \"left\"; engrave(\"U P\", PX - 174, PY + 20.5, \"rgba(52,26,0,0.85)\");\n      ctx.textAlign = \"right\"; engrave(\"D O W N\", PX + 174, PY + 20.5, \"rgba(52,26,0,0.85)\");\n      for (const [x, y, rot] of [[PX - 232, PY + 20, 0.6], [PX + 232, PY + 20, -0.3], [PX, PY - R + 22, 1.2]] as [number, number, number][]) {\n        ctx.beginPath(); ctx.arc(x, y + 0.8, 5.4, 0, Math.PI * 2); ctx.fillStyle = \"rgba(40,18,0,0.6)\"; ctx.fill();\n        const sg = ctx.createRadialGradient(x - 1.5, y - 2, 0.5, x, y, 5); sg.addColorStop(0, brass(255)); sg.addColorStop(0.6, brass(170)); sg.addColorStop(1, brass(84));\n        ctx.beginPath(); ctx.arc(x, y, 4.6, 0, Math.PI * 2); ctx.fillStyle = sg; ctx.fill();\n        ctx.save(); ctx.translate(x, y); ctx.rotate(rot); ctx.fillStyle = \"rgba(34,14,0,0.85)\"; ctx.fillRect(-4, -0.7, 8, 1.4); ctx.fillStyle = \"rgba(255,246,210,0.5)\"; ctx.fillRect(-4, 0.7, 8, 0.5); ctx.restore();\n      }\n\n      // Needle: its shadow lies further from it the higher it stands off the dial, and slides with the light.\n      ctx.save(); ctx.translate(PX + 5 - la * 4, PY + 10); ctx.rotate(s.a); ctx.filter = \"blur(3px)\"; ctx.globalAlpha = 0.34; ctx.fillStyle = \"#2a1600\";\n      needle(); ctx.restore();\n      ctx.save(); ctx.translate(PX + 1.5, PY + 2.5); ctx.rotate(s.a); ctx.globalAlpha = 0.3; needle(); ctx.restore();\n      ctx.save(); ctx.translate(PX, PY); ctx.rotate(s.a); needle();\n      ctx.strokeStyle = \"rgba(170,196,240,0.5)\"; ctx.lineWidth = 0.7; ctx.beginPath(); ctx.moveTo(-0.6, -124); ctx.lineTo(-0.6, 12); ctx.stroke();\n      ctx.restore();\n\n      // Hub: a domed brass boss with a slotted screw.\n      ctx.save(); ctx.shadowColor = \"rgba(30,12,0,0.6)\"; ctx.shadowBlur = 8 * dpr; ctx.shadowOffsetY = 4 * dpr;\n      ctx.beginPath(); ctx.arc(PX, PY, 19, 0, Math.PI * 2); ctx.fillStyle = brass(130); ctx.fill(); ctx.restore();\n      ctx.beginPath(); ctx.arc(PX, PY, 19, 0, Math.PI * 2); ctx.fillStyle = hasConic ? sheen(la * 0.3 + 0.9, 96, 255) : brass(190); ctx.fill();\n      const dome = ctx.createRadialGradient(PX - 6 - la * 3, PY - 8, 1, PX, PY, 19);\n      dome.addColorStop(0, \"rgba(255,252,236,0.95)\"); dome.addColorStop(0.3, \"rgba(255,240,190,0.25)\"); dome.addColorStop(0.75, \"rgba(60,30,0,0)\"); dome.addColorStop(1, \"rgba(50,22,0,0.6)\");\n      ctx.beginPath(); ctx.arc(PX, PY, 19, 0, Math.PI * 2); ctx.fillStyle = dome; ctx.fill();\n      ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(40,18,0,0.7)\"; ctx.stroke();\n      ctx.beginPath(); ctx.arc(PX, PY, 7.5, 0, Math.PI * 2); ctx.fillStyle = brass(210); ctx.fill(); ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(40,18,0,0.75)\"; ctx.stroke();\n      ctx.save(); ctx.translate(PX, PY); ctx.rotate(0.5); ctx.fillStyle = \"rgba(30,12,0,0.9)\"; ctx.fillRect(-7, -1, 14, 2); ctx.fillStyle = \"rgba(255,248,220,0.6)\"; ctx.fillRect(-7, 1, 14, 0.6); ctx.restore();\n    };\n\n    let raf = 0, last = 0, seen = true, touched = -1e9, nextDemo = 500, t0 = 0, step = 0;\n    const tour = [3, 1, 4, 0, 2]; // the floors the idle car visits\n    const select = (i: number) => { if (floorRef.current !== i) { floorRef.current = i; setFloor(i); } };\n\n    const frame = (now: number) => {\n      raf = 0;\n      if (!t0) { t0 = now; last = now; }\n      const dt = Math.min(0.033, (now - last) / 1000); last = now;\n      const t = now - t0;\n      // A lift runs at a steady speed and only eases over the last stretch, so the pull is capped.\n      const gap = s.target - s.a;\n      s.v += (70 * Math.max(-0.42, Math.min(0.42, gap)) - 13 * s.v) * dt;\n      s.v = Math.max(-SPEED, Math.min(SPEED, s.v));\n      s.a += s.v * dt;\n      const moving = Math.abs(gap) > 0.03;\n      s.up += ((moving && gap > 0 ? 1 : 0) - s.up) * Math.min(1, dt * (moving ? 16 : 5));\n      s.down += ((moving && gap < 0 ? 1 : 0) - s.down) * Math.min(1, dt * (moving ? 16 : 5));\n      s.glow = s.glow.map((v, i) => v + ((i === floorRef.current && !moving ? 1 : 0) - v) * Math.min(1, dt * 7));\n      if (now - touched > 6000) {\n        s.lightTo = 0.55 * Math.sin(t / 2300);\n        if (t > nextDemo && !moving) { const n = tour[step++ % tour.length]; s.target = floorAngle(n); select(n); nextDemo = t + 2900; }\n      }\n      s.light += (s.lightTo - s.light) * Math.min(1, dt * 5);\n      draw();\n      if (seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!raf && !reduce) { last = performance.now(); raf = requestAnimationFrame(frame); } };\n    const settle = () => { s.a = s.target; s.v = 0; s.up = 0; s.down = 0; s.glow = floors.map((_, i) => (i === floorRef.current ? 1 : 0)); draw(); };\n\n    api.current = { go: (i, fromUser) => { if (fromUser) touched = performance.now(); s.target = floorAngle(i); select(i); if (reduce) settle(); else wake(); } };\n    if (reduce) settle(); else wake();\n\n    const onMove = (e: PointerEvent) => {\n      const b = wrap.getBoundingClientRect();\n      touched = Math.max(touched, performance.now() - 4200);\n      s.lightTo = Math.max(-1, Math.min(1, ((e.clientX - b.left) / b.width) * 2 - 1));\n      if (reduce) { s.light = s.lightTo; draw(); }\n    };\n    wrap.addEventListener(\"pointermove\", onMove);\n    const io = new IntersectionObserver(([entry]) => { seen = entry.isIntersecting; if (seen) wake(); });\n    io.observe(cv);\n    const onVis = () => { if (!document.hidden) wake(); };\n    document.addEventListener(\"visibilitychange\", onVis);\n    return () => {\n      cancelAnimationFrame(raf); api.current = null;\n      wrap.removeEventListener(\"pointermove\", onMove);\n      io.disconnect(); document.removeEventListener(\"visibilitychange\", onVis);\n    };\n  }, []);\n\n  const choose = (i: number) => { floorRef.current = i; setFloor(i); api.current?.go(i, true); };\n  const onKey = (e: ReactKeyboardEvent, i: number) => {\n    const next = e.key === \"ArrowRight\" || e.key === \"ArrowUp\" ? Math.min(floors.length - 1, i + 1) : e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? Math.max(0, i - 1) : e.key === \"Home\" ? 0 : e.key === \"End\" ? floors.length - 1 : -1;\n    if (next < 0) return;\n    e.preventDefault(); choose(next); tabs.current[next]?.focus();\n  };\n\n  return (\n    <div ref={stage} className=\"flex min-h-[620px] w-full flex-col items-center justify-center bg-[#e6dfd2] bg-[radial-gradient(90%_70%_at_38%_22%,#f6f1e7_0%,#e6dfd2_52%,#cfc6b4_100%)] px-3 py-12 sm:min-h-[720px]\">\n      <div className=\"relative aspect-[600/424] w-full max-w-[600px] lg:max-w-[720px]\">\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n        <div role=\"tablist\" aria-label=\"Floors\" className=\"absolute inset-0\">\n          {floors.map((f, i) => {\n            const a = floorAngle(i);\n            return (\n              <button\n                key={f.name}\n                ref={(el) => { tabs.current[i] = el; }}\n                type=\"button\"\n                role=\"tab\"\n                id={`lift-tab-${i}`}\n                aria-controls=\"lift-panel\"\n                aria-selected={floor === i}\n                aria-label={`Floor ${f.mark}, ${f.name}`}\n                tabIndex={floor === i ? 0 : -1}\n                onClick={() => choose(i)}\n                onKeyDown={(e) => onKey(e, i)}\n                style={{ left: `${((PX + Math.sin(a) * 166) / VW) * 100}%`, top: `${((PY - Math.cos(a) * 166) / VH) * 100}%` }}\n                className=\"absolute h-11 w-11 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-full outline-none focus-visible:ring-2 focus-visible:ring-[#7a1a12] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f4ecd8] sm:h-16 sm:w-16\"\n              />\n            );\n          })}\n        </div>\n      </div>\n      <div id=\"lift-panel\" role=\"tabpanel\" aria-labelledby={`lift-tab-${floor}`} aria-live=\"polite\" className=\"mt-1 min-h-[72px] max-w-[440px] text-center sm:mt-0\">\n        <p className=\"font-serif text-[28px] leading-none tracking-[-0.01em] text-[#2a2118]\">\n          <span className=\"mr-3 align-middle font-mono text-[11px] font-semibold uppercase tracking-[0.2em] text-[#8a5a16]\">Floor {floors[floor].mark}</span>\n          {floors[floor].name}\n        </p>\n        <p className=\"mt-3 font-mono text-[11px] uppercase leading-5 tracking-[0.14em] text-[#5c5143]\">{floors[floor].note}</p>\n      </div>\n    </div>\n  );\n}\n"}]}
