{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"paper-shopping-bag-that-catches-boxed-products-bulges-leans-and-flexes-its-rope-handles","type":"registry:block","title":"Paper Shopping Bag That Catches Boxed Products, Bulges, Leans and Flexes Its Rope Handles","description":"Add to bag piece where boxed products fall into a paper carrier that bulges, leans under the load and flexes its rope handles. Free React and HTML to copy.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/paper-shopping-bag-that-catches-boxed-products-bulges-leans-and-flexes-its-rope-handles.tsx","type":"registry:component","content":"import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The shop's name on the bag, and what drops into it, in order. Sizes are the cartons in design pixels. */\nconst shop = { name: \"Pallant\", line: \"Objects for the house\" };\nconst goods = [\n  { name: \"Sea glass frames\", price: 64, w: 112, h: 60, d: 88, x: -48, rest: 0, turn: 0, card: \"#12a6a6\", kg: 0.6, src: \"https://images.pexels.com/photos/20093366/pexels-photo-20093366.jpeg?auto=compress&cs=tinysrgb&w=500\", alt: \"Green sunglasses resting on a pink roll against a turquoise wall\", focus: \"50% 38%\" },\n  { name: \"Bottle vase pair\", price: 88, w: 100, h: 150, d: 84, x: 56, rest: 0, turn: 0, card: \"#c23f93\", kg: 1.3, src: \"https://images.pexels.com/photos/34775286/pexels-photo-34775286.jpeg?auto=compress&cs=tinysrgb&w=500\", alt: \"Two white ceramic vases against a pink wall on a blue table\", focus: \"40% 70%\" },\n  { name: \"Marbled silk square\", price: 72, w: 112, h: 44, d: 86, x: -48, rest: 60, turn: 0, card: \"#e63f8f\", kg: 0.4, src: \"https://images.pexels.com/photos/1561020/pexels-photo-1561020.jpeg?auto=compress&cs=tinysrgb&w=500\", alt: \"Marbled paint in pink, mint green and white\", focus: \"50% 50%\" },\n  { name: \"Hand wash duo\", price: 38, w: 106, h: 204, d: 78, x: -50, rest: 104, turn: -3, card: \"#1f2c63\", kg: 1.1, src: \"https://images.pexels.com/photos/4176566/pexels-photo-4176566.jpeg?auto=compress&cs=tinysrgb&w=500\", alt: \"Two cream pump bottles on an orange table in front of a red wall\", focus: \"55% 78%\" },\n  { name: \"Stem vase\", price: 46, w: 86, h: 236, d: 62, x: 57, rest: 150, turn: 4, card: \"#5ba9c4\", kg: 0.9, src: \"https://images.pexels.com/photos/7486841/pexels-photo-7486841.jpeg?auto=compress&cs=tinysrgb&w=500\", alt: \"Single calla lily in a small pink vase in front of an orange panel\", focus: \"40% 50%\" },\n];\n\n// Design pixels: x across the bag, y up from the table, z toward you.\nconst BW = 252;\nconst BH = 282;\nconst BD = 112;\nconst STRIPS = 18; // the front is this many panels so it can belly out\nconst CUFF = 30; // the turned-over band at the mouth\nconst SCENE_W = 900;\nconst SCENE_H = 730;\nconst FLOOR = 652;\nconst ZOOM = 1.32;\nconst DROP = 640; // height a carton falls from\nconst GRAVITY = 3300;\n\nconst RED = \"#e5442a\";\nconst RED_SIDE = \"#c2331c\";\nconst INSIDE = \"#f1e7d6\";\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst TOOTH = `url(\"data:image/svg+xml,${encodeURIComponent(\"<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -0.8 0.46'/></filter><rect width='180' height='180' filter='url(#n)'/></svg>\")}\")`;\n// what is printed and creased on the front, drawn once and shared by every panel\nconst FRONT = [\n  `linear-gradient(180deg, rgba(255,255,255,0.16) 0, rgba(255,255,255,0.05) ${CUFF - 1}px, rgba(60,0,0,0.34) ${CUFF}px, rgba(60,0,0,0) ${CUFF + 7}px)`,\n  `linear-gradient(180deg, rgba(60,0,0,0) ${BH - 75}px, rgba(60,0,0,0.3) ${BH - 73.5}px, rgba(255,225,205,0.2) ${BH - 72}px, rgba(255,225,205,0) ${BH - 64}px)`,\n  `linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 40%, rgba(60,0,0,0.22) 100%)`,\n  TOOTH,\n].join(\", \");\n\ntype Spring = { x: number; v: number; to: number; k: number; c: number };\nconst spring = (x: number, k: number, c: number): Spring => ({ x, v: 0, to: x, k, c });\nconst pull = (s: Spring, dt: number) => {\n  s.v += ((s.to - s.x) * s.k - s.v * s.c) * dt;\n  s.x += s.v * dt;\n};\n\nfunction Cord({ back }: { back?: boolean }) {\n  const d = \"M9 96 C 9 -22, 109 -22, 109 96\";\n  return (\n    <svg width=\"118\" height=\"100\" viewBox=\"0 0 118 100\" className=\"absolute left-0 top-0 overflow-visible\" aria-hidden=\"true\">\n      <path d={d} fill=\"none\" stroke=\"rgba(40,10,0,0.35)\" strokeWidth=\"11\" strokeLinecap=\"round\" transform=\"translate(1.5 2.5)\" />\n      <path d={d} fill=\"none\" stroke={back ? \"#b9a888\" : \"#d9c9a8\"} strokeWidth=\"9.5\" strokeLinecap=\"round\" />\n      <path d={d} fill=\"none\" stroke={back ? \"#8d7c5e\" : \"#a8946c\"} strokeWidth=\"9.5\" strokeDasharray=\"1.8 4.6\" />\n      <path d={d} fill=\"none\" stroke=\"rgba(255,250,235,0.7)\" strokeWidth=\"2.4\" strokeLinecap=\"round\" transform=\"translate(-2 -1.4)\" strokeDasharray=\"3.2 3.2\" />\n    </svg>\n  );\n}\n\nexport default function PaperShoppingBag() {\n  const reduce = !!useReducedMotion();\n  const [count, setCount] = useState(0);\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const sceneRef = useRef<HTMLDivElement>(null);\n  const camRef = useRef<HTMLDivElement>(null);\n  const bagRef = useRef<HTMLDivElement>(null);\n  const shadeRef = useRef<HTMLDivElement>(null);\n  const stripRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const glintRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const markRef = useRef<HTMLDivElement>(null);\n  const gussetRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const cordRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const sim = useRef({\n    n: 0,\n    items: goods.map(() => ({ on: false, y: DROP, v: 0, landed: false, down: false })),\n    belly: spring(0, 150, 9),\n    fold: spring(21, 110, 12),\n    lean: spring(0, 120, 6.5),\n    squash: spring(1, 520, 22),\n    cordF: spring(-34, 80, 5),\n    cordB: spring(-9, 70, 4.5),\n    lift: 0,\n    liftV: 0,\n    phase: \"stand\" as \"stand\" | \"lift\" | \"land\",\n    camX: 0,\n    camY: 0,\n    aimX: 0,\n    aimY: 0,\n    touched: false,\n    paused: false,\n    wake: () => {},\n  });\n\n  const settle = useCallback(() => {\n    const s = sim.current;\n    let kg = 0;\n    let tip = 0;\n    goods.forEach((g, i) => {\n      if (!s.items[i].down) return;\n      kg += g.kg;\n      tip += g.kg * g.x;\n    });\n    s.belly.to = clamp(kg * 6, 0, 25);\n    s.fold.to = clamp(21 - kg * 4.4, 3, 21);\n    s.lean.to = clamp(tip * 0.085, -3.4, 3.4);\n  }, []);\n\n  const add = useCallback(() => {\n    const s = sim.current;\n    if (s.phase !== \"stand\") return;\n    if (reduce) {\n      // no travel: the carton is simply in the bag, and a full bag is simply empty again\n      if (s.n >= goods.length) {\n        s.items.forEach((it) => (it.on = it.landed = it.down = false));\n        s.n = 0;\n      } else {\n        const it = s.items[s.n];\n        it.on = it.landed = it.down = true;\n        it.y = goods[s.n].rest;\n        s.n += 1;\n      }\n      setCount(s.n);\n      s.wake();\n      return;\n    }\n    if (s.n >= goods.length) {\n      s.phase = \"lift\";\n      s.cordF.to = -3;\n      s.cordB.to = -1;\n      s.wake();\n      return;\n    }\n    const it = s.items[s.n];\n    it.on = true;\n    it.y = DROP;\n    it.v = 0;\n    it.landed = false;\n    it.down = false;\n    s.n += 1;\n    setCount(s.n);\n    s.wake();\n  }, [reduce]);\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const scene = sceneRef.current;\n    const cam = camRef.current;\n    const bag = bagRef.current;\n    if (!wrap || !scene || !cam || !bag) return;\n    const s = sim.current;\n    let raf = 0;\n    let running = false;\n    let visible = true;\n    let last = 0;\n    let still = 0;\n\n    const fit = () => {\n      const sc = clamp(wrap.clientWidth / (SCENE_W - 200), 0.5, 1);\n      wrap.style.height = `${Math.round(SCENE_H * sc + (sc < 0.8 ? 104 : 64))}px`;\n      scene.style.transform = `translateX(-50%) scale(${sc.toFixed(4)})`;\n    };\n\n    const draw = () => {\n      const b = s.belly.x;\n      const sw = BW / STRIPS;\n      cam.style.transform = `scale3d(${ZOOM}, ${ZOOM}, ${ZOOM}) rotateX(${(-17 + s.camX).toFixed(2)}deg) rotateY(${(-31 + s.camY).toFixed(2)}deg)`;\n      bag.style.transform = `translate3d(0, ${(-s.lift).toFixed(1)}px, 0) rotateZ(${s.lean.x.toFixed(2)}deg) scaleY(${s.squash.x.toFixed(4)})`;\n      if (shadeRef.current) {\n        const k = clamp(1 - s.lift / 420, 0, 1);\n        shadeRef.current.style.opacity = (0.2 + k * 0.5).toFixed(3);\n        shadeRef.current.style.transform = `translate3d(${(s.lean.x * -5).toFixed(1)}px, 0, 0) rotateX(90deg) scale(${(1.25 - k * 0.25).toFixed(3)})`;\n      }\n      // the front: a row of panels laid along an arc\n      for (let i = 0; i < STRIPS; i++) {\n        const el = stripRefs.current[i];\n        if (!el) continue;\n        const z0 = b * Math.sin((Math.PI * i) / STRIPS);\n        const z1 = b * Math.sin((Math.PI * (i + 1)) / STRIPS);\n        const out = Math.atan2((z0 + z1) / 2, BH);\n        const ang = Math.atan2(z1 - z0, sw);\n        el.style.transform = `translate3d(${(-BW / 2 + i * sw - (i ? 1.6 : 0)).toFixed(2)}px, ${-BH}px, ${BD / 2}px) rotateX(${((-out * 180) / Math.PI).toFixed(3)}deg) rotateY(${((-ang * 90) / Math.PI).toFixed(3)}deg)`;\n        const g = glintRefs.current[i];\n        if (g) g.style.background = ang > 0 ? `rgba(255,232,214,${clamp(ang * 0.5, 0, 0.2).toFixed(3)})` : `rgba(70,0,0,${clamp(-ang * 0.95, 0, 0.36).toFixed(3)})`;\n      }\n      if (markRef.current) markRef.current.style.transform = `translate3d(-50%, 0, ${(BD / 2 + b * 0.56 + 1).toFixed(2)}px) rotateX(${((-Math.atan2(b, BH) * 180) / Math.PI).toFixed(2)}deg)`;\n      // side gussets: two panels each, meeting on a crease that the load pushes flat\n      const f = s.fold.x;\n      const glen = Math.hypot(BD / 2, f);\n      const a1 = (Math.atan2(BD / 2, -f) * 180) / Math.PI;\n      const a2 = (Math.atan2(BD / 2, f) * 180) / Math.PI;\n      const sides = [\n        `translate3d(${BW / 2}px, ${-BH}px, ${BD / 2}px) rotateY(${a1.toFixed(2)}deg)`,\n        `translate3d(${(BW / 2 - f).toFixed(2)}px, ${-BH}px, 0) rotateY(${a2.toFixed(2)}deg)`,\n        `translate3d(${-BW / 2}px, ${-BH}px, ${BD / 2}px) rotateY(${(180 - a1).toFixed(2)}deg)`,\n        `translate3d(${(-BW / 2 + f).toFixed(2)}px, ${-BH}px, 0) rotateY(${(180 - a2).toFixed(2)}deg)`,\n      ];\n      sides.forEach((t, i) => {\n        const el = gussetRefs.current[i];\n        if (!el) return;\n        el.style.width = `${(glen + 0.5).toFixed(2)}px`;\n        el.style.transform = t;\n      });\n      const hole = BD / 2 + b * Math.sin(Math.PI * 0.3) * 0.95;\n      if (cordRefs.current[0]) cordRefs.current[0].style.transform = `translate3d(-59px, ${-BH - 86}px, ${(hole + 1.2).toFixed(2)}px) rotateX(${s.cordF.x.toFixed(2)}deg)`;\n      if (cordRefs.current[1]) cordRefs.current[1].style.transform = `translate3d(-59px, ${-BH - 86}px, ${-BD / 2 + 2}px) rotateX(${s.cordB.x.toFixed(2)}deg)`;\n      goods.forEach((g, i) => {\n        const el = itemRefs.current[i];\n        if (!el) return;\n        const it = s.items[i];\n        el.style.visibility = it.on ? \"visible\" : \"hidden\";\n        if (!it.on) return;\n        const air = clamp((it.y - g.rest) / DROP, 0, 1);\n        el.style.transform = `translate3d(${(g.x - g.w / 2 + air * (i % 2 ? 26 : -22)).toFixed(1)}px, ${(-it.y - g.h).toFixed(1)}px, ${(air * 10).toFixed(1)}px) rotateZ(${(g.turn + air * (i % 2 ? 19 : -16)).toFixed(2)}deg) rotateY(${(air * (i % 2 ? -24 : 20)).toFixed(2)}deg)`;\n      });\n    };\n\n    const step = (dt: number) => {\n      let busy = false;\n      goods.forEach((g, i) => {\n        const it = s.items[i];\n        if (!it.on || it.landed) return;\n        busy = true;\n        it.v -= GRAVITY * dt;\n        it.y += it.v * dt;\n        if (it.y <= g.rest) {\n          it.y = g.rest;\n          const hit = -it.v;\n          it.down = true;\n          settle();\n          if (hit <= 260) {\n            it.v = 0;\n            it.landed = true;\n          } else {\n            it.v = hit * 0.2;\n            const m = g.kg * (hit / 1800);\n            s.belly.v += 95 * m;\n            s.fold.v -= 60 * m;\n            s.squash.v -= 0.5 * m;\n            s.lean.v += g.x * 0.36 * m;\n            s.cordF.v += 190 * m;\n            s.cordB.v -= 150 * m;\n          }\n        }\n      });\n      if (s.phase === \"lift\") {\n        busy = true;\n        s.liftV += 2600 * dt;\n        s.lift += s.liftV * dt;\n        s.lean.to = Math.sin(s.lift / 90) * 2.2;\n        if (s.lift > 900) {\n          s.items.forEach((it) => {\n            it.on = it.landed = it.down = false;\n          });\n          s.n = 0;\n          setCount(0);\n          settle();\n          s.belly.x = 0;\n          s.fold.x = 21;\n          s.phase = \"land\";\n          s.lift = 640;\n          s.liftV = 0;\n          s.cordF.to = -34;\n          s.cordB.to = -9;\n        }\n      } else if (s.phase === \"land\") {\n        busy = true;\n        s.liftV -= GRAVITY * 0.7 * dt;\n        s.lift += s.liftV * dt;\n        if (s.lift <= 0) {\n          s.lift = 0;\n          s.squash.v -= 0.9;\n          s.cordF.v += 260;\n          s.cordB.v -= 200;\n          s.lean.v += 9;\n          s.liftV = 0;\n          s.phase = \"stand\";\n        }\n      }\n      [s.belly, s.fold, s.lean, s.squash, s.cordF, s.cordB].forEach((sp) => pull(sp, dt));\n      s.cordF.x = clamp(s.cordF.x, -80, 6);\n      s.cordB.x = clamp(s.cordB.x, -40, 24);\n      s.camX += (s.aimY * -3 - s.camX) * Math.min(1, dt * 5);\n      s.camY += (s.aimX * 6 - s.camY) * Math.min(1, dt * 5);\n      const moving = Math.abs(s.belly.v) + Math.abs(s.lean.v) + Math.abs(s.cordF.v) + Math.abs(s.cordB.v) + Math.abs(s.squash.v) * 50 + Math.abs(s.aimX * 6 - s.camY) * 4 + Math.abs(s.aimY * -3 - s.camX) * 4;\n      return busy || moving > 0.25;\n    };\n\n    const frame = (now: number) => {\n      const dt = Math.min(0.034, (now - last) / 1000);\n      last = now;\n      const a = step(dt / 2);\n      const awake = step(dt / 2) || a;\n      draw();\n      still = awake ? 0 : still + 1;\n      if (still > 20) {\n        running = false;\n        return;\n      }\n      raf = requestAnimationFrame(frame);\n    };\n    const start = () => {\n      if (running || reduce || !visible || document.hidden) return;\n      running = true;\n      still = 0;\n      last = performance.now();\n      raf = requestAnimationFrame(frame);\n    };\n    const stop = () => {\n      running = false;\n      cancelAnimationFrame(raf);\n    };\n    const jump = () => {\n      settle();\n      [s.belly, s.fold, s.lean].forEach((sp) => (sp.x = sp.to));\n      draw();\n    };\n    s.wake = reduce ? jump : start;\n\n    if (reduce) {\n      s.items.forEach((it, i) => {\n        it.on = it.landed = it.down = true;\n        it.y = goods[i].rest;\n      });\n      s.n = goods.length;\n      setCount(goods.length);\n      jump();\n    }\n    fit();\n    draw();\n\n    // the demo: drop everything in, wait, carry the bag off and set down an empty one\n    let tick = 0;\n    const timer = window.setInterval(() => {\n      if (reduce || s.touched || s.paused || document.hidden || !visible) return;\n      tick += 1;\n      if (s.n < goods.length) {\n        if (tick >= 1) add();\n      } else if (tick > goods.length + 9) {\n        add();\n        tick = -4;\n      }\n    }, 480);\n    const first = window.setTimeout(() => !reduce && !s.touched && add(), 120);\n\n    const ro = new ResizeObserver(fit);\n    ro.observe(wrap);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible) start();\n      else stop();\n    });\n    io.observe(wrap);\n    const vis = () => (document.hidden ? stop() : start());\n    document.addEventListener(\"visibilitychange\", vis);\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    };\n  }, [add, reduce, settle]);\n\n  const press = () => {\n    sim.current.touched = true;\n    add();\n  };\n  const onMove = (e: React.PointerEvent) => {\n    if (reduce || e.pointerType === \"touch\") return;\n    const r = e.currentTarget.getBoundingClientRect();\n    sim.current.aimX = ((e.clientX - r.left) / r.width) * 2 - 1;\n    sim.current.aimY = ((e.clientY - r.top) / r.height) * 2 - 1;\n    sim.current.wake();\n  };\n\n  const next = goods[count];\n  const total = goods.slice(0, count).reduce((sum, g) => sum + g.price, 0);\n  const sw = BW / STRIPS;\n  const sidePaper = { backgroundColor: RED_SIDE, backgroundImage: `linear-gradient(180deg, rgba(255,255,255,0.1) 0, rgba(255,255,255,0.03) ${CUFF - 1}px, rgba(60,0,0,0.3) ${CUFF}px, rgba(60,0,0,0) ${CUFF + 7}px), ${TOOTH}` } as const;\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#dfe2e6]\">\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(64% 56% at 50% 46%, #f4f5f6 0%, #e3e6ea 52%, #c6cbd3 100%)\" }} />\n      <div\n        ref={wrapRef}\n        onPointerMove={onMove}\n        onPointerEnter={() => (sim.current.paused = true)}\n        onPointerLeave={() => {\n          sim.current.paused = false;\n          sim.current.aimX = 0;\n          sim.current.aimY = 0;\n          sim.current.wake();\n        }}\n        className=\"relative mx-auto w-full overflow-hidden\"\n        style={{ height: SCENE_H + 64 }}\n      >\n        <div ref={sceneRef} className=\"absolute left-1/2 top-0 select-none\" style={{ width: SCENE_W, height: SCENE_H, transformOrigin: \"50% 0\", transform: \"translateX(-50%)\", perspective: \"2100px\", perspectiveOrigin: \"50% 30%\" }}>\n          <div ref={camRef} className=\"absolute\" style={{ left: SCENE_W / 2 - 8, top: FLOOR, width: 0, height: 0, transformStyle: \"preserve-3d\", transform: `scale3d(${ZOOM}, ${ZOOM}, ${ZOOM}) rotateX(-17deg) rotateY(-31deg)` }}>\n            {/* shadow on the table */}\n            <div ref={shadeRef} aria-hidden=\"true\" className=\"absolute\" style={{ left: -250, top: -150, width: 520, height: 300, transform: \"rotateX(90deg)\", background: \"radial-gradient(closest-side, rgba(28,30,44,0.62) 0%, rgba(28,30,44,0.38) 42%, rgba(28,30,44,0) 100%)\" }} />\n\n            <div aria-hidden=\"true\" className=\"absolute\" style={{ left: -BW / 2 - 6, top: -BD / 2 - 6, width: BW + 30, height: BD + 22, transform: \"rotateX(90deg)\", background: \"rgba(20,22,34,0.55)\", filter: \"blur(9px)\" }} />\n            <div ref={bagRef} className=\"absolute left-0 top-0\" style={{ width: 0, height: 0, transformStyle: \"preserve-3d\", transformOrigin: \"0 0\" }}>\n              {/* back panel and the bottom, seen through the mouth */}\n              <div aria-hidden=\"true\" className=\"absolute\" style={{ left: -BW / 2, top: -BH, width: BW, height: BH, transform: `translateZ(${-BD / 2}px)`, backgroundColor: INSIDE, backgroundImage: `linear-gradient(180deg, rgba(70,44,20,0.16) 0%, rgba(60,36,14,0.5) 16%, rgba(40,22,8,0.86) 60%), ${TOOTH}` }} />\n              <div aria-hidden=\"true\" className=\"absolute\" style={{ left: -BW / 2 + 24, top: -BD / 2, width: BW - 48, height: BD, transform: \"rotateX(90deg)\", background: \"#3a2414\" }} />\n\n              {/* gussets: right pair is the outside you see, left pair is the inside */}\n              {[0, 1, 2, 3].map((i) => (\n                <div\n                  key={i}\n                  ref={(el) => {\n                    gussetRefs.current[i] = el;\n                  }}\n                  aria-hidden=\"true\"\n                  className=\"absolute left-0 top-0\"\n                  style={{ height: BH, transformOrigin: \"0 0\", ...(i < 2 ? sidePaper : { backgroundColor: INSIDE, backgroundImage: `linear-gradient(180deg, rgba(90,60,30,0.14) 0%, rgba(60,36,14,0.66) 100%), ${TOOTH}` }) }}\n                >\n                  {i < 2 && (\n                    <>\n                      <div className=\"absolute inset-0\" style={{ background: i === 0 ? \"linear-gradient(90deg, rgba(255,255,255,0.14), rgba(50,0,0,0.3))\" : \"linear-gradient(90deg, rgba(50,0,0,0.42), rgba(50,0,0,0.12))\" }} />\n                      {/* the diagonal folds at the foot of a gusset */}\n                      <div className=\"absolute bottom-0 h-[58px] w-full\" style={{ background: i === 0 ? \"linear-gradient(to top left, rgba(50,0,0,0) 49.2%, rgba(50,0,0,0.4) 50%, rgba(255,220,200,0.2) 51%, rgba(50,0,0,0) 52%)\" : \"linear-gradient(to top right, rgba(50,0,0,0) 49.2%, rgba(50,0,0,0.4) 50%, rgba(255,220,200,0.16) 51%, rgba(50,0,0,0) 52%)\" }} />\n                    </>\n                  )}\n                </div>\n              ))}\n\n              {/* cartons */}\n              {goods.map((g, i) => (\n                <div\n                  key={g.name}\n                  ref={(el) => {\n                    itemRefs.current[i] = el;\n                  }}\n                  className=\"absolute left-0 top-0\"\n                  style={{ width: g.w, height: g.h, transformStyle: \"preserve-3d\", visibility: \"hidden\" }}\n                >\n                  <div className=\"absolute inset-0 overflow-hidden\" style={{ transform: `translateZ(${g.d / 2}px)`, background: g.card }}>\n                    <img src={g.src} alt={g.alt} draggable={false} className=\"absolute inset-[5px] h-[calc(100%-10px)] w-[calc(100%-10px)] object-cover\" style={{ objectPosition: g.focus }} />\n                    <div className=\"absolute inset-0\" style={{ boxShadow: \"inset 0 0 0 5px rgba(255,255,255,0.94), inset 0 0 0 5.5px rgba(0,0,0,0.25)\" }} />\n                    <div className=\"absolute inset-0\" style={{ background: \"linear-gradient(120deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 34%, rgba(0,0,0,0) 66%, rgba(0,0,0,0.16) 100%)\" }} />\n                  </div>\n                  <div aria-hidden=\"true\" className=\"absolute inset-0\" style={{ transform: `translateZ(${-g.d / 2}px)`, background: g.card }} />\n                  <div aria-hidden=\"true\" className=\"absolute top-0\" style={{ left: (g.w - g.d) / 2, width: g.d, height: g.h, transform: `rotateY(90deg) translateZ(${g.w / 2}px)`, backgroundColor: g.card, backgroundImage: \"linear-gradient(90deg, rgba(0,0,0,0.12), rgba(0,0,0,0.34))\" }}>\n                    <div className=\"absolute left-1/2 top-1/2 whitespace-nowrap font-mono text-[6.5px] font-semibold uppercase tracking-[0.24em] text-white/85\" style={{ transform: \"translate(-50%,-50%) rotate(-90deg)\" }}>\n                      {g.h > 100 ? g.name : shop.name}\n                    </div>\n                  </div>\n                  <div aria-hidden=\"true\" className=\"absolute top-0\" style={{ left: (g.w - g.d) / 2, width: g.d, height: g.h, transform: `rotateY(-90deg) translateZ(${g.w / 2}px)`, backgroundColor: g.card, backgroundImage: \"linear-gradient(90deg, rgba(0,0,0,0.3), rgba(0,0,0,0.1))\" }} />\n                  <div aria-hidden=\"true\" className=\"absolute left-0\" style={{ top: (g.h - g.d) / 2, width: g.w, height: g.d, transform: `rotateX(90deg) translateZ(${g.h / 2}px)`, backgroundColor: g.card, backgroundImage: \"linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.14))\", boxShadow: \"inset 0 0 0 0.5px rgba(0,0,0,0.2)\" }}>\n                    <div className=\"absolute inset-x-0 top-1/2 h-px bg-black/20\" />\n                  </div>\n                </div>\n              ))}\n\n              {/* back cord, front panels, front cord */}\n              <div\n                ref={(el) => {\n                  cordRefs.current[1] = el;\n                }}\n                aria-hidden=\"true\"\n                className=\"absolute left-0 top-0\"\n                style={{ width: 118, height: 100, transformOrigin: \"50% 96px\" }}\n              >\n                <Cord back />\n              </div>\n              {Array.from({ length: STRIPS }, (_, i) => (\n                <div\n                  key={i}\n                  ref={(el) => {\n                    stripRefs.current[i] = el;\n                  }}\n                  aria-hidden=\"true\"\n                  className=\"absolute left-0 top-0\"\n                  style={{ width: sw + 3.2, height: BH, transformOrigin: \"0 100%\", backgroundColor: RED, backgroundImage: FRONT, backgroundSize: `${BW}px ${BH}px, ${BW}px ${BH}px, ${BW}px ${BH}px, 180px 180px`, backgroundPosition: `${-i * sw}px 0, ${-i * sw}px 0, ${-i * sw}px 0, ${-i * sw}px 0` }}\n                >\n                  <div\n                    ref={(el) => {\n                      glintRefs.current[i] = el;\n                    }}\n                    className=\"absolute inset-0\"\n                  />\n                  {(i === 5 || i === 12) && (\n                    <span className=\"absolute h-[9px] w-[9px] rounded-full\" style={{ top: 10, left: i === 5 ? sw * 0.43 - 4 : sw * 0.57 - 4, background: \"radial-gradient(circle at 40% 35%, #2a0c06, #100402)\", boxShadow: \"0 0 0 1.5px rgba(255,214,190,0.5), 0 1px 0 rgba(255,255,255,0.25)\" }} />\n                  )}\n                </div>\n              ))}\n              <div ref={markRef} className=\"pointer-events-none absolute left-0 text-center text-[#fff1e6]\" style={{ top: -BH + 112, width: 180 }}>\n                <div className=\"font-serif text-[34px] italic leading-none tracking-[-0.01em]\">{shop.name}</div>\n                <div className=\"mt-[9px] font-mono text-[6.5px] font-semibold uppercase tracking-[0.34em] text-[#fff1e6]/80\">{shop.line}</div>\n              </div>\n              <div\n                ref={(el) => {\n                  cordRefs.current[0] = el;\n                }}\n                aria-hidden=\"true\"\n                className=\"absolute left-0 top-0\"\n                style={{ width: 118, height: 100, transformOrigin: \"50% 96px\" }}\n              >\n                <Cord />\n              </div>\n            </div>\n          </div>\n        </div>\n\n        <div className=\"absolute bottom-5 left-5 right-5 flex items-end justify-between gap-4 sm:bottom-8 sm:left-8 sm:right-8\">\n          <p className=\"font-mono text-[11px] uppercase leading-relaxed tracking-[0.18em] text-[#5a606b]\" aria-live=\"polite\">\n            <span className=\"text-[#16181d]\">\n              {count} of {goods.length} in the bag\n            </span>\n            <span className=\"block\">Total £{total}</span>\n          </p>\n          <button\n            type=\"button\"\n            onClick={press}\n            className=\"min-h-[40px] max-w-[58%] shrink-0 rounded-full border border-[#16181d]/20 bg-white/70 px-4 py-2 text-right font-mono text-[11px] uppercase leading-snug tracking-[0.16em] text-[#16181d] outline-none transition-colors hover:bg-white focus-visible:ring-2 focus-visible:ring-[#e5442a] focus-visible:ring-offset-2 focus-visible:ring-offset-[#dfe2e6]\"\n          >\n            {next ? `Drop in the ${next.name.toLowerCase()}, £${next.price}` : \"Carry it off and start again\"}\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
