{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-scroll-ring",
  "type": "registry:component",
  "title": "Hero Scroll Ring",
  "description": "A ring of product cards seen from above tilts up to eye level and turns as you scroll. The piece facing you is named in the footer with its number and price.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hero",
    "hero",
    "scroll",
    "3d ring",
    "carousel",
    "shop",
    "collection"
  ],
  "docs": "https://hyperblur.dev/effects/hero-scroll-ring",
  "files": [
    {
      "path": "registry/hyperblur/hero-scroll-ring.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hero-scroll-ring.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HeroScrollRingLink {\n  label: string;\n  href: string;\n}\n\nexport interface HeroScrollRingPiece {\n  name: string;\n  price: string;\n  glaze: string;\n  backdrop: string;\n}\n\nexport interface HeroScrollRingProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  title?: string;\n  subtitle?: string;\n  pieces?: HeroScrollRingPiece[];\n  cta?: HeroScrollRingLink | null;\n  turns?: number;\n  accent?: string;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n  length?: number;\n  height?: string;\n  headingAs?: \"h1\" | \"h2\";\n}\n\nconst defaultPieces: HeroScrollRingPiece[] = [\n  { name: \"Tide vase\", price: \"$84\", glaze: \"#d9e4e0\", backdrop: \"#4b6a72\" },\n  { name: \"Ember bowl\", price: \"$62\", glaze: \"#e0855a\", backdrop: \"#3a2219\" },\n  { name: \"Salt jug\", price: \"$96\", glaze: \"#efe7da\", backdrop: \"#8f7f6a\" },\n  { name: \"Moss cup\", price: \"$34\", glaze: \"#8ea06a\", backdrop: \"#29331f\" },\n  { name: \"Dune bottle\", price: \"$110\", glaze: \"#d8b98c\", backdrop: \"#5a4630\" },\n  { name: \"Ink pitcher\", price: \"$128\", glaze: \"#2b3550\", backdrop: \"#a7b2c8\" },\n  { name: \"Clay lantern\", price: \"$74\", glaze: \"#c6704f\", backdrop: \"#f0d9c2\" },\n  { name: \"Frost carafe\", price: \"$88\", glaze: \"#f4f6f7\", backdrop: \"#30383d\" },\n  { name: \"Plum vessel\", price: \"$142\", glaze: \"#7b3f5c\", backdrop: \"#e6c9d3\" },\n  { name: \"Ash platter\", price: \"$58\", glaze: \"#9a9690\", backdrop: \"#1f1e1c\" },\n];\n\nconst shapes = [\n  \"M40 14h20v8c0 6 14 12 14 34 0 22-10 34-24 34S26 78 26 56c0-22 14-28 14-34z\",\n  \"M16 52h68c0 20-16 34-34 34S16 72 16 52z\",\n  \"M38 16h18l-2 10c12 4 18 16 18 32 0 20-10 30-22 30S28 78 28 58c0-14 4-26 12-30l-6-4z\",\n  \"M30 40h40l-4 44H34z\",\n  \"M44 10h12v20c10 6 14 16 14 30 0 18-8 28-20 28S30 78 30 60c0-14 4-24 14-30z\",\n];\n\nconst css = `\n.hb-va8 {\n  --hb-va8-accent: #f2a5c0;\n  --hb-va8-rx: -62deg;\n  --hb-va8-ry: 0deg;\n  --hb-va8-sc: 0.72;\n  --hb-va8-o: 0;\n  position: relative;\n  width: 100%;\n  height: var(--hb-va8-h);\n  color: #f2ede6;\n  font-family: inherit;\n  background: #0c0a0a;\n}\n.hb-va8[data-pinned=\"true\"] { height: calc(var(--hb-va8-h) * var(--hb-va8-len)); }\n.hb-va8 *, .hb-va8 *::before, .hb-va8 *::after { box-sizing: border-box; }\n.hb-va8-stage {\n  position: sticky;\n  top: 0;\n  height: var(--hb-va8-h);\n  overflow: hidden;\n  container-type: size;\n  isolation: isolate;\n  perspective: 1300px;\n  perspective-origin: 50% 40%;\n  background:\n    radial-gradient(40% 30% at 50% 82%, color-mix(in srgb, var(--hb-va8-accent) 16%, transparent), transparent 70%),\n    radial-gradient(70% 60% at 50% 30%, #1a1414, #0c0a0a 70%);\n}\n.hb-va8-head {\n  position: absolute;\n  inset: 0 0 auto;\n  z-index: 2;\n  display: flex;\n  align-items: flex-start;\n  justify-content: space-between;\n  gap: 2rem;\n  padding: 5cqh 4.5cqw 0;\n}\n.hb-va8-brand {\n  display: block;\n  margin-bottom: 0.9em;\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(10px, 1.1cqw, 12px);\n  letter-spacing: 0.2em;\n  text-transform: uppercase;\n  color: var(--hb-va8-accent);\n}\n.hb-va8-title {\n  max-width: 13ch;\n  margin: 0;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(1.6rem, 4.4cqw, 4rem);\n  font-weight: 500;\n  line-height: 0.98;\n  letter-spacing: -0.04em;\n}\n.hb-va8-sub {\n  max-width: 28ch;\n  margin: 0;\n  padding-top: 1.8em;\n  font-size: clamp(11px, 1.3cqw, 15px);\n  line-height: 1.55;\n  text-align: right;\n  color: rgba(242, 237, 230, 0.55);\n}\n.hb-va8-ring {\n  position: absolute;\n  left: 50%;\n  top: 60%;\n  width: 0;\n  height: 0;\n  transform-style: preserve-3d;\n  transform: scale(var(--hb-va8-sc)) rotateX(var(--hb-va8-rx)) rotateY(var(--hb-va8-ry));\n  will-change: transform;\n}\n.hb-va8-card {\n  position: absolute;\n  left: -6.5cqw;\n  top: -9cqw;\n  width: 13cqw;\n  height: 18cqw;\n  border-radius: 1cqw;\n  overflow: hidden;\n  transform: rotateY(var(--hb-va8-a)) translateZ(23cqw);\n  background:\n    radial-gradient(80% 50% at 50% 100%, rgba(0, 0, 0, 0.35), transparent 70%),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-va8-bg) 80%, #fff 20%), var(--hb-va8-bg));\n  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 2cqw 3cqw -1cqw rgba(0, 0, 0, 0.6);\n}\n.hb-va8-card::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(115deg, rgba(255, 255, 255, 0.22), transparent 38%);\n  mix-blend-mode: soft-light;\n}\n.hb-va8-card svg { position: absolute; left: 10%; bottom: 14%; width: 80%; }\n.hb-va8-shadow {\n  position: absolute;\n  left: 22%;\n  right: 22%;\n  bottom: 12%;\n  height: 6%;\n  border-radius: 50%;\n  background: rgba(0, 0, 0, 0.35);\n  filter: blur(4px);\n}\n.hb-va8-tag {\n  position: absolute;\n  left: 8%;\n  top: 6%;\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(6px, 0.8cqw, 10px);\n  letter-spacing: 0.12em;\n  color: rgba(255, 255, 255, 0.75);\n  mix-blend-mode: difference;\n}\n.hb-va8-foot {\n  position: absolute;\n  inset: auto 4.5cqw 5cqh;\n  z-index: 2;\n  display: flex;\n  align-items: flex-end;\n  justify-content: space-between;\n  gap: 1.5rem;\n}\n.hb-va8-now { font-size: clamp(12px, 1.5cqw, 17px); }\n.hb-va8-now small {\n  display: block;\n  margin-bottom: 0.4em;\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: 0.72em;\n  letter-spacing: 0.16em;\n  color: rgba(242, 237, 230, 0.5);\n}\n.hb-va8-now b { font-weight: 600; }\n.hb-va8-now span { margin-left: 0.6em; color: var(--hb-va8-accent); }\n.hb-va8-cta {\n  display: inline-flex;\n  align-items: center;\n  gap: 0.6em;\n  padding: 0.75em 1.3em;\n  border-radius: 999px;\n  border: 1px solid rgba(242, 237, 230, 0.2);\n  color: #f2ede6;\n  font-size: clamp(12px, 1.35cqw, 15px);\n  font-weight: 500;\n  text-decoration: none;\n  background: rgba(242, 237, 230, 0.04);\n  transition: background 0.3s ease, border-color 0.3s ease;\n}\n.hb-va8-cta:hover { background: rgba(242, 237, 230, 0.1); border-color: rgba(242, 237, 230, 0.4); }\n.hb-va8-cta:focus-visible { outline: 2px solid var(--hb-va8-accent); outline-offset: 3px; }\n.hb-va8-cta i {\n  display: grid;\n  place-items: center;\n  width: 1.6em;\n  height: 1.6em;\n  border-radius: 50%;\n  background: var(--hb-va8-accent);\n  color: #2a0f19;\n  font-style: normal;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-va8-cta { transition: none; }\n}\n`;\n\nfunction findScroller(el: HTMLElement): HTMLElement | null {\n  let node = el.parentElement;\n  while (node && node !== document.body && node !== document.documentElement) {\n    const oy = getComputedStyle(node).overflowY;\n    if ((oy === \"auto\" || oy === \"scroll\" || oy === \"overlay\") && node.scrollHeight > node.clientHeight + 1) return node;\n    node = node.parentElement;\n  }\n  return null;\n}\n\nfunction ease(x: number) {\n  return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\n\nfunction clamp01(x: number) {\n  return Math.min(1, Math.max(0, x));\n}\n\nfunction loopAt(ms: number, duration: number) {\n  const d = Math.max(1, duration) * 1000;\n  const back = d * 0.7;\n  const hold = 1400;\n  const t = ms % (d + hold + back + 700);\n  if (t < d) return ease(t / d);\n  if (t < d + hold) return 1;\n  if (t < d + hold + back) return 1 - ease((t - d - hold) / back);\n  return 0;\n}\n\nfunction useScrollProgress(\n  ref: React.RefObject<HTMLElement | null>,\n  apply: (p: number) => void,\n  progress: number | undefined,\n  autoPlay: boolean,\n  duration: number,\n) {\n  const applyRef = React.useRef(apply);\n  React.useLayoutEffect(() => {\n    applyRef.current = apply;\n  });\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const run = (p: number) => applyRef.current(clamp01(p));\n    if (typeof progress === \"number\") {\n      run(progress);\n      return;\n    }\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      run(1);\n      return;\n    }\n    let raf = 0;\n    if (autoPlay) {\n      let visible = true;\n      let last = 0;\n      let t = 0;\n      const io = new IntersectionObserver((entries) => {\n        visible = entries[0]?.isIntersecting ?? true;\n      });\n      io.observe(el);\n      const loop = (now: number) => {\n        const dt = last ? Math.min(64, now - last) : 0;\n        last = now;\n        if (visible) {\n          t += dt;\n          run(loopAt(t, duration));\n        }\n        raf = requestAnimationFrame(loop);\n      };\n      raf = requestAnimationFrame(loop);\n      return () => {\n        cancelAnimationFrame(raf);\n        io.disconnect();\n      };\n    }\n    const sc = findScroller(el);\n    const measure = () => {\n      raf = 0;\n      const r = el.getBoundingClientRect();\n      const top = sc ? r.top - sc.getBoundingClientRect().top : r.top;\n      const vh = sc ? sc.clientHeight : window.innerHeight;\n      const span = r.height - vh;\n      run(span > 1 ? -top / span : (vh - top) / (vh + r.height));\n    };\n    const onScroll = () => {\n      if (!raf) raf = requestAnimationFrame(measure);\n    };\n    measure();\n    const target: HTMLElement | Window = sc ?? window;\n    target.addEventListener(\"scroll\", onScroll, { passive: true });\n    window.addEventListener(\"resize\", onScroll);\n    return () => {\n      cancelAnimationFrame(raf);\n      target.removeEventListener(\"scroll\", onScroll);\n      window.removeEventListener(\"resize\", onScroll);\n    };\n  }, [ref, progress, autoPlay, duration]);\n}\n\nexport function HeroScrollRing({\n  brand = \"Atelier Noon · Spring 2027\",\n  title = \"Ten pieces, fired once a season\",\n  subtitle = \"Wheel-thrown stoneware from our studio in Porto. When a glaze sells out, it is gone until next year.\",\n  pieces = defaultPieces,\n  cta = { label: \"Shop the collection\", href: \"#\" },\n  turns = 1,\n  accent = \"#f2a5c0\",\n  progress,\n  autoPlay = false,\n  duration = 7,\n  length = 4,\n  height = \"100vh\",\n  headingAs = \"h1\",\n  className,\n  style,\n  ...rest\n}: HeroScrollRingProps) {\n  const ref = React.useRef<HTMLElement>(null);\n  const cards = React.useRef<(HTMLDivElement | null)[]>([]);\n  const nameRef = React.useRef<HTMLElement>(null);\n  const priceRef = React.useRef<HTMLSpanElement>(null);\n  const idxRef = React.useRef<HTMLElement>(null);\n  const front = React.useRef(-1);\n  const uid = React.useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const Heading = headingAs;\n  const pinned = progress === undefined && !autoPlay;\n  const n = Math.max(1, pieces.length);\n  const step = 360 / n;\n\n  useScrollProgress(\n    ref,\n    (p) => {\n      const el = ref.current;\n      if (!el) return;\n      const k = ease(clamp01(p / 0.55));\n      const ry = -p * 360 * turns + 14;\n      el.style.setProperty(\"--hb-va8-rx\", `${(-62 + k * 54).toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-va8-ry\", `${ry.toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-va8-sc\", (0.72 + k * 0.28).toFixed(4));\n      cards.current.forEach((node, i) => {\n        if (!node) return;\n        const facing = Math.cos(((i * step + ry) * Math.PI) / 180);\n        node.style.filter = `brightness(${(0.45 + Math.max(0, facing) * 0.6).toFixed(3)})`;\n      });\n      const idx = (((Math.round(-ry / step) % n) + n) % n);\n      if (idx !== front.current) {\n        front.current = idx;\n        const piece = pieces[idx];\n        if (piece && nameRef.current && priceRef.current && idxRef.current) {\n          nameRef.current.textContent = piece.name;\n          priceRef.current.textContent = piece.price;\n          idxRef.current.textContent = `${String(idx + 1).padStart(2, \"0\")} / ${String(n).padStart(2, \"0\")}`;\n        }\n      }\n    },\n    progress,\n    autoPlay,\n    duration,\n  );\n\n  return (\n    <section\n      ref={ref}\n      className={[\"hb-va8\", className].filter(Boolean).join(\" \")}\n      data-pinned={pinned ? \"true\" : \"false\"}\n      style={{ \"--hb-va8-accent\": accent, \"--hb-va8-h\": height, \"--hb-va8-len\": length, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-hero-scroll-ring\" precedence=\"default\">{css}</style>\n      <div className=\"hb-va8-stage\">\n        <div className=\"hb-va8-head\">\n          <div>\n            <span className=\"hb-va8-brand\">{brand}</span>\n            <Heading className=\"hb-va8-title\">{title}</Heading>\n          </div>\n          {subtitle ? <p className=\"hb-va8-sub\">{subtitle}</p> : null}\n        </div>\n        <div className=\"hb-va8-ring\" aria-hidden=\"true\">\n          {pieces.map((piece, i) => (\n            <div\n              key={piece.name}\n              className=\"hb-va8-card\"\n              ref={(node) => {\n                cards.current[i] = node;\n              }}\n              style={{ \"--hb-va8-a\": `${(i * step).toFixed(2)}deg`, \"--hb-va8-bg\": piece.backdrop } as React.CSSProperties}\n            >\n              <span className=\"hb-va8-tag\">N°{String(i + 1).padStart(2, \"0\")}</span>\n              <span className=\"hb-va8-shadow\" />\n              <svg viewBox=\"0 0 100 100\">\n                <defs>\n                  <linearGradient id={`${uid}g${i}`} x1=\"0\" x2=\"1\">\n                    <stop offset=\"0\" stopColor={piece.glaze} />\n                    <stop offset=\"0.55\" stopColor={piece.glaze} stopOpacity=\"0.92\" />\n                    <stop offset=\"1\" stopColor=\"#000\" stopOpacity=\"0.55\" />\n                  </linearGradient>\n                </defs>\n                <path d={shapes[i % shapes.length]} fill={`url(#${uid}g${i})`} />\n              </svg>\n            </div>\n          ))}\n        </div>\n        <div className=\"hb-va8-foot\">\n          <div className=\"hb-va8-now\" aria-live=\"off\">\n            <small ref={idxRef}>{`01 / ${String(n).padStart(2, \"0\")}`}</small>\n            <b ref={nameRef}>{pieces[0]?.name}</b>\n            <span ref={priceRef}>{pieces[0]?.price}</span>\n          </div>\n          {cta ? (\n            <a className=\"hb-va8-cta\" href={cta.href}>\n              {cta.label}\n              <i aria-hidden=\"true\">→</i>\n            </a>\n          ) : null}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}