{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-scroll-morph",
  "type": "registry:component",
  "title": "Hero Scroll Morph",
  "description": "Twelve app tiles start scattered around the headline, then snap into a grid, bend into an arc and collapse into a single stack as you scroll. The last line of the headline swaps with each layout.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hero",
    "hero",
    "scroll",
    "layout morph",
    "cards",
    "saas",
    "pinned"
  ],
  "docs": "https://hyperblur.dev/effects/hero-scroll-morph",
  "files": [
    {
      "path": "registry/hyperblur/hero-scroll-morph.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hero-scroll-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HeroScrollMorphLink {\n  label: string;\n  href: string;\n}\n\nexport interface HeroScrollMorphTile {\n  label: string;\n  meta: string;\n  hue: number;\n}\n\nexport interface HeroScrollMorphProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  title?: string;\n  phases?: [string, string, string, string];\n  tiles?: HeroScrollMorphTile[];\n  cta?: HeroScrollMorphLink | null;\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 defaultTiles: HeroScrollMorphTile[] = [\n  { label: \"Docs\", meta: \"214 pages\", hue: 262 },\n  { label: \"Tasks\", meta: \"38 open\", hue: 18 },\n  { label: \"Calendar\", meta: \"Today, 6\", hue: 200 },\n  { label: \"Clients\", meta: \"1,204\", hue: 150 },\n  { label: \"Chat\", meta: \"12 unread\", hue: 330 },\n  { label: \"Files\", meta: \"8.4 GB\", hue: 42 },\n  { label: \"Sheets\", meta: \"Q3 plan\", hue: 170 },\n  { label: \"Forms\", meta: \"96 replies\", hue: 285 },\n  { label: \"Wiki\", meta: \"Onboarding\", hue: 222 },\n  { label: \"Goals\", meta: \"74% done\", hue: 95 },\n  { label: \"Bugs\", meta: \"3 critical\", hue: 0 },\n  { label: \"Design\", meta: \"v2.3 specs\", hue: 305 },\n];\n\nconst glyphs = [\n  \"M6 4h9l3 3v13H6z M9 11h6 M9 14h6 M9 17h4\",\n  \"M5 7l2 2 3-3 M12 8h7 M5 13l2 2 3-3 M12 14h7 M12 19h7\",\n  \"M4 6h16v14H4z M4 10h16 M8 3v5 M16 3v5\",\n  \"M12 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z M5 20c1.2-3.6 4-5 7-5s5.8 1.4 7 5\",\n  \"M4 5h16v11h-9l-5 4v-4H4z\",\n  \"M3 7h7l2 2h9v10H3z\",\n  \"M4 4h16v16H4z M4 10h16 M4 15h16 M10 4v16\",\n  \"M5 4h14v16H5z M8 8h8 M8 12h8 M8 16h5\",\n  \"M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z M5 17a3 3 0 0 1 3-3h11\",\n  \"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8z\",\n  \"M8 7a4 4 0 0 1 8 0v2H8z M6 11h12v4a6 6 0 0 1-12 0z M3 13h3 M18 13h3 M4 8l3 2 M20 8l-3 2\",\n  \"M12 3l9 9-9 9-9-9z M12 8l4 4-4 4-4-4z\",\n];\n\nconst css = `\n.hb-va2 {\n  --hb-va2-accent: #8b5cf6;\n  position: relative;\n  width: 100%;\n  height: var(--hb-va2-h);\n  color: #ededed;\n  font-family: inherit;\n  background: #0a0a0b;\n}\n.hb-va2[data-pinned=\"true\"] { height: calc(var(--hb-va2-h) * var(--hb-va2-len)); }\n.hb-va2 *, .hb-va2 *::before, .hb-va2 *::after { box-sizing: border-box; }\n.hb-va2-stage {\n  position: sticky;\n  top: 0;\n  height: var(--hb-va2-h);\n  overflow: hidden;\n  container-type: size;\n  isolation: isolate;\n  background:\n    radial-gradient(50% 45% at 50% 64%, color-mix(in srgb, var(--hb-va2-accent) 16%, transparent), transparent 70%),\n    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.07) 1px, transparent 1.4px) 0 0 / 26px 26px,\n    #0a0a0b;\n}\n.hb-va2-copy {\n  position: absolute;\n  inset: 7cqh 0 auto;\n  z-index: 3;\n  text-align: center;\n  pointer-events: none;\n}\n.hb-va2-brand {\n  display: inline-flex;\n  align-items: center;\n  gap: 0.55em;\n  padding: 0.35em 0.85em 0.35em 0.4em;\n  border: 1px solid rgba(255, 255, 255, 0.1);\n  border-radius: 999px;\n  background: rgba(23, 23, 23, 0.7);\n  font-size: clamp(11px, 1.2cqw, 13px);\n  color: #a1a1a1;\n}\n.hb-va2-dot {\n  width: 1.4em;\n  height: 1.4em;\n  border-radius: 50%;\n  background: conic-gradient(from 200deg, var(--hb-va2-accent), #f0abfc, var(--hb-va2-accent));\n  box-shadow: inset 0 0 0 0.32em #171717;\n}\n.hb-va2-title {\n  margin: 0.55em 0 0;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(1.8rem, 5.4cqw, 4.6rem);\n  font-weight: 600;\n  line-height: 1;\n  letter-spacing: -0.045em;\n}\n.hb-va2-lines {\n  position: relative;\n  display: block;\n  height: 1.08em;\n  margin-top: 0.06em;\n}\n.hb-va2-line {\n  position: absolute;\n  inset: 0;\n  display: block;\n  white-space: nowrap;\n  color: transparent;\n  background: linear-gradient(90deg, #ededed, color-mix(in srgb, var(--hb-va2-accent) 70%, #fff) 55%, #ededed);\n  -webkit-background-clip: text;\n  background-clip: text;\n  opacity: 0;\n  will-change: transform, opacity;\n}\n.hb-va2-line:first-child { opacity: 1; }\n.hb-va2-card {\n  position: absolute;\n  left: 50%;\n  top: 62%;\n  z-index: 1;\n  width: 9.6cqw;\n  height: 12cqw;\n  margin: -6cqw 0 0 -4.8cqw;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  padding: 0.9cqw;\n  border-radius: 1.1cqw;\n  border: 1px solid rgba(255, 255, 255, 0.09);\n  background: linear-gradient(180deg, #1a1a1c, #121213);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1.6cqw 3cqw -1cqw rgba(0, 0, 0, 0.8);\n  will-change: transform;\n}\n.hb-va2-art {\n  position: relative;\n  display: grid;\n  place-items: center;\n  height: 6.3cqw;\n  border-radius: 0.7cqw;\n  background:\n    radial-gradient(90% 80% at 30% 20%, hsl(var(--hb-va2-hue) 90% 70% / 0.55), transparent 60%),\n    linear-gradient(150deg, hsl(var(--hb-va2-hue) 70% 32%), hsl(var(--hb-va2-hue) 60% 14%));\n  overflow: hidden;\n}\n.hb-va2-art::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 40%);\n}\n.hb-va2-art svg { width: 2.8cqw; height: 2.8cqw; color: #fff; }\n.hb-va2-label {\n  display: block;\n  font-size: clamp(7px, 1.15cqw, 14px);\n  font-weight: 600;\n  letter-spacing: -0.01em;\n}\n.hb-va2-meta {\n  display: block;\n  margin-top: 0.15em;\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(6px, 0.82cqw, 10px);\n  color: #8f8f8f;\n}\n.hb-va2-foot {\n  position: absolute;\n  inset: auto 4cqw 4.5cqh;\n  z-index: 3;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 1rem;\n}\n.hb-va2-steps { display: flex; gap: 0.5rem; }\n.hb-va2-step {\n  position: relative;\n  width: clamp(22px, 4cqw, 46px);\n  height: 3px;\n  border-radius: 3px;\n  background: rgba(255, 255, 255, 0.12);\n  overflow: hidden;\n}\n.hb-va2-step span {\n  position: absolute;\n  inset: 0;\n  transform-origin: 0 50%;\n  transform: scaleX(0);\n  background: var(--hb-va2-accent);\n}\n.hb-va2-step:first-child span { transform: scaleX(1); }\n.hb-va2-cta {\n  display: inline-flex;\n  align-items: center;\n  gap: 0.5em;\n  padding: 0.7em 1.2em;\n  border-radius: 999px;\n  background: #ededed;\n  color: #0a0a0a;\n  font-size: clamp(12px, 1.35cqw, 15px);\n  font-weight: 600;\n  text-decoration: none;\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 10px 30px -10px color-mix(in srgb, var(--hb-va2-accent) 80%, transparent);\n  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;\n}\n.hb-va2-cta:hover { transform: translateY(-1px); background: #fff; }\n.hb-va2-cta:focus-visible { outline: 2px solid var(--hb-va2-accent); outline-offset: 3px; }\n.hb-va2-cta svg { transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-va2-cta:hover svg { transform: translateX(3px); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-va2-cta, .hb-va2-cta svg { 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\ntype Pose = { x: number; y: number; r: number; s: number };\n\nfunction hash(n: number) {\n  let h = (n + 1) * 2654435761;\n  h = Math.imul(h ^ (h >>> 15), 2246822519);\n  h = Math.imul(h ^ (h >>> 13), 3266489917);\n  return ((h ^ (h >>> 16)) >>> 0) / 4294967295;\n}\n\nfunction layouts(count: number): Pose[][] {\n  const scatter: Pose[] = [];\n  const grid: Pose[] = [];\n  const arc: Pose[] = [];\n  const stack: Pose[] = [];\n  const cols = Math.ceil(count / 2);\n  for (let i = 0; i < count; i++) {\n    const a = (i / count) * Math.PI * 2 + (hash(i) - 0.5) * 0.5;\n    scatter.push({\n      x: Math.cos(a) * (34 + hash(i + 40) * 8),\n      y: Math.sin(a) * (17 + hash(i + 80) * 6) - 3,\n      r: (hash(i + 120) - 0.5) * 56,\n      s: 0.82 + hash(i + 160) * 0.22,\n    });\n    const c = i % cols;\n    const row = Math.floor(i / cols);\n    grid.push({ x: (c - (cols - 1) / 2) * 11, y: (row - 0.5) * 13.4, r: 0, s: 1 });\n    const t = count > 1 ? i / (count - 1) : 0.5;\n    const ang = (-62 + t * 124) * (Math.PI / 180);\n    arc.push({ x: Math.sin(ang) * 40, y: 34 - Math.cos(ang) * 40, r: ang * (180 / Math.PI), s: 0.94 });\n    stack.push({ x: (i - (count - 1) / 2) * 0.28, y: 2.5 - i * 0.38, r: (hash(i + 200) - 0.5) * 10, s: 1.22 });\n  }\n  return [scatter, grid, arc, stack];\n}\n\nfunction poseCss(p: Pose) {\n  return `translate(${p.x.toFixed(2)}cqw, ${p.y.toFixed(2)}cqw) rotate(${p.r.toFixed(2)}deg) scale(${p.s.toFixed(3)})`;\n}\n\nexport function HeroScrollMorph({\n  brand = \"Tandem 3.0 is here\",\n  title = \"Every tool your team uses,\",\n  phases = [\"scattered across tabs.\", \"lined up in one grid.\", \"connected end to end.\", \"shipped as one workspace.\"],\n  tiles = defaultTiles,\n  cta = { label: \"Start with Tandem\", href: \"#\" },\n  accent = \"#8b5cf6\",\n  progress,\n  autoPlay = false,\n  duration = 7,\n  length = 4,\n  height = \"100vh\",\n  headingAs = \"h1\",\n  className,\n  style,\n  ...rest\n}: HeroScrollMorphProps) {\n  const ref = React.useRef<HTMLElement>(null);\n  const cards = React.useRef<(HTMLDivElement | null)[]>([]);\n  const lines = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const steps = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const poses = React.useMemo(() => layouts(tiles.length), [tiles.length]);\n  const Heading = headingAs;\n  const pinned = progress === undefined && !autoPlay;\n\n  useScrollProgress(\n    ref,\n    (p) => {\n      const s = p * 3;\n      const seg = Math.min(2, Math.floor(s));\n      const t = ease(clamp01((s - seg - 0.12) / 0.76));\n      const from = poses[seg];\n      const to = poses[seg + 1];\n      cards.current.forEach((node, i) => {\n        if (!node || !from[i] || !to[i]) return;\n        const lag = clamp01(t * 1.25 - (i / tiles.length) * 0.25);\n        const k = ease(lag);\n        node.style.transform = poseCss({\n          x: from[i].x + (to[i].x - from[i].x) * k,\n          y: from[i].y + (to[i].y - from[i].y) * k,\n          r: from[i].r + (to[i].r - from[i].r) * k,\n          s: from[i].s + (to[i].s - from[i].s) * k,\n        });\n      });\n      lines.current.forEach((node, k) => {\n        if (!node) return;\n        const d = s - k;\n        const o = clamp01(1 - Math.abs(d) * 2.4);\n        node.style.opacity = o.toFixed(3);\n        node.style.transform = `translateY(${(-d * 0.5).toFixed(3)}em)`;\n        node.style.filter = `blur(${((1 - o) * 6).toFixed(2)}px)`;\n      });\n      steps.current.forEach((node, k) => {\n        if (node) node.style.transform = `scaleX(${clamp01(s - k + 1).toFixed(3)})`;\n      });\n    },\n    progress,\n    autoPlay,\n    duration,\n  );\n\n  return (\n    <section\n      ref={ref}\n      className={[\"hb-va2\", className].filter(Boolean).join(\" \")}\n      data-pinned={pinned ? \"true\" : \"false\"}\n      style={{ \"--hb-va2-accent\": accent, \"--hb-va2-h\": height, \"--hb-va2-len\": length, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-hero-scroll-morph\" precedence=\"default\">{css}</style>\n      <div className=\"hb-va2-stage\">\n        <div className=\"hb-va2-copy\">\n          <span className=\"hb-va2-brand\">\n            <span className=\"hb-va2-dot\" aria-hidden=\"true\" />\n            {brand}\n          </span>\n          <Heading className=\"hb-va2-title\">\n            {title}\n            <span className=\"hb-va2-lines\">\n              {phases.map((line, k) => (\n                <span\n                  key={line}\n                  className=\"hb-va2-line\"\n                  ref={(node) => {\n                    lines.current[k] = node;\n                  }}\n                  aria-hidden={k === 0 ? undefined : true}\n                >\n                  {line}\n                </span>\n              ))}\n            </span>\n          </Heading>\n        </div>\n        {tiles.map((tile, i) => (\n          <div\n            key={tile.label + i}\n            className=\"hb-va2-card\"\n            aria-hidden=\"true\"\n            ref={(node) => {\n              cards.current[i] = node;\n            }}\n            style={{ transform: poses[0][i] ? poseCss(poses[0][i]) : undefined, \"--hb-va2-hue\": tile.hue } as React.CSSProperties}\n          >\n            <span className=\"hb-va2-art\">\n              <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                <path d={glyphs[i % glyphs.length]} />\n              </svg>\n            </span>\n            <span>\n              <span className=\"hb-va2-label\">{tile.label}</span>\n              <span className=\"hb-va2-meta\">{tile.meta}</span>\n            </span>\n          </div>\n        ))}\n        <div className=\"hb-va2-foot\">\n          <div className=\"hb-va2-steps\" aria-hidden=\"true\">\n            {phases.map((line, k) => (\n              <span key={line} className=\"hb-va2-step\">\n                <span\n                  ref={(node) => {\n                    steps.current[k] = node;\n                  }}\n                />\n              </span>\n            ))}\n          </div>\n          {cta ? (\n            <a className=\"hb-va2-cta\" href={cta.href}>\n              {cta.label}\n              <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <path d=\"M3 8h10M9 4l4 4-4 4\" />\n              </svg>\n            </a>\n          ) : null}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}