{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-ink-reveal",
  "type": "registry:component",
  "title": "Motion Ink Reveal",
  "description": "A photograph that develops through spreading blots of ink as you scroll, with ragged edges from a turbulence filter and a warm rim on each blot. The title and an exposure readout settle in once the image is clear.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "motion",
    "scroll",
    "mask",
    "image",
    "reveal",
    "svg",
    "pinned"
  ],
  "docs": "https://hyperblur.dev/effects/motion-ink-reveal",
  "files": [
    {
      "path": "registry/hyperblur/motion-ink-reveal.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/motion-ink-reveal.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MotionInkRevealProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  caption?: string;\n  hint?: string;\n  inkColor?: string;\n  turbulence?: number;\n  accent?: string;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n  length?: number;\n  height?: string;\n}\n\nconst BLOBS = [\n  { x: 380, y: 300, r: 420, d: 0 },\n  { x: 860, y: 470, r: 380, d: 0.12 },\n  { x: 140, y: 620, r: 300, d: 0.24 },\n  { x: 1080, y: 140, r: 320, d: 0.3 },\n  { x: 620, y: 700, r: 300, d: 0.38 },\n  { x: 120, y: 90, r: 260, d: 0.46 },\n  { x: 640, y: 380, r: 640, d: 0.55 },\n];\n\nconst LINES = Array.from({ length: 16 }, (_, i) => {\n  const y = 492 + i * i * 1.05 + i * 6;\n  const w = 380 - i * 14 + ((i * 37) % 50);\n  return { y: y.toFixed(1), x: (820 - w / 2).toFixed(1), w: Math.max(40, w).toFixed(1), o: (0.75 - i * 0.04).toFixed(2) };\n});\n\nconst css = `\n.hb-wh9 {\n  --hb-wh9-a: #ffb27a;\n  --hb-wh9-p: 0;\n  position: relative;\n  width: 100%;\n  height: var(--hb-wh9-h);\n  color: #fff;\n  font-family: inherit;\n  background: #0b0b0b;\n}\n.hb-wh9[data-pinned=\"true\"] { height: calc(var(--hb-wh9-h) * var(--hb-wh9-len)); }\n.hb-wh9 *, .hb-wh9 *::before, .hb-wh9 *::after { box-sizing: border-box; }\n.hb-wh9-stage {\n  position: sticky;\n  top: 0;\n  height: var(--hb-wh9-h);\n  overflow: hidden;\n  container-type: size;\n  background-color: #0c0c0c;\n  background-image:\n    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),\n    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);\n  background-size: clamp(16px, 4cqw, 44px) clamp(16px, 4cqw, 44px);\n}\n.hb-wh9-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }\n.hb-wh9-hint {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 0.55em;\n  transform: translate(-50%, -50%);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(8px, 1.4cqw, 13px);\n  letter-spacing: 0.24em;\n  text-transform: uppercase;\n  white-space: nowrap;\n  color: #6f6f6f;\n  opacity: clamp(0, calc(1 - var(--hb-wh9-p) * 6), 1);\n  pointer-events: none;\n}\n.hb-wh9-hint i {\n  width: clamp(18px, 3cqw, 30px);\n  height: clamp(18px, 3cqw, 30px);\n  border-radius: 50%;\n  border: 1px dashed #4a4a4a;\n  animation: hb-wh9-spin 6s linear infinite;\n}\n@keyframes hb-wh9-spin { to { transform: rotate(360deg); } }\n.hb-wh9-copy {\n  position: absolute;\n  left: max(14px, 5cqw);\n  top: max(12px, 7cqh);\n  max-width: 70cqw;\n  opacity: clamp(0, calc((var(--hb-wh9-p) - 0.55) * 3.2), 1);\n  transform: translateY(calc((1 - clamp(0, calc((var(--hb-wh9-p) - 0.55) * 3.2), 1)) * 14px));\n  pointer-events: none;\n}\n.hb-wh9-eyebrow {\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(7px, 1.3cqw, 12px);\n  letter-spacing: 0.22em;\n  text-transform: uppercase;\n  color: rgba(255, 238, 222, 0.78);\n}\n.hb-wh9-title {\n  margin: 0.3em 0 0;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(16px, min(6cqw, 10cqh), 88px);\n  font-weight: 600;\n  line-height: 0.98;\n  letter-spacing: -0.04em;\n  color: #fff8f0;\n  text-shadow: 0 2px 30px rgba(40, 10, 30, 0.45);\n}\n.hb-wh9-meta {\n  position: absolute;\n  right: max(14px, 5cqw);\n  bottom: max(10px, 6cqh);\n  display: flex;\n  align-items: center;\n  gap: 0.9em;\n  padding: 0.45em 0.8em;\n  border-radius: 999px;\n  border: 1px solid rgba(255, 255, 255, 0.14);\n  background: rgba(10, 10, 14, 0.55);\n  backdrop-filter: blur(8px);\n  -webkit-backdrop-filter: blur(8px);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(7px, 1.2cqw, 12px);\n  letter-spacing: 0.08em;\n  font-variant-numeric: tabular-nums;\n  color: rgba(255, 255, 255, 0.72);\n}\n.hb-wh9-meta b { font-weight: 500; color: var(--hb-wh9-a); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wh9-hint i { animation: none; }\n}\n`;\n\nfunction clamp01(x: number) {\n  return Math.min(1, Math.max(0, x));\n}\n\nfunction inOut(x: number) {\n  return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\n\nfunction outCubic(x: number) {\n  return 1 - Math.pow(1 - x, 3);\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 loopAt(ms: number, duration: number) {\n  const d = Math.max(1, duration) * 1000;\n  const back = d * 0.45;\n  const hold = 1800;\n  const t = ms % (d + hold + back + 700);\n  if (t < d) return t / d;\n  if (t < d + hold) return 1;\n  if (t < d + hold + back) return 1 - inOut((t - d - hold) / back);\n  return 0;\n}\n\nfunction useProgress(\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\nfunction radius(p: number, i: number) {\n  const b = BLOBS[i];\n  return b.r * outCubic(clamp01((p - b.d) / 0.42));\n}\n\nfunction ringOpacity(p: number) {\n  return 0.6 * clamp01(p * 8) * (1 - clamp01((p - 0.55) / 0.35));\n}\n\nexport function MotionInkReveal({\n  eyebrow = \"Field notes · Lofoten\",\n  title = \"Light at 21:40\",\n  caption = \"f/2.8 · 1/60s · ISO 400\",\n  hint = \"Scroll to develop\",\n  inkColor = \"#ffb27a\",\n  turbulence = 1,\n  accent = \"#ffb27a\",\n  progress,\n  autoPlay = false,\n  duration = 5,\n  length = 3,\n  height = \"100vh\",\n  className,\n  style,\n  ...rest\n}: MotionInkRevealProps) {\n  const ref = React.useRef<HTMLElement>(null);\n  const fills = React.useRef<(SVGCircleElement | null)[]>([]);\n  const rings = React.useRef<(SVGCircleElement | null)[]>([]);\n  const pctRef = React.useRef<HTMLElement>(null);\n  const ringGroup = React.useRef<SVGGElement>(null);\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const pinned = progress === undefined && !autoPlay;\n  const start = typeof progress === \"number\" ? clamp01(progress) : 0;\n  const scale = (60 * Math.max(0, turbulence)).toFixed(1);\n\n  useProgress(\n    ref,\n    (p) => {\n      const el = ref.current;\n      if (!el) return;\n      el.style.setProperty(\"--hb-wh9-p\", p.toFixed(4));\n      for (let i = 0; i < BLOBS.length; i++) {\n        const r = radius(p, i).toFixed(1);\n        fills.current[i]?.setAttribute(\"r\", r);\n        rings.current[i]?.setAttribute(\"r\", r);\n      }\n      ringGroup.current?.setAttribute(\"opacity\", ringOpacity(p).toFixed(3));\n      if (pctRef.current) pctRef.current.textContent = `${Math.round(clamp01(p / 0.97) * 100)}%`;\n    },\n    progress,\n    autoPlay,\n    duration,\n  );\n\n  return (\n    <section\n      ref={ref}\n      className={[\"hb-wh9\", className].filter(Boolean).join(\" \")}\n      data-pinned={pinned ? \"true\" : \"false\"}\n      style={\n        {\n          \"--hb-wh9-a\": accent,\n          \"--hb-wh9-h\": height,\n          \"--hb-wh9-len\": length,\n          \"--hb-wh9-p\": start,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...rest}\n    >\n      <style href=\"hb-motion-ink-reveal\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wh9-stage\">\n        {hint ? (\n          <div className=\"hb-wh9-hint\" aria-hidden=\"true\">\n            <i />\n            <span>{hint}</span>\n          </div>\n        ) : null}\n        <svg className=\"hb-wh9-svg\" viewBox=\"0 0 1200 760\" preserveAspectRatio=\"xMidYMid slice\" role=\"img\" aria-label={`${title}. ${caption}`}>\n          <defs>\n            <filter id={`${uid}-ink`} x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"140%\">\n              <feTurbulence type=\"fractalNoise\" baseFrequency=\"0.011\" numOctaves=\"3\" seed=\"7\" />\n              <feDisplacementMap in=\"SourceGraphic\" scale={scale} xChannelSelector=\"R\" yChannelSelector=\"G\" />\n            </filter>\n            <mask id={`${uid}-m`} maskUnits=\"userSpaceOnUse\" x=\"-100\" y=\"-100\" width=\"1400\" height=\"960\">\n              <rect x=\"-100\" y=\"-100\" width=\"1400\" height=\"960\" fill=\"#000\" />\n              <g filter={`url(#${uid}-ink)`}>\n                {BLOBS.map((b, i) => (\n                  <circle\n                    key={i}\n                    ref={(node) => {\n                      fills.current[i] = node;\n                    }}\n                    cx={b.x}\n                    cy={b.y}\n                    r={radius(start, i).toFixed(1)}\n                    fill=\"#fff\"\n                  />\n                ))}\n              </g>\n            </mask>\n            <linearGradient id={`${uid}-sky`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor=\"#101a3a\" />\n              <stop offset=\"0.42\" stopColor=\"#5a3f78\" />\n              <stop offset=\"0.6\" stopColor=\"#e47f6c\" />\n              <stop offset=\"0.66\" stopColor=\"#ffcf96\" />\n            </linearGradient>\n            <linearGradient id={`${uid}-sea`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor=\"#c76f6a\" />\n              <stop offset=\"0.25\" stopColor=\"#4b3463\" />\n              <stop offset=\"1\" stopColor=\"#0d0e22\" />\n            </linearGradient>\n            <radialGradient id={`${uid}-sun`}>\n              <stop offset=\"0\" stopColor=\"#fff1d6\" stopOpacity=\"0.95\" />\n              <stop offset=\"0.25\" stopColor=\"#ffc98d\" stopOpacity=\"0.6\" />\n              <stop offset=\"1\" stopColor=\"#ff9a6b\" stopOpacity=\"0\" />\n            </radialGradient>\n          </defs>\n          <g mask={`url(#${uid}-m)`}>\n            <rect x=\"-100\" y=\"-100\" width=\"1400\" height=\"580\" fill={`url(#${uid}-sky)`} />\n            <circle cx=\"820\" cy=\"430\" r=\"260\" fill={`url(#${uid}-sun)`} />\n            <circle cx=\"820\" cy=\"452\" r=\"52\" fill=\"#fff0d8\" />\n            <path d=\"M-100 480 L80 330 L190 400 L330 250 L470 390 L560 340 L700 470 L-100 480Z\" fill=\"#3a2f57\" />\n            <path d=\"M520 480 L690 360 L780 410 L930 290 L1060 400 L1150 350 L1300 440 L1300 480Z\" fill=\"#33294e\" />\n            <path d=\"M-100 480 L120 420 L260 455 L400 405 L520 470 L-100 480Z\" fill=\"#221c3a\" />\n            <rect x=\"-100\" y=\"478\" width=\"1400\" height=\"380\" fill={`url(#${uid}-sea)`} />\n            {LINES.map((l, i) => (\n              <rect key={i} x={l.x} y={l.y} width={l.w} height=\"2.4\" rx=\"1.2\" fill=\"#ffd9a8\" opacity={l.o} />\n            ))}\n            <path d=\"M-100 760 L-100 600 C 80 590 200 640 330 660 C 420 672 470 700 520 760Z\" fill=\"#0b0a18\" />\n            <rect x=\"196\" y=\"606\" width=\"54\" height=\"34\" fill=\"#0b0a18\" />\n            <path d=\"M190 608 L223 584 L256 608Z\" fill=\"#0b0a18\" />\n            <rect x=\"214\" y=\"616\" width=\"10\" height=\"10\" fill=\"#ffc77d\" />\n            <path d=\"M960 560 l60 0 l-10 10 l-42 0Z\" fill=\"#14122a\" />\n            <rect x=\"986\" y=\"534\" width=\"2.5\" height=\"26\" fill=\"#14122a\" />\n            <path d=\"M988.5 536 l16 20 l-16 0Z\" fill=\"#1d1a36\" />\n          </g>\n          <g ref={ringGroup} filter={`url(#${uid}-ink)`} opacity={ringOpacity(start).toFixed(3)}>\n            {BLOBS.map((b, i) => (\n              <circle\n                key={i}\n                ref={(node) => {\n                  rings.current[i] = node;\n                }}\n                cx={b.x}\n                cy={b.y}\n                r={radius(start, i).toFixed(1)}\n                fill=\"none\"\n                stroke={inkColor}\n                strokeWidth=\"2\"\n              />\n            ))}\n          </g>\n        </svg>\n        <div className=\"hb-wh9-copy\">\n          <div className=\"hb-wh9-eyebrow\">{eyebrow}</div>\n          <h2 className=\"hb-wh9-title\">{title}</h2>\n        </div>\n        <div className=\"hb-wh9-meta\" aria-hidden=\"true\">\n          <span>{caption}</span>\n          <b ref={pctRef}>{`${Math.round(clamp01(start / 0.97) * 100)}%`}</b>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}