{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hotel-room-key-and-enamel-fob-on-a-brass-ring-that-swing-and-knock-together","type":"registry:block","title":"Hotel Room Key and Enamel Fob on a Brass Ring That Swing and Knock Together","description":"Pendulum piece with a brass room key and an enamel fob on one ring: they swing at their own speeds and knock when they meet. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/hotel-room-key-and-enamel-fob-on-a-brass-ring-that-swing-and-knock-together.tsx","type":"registry:component","content":"import { useCallback, useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** What is stamped on the fob and engraved on the plate above the hook. */\nconst room = { number: \"12\", house: \"Larkmoor\", floor: \"First floor, garden side\" };\n\n// Design pixels for a 340 wide scene; the whole scene is scaled to fit.\nconst W = 340;\nconst H = 500;\nconst CX = 170; // centre line the plate and hook sit on\nconst HOOK = { x: CX - 9, y: 173 }; // the point inside the hook that the ring rests on\nconst RING_R = 18;\nconst FOB_W = 88;\nconst FOB_H = 164;\nconst FOB_HOLE = { x: 44, y: 18 };\nconst FOB_LEN = 84; // hole to the fob's centre of weight\nconst KEY_W = 40;\nconst KEY_H = 124;\nconst KEY_HOLE = { x: 20, y: 11 };\nconst KEY_LEN = 52;\nconst GRAVITY = 0.27; // pixels per step squared, at 120 steps a second\nconst DAMPING = 0.9978;\nconst SHADOW = { x: 16, y: 22 };\n\ntype Pt = { x: number; y: number; px: number; py: number; w: number };\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n\n// Points: 0 hook (pinned), 1 and 2 where fob and key sit on the ring, 3 fob weight, 4 key weight.\nconst REST = [\n  { x: 0, y: 0, w: 0 },\n  { x: -11.5, y: 29.5, w: 1.6 },\n  { x: 11.5, y: 29.5, w: 1.6 },\n  { x: -11.5, y: 29.5 + FOB_LEN, w: 0.1 },\n  { x: 11.5, y: 29.5 + KEY_LEN, w: 0.42 },\n];\nconst LINKS: [number, number][] = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4]];\nconst LENGTHS = LINKS.map(([a, b]) => Math.hypot(REST[a].x - REST[b].x, REST[a].y - REST[b].y));\n// Contact between the two: three spots along the key are tested against the fob's oval outline.\nconst KEY_BUMPERS = [0.7, 1.35, 2.05]; // as multiples of KEY_LEN from the key's hole\nconst FOB_MID = FOB_H / 2 - FOB_HOLE.y; // hole to the middle of the oval\nconst TUCK = 0.8; // how much of the fob's half width the key has to clear; under 1 lets it sit partly behind\n\nfunction makePoints(angle: number): Pt[] {\n  const c = Math.cos(angle);\n  const s = Math.sin(angle);\n  return REST.map((p) => {\n    const x = HOOK.x + p.x * c - p.y * s;\n    const y = HOOK.y + p.x * s + p.y * c;\n    return { x, y, px: x, py: y, w: p.w };\n  });\n}\n\nfunction link(a: Pt, b: Pt, len: number) {\n  const dx = b.x - a.x;\n  const dy = b.y - a.y;\n  const d = Math.hypot(dx, dy) || 0.0001;\n  const sum = a.w + b.w;\n  const k = (d - len) / d;\n  a.x += dx * k * (a.w / sum);\n  a.y += dy * k * (a.w / sum);\n  b.x -= dx * k * (b.w / sum);\n  b.y -= dy * k * (b.w / sum);\n}\n\nconst BRASS = \"linear-gradient(90deg, #6a4a10 0%, #c79a3c 18%, #fff0b8 36%, #dcb457 52%, #8f6a1c 78%, #5a3e0b 100%)\";\n\nexport default function HotelKeyFob() {\n  const reduce = useReducedMotion();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const sceneRef = useRef<HTMLDivElement>(null);\n  const fobRef = useRef<HTMLDivElement>(null);\n  const keyRef = useRef<HTMLDivElement>(null);\n  const ringRef = useRef<SVGSVGElement>(null);\n  const fobShadowRef = useRef<HTMLDivElement>(null);\n  const keyShadowRef = useRef<HTMLDivElement>(null);\n  const ringShadowRef = useRef<HTMLDivElement>(null);\n  const fobEdgeRef = useRef<HTMLDivElement>(null);\n  const keyEdgeRef = useRef<SVGGElement>(null);\n  const rimRef = useRef<HTMLDivElement>(null);\n  const glossRef = useRef<HTMLDivElement>(null);\n  const sim = useRef({ pts: makePoints(0), scale: 1, drag: -1, tx: 0, ty: 0, ox: 0, oy: 0, lastTouch: 0, side: 1 });\n\n  const push = useCallback(() => {\n    const s = sim.current;\n    s.side = -s.side;\n    s.pts[3].px -= s.side * 5.2;\n    s.pts[4].px -= s.side * 2.4;\n    s.lastTouch = performance.now();\n  }, []);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const scene = sceneRef.current;\n    const fobEl = fobRef.current;\n    const keyEl = keyRef.current;\n    if (!root || !scene || !fobEl || !keyEl) return;\n    const s = sim.current;\n    s.pts = makePoints(reduce ? 0 : -0.95);\n    let raf = 0;\n    let running = false;\n    let visible = true;\n    let last = 0;\n    let acc = 0;\n\n    const fit = () => {\n      s.scale = Math.min(1.6, root.clientWidth / W);\n      scene.style.transform = `translateX(-50%) scale(${s.scale})`;\n      root.style.height = `${Math.round(H * s.scale)}px`;\n    };\n\n    const stepOnce = () => {\n      const pts = s.pts;\n      for (let i = 1; i < pts.length; i++) {\n        const p = pts[i];\n        const vx = clamp((p.x - p.px) * DAMPING, -36, 36);\n        const vy = clamp((p.y - p.py) * DAMPING, -36, 36);\n        p.px = p.x;\n        p.py = p.y;\n        p.x += vx;\n        p.y += vy + GRAVITY;\n      }\n      const fob = pts[3];\n      const key = pts[4];\n      for (let it = 0; it < 16; it++) {\n        if (s.drag > 0) {\n          const g = pts[s.drag];\n          g.x += (s.tx - g.x) * 0.35;\n          g.y += (s.ty - g.y) * 0.35;\n        }\n        for (let i = 0; i < LINKS.length; i++) link(pts[LINKS[i][0]], pts[LINKS[i][1]], LENGTHS[i]);\n        // the key hangs on one side of the fob, tucked a little way behind its edge, and cannot\n        // pass through: measure each key bumper against the fob's oval outline and push apart\n        const ax = fob.x - pts[1].x;\n        const ay = fob.y - pts[1].y;\n        const al = Math.hypot(ax, ay) || 0.0001;\n        const ux = ax / al;\n        const uy = ay / al;\n        for (const at of KEY_BUMPERS) {\n          const bx = pts[2].x + (key.x - pts[2].x) * at - pts[1].x;\n          const by = pts[2].y + (key.y - pts[2].y) * at - pts[1].y;\n          const along = bx * ux + by * uy;\n          const side = bx * uy - by * ux;\n          const t = (along - FOB_MID) / (FOB_H / 2);\n          const half = t > -1 && t < 1 ? (FOB_W / 2) * Math.sqrt(1 - t * t) : 0;\n          const need = half * TUCK + 7 - side;\n          if (need > 0) {\n            const sum = fob.w + key.w;\n            key.x += uy * need * (key.w / sum) * 0.7;\n            key.y -= ux * need * (key.w / sum) * 0.7;\n            fob.x -= uy * need * (fob.w / sum) * 0.7;\n            fob.y += ux * need * (fob.w / sum) * 0.7;\n          }\n        }\n      }\n    };\n\n    const draw = () => {\n      const [, a1, a2, fob, key] = s.pts;\n      const rotF = Math.atan2(-(fob.x - a1.x), fob.y - a1.y);\n      const rotK = Math.atan2(-(key.x - a2.x), key.y - a2.y);\n      const degF = (rotF * 180) / Math.PI;\n      const degK = (rotK * 180) / Math.PI;\n      const fx = a1.x - FOB_HOLE.x;\n      const fy = a1.y - FOB_HOLE.y;\n      const kx = a2.x - KEY_HOLE.x;\n      const ky = a2.y - KEY_HOLE.y;\n      fobEl.style.transform = `translate3d(${fx.toFixed(2)}px, ${fy.toFixed(2)}px, 0) rotate(${degF.toFixed(2)}deg)`;\n      keyEl.style.transform = `translate3d(${kx.toFixed(2)}px, ${ky.toFixed(2)}px, 0) rotate(${degK.toFixed(2)}deg)`;\n      if (fobShadowRef.current) fobShadowRef.current.style.transform = `translate3d(${(fx + SHADOW.x).toFixed(2)}px, ${(fy + SHADOW.y).toFixed(2)}px, 0) rotate(${degF.toFixed(2)}deg)`;\n      if (keyShadowRef.current) keyShadowRef.current.style.transform = `translate3d(${(kx + SHADOW.x * 0.8).toFixed(2)}px, ${(ky + SHADOW.y * 0.8).toFixed(2)}px, 0) rotate(${degK.toFixed(2)}deg)`;\n      // the ring hangs from the hook and passes through both holes\n      const mx = (a1.x + a2.x) / 2 - HOOK.x;\n      const my = (a1.y + a2.y) / 2 - HOOK.y;\n      const ml = Math.hypot(mx, my) || 1;\n      const cx = HOOK.x + (mx / ml) * (RING_R - 2);\n      const cy = HOOK.y + (my / ml) * (RING_R - 2);\n      if (ringRef.current) ringRef.current.style.transform = `translate3d(${(cx - 24).toFixed(2)}px, ${(cy - 24).toFixed(2)}px, 0)`;\n      if (ringShadowRef.current) ringShadowRef.current.style.transform = `translate3d(${(cx - RING_R + SHADOW.x * 0.6).toFixed(2)}px, ${(cy - RING_R + SHADOW.y * 0.6).toFixed(2)}px, 0)`;\n      // cut edges and highlights keep facing the lamp while the pieces turn\n      const c = Math.cos(-rotF);\n      const sn = Math.sin(-rotF);\n      if (fobEdgeRef.current) fobEdgeRef.current.style.transform = `translate(${(2 * c - 3.4 * sn).toFixed(2)}px, ${(2 * sn + 3.4 * c).toFixed(2)}px)`;\n      if (rimRef.current) rimRef.current.style.background = `linear-gradient(${(138 - degF).toFixed(1)}deg, #fff6cf 0%, #e6c268 18%, #a57b25 42%, #6b4a0f 60%, #c9a047 82%, #f6dd94 100%)`;\n      if (glossRef.current) {\n        const lx = 50 + (-26 * c + 34 * sn) * 1;\n        const ly = 50 + (-26 * sn - 34 * c) * 0.6;\n        glossRef.current.style.background = `radial-gradient(52% 34% at ${lx.toFixed(1)}% ${ly.toFixed(1)}%, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.14) 45%, rgba(255,255,255,0) 100%)`;\n      }\n      const ck = Math.cos(-rotK);\n      const sk = Math.sin(-rotK);\n      if (keyEdgeRef.current) keyEdgeRef.current.setAttribute(\"transform\", `translate(${(1.4 * ck - 2.2 * sk).toFixed(2)} ${(1.4 * sk + 2.2 * ck).toFixed(2)})`);\n    };\n\n    const frame = (now: number) => {\n      raf = requestAnimationFrame(frame);\n      acc += Math.min(0.05, (now - last) / 1000);\n      last = now;\n      let n = 0;\n      while (acc >= 1 / 120 && n < 6) {\n        stepOnce();\n        acc -= 1 / 120;\n        n++;\n      }\n      const fob = s.pts[3];\n      if (s.drag < 0 && now - s.lastTouch > 4800 && Math.abs(fob.x - fob.px) < 0.02) {\n        s.side = -s.side;\n        fob.px -= s.side * 3.6;\n        s.pts[4].px += s.side * 1.2;\n        s.lastTouch = now;\n      }\n      draw();\n    };\n\n    const start = () => {\n      if (running || reduce || !visible || document.hidden) return;\n      running = true;\n      last = performance.now();\n      acc = 0;\n      raf = requestAnimationFrame(frame);\n    };\n    const stop = () => {\n      running = false;\n      cancelAnimationFrame(raf);\n    };\n\n    const toScene = (e: PointerEvent) => {\n      const r = scene.getBoundingClientRect();\n      return { x: (e.clientX - r.left) / s.scale, y: (e.clientY - r.top) / s.scale };\n    };\n    const aim = (e: PointerEvent) => {\n      const p = toScene(e);\n      const reach = 28 + (s.drag === 3 ? FOB_LEN : KEY_LEN);\n      let x = p.x + s.ox;\n      let y = p.y + s.oy;\n      const dx = x - HOOK.x;\n      const dy = y - HOOK.y;\n      const d = Math.hypot(dx, dy);\n      if (d > reach) {\n        x = HOOK.x + (dx / d) * reach;\n        y = HOOK.y + (dy / d) * reach;\n      }\n      s.tx = x;\n      s.ty = y;\n    };\n    const grab = (index: number, el: HTMLElement) => (e: PointerEvent) => {\n      if (reduce) return;\n      const p = toScene(e);\n      s.drag = index;\n      s.ox = s.pts[index].x - p.x;\n      s.oy = s.pts[index].y - p.y;\n      aim(e);\n      el.setPointerCapture(e.pointerId);\n      el.style.cursor = \"grabbing\";\n    };\n    const move = (e: PointerEvent) => {\n      if (s.drag > 0) aim(e);\n    };\n    const up = () => {\n      s.drag = -1;\n      s.lastTouch = performance.now();\n      fobEl.style.cursor = \"grab\";\n      keyEl.style.cursor = \"grab\";\n    };\n    const grabFob = grab(3, fobEl);\n    const grabKey = grab(4, keyEl);\n\n    fit();\n    // with motion reduced nothing animates, so settle the key against the fob before the one drawing\n    if (reduce) for (let i = 0; i < 900; i++) stepOnce();\n    draw();\n    s.lastTouch = performance.now();\n    const ro = new ResizeObserver(fit);\n    ro.observe(root);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible) start();\n      else stop();\n    });\n    io.observe(root);\n    const vis = () => (document.hidden ? stop() : start());\n    document.addEventListener(\"visibilitychange\", vis);\n    fobEl.addEventListener(\"pointerdown\", grabFob);\n    keyEl.addEventListener(\"pointerdown\", grabKey);\n    for (const el of [fobEl, keyEl]) {\n      el.addEventListener(\"pointermove\", move);\n      el.addEventListener(\"pointerup\", up);\n      el.addEventListener(\"pointercancel\", up);\n    }\n    start();\n    return () => {\n      stop();\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      fobEl.removeEventListener(\"pointerdown\", grabFob);\n      keyEl.removeEventListener(\"pointerdown\", grabKey);\n      for (const el of [fobEl, keyEl]) {\n        el.removeEventListener(\"pointermove\", move);\n        el.removeEventListener(\"pointerup\", up);\n        el.removeEventListener(\"pointercancel\", up);\n      }\n    };\n  }, [reduce]);\n\n  // The key outline: bow at the top with its hole, a collar, the shaft and the bit.\n  const keyPath = \"M20 1C9.5 1 2 8 2 17.5 2 25.5 7.6 31.4 15.6 32.8V38H13.4V44H15.6V112.5C15.6 116.8 17.5 120 20 120S24.4 116.8 24.4 112.5V110H37V103.5H31.5V98.5H37V88H31.5V83.5H24.4V44H26.6V38H24.4V32.8C32.4 31.4 38 25.5 38 17.5 38 8 30.5 1 20 1ZM20 5.6A5.4 5.4 0 1 1 20 16.4 5.4 5.4 0 0 1 20 5.6Z\";\n\n  return (\n    <div\n      ref={rootRef}\n      className=\"relative h-[800px] w-full select-none overflow-hidden bg-[#10231c]\"\n      style={{ backgroundImage: \"radial-gradient(90% 80% at 30% 14%, #24493c 0%, #17352b 38%, #0c1c16 100%)\" }}\n    >\n      {/* painted boards: a fine joint every so often, and a little grain */}\n      <div className=\"pointer-events-none absolute inset-0 opacity-70\" style={{ backgroundImage: \"repeating-linear-gradient(90deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 150px, rgba(0,0,0,0.42) 150px, rgba(0,0,0,0.42) 151.5px, rgba(255,255,255,0.05) 151.5px, rgba(255,255,255,0.05) 153px)\", backgroundPosition: \"center top\" }} />\n      <svg className=\"pointer-events-none absolute inset-0 h-full w-full opacity-[0.22] mix-blend-overlay\" aria-hidden=\"true\">\n        <filter id=\"hotel-key-wall\">\n          <feTurbulence type=\"fractalNoise\" baseFrequency=\"0.9 0.012\" numOctaves=\"3\" seed=\"3\" />\n          <feColorMatrix values=\"0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -1.6 1.1\" />\n        </filter>\n        <rect width=\"100%\" height=\"100%\" filter=\"url(#hotel-key-wall)\" />\n      </svg>\n\n      <div ref={sceneRef} className=\"absolute left-1/2 top-0 origin-top\" style={{ width: W, height: H, transform: \"translateX(-50%)\" }}>\n        {/* engraved number plate */}\n        <div className=\"absolute rounded-[50%] bg-black/50 blur-[5px]\" style={{ left: CX - 38 + 7, top: 48 + 9, width: 76, height: 46 }} />\n        <div\n          className=\"absolute flex items-center justify-center rounded-[50%]\"\n          style={{ left: CX - 38, top: 48, width: 76, height: 46, background: \"linear-gradient(140deg, #fff3c4 0%, #dfbb62 22%, #b08630 55%, #7a5914 78%, #c9a24a 100%)\", boxShadow: \"inset 0 0 0 1px rgba(60,38,4,0.8), inset 0 0 0 3px rgba(255,240,190,0.25), inset 0 0 0 4px rgba(60,38,4,0.35), 0 1px 0 rgba(0,0,0,0.6)\" }}\n        >\n          <span className=\"absolute left-[7px] top-1/2 h-[5px] w-[5px] -translate-y-1/2 rounded-full\" style={{ background: \"radial-gradient(circle at 35% 30%, #fff3c4, #8a6519 70%)\", boxShadow: \"inset 0 0 0 0.5px rgba(40,25,0,0.8)\" }} />\n          <span className=\"absolute right-[7px] top-1/2 h-[5px] w-[5px] -translate-y-1/2 rounded-full\" style={{ background: \"radial-gradient(circle at 35% 30%, #fff3c4, #8a6519 70%)\", boxShadow: \"inset 0 0 0 0.5px rgba(40,25,0,0.8)\" }} />\n          <span className=\"font-serif text-[24px] leading-none\" style={{ color: \"#3d2a05\", textShadow: \"0 1px 0 rgba(255,240,190,0.7)\" }}>{room.number}</span>\n        </div>\n\n        {/* shadows on the wall */}\n        <div ref={ringShadowRef} className=\"pointer-events-none absolute left-0 top-0 rounded-full border-[4px] border-black/55 blur-[3px]\" style={{ width: RING_R * 2, height: RING_R * 2 }} />\n        <div ref={keyShadowRef} className=\"pointer-events-none absolute left-0 top-0 blur-[5px]\" style={{ width: KEY_W, height: KEY_H, transformOrigin: `${KEY_HOLE.x}px ${KEY_HOLE.y}px` }}>\n          <svg width={KEY_W} height={KEY_H} viewBox={`0 0 ${KEY_W} ${KEY_H}`} aria-hidden=\"true\">\n            <path d={keyPath} fill=\"rgba(0,0,0,0.55)\" fillRule=\"evenodd\" />\n          </svg>\n        </div>\n        <div ref={fobShadowRef} className=\"pointer-events-none absolute left-0 top-0 rounded-[50%] bg-black/55 blur-[11px]\" style={{ width: FOB_W, height: FOB_H, transformOrigin: `${FOB_HOLE.x}px ${FOB_HOLE.y}px` }} />\n\n        {/* cup hook: its plate, then the ring, key and fob, then the hook wire over the ring */}\n        <div className=\"absolute rounded-full\" style={{ left: CX - 14, top: 120, width: 28, height: 28, background: \"radial-gradient(circle at 36% 30%, #fff8d8 0%, #efcd76 24%, #c0933a 58%, #7f5c16 86%, #4f3708 100%)\", boxShadow: \"0 3px 6px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(60,38,4,0.8), inset 0 0 0 4px rgba(255,240,190,0.16), inset 0 0 0 5px rgba(60,38,4,0.32)\" }} />\n\n        {/* the key */}\n        <div ref={keyRef} className=\"absolute left-0 top-0 cursor-grab touch-none\" style={{ width: KEY_W, height: KEY_H, transformOrigin: `${KEY_HOLE.x}px ${KEY_HOLE.y}px`, willChange: \"transform\" }}>\n          <svg width={KEY_W} height={KEY_H} viewBox={`0 0 ${KEY_W} ${KEY_H}`} className=\"overflow-visible\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id=\"hotel-key-brass\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\">\n                <stop offset=\"0\" stopColor=\"#6e4d11\" />\n                <stop offset=\"0.22\" stopColor=\"#d0a443\" />\n                <stop offset=\"0.42\" stopColor=\"#fff2bd\" />\n                <stop offset=\"0.6\" stopColor=\"#d8b052\" />\n                <stop offset=\"0.85\" stopColor=\"#8a651a\" />\n                <stop offset=\"1\" stopColor=\"#56390a\" />\n              </linearGradient>\n              <linearGradient id=\"hotel-key-shaft\" x1=\"15\" y1=\"0\" x2=\"25\" y2=\"0\" gradientUnits=\"userSpaceOnUse\">\n                <stop offset=\"0\" stopColor=\"#5e4210\" />\n                <stop offset=\"0.3\" stopColor=\"#fff2bd\" />\n                <stop offset=\"0.55\" stopColor=\"#cfa446\" />\n                <stop offset=\"1\" stopColor=\"#4f3508\" />\n              </linearGradient>\n              <radialGradient id=\"hotel-key-bow\" cx=\"0.38\" cy=\"0.3\" r=\"0.8\">\n                <stop offset=\"0\" stopColor=\"#fff6cf\" />\n                <stop offset=\"0.3\" stopColor=\"#e6c268\" />\n                <stop offset=\"0.7\" stopColor=\"#a37a26\" />\n                <stop offset=\"1\" stopColor=\"#5a3e0b\" />\n              </radialGradient>\n            </defs>\n            <g ref={keyEdgeRef}>\n              <path d={keyPath} fill=\"#3a2706\" fillRule=\"evenodd\" />\n            </g>\n            <path d={keyPath} fill=\"url(#hotel-key-brass)\" fillRule=\"evenodd\" stroke=\"#3a2706\" strokeWidth=\"0.6\" />\n            <path d=\"M20 1C9.5 1 2 8 2 17.5 2 25.5 7.6 31.4 15.6 32.8H24.4C32.4 31.4 38 25.5 38 17.5 38 8 30.5 1 20 1ZM20 5.6A5.4 5.4 0 1 1 20 16.4 5.4 5.4 0 0 1 20 5.6Z\" fill=\"url(#hotel-key-bow)\" fillRule=\"evenodd\" />\n            <ellipse cx=\"20\" cy=\"18\" rx=\"13.2\" ry=\"11.6\" fill=\"none\" stroke=\"#5a3e0b\" strokeOpacity=\"0.55\" strokeWidth=\"0.8\" />\n            <ellipse cx=\"20\" cy=\"18.6\" rx=\"13.2\" ry=\"11.6\" fill=\"none\" stroke=\"#fff6cf\" strokeOpacity=\"0.5\" strokeWidth=\"0.6\" />\n            <text x=\"20\" y=\"27.4\" textAnchor=\"middle\" fontFamily=\"Georgia, serif\" fontSize=\"7.5\" fill=\"#4a3206\" fillOpacity=\"0.85\">{room.number}</text>\n            <rect x=\"15.6\" y=\"44\" width=\"8.8\" height=\"76\" rx=\"4.4\" fill=\"url(#hotel-key-shaft)\" />\n            <rect x=\"13.4\" y=\"38\" width=\"13.2\" height=\"6\" rx=\"1\" fill=\"url(#hotel-key-brass)\" stroke=\"#3a2706\" strokeWidth=\"0.5\" />\n            <path d=\"M13.8 39.4H26.2\" stroke=\"#fff6cf\" strokeOpacity=\"0.8\" strokeWidth=\"0.7\" />\n            <path d=\"M24.8 84.2H31V88.6H36.4M24.8 98.9H31V103.9H36.4\" fill=\"none\" stroke=\"#fff6cf\" strokeOpacity=\"0.65\" strokeWidth=\"0.7\" />\n            <circle cx=\"20\" cy=\"11\" r=\"5.4\" fill=\"none\" stroke=\"#3a2706\" strokeOpacity=\"0.8\" strokeWidth=\"0.9\" />\n          </svg>\n        </div>\n\n        {/* the fob */}\n        <div ref={fobRef} className=\"absolute left-0 top-0 cursor-grab touch-none\" style={{ width: FOB_W, height: FOB_H, transformOrigin: `${FOB_HOLE.x}px ${FOB_HOLE.y}px`, willChange: \"transform\" }}>\n          <div ref={fobEdgeRef} className=\"absolute inset-0 rounded-[50%] bg-[#33230a]\" />\n          <div ref={rimRef} className=\"absolute inset-0 rounded-[50%]\" style={{ background: \"linear-gradient(138deg, #fff6cf 0%, #e6c268 18%, #a57b25 42%, #6b4a0f 60%, #c9a047 82%, #f6dd94 100%)\", boxShadow: \"inset 0 0 0 0.8px rgba(50,32,4,0.85)\" }} />\n          <div\n            className=\"absolute inset-[6px] overflow-hidden rounded-[50%]\"\n            style={{ background: \"radial-gradient(70% 60% at 42% 34%, #b42a2c 0%, #8c1519 48%, #5a0a0f 100%)\", boxShadow: \"inset 0 2.5px 5px rgba(20,0,0,0.75), inset 0 -1px 1px rgba(255,160,150,0.25), 0 0 0 1px rgba(50,32,4,0.7)\" }}\n          >\n            <div className=\"absolute inset-[5px] rounded-[50%] border border-[#e9c871]/55\" />\n            <div className=\"absolute inset-x-0 top-[40px] text-center font-mono text-[6.5px] uppercase leading-none tracking-[0.34em] text-[#ecd08a]\" style={{ textIndent: \"0.34em\" }}>Room</div>\n            <div\n              className=\"absolute inset-x-0 top-[50px] text-center font-serif text-[44px] leading-none\"\n              style={{ backgroundImage: \"linear-gradient(180deg, #fff3bf 0%, #e8c468 42%, #a67c22 78%, #dcb65a 100%)\", WebkitBackgroundClip: \"text\", backgroundClip: \"text\", color: \"transparent\", filter: \"drop-shadow(0 1px 0 rgba(40,0,0,0.7))\" }}\n            >\n              {room.number}\n            </div>\n            <div className=\"absolute left-1/2 top-[101px] h-px w-[26px] -translate-x-1/2 bg-[#e9c871]/70\" />\n            <div className=\"absolute inset-x-0 top-[108px] text-center font-serif text-[9px] italic leading-none text-[#f0d490]\">{room.house}</div>\n            <div ref={glossRef} className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(52% 34% at 30% 22%, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.14) 45%, rgba(255,255,255,0) 100%)\" }} />\n          </div>\n          {/* brass grommet round the hole */}\n          <div className=\"absolute rounded-full\" style={{ left: FOB_HOLE.x - 8.5, top: FOB_HOLE.y - 8.5, width: 17, height: 17, background: \"radial-gradient(circle at 36% 30%, #fff6cf 0%, #e3bf66 40%, #8a6519 100%)\", boxShadow: \"0 1px 2px rgba(0,0,0,0.6), inset 0 0 0 0.7px rgba(50,32,4,0.8)\" }}>\n            <div className=\"absolute inset-[4px] rounded-full bg-[#0b1712]\" style={{ boxShadow: \"inset 0 1.5px 2px rgba(0,0,0,0.9)\" }} />\n          </div>\n        </div>\n\n        {/* split ring, in front of both holes */}\n        <svg ref={ringRef} className=\"pointer-events-none absolute left-0 top-0 overflow-visible\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" aria-hidden=\"true\">\n          <circle cx=\"24\" cy=\"25.4\" r={RING_R} fill=\"none\" stroke=\"#000\" strokeOpacity=\"0.4\" strokeWidth=\"4\" />\n          <circle cx=\"24\" cy=\"24\" r={RING_R} fill=\"none\" stroke=\"#4a3408\" strokeWidth=\"4.6\" />\n          <circle cx=\"24\" cy=\"24\" r={RING_R} fill=\"none\" stroke=\"#c9a047\" strokeWidth=\"3.2\" />\n          <circle cx=\"24\" cy=\"24\" r={RING_R + 0.2} fill=\"none\" stroke=\"#7d5c18\" strokeWidth=\"0.7\" />\n          <path d={`M${24 - RING_R * 0.92} ${24 - RING_R * 0.4}A${RING_R} ${RING_R} 0 0 1 ${24 + RING_R * 0.2} ${24 - RING_R * 0.98}`} fill=\"none\" stroke=\"#fff6cf\" strokeWidth=\"1.5\" strokeLinecap=\"round\" transform=\"translate(0.5 0.5)\" />\n          <path d={`M${24 + RING_R * 0.5} ${24 + RING_R * 0.87}A${RING_R} ${RING_R} 0 0 1 ${24 - RING_R * 0.3} ${24 + RING_R * 0.95}`} fill=\"none\" stroke=\"#f3d98f\" strokeOpacity=\"0.7\" strokeWidth=\"1\" strokeLinecap=\"round\" />\n        </svg>\n\n        {/* hook wire: down from the plate, round under the ring and up to a small ball */}\n        <svg className=\"pointer-events-none absolute left-0 top-0 overflow-visible\" width={W} height={H} style={{ transform: `translate(${CX - 230}px, -14px)` }} aria-hidden=\"true\">\n          <path d=\"M230 150V180A9.5 9.5 0 0 1 211 180V172\" fill=\"none\" stroke=\"#000\" strokeOpacity=\"0.35\" strokeWidth=\"7\" strokeLinecap=\"round\" transform=\"translate(2 3)\" />\n          <path d=\"M230 150V180A9.5 9.5 0 0 1 211 180V172\" fill=\"none\" stroke=\"#4a3408\" strokeWidth=\"7.4\" strokeLinecap=\"round\" />\n          <path d=\"M230 150V180A9.5 9.5 0 0 1 211 180V172\" fill=\"none\" stroke=\"#c79a3c\" strokeWidth=\"5.6\" strokeLinecap=\"round\" />\n          <path d=\"M228.6 150V180A8.2 8.2 0 0 1 212.3 180V172\" fill=\"none\" stroke=\"#fff3c4\" strokeOpacity=\"0.85\" strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n          <circle cx=\"211\" cy=\"170.5\" r=\"4.6\" fill=\"#d6ae54\" stroke=\"#4a3408\" strokeWidth=\"0.9\" />\n          <circle cx=\"209.8\" cy=\"169.2\" r=\"1.4\" fill=\"#fff6cf\" />\n          <circle cx=\"230\" cy=\"148\" r=\"6\" fill=\"#c79a3c\" stroke=\"#4a3408\" strokeWidth=\"0.9\" />\n          <circle cx=\"228.4\" cy=\"146.4\" r=\"1.8\" fill=\"#fff6cf\" fillOpacity=\"0.9\" />\n        </svg>\n      </div>\n\n      <p className=\"pointer-events-none absolute bottom-6 left-6 font-mono text-[10px] uppercase leading-[1.7] tracking-[0.18em] text-[#8fa89c]\">\n        <span className=\"font-semibold text-[#f0e2b6]\">{room.house} / room {room.number}</span>\n        <br />\n        {room.floor}\n      </p>\n      <button\n        type=\"button\"\n        onClick={push}\n        aria-label=\"Flick the room key so it swings\"\n        className=\"absolute bottom-5 right-5 flex h-11 w-11 items-center justify-center rounded-full border border-[#f0e2b6]/30 bg-[#0c1c16]/60 text-[#f0e2b6] transition-colors hover:bg-[#1c3a30] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f0e2b6] focus-visible:ring-offset-2 focus-visible:ring-offset-[#10231c]\"\n      >\n        <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n          <circle cx=\"7\" cy=\"6\" r=\"3.5\" />\n          <path d=\"M9.4 8.6l6.6 6.6M13.2 12.4l-1.8 1.8M15.4 14.6l-1.6 1.6\" />\n        </svg>\n      </button>\n    </div>\n  );\n}\n"}]}
