{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"olive-oil-bottle-hero-turning-on-a-seamless-backdrop-with-the-headline-orbiting-round-the-glass","type":"registry:block","title":"Olive Oil Bottle Hero Turning on a Seamless Backdrop with the Headline Orbiting Round the Glass","description":"Product hero where a dark glass bottle turns on a yellow backdrop and the headline circles it as a ring of type, passing behind. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/olive-oil-bottle-hero-turning-on-a-seamless-backdrop-with-the-headline-orbiting-round-the-glass.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n// The words on the page and on the bottle. The headline is set twice round the ring so half of it always faces you.\nconst hero = {\n  maker: \"Halden Grove\",\n  note: \"Early harvest, 500 ml\",\n  headline: \"Worth the wait\",\n  line: \"One grove, picked green in the first week of November and pressed the same night.\",\n  button: \"Reserve a bottle\",\n  label: { top: \"EARLY HARVEST\", name: \"Halden\", sub: \"GROVE\", foot: \"EXTRA VIRGIN OLIVE OIL\", lot: \"Lot 14  ·  500 ml\" },\n  back: [\"Pressed within six hours\", \"of picking. Unfiltered.\", \"Keep cool and out of\", \"the light. Shake gently.\"],\n};\n\n/** How far the camera looks down on the bottle. It bends the label edges, the base and the ring of type together. */\nconst TILT = 0.15;\n/** Seconds for one unaided turn of the bottle, and of the ring of type going the other way. */\nconst BOTTLE_TURN = 26;\nconst RING_TURN = 46;\n/** Bottle height in units of its own body radius. */\nconst TALL = 7.2;\nconst LABEL_TOP = 4.25;\nconst LABEL_TALL = 2.3;\nconst TEX_W = 1536;\nconst TEX_H = Math.round((TEX_W * LABEL_TALL) / (Math.PI * 2));\n\nconst step = (a: number, b: number, v: number) => {\n  const t = Math.min(1, Math.max(0, (v - a) / (b - a)));\n  return t * t * (3 - 2 * t);\n};\n\n/** Radius of the bottle at a height measured down from the top of the cap, both in body radii. */\nfunction profile(y: number) {\n  if (y < 0 || y > TALL) return 0;\n  if (y < 0.82) return 0.375 - 0.05 * Math.pow(Math.max(0, 1 - y / 0.07), 2);\n  if (y < 0.98) return 0.405;\n  if (y < 1.9) return 0.315 + 0.03 * ((y - 0.98) / 0.92);\n  if (y < 3.0) {\n    const t = (y - 1.9) / 1.1;\n    return 0.345 + 0.655 * Math.sqrt(1 - (1 - t) * (1 - t));\n  }\n  if (y < 7.0) return 1;\n  const t = (y - 7.0) / 0.2;\n  return 0.9 + 0.1 * Math.sqrt(Math.max(0, 1 - t * t));\n}\n\n/** What the glass mirrors: a tall window on the left with a glazing bar, a dim card on the right, a pale ceiling. */\nfunction studio(rx: number, ry: number, rz: number) {\n  const az = (Math.atan2(rx, rz) * 180) / Math.PI;\n  const el = (Math.asin(Math.max(-1, Math.min(1, -ry))) * 180) / Math.PI;\n  let light = 0.5 + 0.35 * step(-40, 60, el);\n  const tall = step(-34, -22, el) * (1 - step(62, 80, el));\n  const win = step(-74, -69, az) * (1 - step(-33, -29, az)) * tall;\n  const bar = 1 - 0.85 * step(-56, -54.5, az) * (1 - step(-51.5, -50, az));\n  light += 15 * win * bar;\n  light += 2.4 * step(36, 44, az) * (1 - step(70, 82, az)) * tall;\n  light += 5 * step(96, 104, az) * (1 - step(118, 126, az)) * tall;\n  light += 1.6 * step(58, 78, el);\n  return light;\n}\n\n/** Paints the bottle once, without its paper: black capsule, dark green glass, reflections and its shadow on the floor. */\nfunction paintBottle(cv: HTMLCanvasElement, R: number, cx: number, top: number) {\n  const ctx = cv.getContext(\"2d\");\n  if (!ctx) return;\n  const W = cv.width;\n  const H = cv.height;\n  ctx.clearRect(0, 0, W, H);\n\n  // Shadow first: a tight dark pool under the base and a long soft one thrown to the right, away from the window.\n  const floor = top + (TALL + TILT * 0.45) * R;\n  const pool = (dx: number, sx: number, sy: number, a: number) => {\n    ctx.save();\n    ctx.translate(cx + dx * R, floor);\n    ctx.scale(sx, sy);\n    const g = ctx.createRadialGradient(0, 0, 0, 0, 0, R);\n    g.addColorStop(0, `rgba(58,44,8,${a})`);\n    g.addColorStop(0.55, `rgba(58,44,8,${a * 0.45})`);\n    g.addColorStop(1, \"rgba(58,44,8,0)\");\n    ctx.fillStyle = g;\n    ctx.beginPath();\n    ctx.arc(0, 0, R, 0, Math.PI * 2);\n    ctx.fill();\n    ctx.restore();\n  };\n  pool(1.5, 2.9, 0.2, 0.3);\n  pool(0.5, 1.7, 0.2, 0.42);\n  pool(0.05, 1.12, 0.17, 0.85);\n  // Light that has come through the oil lands as a green smear inside the long shadow.\n  ctx.save();\n  ctx.translate(cx + 1.25 * R, floor + 0.02 * R);\n  ctx.scale(1.3, 0.1);\n  const through = ctx.createRadialGradient(0, 0, 0, 0, 0, R);\n  through.addColorStop(0, \"rgba(150,160,30,0.5)\");\n  through.addColorStop(1, \"rgba(150,160,30,0)\");\n  ctx.fillStyle = through;\n  ctx.beginPath();\n  ctx.arc(0, 0, R, 0, Math.PI * 2);\n  ctx.fill();\n  ctx.restore();\n\n  const x0 = Math.max(0, Math.floor(cx - R - 2));\n  const x1 = Math.min(W, Math.ceil(cx + R + 2));\n  const y0 = Math.max(0, Math.floor(top - TILT * R - 2));\n  const y1 = Math.min(H, Math.ceil(top + (TALL + TILT) * R + 2));\n  const img = ctx.getImageData(x0, y0, x1 - x0, y1 - y0);\n  const d = img.data;\n  const capR = profile(0.1);\n\n  for (let py = y0; py < y1; py++) {\n    for (let px = x0; px < x1; px++) {\n      const xs = (px + 0.5 - cx) / R;\n      const ys = (py + 0.5 - top) / R;\n      // Each ring of the bottle is seen as a shallow ellipse, so find the height whose front edge passes through this pixel.\n      let y = ys;\n      for (let k = 0; k < 4; k++) {\n        const r = profile(y);\n        y = ys - TILT * Math.sqrt(Math.max(0, r * r - xs * xs));\n      }\n      const r = profile(y);\n      let cr = 0;\n      let cg = 0;\n      let cb = 0;\n      let cover = 0;\n      if (y >= 0 && y <= TALL && Math.abs(xs) < r) {\n        cover = Math.min(1, (r - Math.abs(xs)) * R);\n        const slope = (profile(y + 0.012) - profile(y - 0.012)) / 0.024;\n        const side = xs / r;\n        const facing = Math.sqrt(Math.max(0, 1 - side * side));\n        const len = Math.sqrt(1 + slope * slope);\n        const nx = side / len;\n        const ny = -slope / len;\n        const nz = facing / len;\n        // Mirror the view direction in the surface to see which part of the studio this point shows.\n        const env = studio(2 * nz * nx, 2 * nz * ny, 2 * nz * nz - 1);\n        const fres = 0.045 + 0.955 * Math.pow(1 - nz, 5);\n        if (y < 0.98) {\n          // Matte black capsule with fine vertical ribs and one soft sheen.\n          const rib = 0.86 + 0.14 * Math.sin(Math.asin(side) * 46);\n          const lit = 0.3 + 0.9 * Math.max(0, nx * -0.5 + ny * -0.42 + nz * 0.76);\n          const sheen = Math.pow(Math.max(0, nx * -0.36 + ny * -0.3 + nz * 0.88), 26) * 70;\n          const v = 24 * lit * rib + sheen + env * fres * 3;\n          cr = v;\n          cg = v;\n          cb = v * 1.02;\n          if (y > 0.82 && y < 0.86) {\n            cr *= 0.5;\n            cg *= 0.5;\n            cb *= 0.5;\n          }\n        } else {\n          // Dark green glass: nearly black face on, the room mirrored on top, and oil glowing where light gets through.\n          const glow = step(0.1, 0.98, side) * 0.55 + step(6.55, 7.1, y) * (0.35 + 0.65 * step(-0.6, 0.9, side)) * 0.9;\n          const thin = y < 3 ? 0.55 : 1;\n          cr = 9 + 96 * glow * thin + env * fres * 236;\n          cg = 17 + 112 * glow * thin + env * fres * 232;\n          cb = 12 + 12 * glow * thin + env * fres * 214;\n          // The thick base ring shows as a darker line just above the foot.\n          const foot = step(6.93, 6.97, y) * (1 - step(7.0, 7.04, y));\n          cr *= 1 - 0.45 * foot;\n          cg *= 1 - 0.4 * foot;\n          cb *= 1 - 0.45 * foot;\n        }\n      } else if (ys < TILT * capR) {\n        // The flat top of the capsule, seen as a thin ellipse.\n        const ex = xs / capR;\n        const ey = ys / (TILT * capR);\n        const q = ex * ex + ey * ey;\n        if (q < 1) {\n          cover = Math.min(1, (1 - Math.sqrt(q)) * capR * R);\n          const v = 58 - 16 * ex;\n          cr = v;\n          cg = v;\n          cb = v + 1;\n        }\n      }\n      if (cover > 0) {\n        const i = ((py - y0) * (x1 - x0) + (px - x0)) * 4;\n        const under = d[i + 3] / 255;\n        const keep = (1 - cover) * under;\n        const a = cover + keep;\n        d[i] = (Math.min(255, cr) * cover + d[i] * keep) / a;\n        d[i + 1] = (Math.min(255, cg) * cover + d[i + 1] * keep) / a;\n        d[i + 2] = (Math.min(255, cb) * cover + d[i + 2] * keep) / a;\n        d[i + 3] = a * 255;\n      }\n    }\n  }\n  ctx.putImageData(img, x0, y0);\n}\n\n/** The light and shade that lies over the paper wherever it happens to be: darker toward the edges, a faint window sheen. */\nfunction paintPaperLight(cv: HTMLCanvasElement, R: number) {\n  const ctx = cv.getContext(\"2d\");\n  if (!ctx) return;\n  const img = ctx.createImageData(cv.width, cv.height);\n  const d = img.data;\n  for (let px = 0; px < cv.width; px++) {\n    const side = Math.max(-0.999, Math.min(0.999, (px + 0.5 - R) / R));\n    const nz = Math.sqrt(1 - side * side);\n    const lit = (0.56 + 0.62 * Math.max(0, side * -0.42 + nz * 0.84)) * (0.6 + 0.4 * Math.pow(nz, 0.7));\n    const az = (Math.asin(side) * 360) / Math.PI;\n    const sheen = 0.045 * step(-84, -58, az) * (1 - step(-44, -18, az));\n    for (let py = 0; py < cv.height; py++) {\n      const i = (py * cv.width + px) * 4;\n      if (lit < 1) {\n        d[i] = 34;\n        d[i + 1] = 30;\n        d[i + 2] = 8;\n        d[i + 3] = (1 - lit) * 255 * (1 - sheen * 3);\n      } else {\n        d[i] = d[i + 1] = d[i + 2] = 255;\n        d[i + 3] = Math.min(1, (lit - 1) * 0.8 + sheen) * 255;\n      }\n    }\n  }\n  ctx.putImageData(img, 0, 0);\n}\n\n/** Prints the front and back labels flat, as one strip that wraps the whole way round the bottle (twice, so it can be read past the seam). */\nfunction printLabels(): HTMLCanvasElement {\n  const cv = document.createElement(\"canvas\");\n  cv.width = TEX_W * 2;\n  cv.height = TEX_H;\n  const c = cv.getContext(\"2d\");\n  if (!c) return cv;\n  const ink = \"#1f3a29\";\n  const serif = 'Georgia, \"Times New Roman\", serif';\n  const paper = (x: number, y: number, w: number, h: number) => {\n    c.fillStyle = \"#f2ead6\";\n    c.fillRect(x, y, w, h);\n    // Laid paper: faint darker fibres.\n    for (let k = 0; k < 900; k++) {\n      c.fillStyle = `rgba(120,100,60,${0.03 + Math.random() * 0.05})`;\n      const long = 1 + Math.random() * 14;\n      c.fillRect(x + Math.random() * (w - long), y + Math.random() * (h - 1), long, 1);\n    }\n  };\n  for (let copy = 0; copy < 2; copy++) {\n    const o = copy * TEX_W;\n    // Front label, centred on the start of the strip, so it is drawn in two halves across the seam.\n    const fw = TEX_W * 0.4;\n    for (const fx of [o - fw / 2, o + TEX_W - fw / 2]) {\n      const mid = fx + fw / 2;\n      paper(fx, 0, fw, TEX_H);\n      c.fillStyle = \"#c8452b\";\n      c.fillRect(fx, 0, fw, TEX_H * 0.045);\n      c.strokeStyle = ink;\n      c.lineWidth = 3;\n      c.strokeRect(fx + 24, TEX_H * 0.045 + 22, fw - 48, TEX_H * 0.955 - 46);\n      c.fillStyle = ink;\n      c.textAlign = \"center\";\n      c.textBaseline = \"middle\";\n      const spaced = (text: string, y: number, size: number, gap: number, weight = \"600\") => {\n        c.font = `${weight} ${size}px ${serif}`;\n        const widths = [...text].map((ch) => c.measureText(ch).width + gap);\n        let x = mid - widths.reduce((a, b) => a + b, 0) / 2;\n        [...text].forEach((ch, i) => {\n          c.fillText(ch, x + widths[i] / 2, y);\n          x += widths[i];\n        });\n      };\n      spaced(hero.label.top, TEX_H * 0.17, 23, 9);\n      // An olive sprig: a bowed stem, leaves in pairs, two fruit.\n      c.save();\n      c.translate(mid, TEX_H * 0.33);\n      c.strokeStyle = ink;\n      c.lineWidth = 3;\n      c.beginPath();\n      c.moveTo(-120, 16);\n      c.quadraticCurveTo(0, -22, 120, 10);\n      c.stroke();\n      for (let k = 0; k < 7; k++) {\n        const t = k / 6;\n        const lx = -112 + t * 224;\n        const ly = 16 - 26 * Math.sin(t * Math.PI) * 0.9 + (t > 0.5 ? (t - 0.5) * -8 : 0);\n        for (const up of [-1, 1]) {\n          c.save();\n          c.translate(lx, ly);\n          c.rotate(up * (0.75 - t * 0.25) - 0.1);\n          c.beginPath();\n          c.ellipse(21, 0, 23, 6.5, 0, 0, Math.PI * 2);\n          c.fillStyle = up < 0 ? ink : \"#55713a\";\n          c.fill();\n          c.restore();\n        }\n      }\n      c.fillStyle = \"#c8452b\";\n      for (const [ox, oy] of [[-34, 34], [46, 30]]) {\n        c.beginPath();\n        c.ellipse(ox, oy, 10, 13, 0.2, 0, Math.PI * 2);\n        c.fill();\n      }\n      c.restore();\n      c.fillStyle = ink;\n      c.font = `italic 400 ${Math.round(TEX_H * 0.27)}px ${serif}`;\n      c.fillText(hero.label.name, mid, TEX_H * 0.575);\n      spaced(hero.label.sub, TEX_H * 0.735, 34, 22, \"400\");\n      c.fillRect(mid - 26, TEX_H * 0.805, 52, 2);\n      spaced(hero.label.foot, TEX_H * 0.865, 17, 5);\n      spaced(hero.label.lot, TEX_H * 0.925, 16, 3, \"400\");\n    }\n    // Back label: smaller, lower, plain.\n    const bw = TEX_W * 0.2;\n    const bx = o + TEX_W * 0.5 - bw / 2;\n    const by = TEX_H * 0.24;\n    const bh = TEX_H * 0.6;\n    paper(bx, by, bw, bh);\n    c.fillStyle = ink;\n    c.textAlign = \"left\";\n    c.font = `italic 400 30px ${serif}`;\n    c.fillText(hero.label.name, bx + 26, by + 44);\n    c.fillRect(bx + 26, by + 70, bw - 52, 1.5);\n    c.font = `400 17px ${serif}`;\n    hero.back.forEach((text, i) => c.fillText(text, bx + 26, by + 104 + i * 27));\n    c.fillRect(bx + 26, by + bh - 74, bw - 52, 1.5);\n    c.font = `600 15px ${serif}`;\n    c.fillText(hero.label.lot, bx + 26, by + bh - 42);\n  }\n  return cv;\n}\n\nexport default function OliveOilBottleHeroTurningOnASeamlessBackdropWithTheHeadlineOrbitingRoundTheGlass() {\n  const reduce = useReducedMotion();\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const ring = useRef<HTMLDivElement>(null);\n  /** Bottle angle in turns, its spin in turns per second, and the drag in progress if there is one. */\n  const spin = useRef({ angle: 0, speed: 0, ringAngle: 0, dragX: null as number | null, dragAt: 0, radius: 70 });\n\n  const once = [...hero.headline, \" \", \"•\", \" \"];\n  const letters = [...once, ...once];\n\n  useEffect(() => {\n    const el = stage.current;\n    const cv = canvas.current;\n    const band = ring.current;\n    if (!el || !cv || !band) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const glyphs = Array.from(band.children) as HTMLElement[];\n    const texture = printLabels();\n    const body = document.createElement(\"canvas\");\n    const paper = document.createElement(\"canvas\");\n    const light = document.createElement(\"canvas\");\n    const idle = reduce ? 0 : 1 / BOTTLE_TURN;\n    const s = spin.current;\n    // Start a little before the label faces front, so it is square on a couple of seconds in.\n    s.angle = reduce ? -0.02 : -0.02 - idle * 2.6;\n    s.speed = idle;\n    s.ringAngle = reduce ? 0 : 2.6 / RING_TURN;\n\n    let R = 70;\n    let cx = 0;\n    let top = 0;\n    let ringR = 300;\n    let ringY = 0;\n    let offsets: number[] = [];\n    let widths: number[] = [];\n    let glyphH = 0;\n    let visible = true;\n    let raf = 0;\n    let last = 0;\n    let drawn = NaN;\n\n    const layout = () => {\n      const w = el.clientWidth;\n      const h = el.clientHeight;\n      const ratio = Math.min(window.devicePixelRatio || 1, 2);\n      const r = Math.min(h * 0.122, w * 0.15, 82);\n      R = Math.round(r * ratio);\n      s.radius = r;\n      cv.width = Math.round(w * ratio);\n      cv.height = Math.round(h * ratio);\n      cx = Math.round(cv.width / 2);\n      top = Math.round(h * 0.035 * ratio + TILT * R);\n      body.width = cv.width;\n      body.height = cv.height;\n      paintBottle(body, R, cx, top);\n      paper.width = light.width = R * 2;\n      paper.height = light.height = Math.ceil((LABEL_TALL + TILT) * R) + 2;\n      paintPaperLight(light, R);\n\n      // Set the type so that the whole string exactly closes the ring.\n      ringR = Math.min(w * 0.4, 430);\n      ringY = top / ratio + 2.95 * r;\n      band.style.fontSize = \"100px\";\n      glyphs.forEach((g) => (g.style.transform = \"none\"));\n      const raw = glyphs.map((g) => g.getBoundingClientRect().width);\n      const total = raw.reduce((a, b) => a + b, 0) || 1;\n      const size = (100 * Math.PI * 2 * ringR) / total;\n      band.style.fontSize = `${size}px`;\n      widths = raw.map((v) => (v * size) / 100);\n      glyphH = glyphs[0] ? glyphs[0].offsetHeight : size;\n      let run = 0;\n      offsets = widths.map((v) => {\n        const mid = run + v / 2;\n        run += v;\n        return mid / ((total * size) / 100);\n      });\n      drawn = NaN;\n    };\n\n    const draw = () => {\n      const turn = s.angle - Math.floor(s.angle);\n      ctx.clearRect(0, 0, cv.width, cv.height);\n      ctx.drawImage(body, 0, 0);\n      // The paper: one thin slice of the flat print per column, squeezed toward the edges as the glass curves away.\n      const pc = paper.getContext(\"2d\");\n      if (pc) {\n        pc.globalCompositeOperation = \"source-over\";\n        pc.clearRect(0, 0, paper.width, paper.height);\n        const tall = LABEL_TALL * R;\n        for (let px = 0; px < R * 2; px++) {\n          const a = Math.max(-1, Math.min(1, (px - R) / R));\n          const b = Math.max(-1, Math.min(1, (px + 1 - R) / R));\n          const ua = Math.asin(a) / (Math.PI * 2);\n          const ub = Math.asin(b) / (Math.PI * 2);\n          const from = (((ua - turn) % 1) + 1) % 1;\n          const facing = Math.sqrt(1 - ((a + b) / 2) * ((a + b) / 2));\n          pc.drawImage(texture, from * TEX_W, 0, Math.max(0.5, (ub - ua) * TEX_W), TEX_H, px, Math.round(TILT * R * facing), 1, Math.round(tall));\n        }\n        pc.globalCompositeOperation = \"source-atop\";\n        pc.drawImage(light, 0, 0);\n        ctx.drawImage(paper, cx - R, top + LABEL_TOP * R);\n      }\n\n      // The headline: each letter rides a tilted circle, shrinks and mirrors as it goes round the back, and drops behind the glass.\n      const cssX = el.clientWidth / 2;\n      for (let i = 0; i < glyphs.length; i++) {\n        const th = (offsets[i] - 0.22 + s.ringAngle) * Math.PI * 2;\n        const z = Math.cos(th);\n        const depth = 1 + 0.13 * z;\n        const x = cssX + ringR * Math.sin(th) - widths[i] / 2;\n        const y = ringY + TILT * ringR * z - glyphH / 2;\n        const g = glyphs[i];\n        g.style.transform = `matrix(${(depth * z).toFixed(4)},${(-depth * TILT * Math.sin(th)).toFixed(4)},0,${depth.toFixed(4)},${x.toFixed(2)},${y.toFixed(2)})`;\n        // Edge on, a letter is a sliver, so it fades out for the moment it turns over.\n        g.style.opacity = ((0.34 + 0.66 * step(-0.3, 0.2, z)) * step(0.04, 0.22, Math.abs(z))).toFixed(3);\n        g.style.zIndex = z > 0 ? \"30\" : \"10\";\n      }\n    };\n\n    const loop = (stamp: number) => {\n      const dt = Math.min(last ? (stamp - last) / 1000 : 0.016, 0.05);\n      last = stamp;\n      if (s.dragX === null) {\n        // Let go, the bottle coasts and settles back to its slow unaided turn.\n        s.speed += (idle - s.speed) * Math.min(1, dt * 1.1);\n        s.angle += s.speed * dt;\n      }\n      if (!reduce) s.ringAngle += (-1 / RING_TURN - (s.speed - idle) * 0.22) * dt;\n      else s.ringAngle -= s.speed * 0.22 * dt;\n      const key = s.angle * 7 + s.ringAngle;\n      if (key !== drawn) {\n        draw();\n        drawn = key;\n      }\n      raf = visible && !document.hidden ? requestAnimationFrame(loop) : 0;\n    };\n    const wake = () => {\n      if (!raf && visible && !document.hidden) {\n        last = 0;\n        raf = requestAnimationFrame(loop);\n      }\n    };\n\n    layout();\n    draw();\n    const ro = new ResizeObserver(() => {\n      layout();\n      draw();\n    });\n    ro.observe(el);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      wake();\n    });\n    io.observe(el);\n    document.addEventListener(\"visibilitychange\", wake);\n    wake();\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", wake);\n    };\n  }, [reduce]);\n\n  function grab(e: ReactPointerEvent<HTMLButtonElement>) {\n    e.currentTarget.setPointerCapture(e.pointerId);\n    spin.current.dragX = e.clientX;\n    spin.current.dragAt = performance.now();\n    spin.current.speed = 0;\n  }\n  function drag(e: ReactPointerEvent<HTMLButtonElement>) {\n    const s = spin.current;\n    if (s.dragX === null) return;\n    const now = performance.now();\n    // Moving the hand one bottle radius turns the surface by the same distance.\n    const turned = (e.clientX - s.dragX) / (s.radius * Math.PI * 2);\n    const dt = Math.max(0.008, (now - s.dragAt) / 1000);\n    s.angle += turned;\n    s.speed = s.speed * 0.6 + (turned / dt) * 0.4;\n    s.dragX = e.clientX;\n    s.dragAt = now;\n  }\n  function release() {\n    const s = spin.current;\n    s.dragX = null;\n    s.speed = Math.max(-1.6, Math.min(1.6, s.speed));\n  }\n  function onKey(e: ReactKeyboardEvent<HTMLButtonElement>) {\n    if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\") return;\n    e.preventDefault();\n    spin.current.speed = e.key === \"ArrowRight\" ? 0.5 : -0.5;\n    if (reduce) spin.current.angle += e.key === \"ArrowRight\" ? 0.06 : -0.06;\n  }\n\n  return (\n    <section className=\"relative isolate h-[700px] w-full overflow-hidden bg-[#e6d49c] sm:h-[820px]\">\n      <style>{`\n        .oob-glyph { position: absolute; left: 0; top: 0; display: block; white-space: pre; line-height: 1; transform-origin: 50% 50%; will-change: transform, opacity; }\n      `}</style>\n      {/* The paper sweep: wall above, floor below, with no visible join. */}\n      <div aria-hidden=\"true\" className=\"absolute inset-0 -z-10\" style={{ background: \"radial-gradient(90% 55% at 42% 30%, #f3e6b8 0%, #e6d49c 55%, #d6c184 100%)\" }} />\n      <div aria-hidden=\"true\" className=\"absolute inset-x-0 bottom-0 -z-10 h-[30%]\" style={{ background: \"linear-gradient(180deg, rgba(214,193,132,0) 0%, rgba(201,178,112,0.75) 100%)\" }} />\n\n      <header className=\"absolute inset-x-0 top-0 z-40 flex items-center justify-between px-5 pt-5 text-[13px] font-medium text-[#1f3a29] sm:px-10 sm:pt-8\">\n        <span className=\"font-serif text-[17px] italic\">{hero.maker}</span>\n        <span>{hero.note}</span>\n      </header>\n\n      <h1 className=\"sr-only\">{hero.headline}</h1>\n\n      <div ref={stage} className=\"absolute inset-x-0 top-[52px] h-[470px] sm:top-[40px] sm:h-[640px]\">\n        <div ref={ring} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 select-none font-serif text-[#bd3a1f]\">\n          {letters.map((ch, i) => (\n            <span key={i} className=\"oob-glyph\">\n              {ch}\n            </span>\n          ))}\n        </div>\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 z-20 h-full w-full\" />\n        <button\n          type=\"button\"\n          aria-label=\"Turn the bottle. Drag it sideways, or use the left and right arrow keys.\"\n          onPointerDown={grab}\n          onPointerMove={drag}\n          onPointerUp={release}\n          onPointerCancel={release}\n          onKeyDown={onKey}\n          className=\"absolute left-1/2 top-[3%] z-40 h-[94%] w-[150px] -translate-x-1/2 cursor-grab touch-pan-y rounded-[40px] active:cursor-grabbing focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1f3a29] focus-visible:ring-offset-4 focus-visible:ring-offset-[#e6d49c] sm:w-[190px]\"\n        />\n      </div>\n\n      <div className=\"absolute inset-x-0 bottom-0 z-40 flex flex-col items-center gap-5 px-6 pb-7 text-center sm:pb-9\">\n        <p className=\"max-w-[21rem] text-[14px] font-medium leading-snug text-[#1f3a29] sm:max-w-md sm:text-[15px]\">{hero.line}</p>\n        <a\n          href=\"#\"\n          className=\"inline-flex h-12 items-center rounded-full bg-[#1f3a29] px-7 text-[15px] font-semibold text-[#f6efd6] shadow-[0_14px_26px_-14px_rgba(31,58,41,0.9)] transition-transform duration-200 hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1f3a29] focus-visible:ring-offset-2 focus-visible:ring-offset-[#e6d49c] motion-reduce:transition-none\"\n        >\n          {hero.button}\n        </a>\n      </div>\n    </section>\n  );\n}\n"}]}
