{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cinema-dolly-zoom",
  "type": "registry:component",
  "title": "Cinema Dolly Zoom",
  "description": "A true dolly zoom down a hallway of door frames: the figure at the end keeps its size while the corridor stretches and compresses around it, with focal length and dolly distance readouts. Runs by itself or follows a progress value.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "cinematic",
    "cinematic",
    "dolly zoom",
    "perspective",
    "suspense",
    "scroll",
    "hero"
  ],
  "docs": "https://hyperblur.dev/effects/cinema-dolly-zoom",
  "files": [
    {
      "path": "registry/hyperblur/cinema-dolly-zoom.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/cinema-dolly-zoom.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CinemaDollyZoomAction {\n  label: string;\n  href: string;\n}\n\nexport interface CinemaDollyZoomProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  kicker?: string;\n  title?: string;\n  subtitle?: string;\n  cta?: CinemaDollyZoomAction | null;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n  frames?: number;\n  accent?: string;\n  headingAs?: \"h1\" | \"h2\";\n}\n\nconst css = `\n.hb-vc11 {\n  --hb-vc11-accent: #ff4d4d;\n  position: relative;\n  box-sizing: border-box;\n  display: block;\n  width: 100%;\n  height: 600px;\n  overflow: hidden;\n  isolation: isolate;\n  container-type: inline-size;\n  background: radial-gradient(60% 60% at 50% 46%, #2a1414, #0a0606 70%);\n  color: #fbeeee;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-vc11 *, .hb-vc11 *::before, .hb-vc11 *::after { box-sizing: border-box; }\n.hb-vc11-hall { position: absolute; inset: 0; }\n.hb-vc11-lines { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .4; }\n.hb-vc11-frame {\n  position: absolute;\n  left: 50%;\n  top: 0;\n  width: 62cqi;\n  height: 92%;\n  margin-left: -31cqi;\n  border: 2px solid rgba(255, 220, 210, .8);\n  border-bottom-color: transparent;\n  will-change: transform, opacity;\n  transform-origin: 50% 50%;\n}\n.hb-vc11-frame[data-lamp]::before {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  top: 6%;\n  width: 18%;\n  height: 2.2%;\n  border-radius: 2px;\n  background: #ffe9d6;\n  box-shadow: 0 0 30px 8px rgba(255, 200, 170, .45);\n  transform: translateX(-50%);\n}\n.hb-vc11-frame[data-door]::after {\n  content: \"\";\n  position: absolute;\n  top: 18%;\n  bottom: 0;\n  width: 14%;\n  border: 1px solid rgba(255, 220, 210, .5);\n  border-bottom: 0;\n  background: rgba(40, 14, 14, .6);\n}\n.hb-vc11-frame[data-door=\"l\"]::after { left: 4%; }\n.hb-vc11-frame[data-door=\"r\"]::after { right: 4%; }\n.hb-vc11-subject {\n  position: absolute;\n  left: 50%;\n  bottom: 37.4%;\n  width: 5cqi;\n  min-width: 34px;\n  transform: translateX(-50%);\n  filter: drop-shadow(0 0 24px rgba(255, 80, 80, .35));\n}\n.hb-vc11-subject svg { display: block; width: 100%; height: auto; }\n.hb-vc11-shade {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  background: linear-gradient(0deg, rgba(8, 4, 4, .92), transparent 42%), radial-gradient(80% 80% at 50% 46%, transparent 50%, rgba(0, 0, 0, .6));\n}\n.hb-vc11-copy {\n  position: absolute;\n  left: clamp(20px, 5cqi, 56px);\n  bottom: clamp(26px, 5cqi, 52px);\n  z-index: 3;\n  max-width: 520px;\n  padding-right: 20px;\n}\n.hb-vc11-kicker {\n  margin: 0 0 12px;\n  color: var(--hb-vc11-accent);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: 11px;\n  letter-spacing: .3em;\n  text-transform: uppercase;\n}\n.hb-vc11-title {\n  margin: 0;\n  font-family: var(--font-grotesk, var(--font-sans, ui-sans-serif, system-ui, sans-serif));\n  font-size: clamp(34px, 6.4cqi, 80px);\n  font-weight: 700;\n  line-height: .94;\n  letter-spacing: -.04em;\n}\n.hb-vc11-sub {\n  max-width: 420px;\n  margin: 14px 0 0;\n  color: rgba(251, 238, 238, .72);\n  font-size: clamp(13.5px, 1.6cqi, 15.5px);\n  line-height: 1.55;\n}\n.hb-vc11-cta {\n  display: inline-flex;\n  align-items: center;\n  gap: 10px;\n  height: 44px;\n  margin-top: 20px;\n  padding: 0 20px;\n  border-radius: 999px;\n  background: #fbeeee;\n  color: #120808;\n  font-size: 14px;\n  font-weight: 600;\n  text-decoration: none;\n  transition: transform .2s ease, background .25s ease;\n}\n.hb-vc11-cta:hover { background: #ffffff; }\n.hb-vc11-cta:active { transform: scale(.97); }\n.hb-vc11-cta:focus-visible { outline: 2px solid var(--hb-vc11-accent); outline-offset: 3px; }\n.hb-vc11-hud {\n  position: absolute;\n  top: 18px;\n  right: clamp(16px, 3cqi, 30px);\n  z-index: 3;\n  display: grid;\n  grid-template-columns: auto auto;\n  gap: 6px 16px;\n  padding: 12px 14px;\n  border: 1px solid rgba(251, 238, 238, .14);\n  border-radius: 12px;\n  background: rgba(14, 8, 8, .55);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: 10.5px;\n  letter-spacing: .12em;\n  text-transform: uppercase;\n  backdrop-filter: blur(10px);\n}\n.hb-vc11-k { margin: 0; color: rgba(251, 238, 238, .5); }\n.hb-vc11-v { margin: 0; color: #fbeeee; text-align: right; font-variant-numeric: tabular-nums; }\n.hb-vc11-meter {\n  grid-column: 1 / -1;\n  position: relative;\n  height: 3px;\n  margin-top: 4px;\n  border-radius: 3px;\n  background: rgba(251, 238, 238, .14);\n  overflow: hidden;\n}\n.hb-vc11-meter span {\n  position: absolute;\n  inset: 0;\n  background: var(--hb-vc11-accent);\n  transform-origin: left;\n}\n`;\n\nconst Z_SUBJECT = 5;\nconst K = 0.36;\n\nexport function CinemaDollyZoom({\n  kicker = \"Chapter four\",\n  title = \"The hallway keeps getting longer\",\n  subtitle = \"Nothing in the house moves. Only the distance between you and the door at the end.\",\n  cta = { label: \"Continue the story\", href: \"#\" },\n  progress,\n  autoPlay = true,\n  duration = 7,\n  frames = 14,\n  accent = \"#ff4d4d\",\n  headingAs = \"h1\",\n  className,\n  style,\n  ...rest\n}: CinemaDollyZoomProps) {\n  const Heading = headingAs;\n  const rootRef = React.useRef<HTMLElement>(null);\n  const frameRefs = React.useRef<(HTMLDivElement | null)[]>([]);\n  const focalRef = React.useRef<HTMLSpanElement>(null);\n  const dollyRef = React.useRef<HTMLSpanElement>(null);\n  const meterRef = React.useRef<HTMLSpanElement>(null);\n  const count = Math.max(6, Math.min(24, Math.round(frames)));\n  const depths = React.useMemo(() => Array.from({ length: count }, (_, i) => 0.4 + i * 0.9), [count]);\n  const behind = depths.filter((z) => z > Z_SUBJECT).length;\n\n  const apply = React.useCallback(\n    (p: number) => {\n      const d = 0.5 + p * 7.5;\n      depths.forEach((z, i) => {\n        const el = frameRefs.current[i];\n        if (!el) return;\n        const s = (K * (d + Z_SUBJECT)) / (d + z);\n        el.style.transform = `scale(${s.toFixed(4)})`;\n        el.style.opacity = Math.max(0.08, 1 - z / 14).toFixed(3);\n      });\n      if (focalRef.current) focalRef.current.textContent = `${Math.round(18 + p * 117)} mm`;\n      if (dollyRef.current) dollyRef.current.textContent = `${d.toFixed(1)} m`;\n      if (meterRef.current) meterRef.current.style.transform = `scaleX(${p.toFixed(3)})`;\n    },\n    [depths],\n  );\n\n  React.useEffect(() => {\n    if (progress !== undefined) {\n      apply(Math.max(0, Math.min(1, progress)));\n      return;\n    }\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    if (!autoPlay || reduce) {\n      apply(reduce ? 1 : 0);\n      return;\n    }\n    let raf = 0;\n    let visible = true;\n    let elapsed = 0;\n    let last = 0;\n    const el = rootRef.current;\n    const io = el\n      ? new IntersectionObserver((entries) => {\n          visible = entries[0]?.isIntersecting ?? true;\n        })\n      : null;\n    if (el && io) io.observe(el);\n    const loop = (now: number) => {\n      if (last && visible) elapsed += (now - last) / 1000;\n      last = now;\n      const cycle = (elapsed / duration) % 2;\n      const k = cycle < 1 ? cycle : 2 - cycle;\n      const e = k < 0.5 ? 4 * k * k * k : 1 - Math.pow(-2 * k + 2, 3) / 2;\n      apply(e);\n      raf = requestAnimationFrame(loop);\n    };\n    raf = requestAnimationFrame(loop);\n    return () => {\n      cancelAnimationFrame(raf);\n      io?.disconnect();\n    };\n  }, [progress, autoPlay, duration, apply]);\n\n  const vars = { \"--hb-vc11-accent\": accent, ...style } as React.CSSProperties;\n  const order = depths.map((z, i) => ({ z, i })).reverse();\n\n  const frameEl = (z: number, i: number) => {\n    const h = Math.imul(i + 3, 2654435761) >>> 0;\n    const s0 = (K * (0.5 + Z_SUBJECT)) / (0.5 + z);\n    return (\n      <div\n        key={i}\n        ref={(node) => {\n          frameRefs.current[i] = node;\n        }}\n        className=\"hb-vc11-frame\"\n        data-lamp={i % 2 === 0 ? \"\" : undefined}\n        data-door={h % 3 === 0 ? \"l\" : h % 3 === 1 ? \"r\" : undefined}\n        style={{ transform: `scale(${s0.toFixed(4)})`, opacity: Math.max(0.08, 1 - z / 14).toFixed(3) }}\n      />\n    );\n  };\n\n  return (\n    <section ref={rootRef} className={[\"hb-vc11\", className].filter(Boolean).join(\" \")} style={vars} {...rest}>\n      <style href=\"hb-cinema-dolly-zoom\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vc11-hall\" aria-hidden=\"true\">\n        <svg className=\"hb-vc11-lines\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\">\n          <path d=\"M0 100 L50 46 M100 100 L50 46 M0 0 L50 46 M100 0 L50 46\" stroke=\"#ffd8cc\" strokeWidth=\".15\" vectorEffect=\"non-scaling-stroke\" fill=\"none\" />\n        </svg>\n        {order.slice(0, behind).map(({ z, i }) => frameEl(z, i))}\n        <div className=\"hb-vc11-subject\">\n          <svg viewBox=\"0 0 40 110\">\n            <circle cx=\"20\" cy=\"10\" r=\"8\" fill=\"#0d0505\" />\n            <path d=\"M8 22 C8 19 12 18 20 18 C28 18 32 19 32 22 L34 62 L29 62 L28 108 L22 108 L20 70 L18 108 L12 108 L11 62 L6 62Z\" fill=\"#0d0505\" />\n            <path d=\"M8 22 C8 19 12 18 20 18 C28 18 32 19 32 22\" stroke=\"#ff8a7a\" strokeWidth=\"1\" fill=\"none\" opacity=\".6\" />\n          </svg>\n        </div>\n        {order.slice(behind).map(({ z, i }) => frameEl(z, i))}\n      </div>\n      <div className=\"hb-vc11-shade\" aria-hidden=\"true\" />\n      <div className=\"hb-vc11-hud\" aria-hidden=\"true\">\n        <span className=\"hb-vc11-k\">Focal</span>\n        <span className=\"hb-vc11-v\" ref={focalRef}>18 mm</span>\n        <span className=\"hb-vc11-k\">Dolly</span>\n        <span className=\"hb-vc11-v\" ref={dollyRef}>0.5 m</span>\n        <span className=\"hb-vc11-meter\"><span ref={meterRef} style={{ transform: \"scaleX(0)\" }} /></span>\n      </div>\n      <div className=\"hb-vc11-copy\">\n        {kicker ? <p className=\"hb-vc11-kicker\">{kicker}</p> : null}\n        <Heading className=\"hb-vc11-title\">{title}</Heading>\n        {subtitle ? <p className=\"hb-vc11-sub\">{subtitle}</p> : null}\n        {cta ? (\n          <a className=\"hb-vc11-cta\" href={cta.href}>\n            {cta.label}\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M3 8h10M9 4l4 4-4 4\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n          </a>\n        ) : null}\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}