{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-image-reveal",
  "type": "registry:component",
  "title": "Scroll Image Reveal",
  "description": "An image that opens from a thin glowing slit to full size when it scrolls into view, while it settles from a 1.3x zoom and its caption slides up line by line.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "motion",
    "scroll",
    "image",
    "reveal",
    "clip-path",
    "caption",
    "gallery"
  ],
  "docs": "https://hyperblur.dev/effects/scroll-image-reveal",
  "files": [
    {
      "path": "registry/hyperblur/scroll-image-reveal.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/scroll-image-reveal.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ScrollImageRevealProps extends Omit<React.HTMLAttributes<HTMLElement>, \"children\"> {\n  src?: string;\n  alt?: string;\n  eyebrow?: string;\n  caption?: string;\n  detail?: string;\n  aspect?: string;\n  axis?: \"vertical\" | \"horizontal\";\n  radius?: number;\n  duration?: number;\n  threshold?: number;\n  once?: boolean;\n  loop?: boolean;\n  loopHold?: number;\n  accent?: string;\n}\n\nconst css = `\n.hb-zb2 {\n  --hb-zb2-a: #ff9f6e;\n  --hb-zb2-d: 1400ms;\n  --hb-zb2-r: 20px;\n  --hb-zb2-ease: cubic-bezier(0.77, 0, 0.18, 1);\n  position: relative;\n  display: block;\n  width: 100%;\n  margin: 0;\n  box-sizing: border-box;\n  color: #ededed;\n  font-family: inherit;\n}\n.hb-zb2 *, .hb-zb2 *::before, .hb-zb2 *::after { box-sizing: border-box; }\n.hb-zb2-wrap {\n  width: 100%;\n  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--hb-zb2-a) 75%, transparent));\n  transition: filter var(--hb-zb2-d) var(--hb-zb2-ease);\n}\n.hb-zb2[data-in=\"true\"] .hb-zb2-wrap { filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.45)); }\n.hb-zb2-frame {\n  position: relative;\n  width: 100%;\n  overflow: hidden;\n  aspect-ratio: var(--hb-zb2-ar, 4 / 3);\n  background: #141414;\n  clip-path: inset(calc(50% - 1.5px) 0 round 2px);\n  transition: clip-path var(--hb-zb2-d) var(--hb-zb2-ease);\n}\n.hb-zb2[data-axis=\"horizontal\"] .hb-zb2-frame { clip-path: inset(0 calc(50% - 1.5px) round 2px); }\n.hb-zb2[data-in=\"true\"] .hb-zb2-frame { clip-path: inset(0 0 0 0 round var(--hb-zb2-r)); }\n.hb-zb2-media {\n  position: absolute;\n  inset: 0;\n  transform: scale(1.3);\n  transform-origin: 50% 60%;\n  transition: transform calc(var(--hb-zb2-d) * 1.25) var(--hb-zb2-ease);\n}\n.hb-zb2[data-in=\"true\"] .hb-zb2-media { transform: scale(1); }\n.hb-zb2[data-in=\"true\"]:hover .hb-zb2-media { transform: scale(1.035); transition-duration: 1.2s; }\n.hb-zb2-img, .hb-zb2-svg { display: block; width: 100%; height: 100%; object-fit: cover; }\n.hb-zb2-img { background-size: cover; background-position: center; }\n.hb-zb2-shade {\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(to top, rgba(8, 8, 12, 0.78), rgba(8, 8, 12, 0) 52%);\n  opacity: 0;\n  transition: opacity calc(var(--hb-zb2-d) * 0.6) ease calc(var(--hb-zb2-d) * 0.4);\n}\n.hb-zb2[data-in=\"true\"] .hb-zb2-shade { opacity: 1; }\n.hb-zb2-cap {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  flex-direction: column;\n  gap: 4px;\n  padding: clamp(14px, 4cqw, 28px);\n}\n.hb-zb2-ln { display: block; overflow: hidden; padding-bottom: 0.12em; }\n.hb-zb2-tx {\n  display: block;\n  transform: translateY(115%);\n  transition: transform calc(var(--hb-zb2-d) * 0.7) var(--hb-zb2-ease) calc(var(--hb-zb2-d) * 0.5 + var(--hb-zb2-i, 0) * 110ms);\n}\n.hb-zb2[data-in=\"true\"] .hb-zb2-tx { transform: translateY(0); }\n.hb-zb2-eb {\n  font-size: 11px;\n  font-weight: 600;\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  color: color-mix(in srgb, var(--hb-zb2-a) 80%, #ffffff);\n}\n.hb-zb2-ti { font-size: clamp(20px, 5.4cqw, 34px); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; color: #ffffff; }\n.hb-zb2-de { font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, 0.72); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-zb2-wrap, .hb-zb2-frame, .hb-zb2-media, .hb-zb2-shade, .hb-zb2-tx { transition: none; }\n  .hb-zb2-frame { clip-path: inset(0 0 0 0 round var(--hb-zb2-r)); }\n  .hb-zb2-media, .hb-zb2[data-in=\"true\"]:hover .hb-zb2-media { transform: scale(1); }\n  .hb-zb2-shade { opacity: 1; }\n  .hb-zb2-tx { transform: none; }\n  .hb-zb2-wrap { filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.45)); }\n}\n`;\n\nfunction Scene({ id }: { id: string }) {\n  return (\n    <svg className=\"hb-zb2-svg\" viewBox=\"0 0 400 300\" preserveAspectRatio=\"xMidYMid slice\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id={`${id}-s`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"#1a2547\" />\n          <stop offset=\"0.45\" stopColor=\"#8a4f6e\" />\n          <stop offset=\"0.75\" stopColor=\"#f08f5e\" />\n          <stop offset=\"1\" stopColor=\"#f9cd86\" />\n        </linearGradient>\n        <radialGradient id={`${id}-u`}>\n          <stop offset=\"0\" stopColor=\"#fff3d0\" />\n          <stop offset=\"0.45\" stopColor=\"#ffc989\" />\n          <stop offset=\"1\" stopColor=\"#ffb56b\" stopOpacity=\"0\" />\n        </radialGradient>\n        <linearGradient id={`${id}-w`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"#f6a26a\" stopOpacity=\"0.7\" />\n          <stop offset=\"1\" stopColor=\"#3b2a4f\" stopOpacity=\"0.9\" />\n        </linearGradient>\n      </defs>\n      <rect width=\"400\" height=\"300\" fill={`url(#${id}-s)`} />\n      <g fill=\"#ffffff\" opacity=\"0.8\">\n        <circle cx=\"52\" cy=\"38\" r=\"1.1\" />\n        <circle cx=\"118\" cy=\"22\" r=\"0.9\" />\n        <circle cx=\"170\" cy=\"56\" r=\"1.2\" />\n        <circle cx=\"236\" cy=\"28\" r=\"0.8\" />\n        <circle cx=\"332\" cy=\"44\" r=\"1.1\" />\n        <circle cx=\"372\" cy=\"86\" r=\"0.9\" />\n        <circle cx=\"24\" cy=\"92\" r=\"0.9\" />\n      </g>\n      <circle cx=\"268\" cy=\"168\" r=\"92\" fill={`url(#${id}-u)`} />\n      <circle cx=\"268\" cy=\"168\" r=\"30\" fill=\"#fff0cc\" />\n      <path d=\"M0 196 L46 168 L84 186 L138 146 L196 190 L254 160 L312 188 L360 164 L400 182 V300 H0 Z\" fill=\"#5a3d63\" opacity=\"0.92\" />\n      <path d=\"M0 226 L58 196 L112 218 L170 184 L236 224 L300 200 L352 220 L400 204 V300 H0 Z\" fill=\"#33284f\" />\n      <rect x=\"0\" y=\"236\" width=\"400\" height=\"64\" fill={`url(#${id}-w)`} opacity=\"0.55\" />\n      <path d=\"M0 258 L70 240 L140 254 L212 238 L290 256 L352 244 L400 254 V300 H0 Z\" fill=\"#171226\" />\n    </svg>\n  );\n}\n\nexport function ScrollImageReveal({\n  src,\n  alt = \"\",\n  eyebrow = \"Plate 07 / Dawn\",\n  caption = \"Salt flats before the heat\",\n  detail = \"Uyuni, Bolivia. Shot at 05:42, thirty minutes ahead of sunrise.\",\n  aspect = \"4 / 3\",\n  axis = \"vertical\",\n  radius = 20,\n  duration = 1400,\n  threshold = 0.25,\n  once = true,\n  loop = false,\n  loopHold = 2800,\n  accent = \"#ff9f6e\",\n  className = \"\",\n  style,\n  ...rest\n}: ScrollImageRevealProps) {\n  const uid = React.useId().replace(/:/g, \"\");\n  const ref = React.useRef<HTMLElement>(null);\n  const [shown, setShown] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    let timer = 0;\n    const step = (next: boolean) => {\n      setShown(next);\n      timer = window.setTimeout(() => step(!next), next ? loopHold + duration : 1100);\n    };\n    const io = new IntersectionObserver(\n      (entries) => {\n        const hit = entries[entries.length - 1].isIntersecting;\n        window.clearTimeout(timer);\n        if (loop) {\n          if (hit) step(true);\n          else setShown(false);\n          return;\n        }\n        if (hit) {\n          setShown(true);\n          if (once) io.disconnect();\n        } else if (!once) {\n          setShown(false);\n        }\n      },\n      { threshold }\n    );\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      window.clearTimeout(timer);\n    };\n  }, [loop, once, loopHold, duration, threshold]);\n\n  const lines = [\n    { key: \"eb\", cls: \"hb-zb2-eb\", text: eyebrow },\n    { key: \"ti\", cls: \"hb-zb2-ti\", text: caption },\n    { key: \"de\", cls: \"hb-zb2-de\", text: detail },\n  ].filter((l) => l.text);\n\n  return (\n    <figure\n      ref={ref}\n      data-in={shown ? \"true\" : \"false\"}\n      data-axis={axis}\n      className={`hb-zb2 ${className}`.trim()}\n      style={\n        {\n          \"--hb-zb2-a\": accent,\n          \"--hb-zb2-d\": `${duration}ms`,\n          \"--hb-zb2-r\": `${radius}px`,\n          \"--hb-zb2-ar\": aspect,\n          containerType: \"inline-size\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...rest}\n    >\n      <style href=\"hb-scroll-image-reveal\" precedence=\"default\">{css}</style>\n      <div className=\"hb-zb2-wrap\">\n        <div className=\"hb-zb2-frame\">\n          <div className=\"hb-zb2-media\">\n            {src ? <div className=\"hb-zb2-img\" role=\"img\" aria-label={alt} style={{ backgroundImage: `url(\"${src}\")` }} /> : <Scene id={uid} />}\n          </div>\n          <div className=\"hb-zb2-shade\" aria-hidden=\"true\" />\n          <figcaption className=\"hb-zb2-cap\">\n            {lines.map((l, i) => (\n              <span key={l.key} className=\"hb-zb2-ln\">\n                <span className={`hb-zb2-tx ${l.cls}`} style={{ \"--hb-zb2-i\": i } as React.CSSProperties}>\n                  {l.text}\n                </span>\n              </span>\n            ))}\n          </figcaption>\n        </div>\n      </div>\n    </figure>\n  );\n}\n"
    }
  ]
}