{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"chrome-shop-rail-of-silk-scarves-on-clamp-hangers-that-slide-swing-and-settle-in-soft-pleats","type":"registry:block","title":"Chrome Shop Rail of Silk Scarves on Clamp Hangers That Slide, Swing and Settle in Soft Pleats","description":"Product carousel on a canvas: printed silk scarves hang in pleats from a chrome rail and swing when you slide them along. Free React and HTML code to copy.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/chrome-shop-rail-of-silk-scarves-on-clamp-hangers-that-slide-swing-and-settle-in-soft-pleats.tsx","type":"registry:component","content":"import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The scarves on the rail, left to right. `tone` is what a scarf is filled with until its print arrives. */\nconst scarves = [\n  { name: \"Lagoon\", alt: \"Marbled paint in turquoise, white and gold\", note: \"Turquoise marble\", price: 120, tone: \"#22b8c4\", src: \"https://images.pexels.com/photos/5112008/pexels-photo-5112008.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Sorbet\", alt: \"Marbled paint in fuchsia pink, mint green and white\", note: \"Fuchsia and mint\", price: 120, tone: \"#ee4f9d\", src: \"https://images.pexels.com/photos/1561020/pexels-photo-1561020.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Regatta\", alt: \"Poured paint in blue, red, yellow and white\", note: \"Poured primaries\", price: 135, tone: \"#2f7fd0\", src: \"https://images.pexels.com/photos/1579243/pexels-photo-1579243.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Ember\", alt: \"Marbled paint in red and black with small blue cells\", note: \"Red on black\", price: 120, tone: \"#d3201c\", src: \"https://images.pexels.com/photos/5112006/pexels-photo-5112006.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Nacre\", alt: \"Soft wash of pink, violet and pale blue paint\", note: \"Shell pink wash\", price: 110, tone: \"#e9a5d6\", src: \"https://images.pexels.com/photos/4391611/pexels-photo-4391611.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Poppy\", alt: \"Single red poppy against a dark maroon ground\", note: \"One red bloom\", price: 145, tone: \"#8c1418\", src: \"https://images.pexels.com/photos/31739332/pexels-photo-31739332.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n  { name: \"Gladiolus\", alt: \"White gladiolus flowers with yellow throats on a lilac ground\", note: \"White on lilac\", price: 145, tone: \"#b98abf\", src: \"https://images.pexels.com/photos/33145724/pexels-photo-33145724.jpeg?auto=compress&cs=tinysrgb&w=700\" },\n];\n\n// Design units for an 1100 wide stage; the whole drawing is scaled to the width it is given.\nconst STAGE_H = 640;\nconst RAIL_Y = 84;\nconst RAIL_R = 10.5;\nconst GAP = 268; // distance between hangers\nconst TOP_W = 172; // width of the silk where the clamp grips it\nconst HEM_W = 236; // width at the hem\nconst LENGTH = 348;\nconst COLS = 30;\nconst ROWS = 5;\nconst PLEATS = 2.7;\nconst TEX_W = 270; // each scarf is lit once into a small picture of this size, then that picture is bent\nconst TEX_H = 400;\nconst CROP = 0.64; // share of the print's width that shows\n\nconst N = scarves.length;\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst wrap = (d: number) => ((((d + N / 2) % N) + N) % N) - N / 2;\n\nexport default function SilkScarfRail() {\n  const reduce = !!useReducedMotion();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const printRefs = useRef<(HTMLImageElement | null)[]>([]);\n  const [active, setActive] = useState(0);\n  const [announce, setAnnounce] = useState(false);\n  const sim = useRef({\n    pos: 0,\n    vel: 0,\n    goal: 0,\n    dragging: false,\n    moved: 0,\n    startX: 0,\n    startPos: 0,\n    lastX: 0,\n    lastT: 0,\n    k: 1,\n    touched: false,\n    paused: false,\n    shown: 0,\n    swing: scarves.map((_, i) => ({ a: (i % 2 ? -1 : 1) * 0.07, w: 0, c: (i % 2 ? -1 : 1) * 0.11, cw: 0, ph: i * 1.7 })),\n    wake: () => {},\n  });\n\n  const go = useCallback((step: number) => {\n    const s = sim.current;\n    s.goal = Math.round(s.goal) + step;\n    s.wake();\n  }, []);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!root || !canvas || !ctx) return;\n    const s = sim.current;\n    let raf = 0;\n    let running = false;\n    let visible = true;\n    let last = 0;\n    let W = 1100;\n    let S = 1;\n    let time = 0;\n\n    const prints = scarves.map((_, i) => printRefs.current[i] as HTMLImageElement);\n    // print plus light: the dark and bright faces of each pleat are painted into the cloth once\n    const cloths = scarves.map(() => {\n      const c = document.createElement(\"canvas\");\n      c.width = TEX_W;\n      c.height = TEX_H;\n      return c;\n    });\n    const bake = (i: number) => {\n      const g = cloths[i].getContext(\"2d\");\n      const img = prints[i];\n      if (!g) return;\n      g.fillStyle = scarves[i].tone;\n      g.fillRect(0, 0, TEX_W, TEX_H);\n      if (img && img.complete && img.naturalWidth > 0) {\n        const iw = Math.min(img.naturalWidth, img.naturalHeight * CROP);\n        g.drawImage(img, (img.naturalWidth - iw) / 2, 0, iw, img.naturalHeight, 0, 0, TEX_W, TEX_H);\n      }\n      const ph = s.swing[i].ph;\n      for (let x = 0; x < TEX_W; x += 2) {\n        const p = Math.PI * 2 * PLEATS * ((x + 1) / TEX_W) + ph;\n        const slope = -Math.sin(p) - 0.69 * Math.sin(p * 2.3 + 1);\n        const dark = slope > 0 ? clamp(slope * 0.31, 0, 0.5) : 0;\n        const shine = Math.pow(clamp(1 - Math.abs(slope + 0.62) * 1.5, 0, 1), 2) * 0.42;\n        if (dark < 0.01 && shine < 0.01) continue;\n        const rgb = dark > 0 ? \"22,10,30\" : \"255,251,244\";\n        const a = dark > 0 ? dark : shine;\n        const fall = g.createLinearGradient(0, 0, 0, TEX_H);\n        fall.addColorStop(0, `rgba(${rgb},${(a * 0.3).toFixed(3)})`);\n        fall.addColorStop(1, `rgba(${rgb},${a.toFixed(3)})`);\n        g.fillStyle = fall;\n        g.fillRect(x, 0, 2, TEX_H);\n      }\n    };\n    scarves.forEach((_, i) => bake(i));\n    const loaded = (e: Event) => {\n      bake(prints.indexOf(e.target as HTMLImageElement));\n      if (reduce || !running) draw();\n    };\n    prints.forEach((img) => img.addEventListener(\"load\", loaded));\n\n    const fit = () => {\n      const w = root.clientWidth;\n      const k = clamp(w / 1100, 0.6, 1.05);\n      const dpr = Math.min(2, window.devicePixelRatio || 1);\n      s.k = k;\n      W = w / k;\n      S = dpr * k;\n      const h = Math.round(STAGE_H * k);\n      canvas.width = Math.round(w * dpr);\n      canvas.height = Math.round(h * dpr);\n      canvas.style.height = `${h}px`;\n      draw();\n    };\n\n    // where a point of the silk is: u across, t down, for a scarf whose clamp is at (cx, cy)\n    const pts = new Float32Array((COLS + 1) * (ROWS + 1) * 2);\n    const lay = (cx: number, cy: number, a: number, c: number, ph: number) => {\n      for (let j = 0; j <= COLS; j++) {\n        const u = j / COLS;\n        const p = Math.PI * 2 * PLEATS * u + ph;\n        const zx = Math.sin(p) * 8.5 + Math.sin(p * 2.3 + 1) * 2.4;\n        const zy = Math.cos(p) * 8 + Math.cos(p * 2.3 + 1) * 2.5;\n        for (let r = 0; r <= ROWS; r++) {\n          const t = r / ROWS;\n          const ang = a + (c - a) * Math.pow(t, 1.25);\n          const lx = (TOP_W + (HEM_W - TOP_W) * Math.pow(t, 0.8)) * (u - 0.5) + zx * (0.25 + 0.75 * t);\n          const ly = LENGTH * t + zy * t * t;\n          const o = (j * (ROWS + 1) + r) * 2;\n          pts[o] = cx + lx * Math.cos(ang) - ly * Math.sin(ang);\n          pts[o + 1] = cy + lx * Math.sin(ang) + ly * Math.cos(ang);\n        }\n      }\n    };\n    const outline = () => {\n      ctx.beginPath();\n      ctx.moveTo(pts[0], pts[1]);\n      for (let r = 1; r <= ROWS; r++) ctx.lineTo(pts[r * 2], pts[r * 2 + 1]);\n      for (let j = 1; j <= COLS; j++) ctx.lineTo(pts[(j * (ROWS + 1) + ROWS) * 2], pts[(j * (ROWS + 1) + ROWS) * 2 + 1]);\n      for (let r = ROWS - 1; r >= 0; r--) ctx.lineTo(pts[(COLS * (ROWS + 1) + r) * 2], pts[(COLS * (ROWS + 1) + r) * 2 + 1]);\n      ctx.closePath();\n    };\n\n    const chrome = (g: CanvasGradient) => {\n      [\n        [0, \"#6b7078\"],\n        [0.16, \"#fbfcfd\"],\n        [0.3, \"#c3c8cf\"],\n        [0.52, \"#565a62\"],\n        [0.7, \"#8e939b\"],\n        [0.88, \"#dfe3e8\"],\n        [1, \"#484b52\"],\n      ].forEach(([p, col]) => g.addColorStop(p as number, col as string));\n      return g;\n    };\n\n    const draw = () => {\n      const H = STAGE_H;\n      ctx.setTransform(S, 0, 0, S, 0, 0);\n      ctx.clearRect(0, 0, W, H);\n      const mid = W / 2;\n      const order = scarves.map((_, i) => ({ i, d: wrap(i - s.pos) })).filter((o) => Math.abs(o.d) * GAP < mid + 190);\n\n      // shadows thrown on the wall, drawn by filling each shape far off canvas and keeping only its shadow\n      ctx.save();\n      ctx.shadowColor = \"rgba(44,38,30,0.26)\";\n      ctx.shadowBlur = 30 * S;\n      ctx.shadowOffsetX = (9000 + 30) * S;\n      ctx.shadowOffsetY = 26 * S;\n      ctx.fillStyle = \"#000\";\n      ctx.fillRect(-9000, RAIL_Y - RAIL_R, W, RAIL_R * 2);\n      for (const o of order) {\n        const sw = s.swing[o.i];\n        const x = mid + o.d * GAP - 9000;\n        lay(x + Math.sin(-sw.a) * 74, RAIL_Y + Math.cos(sw.a) * 74, sw.a, sw.c, sw.ph);\n        outline();\n        ctx.fill();\n      }\n      ctx.restore();\n\n      // ceiling rods and the rail\n      for (const rx of [W * 0.14, W * 0.86]) {\n        ctx.fillStyle = chrome(ctx.createLinearGradient(rx - 4.5, 0, rx + 4.5, 0));\n        ctx.fillRect(rx - 4.5, 0, 9, RAIL_Y);\n        ctx.fillStyle = chrome(ctx.createLinearGradient(rx - 10, 0, rx + 10, 0));\n        ctx.fillRect(rx - 10, RAIL_Y - RAIL_R - 5, 20, RAIL_R * 2 + 10);\n        ctx.fillStyle = \"rgba(0,0,0,0.3)\";\n        ctx.fillRect(rx - 10, RAIL_Y - RAIL_R - 5, 20, 1);\n        ctx.fillRect(rx - 10, RAIL_Y + RAIL_R + 4, 20, 1);\n      }\n      ctx.fillStyle = chrome(ctx.createLinearGradient(0, RAIL_Y - RAIL_R, 0, RAIL_Y + RAIL_R));\n      ctx.fillRect(0, RAIL_Y - RAIL_R, W * 0.14 - 10, RAIL_R * 2);\n      ctx.fillRect(W * 0.14 + 10, RAIL_Y - RAIL_R, W * 0.72 - 20, RAIL_R * 2);\n      ctx.fillRect(W * 0.86 + 10, RAIL_Y - RAIL_R, W, RAIL_R * 2);\n\n      for (const o of order) {\n        const sw = s.swing[o.i];\n        const cloth = cloths[o.i];\n        const x = mid + o.d * GAP;\n        const cx = x - Math.sin(sw.a) * 74;\n        const cy = RAIL_Y + Math.cos(sw.a) * 74;\n        lay(cx, cy, sw.a, sw.c, sw.ph);\n\n        // the silk, cell by cell: each cell of the lit print is sheared onto its patch of cloth\n        const cw = TEX_W / COLS;\n        const ch = TEX_H / ROWS;\n        for (let j = 0; j < COLS; j++) {\n          for (let r = 0; r < ROWS; r++) {\n            const o0 = (j * (ROWS + 1) + r) * 2;\n            const o1 = ((j + 1) * (ROWS + 1) + r) * 2;\n            const x0 = pts[o0];\n            const y0 = pts[o0 + 1];\n            ctx.setTransform((S * (pts[o1] - x0)) / cw, (S * (pts[o1 + 1] - y0)) / cw, (S * (pts[o0 + 2] - x0)) / ch, (S * (pts[o0 + 3] - y0)) / ch, S * x0, S * y0);\n            // drawn a little oversize so no hairline shows between cells; the next cell covers the overlap\n            ctx.drawImage(cloth, j * cw, r * ch, cw, ch, 0, 0, j < COLS - 1 ? cw * 1.16 : cw, r < ROWS - 1 ? ch * 1.05 : ch);\n          }\n        }\n        ctx.setTransform(S, 0, 0, S, 0, 0);\n        // rolled edge all round, and the shade the clamp throws on the silk\n        outline();\n        ctx.lineWidth = 1.1;\n        ctx.strokeStyle = \"rgba(20,12,24,0.38)\";\n        ctx.stroke();\n        ctx.save();\n        outline();\n        ctx.clip();\n        ctx.translate(x, RAIL_Y);\n        ctx.rotate(sw.a);\n        const under = ctx.createLinearGradient(0, 74, 0, 104);\n        under.addColorStop(0, \"rgba(20,10,10,0.5)\");\n        under.addColorStop(1, \"rgba(20,10,10,0)\");\n        ctx.fillStyle = under;\n        ctx.fillRect(-TOP_W, 70, TOP_W * 2, 40);\n        ctx.restore();\n\n        // the hanger: a wire hook over the rail and a walnut clamp\n        ctx.save();\n        ctx.translate(x, RAIL_Y);\n        ctx.rotate(sw.a);\n        ctx.lineCap = \"round\";\n        const hook = () => {\n          ctx.beginPath();\n          ctx.moveTo(0, 60);\n          ctx.lineTo(0, 13.5);\n          ctx.arc(0, 0, 13.5, Math.PI / 2, -Math.PI * 1.12, true);\n        };\n        hook();\n        ctx.lineWidth = 5.4;\n        ctx.strokeStyle = \"#4d5158\";\n        ctx.stroke();\n        hook();\n        ctx.lineWidth = 3.4;\n        ctx.strokeStyle = \"#c9ced5\";\n        ctx.stroke();\n        ctx.translate(-0.9, -0.9);\n        hook();\n        ctx.lineWidth = 1.1;\n        ctx.strokeStyle = \"rgba(255,255,255,0.95)\";\n        ctx.stroke();\n        ctx.translate(0.9, 0.9);\n        const bw = TOP_W + 26;\n        const wood = ctx.createLinearGradient(0, 56, 0, 76);\n        wood.addColorStop(0, \"#a8733f\");\n        wood.addColorStop(0.18, \"#8f5d31\");\n        wood.addColorStop(0.5, \"#6f4523\");\n        wood.addColorStop(0.52, \"#4a2c14\");\n        wood.addColorStop(0.58, \"#82532b\");\n        wood.addColorStop(1, \"#53331a\");\n        ctx.shadowColor = \"rgba(20,10,0,0.4)\";\n        ctx.shadowBlur = 5 * S;\n        ctx.shadowOffsetY = 3 * S;\n        ctx.fillStyle = wood;\n        ctx.beginPath();\n        ctx.roundRect(-bw / 2, 56, bw, 20, 5);\n        ctx.fill();\n        ctx.shadowColor = \"transparent\";\n        ctx.fillStyle = \"rgba(255,226,186,0.4)\";\n        ctx.fillRect(-bw / 2 + 5, 57, bw - 10, 1.2);\n        // grain\n        ctx.strokeStyle = \"rgba(40,20,6,0.22)\";\n        ctx.lineWidth = 0.6;\n        for (let g = 0; g < 5; g++) {\n          ctx.beginPath();\n          ctx.moveTo(-bw / 2 + 8, 59.5 + g * 3.4);\n          ctx.bezierCurveTo(-bw / 6, 58.5 + g * 3.4 + (g % 2), bw / 6, 61 + g * 3.4 - (g % 2), bw / 2 - 8, 59.6 + g * 3.4);\n          ctx.stroke();\n        }\n        for (const bx of [-bw / 2 + 13, bw / 2 - 13]) {\n          const brass = ctx.createRadialGradient(bx - 1.2, 64.8, 0.4, bx, 66, 4.6);\n          brass.addColorStop(0, \"#fff3c4\");\n          brass.addColorStop(0.45, \"#d2a546\");\n          brass.addColorStop(1, \"#7a5718\");\n          ctx.fillStyle = brass;\n          ctx.beginPath();\n          ctx.arc(bx, 66, 4.3, 0, Math.PI * 2);\n          ctx.fill();\n          ctx.strokeStyle = \"rgba(60,36,4,0.7)\";\n          ctx.lineWidth = 0.9;\n          ctx.beginPath();\n          ctx.moveTo(bx - 2.6, 67.2);\n          ctx.lineTo(bx + 2.6, 64.8);\n          ctx.stroke();\n        }\n        ctx.restore();\n      }\n    };\n\n    const step = (dt: number) => {\n      time += dt;\n      const before = s.vel;\n      if (!s.dragging) {\n        s.vel += ((s.goal - s.pos) * 46 - s.vel * 9.5) * dt;\n        s.pos += s.vel * dt;\n      }\n      const push = ((s.vel - before) / dt) * GAP; // how hard the rail is being shoved, in design units\n      let energy = Math.abs(s.vel) + Math.abs(s.goal - s.pos);\n      s.swing.forEach((sw, i) => {\n        const air = Math.sin(time * 0.9 + i * 2.1) * 0.05;\nconst f = 1 + (((i * 37) % 7) - 3) * 0.05; // no two hangers swing at quite the same rate\n        sw.w += (-34 * f * Math.sin(sw.a) - (1.2 + (i % 3) * 0.25) * sw.w - (clamp(push, -9000, 9000) / 520) * f * Math.cos(sw.a) + air) * dt;\n        sw.a = clamp(sw.a + sw.w * dt, -0.7, 0.7);\n        sw.cw += (-22 * Math.sin(sw.c) - 30 * (sw.c - sw.a) - 1.7 * sw.cw - clamp(push, -9000, 9000) / (560 + (i % 4) * 60)) * dt;\n        sw.c = clamp(sw.c + sw.cw * dt, -1, 1);\n        energy += Math.abs(sw.w) + Math.abs(sw.cw) + Math.abs(sw.a) * 2;\n      });\n      return energy;\n    };\n\n    const frame = (now: number) => {\n      const dt = Math.min(0.034, (now - last) / 1000);\n      last = now;\n      step(dt / 2);\n      step(dt / 2);\n      draw();\n      const at = ((Math.round(s.pos) % N) + N) % N;\n      if (at !== s.shown) {\n        s.shown = at;\n        setActive(at);\n      }\n      raf = requestAnimationFrame(frame);\n    };\n    const start = () => {\n      if (running || reduce || !visible || document.hidden) return;\n      running = true;\n      last = performance.now();\n      raf = requestAnimationFrame(frame);\n    };\n    const stop = () => {\n      running = false;\n      cancelAnimationFrame(raf);\n    };\n    s.wake = () => {\n      if (!reduce) return start();\n      s.pos = s.goal;\n      const at = ((Math.round(s.pos) % N) + N) % N;\n      s.shown = at;\n      setActive(at);\n      draw();\n    };\n    if (reduce) s.swing.forEach((sw) => (sw.a = sw.c = sw.w = sw.cw = 0));\n\n    const down = (e: PointerEvent) => {\n      if (e.button !== 0) return;\n      s.dragging = true;\n      s.touched = true;\n      s.moved = 0;\n      s.startX = s.lastX = e.clientX;\n      s.startPos = s.pos;\n      s.lastT = performance.now();\n      canvas.setPointerCapture(e.pointerId);\n      canvas.style.cursor = \"grabbing\";\n    };\n    const move = (e: PointerEvent) => {\n      const r = canvas.getBoundingClientRect();\n      if (s.dragging) {\n        const now = performance.now();\n        const next = s.startPos - (e.clientX - s.startX) / (GAP * s.k);\n        const dt = Math.max(0.004, (now - s.lastT) / 1000);\n        s.vel = s.vel * 0.5 + ((next - s.pos) / dt) * 0.5;\n        s.moved += Math.abs(e.clientX - s.lastX);\n        s.pos = next;\n        s.lastT = now;\n        if (reduce) {\n          s.goal = next;\n          s.wake();\n        }\n      } else if (!reduce && e.pointerType !== \"touch\") {\n        // a hand passing through the silk sets it moving\n        const px = (e.clientX - r.left) / s.k;\n        const py = (e.clientY - r.top) / s.k;\n        const dx = (e.clientX - s.lastX) / s.k;\n        if (py > RAIL_Y + 80 && py < RAIL_Y + 110 + LENGTH)\n          scarves.forEach((_, i) => {\n            const x = W / 2 + wrap(i - s.pos) * GAP;\n            if (Math.abs(px - x) < HEM_W / 2) s.swing[i].cw += clamp(dx, -40, 40) * 0.03;\n          });\n      }\n      s.lastX = e.clientX;\n    };\n    const up = () => {\n      if (!s.dragging) return;\n      s.dragging = false;\n      canvas.style.cursor = \"grab\";\n      s.goal = Math.round(s.pos + clamp(s.vel, -6, 6) * 0.22);\n      s.wake();\n    };\n\n    const timer = window.setInterval(() => {\n      if (reduce || s.touched || s.paused || s.dragging || document.hidden || !visible) return;\n      s.goal = Math.round(s.goal) + 1;\n    }, 2600);\n    const first = window.setTimeout(() => {\n      if (!reduce && !s.touched) s.goal = 1;\n    }, 900);\n\n    fit();\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    canvas.addEventListener(\"pointerdown\", down);\n    canvas.addEventListener(\"pointermove\", move);\n    canvas.addEventListener(\"pointerup\", up);\n    canvas.addEventListener(\"pointercancel\", up);\n    start();\n    return () => {\n      stop();\n      window.clearInterval(timer);\n      window.clearTimeout(first);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      canvas.removeEventListener(\"pointerdown\", down);\n      canvas.removeEventListener(\"pointermove\", move);\n      canvas.removeEventListener(\"pointerup\", up);\n      canvas.removeEventListener(\"pointercancel\", up);\n      prints.forEach((img) => img.removeEventListener(\"load\", loaded));\n    };\n  }, [reduce]);\n\n  const press = (stepBy: number) => {\n    sim.current.touched = true;\n    setAnnounce(true);\n    go(stepBy);\n  };\n  const item = scarves[active];\n\n  return (\n    <section\n      ref={rootRef}\n      className=\"relative w-full select-none overflow-hidden bg-[#efece6]\"\n      onPointerEnter={() => (sim.current.paused = true)}\n      onPointerLeave={() => (sim.current.paused = false)}\n      onKeyDown={(e) => {\n        if (e.key === \"ArrowRight\") press(1);\n        if (e.key === \"ArrowLeft\") press(-1);\n      }}\n    >\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(90% 70% at 42% 30%, #fbfaf7 0%, #efece6 55%, #dcd7cd 100%)\" }} />\n      <canvas\n        ref={canvasRef}\n        aria-hidden=\"true\"\n        className=\"relative block w-full cursor-grab touch-pan-y\"\n        style={{ height: STAGE_H }}\n      />\n      {/* the prints themselves: the canvas draws from these, and they carry the descriptions */}\n      <ul className=\"sr-only\">\n        {scarves.map((sc, i) => (\n          <li key={sc.name}>\n            <img\n              alt={`${sc.name} scarf: ${sc.alt}`}\n              src={sc.src}\n              ref={(el) => {\n                printRefs.current[i] = el;\n              }}\n              width={700}\n              height={700}\n            />\n          </li>\n        ))}\n      </ul>\n      <div className=\"relative -mt-4 flex items-end justify-between gap-4 px-5 pb-5 sm:-mt-10 sm:px-8 sm:pb-8\">\n        <p className=\"font-mono text-[11px] uppercase leading-relaxed tracking-[0.18em] text-[#6a6458]\" aria-live={announce ? \"polite\" : \"off\"}>\n          <span className=\"text-[#1b1915]\">\n            {String(active + 1).padStart(2, \"0\")} / {String(N).padStart(2, \"0\")} {item.name}\n          </span>\n          <span className=\"block\">\n            {item.note}, silk twill, £{item.price}\n          </span>\n        </p>\n        <div className=\"flex shrink-0 gap-2\">\n          {[-1, 1].map((d) => (\n            <button\n              key={d}\n              type=\"button\"\n              onClick={() => press(d)}\n              aria-label={d < 0 ? \"Slide the rail to the previous scarf\" : \"Slide the rail to the next scarf\"}\n              className=\"grid h-11 w-11 place-items-center rounded-full border border-[#1b1915]/20 bg-white/70 text-[#1b1915] outline-none transition-colors hover:bg-white focus-visible:ring-2 focus-visible:ring-[#1b1915] focus-visible:ring-offset-2 focus-visible:ring-offset-[#efece6]\"\n            >\n              <svg width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <path d={d < 0 ? \"M12.5 4.5 7 10l5.5 5.5\" : \"M7.5 4.5 13 10l-5.5 5.5\"} />\n              </svg>\n            </button>\n          ))}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
