{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gallery-drift-wall",
  "type": "registry:component",
  "title": "Drift Wall",
  "description": "A wall of tiles in columns that drift against the pointer at different depths, with the hovered tile lifting forward.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "components",
    "gallery",
    "wall",
    "parallax",
    "tiles",
    "depth",
    "pointer"
  ],
  "docs": "https://hyperblur.dev/effects/gallery-drift-wall",
  "files": [
    {
      "path": "registry/hyperblur/gallery-drift-wall.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/gallery-drift-wall.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface DriftTile {\n  label?: string;\n  color?: string;\n  src?: string;\n}\n\nexport interface GalleryDriftWallProps extends React.HTMLAttributes<HTMLDivElement> {\n  tiles?: DriftTile[];\n  columns?: number;\n  strength?: number;\n  height?: number;\n  gap?: number;\n  idle?: boolean;\n}\n\nconst css = `\n.hb-qk9 {\n  --hb-qk9-x: 0;\n  --hb-qk9-y: 0;\n  position: relative;\n  width: 100%;\n  height: var(--hb-qk9-h);\n  overflow: hidden;\n  border-radius: 16px;\n  border: 1px solid #262626;\n  background: #0a0a0a;\n  font-family: inherit;\n  box-sizing: border-box;\n  touch-action: pan-y;\n}\n.hb-qk9 *, .hb-qk9 *::before, .hb-qk9 *::after { box-sizing: border-box; }\n.hb-qk9-wall {\n  position: absolute;\n  inset: -22% -12%;\n  display: flex;\n  gap: var(--hb-qk9-gap);\n}\n.hb-qk9-col {\n  position: relative;\n  display: flex;\n  flex: 1 1 0;\n  min-width: 0;\n  flex-direction: column;\n  gap: var(--hb-qk9-gap);\n  transform: translate3d(calc(var(--hb-qk9-x) * var(--hb-qk9-d) * 1px), calc(var(--hb-qk9-y) * var(--hb-qk9-d) * 1px), 0) translateY(var(--hb-qk9-o));\n  will-change: transform;\n}\n.hb-qk9-t {\n  position: relative;\n  flex: var(--hb-qk9-w) 1 0;\n  min-height: 0;\n  margin: 0;\n  overflow: hidden;\n  border-radius: 12px;\n  border: 1px solid rgba(255, 255, 255, 0.1);\n  background-color: var(--hb-qk9-c);\n  background-size: cover;\n  background-position: center;\n  outline: none;\n  cursor: pointer;\n  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, box-shadow 0.45s ease, border-color 0.3s ease;\n}\n.hb-qk9-art {\n  position: absolute;\n  inset: 0;\n}\n.hb-qk9-t[data-v=\"0\"] .hb-qk9-art {\n  background:\n    radial-gradient(circle at 70% 30%, color-mix(in srgb, var(--hb-qk9-c) 40%, #ffffff) 0 20%, transparent 21%),\n    linear-gradient(160deg, var(--hb-qk9-c), color-mix(in srgb, var(--hb-qk9-c) 25%, #050508));\n}\n.hb-qk9-t[data-v=\"1\"] .hb-qk9-art {\n  background:\n    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.13) 0 6px, transparent 6px 15px),\n    linear-gradient(200deg, var(--hb-qk9-c), color-mix(in srgb, var(--hb-qk9-c) 30%, #050508));\n}\n.hb-qk9-t[data-v=\"2\"] .hb-qk9-art {\n  background:\n    conic-gradient(from 210deg at 28% 72%, var(--hb-qk9-c), color-mix(in srgb, var(--hb-qk9-c) 55%, #ffffff), color-mix(in srgb, var(--hb-qk9-c) 25%, #050508), var(--hb-qk9-c));\n}\n.hb-qk9-t[data-v=\"3\"] .hb-qk9-art {\n  background:\n    radial-gradient(120% 80% at 20% 100%, color-mix(in srgb, var(--hb-qk9-c) 55%, #ffffff), transparent 62%),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-qk9-c) 30%, #050508), var(--hb-qk9-c));\n}\n.hb-qk9-t[data-s=\"true\"] .hb-qk9-art { background: none; }\n.hb-qk9-cap {\n  position: absolute;\n  left: 8px;\n  bottom: 7px;\n  right: 8px;\n  overflow: hidden;\n  font-size: 10px;\n  font-weight: 500;\n  letter-spacing: 0.04em;\n  line-height: 1.2;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  color: rgba(255, 255, 255, 0.92);\n  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);\n  opacity: 0;\n  transform: translateY(4px);\n  transition: opacity 0.3s ease, transform 0.3s ease;\n}\n.hb-qk9-t:hover, .hb-qk9-t:focus-visible, .hb-qk9-t[data-lift=\"true\"] {\n  z-index: 5;\n  transform: scale(1.12);\n  border-color: rgba(255, 255, 255, 0.4);\n  box-shadow: 0 18px 32px -10px rgba(0, 0, 0, 0.9);\n}\n.hb-qk9-t:hover .hb-qk9-cap, .hb-qk9-t:focus-visible .hb-qk9-cap, .hb-qk9-t[data-lift=\"true\"] .hb-qk9-cap { opacity: 1; transform: none; }\n.hb-qk9-wall:has(.hb-qk9-t:hover, .hb-qk9-t:focus-visible) .hb-qk9-t:not(:hover):not(:focus-visible) { opacity: 0.5; }\n.hb-qk9-col:has(.hb-qk9-t:hover, .hb-qk9-t:focus-visible, .hb-qk9-t[data-lift=\"true\"]) { z-index: 5; }\n.hb-qk9[data-demo=\"true\"] .hb-qk9-t:not([data-lift=\"true\"]) { opacity: 0.55; }\n.hb-qk9-t:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qk9-col, .hb-qk9-t, .hb-qk9-cap { transition: none; will-change: auto; }\n}\n`;\n\nconst palette = [\"#3b82f6\", \"#e5603f\", \"#2fa67c\", \"#9a6bf0\", \"#d8a431\", \"#e0568f\", \"#38a9c9\", \"#7d8f3a\"];\nconst names = [\n  \"Tide pool\",\n  \"Salt flat\",\n  \"Night market\",\n  \"Rooftop 04\",\n  \"Basalt\",\n  \"Cedar light\",\n  \"Harbor fog\",\n  \"Neon alley\",\n  \"Dune line\",\n  \"Glasshouse\",\n  \"Paper lanterns\",\n  \"Slate steps\",\n  \"Marigold\",\n  \"Underpass\",\n  \"Orchard\",\n  \"Ferry wake\",\n  \"Moth light\",\n  \"Concrete bloom\",\n];\n\nfunction hash(n: number) {\n  let h = Math.imul(n + 1, 2654435761) >>> 0;\n  h ^= h >>> 15;\n  h = Math.imul(h, 2246822519) >>> 0;\n  h ^= h >>> 13;\n  return (h >>> 0) / 4294967296;\n}\n\nconst defaultTiles: DriftTile[] = names.map((label, i) => ({\n  label: `No. ${String(i + 1).padStart(2, \"0\")}  ${label}`,\n  color: palette[(i * 3 + Math.floor(i / 6)) % palette.length],\n}));\n\nfunction clampN(n: number) {\n  return Math.min(1, Math.max(-1, n));\n}\n\nexport function GalleryDriftWall({\n  tiles = defaultTiles,\n  columns = 6,\n  strength = 28,\n  height = 220,\n  gap = 8,\n  idle = true,\n  className = \"\",\n  style,\n  onPointerMove,\n  onPointerEnter,\n  onPointerLeave,\n  onPointerCancel,\n  ...rest\n}: GalleryDriftWallProps) {\n  const root = React.useRef<HTMLDivElement>(null);\n  const st = React.useRef({ tx: 0, ty: 0, x: 0, y: 0, hover: false });\n  const user = React.useRef(false);\n  const visible = React.useRef(true);\n  const [demo, setDemo] = React.useState(-1);\n\n  React.useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const s = st.current;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    if (reduce) return;\n    let raf = 0;\n    const frame = (ms: number) => {\n      const t = ms / 1000;\n      if (!s.hover) {\n        if (idle) {\n          s.tx = Math.sin(t * 0.55);\n          s.ty = 0.8 * Math.sin(t * 0.41 + 1.3);\n        } else {\n          s.tx = 0;\n          s.ty = 0;\n        }\n      }\n      s.x += (-s.tx * strength - s.x) * 0.08;\n      s.y += (-s.ty * strength * 0.6 - s.y) * 0.08;\n      el.style.setProperty(\"--hb-qk9-x\", s.x.toFixed(2));\n      el.style.setProperty(\"--hb-qk9-y\", s.y.toFixed(2));\n      raf = requestAnimationFrame(frame);\n    };\n    const io = new IntersectionObserver(([entry]) => {\n      visible.current = entry.isIntersecting;\n      cancelAnimationFrame(raf);\n      if (entry.isIntersecting) raf = requestAnimationFrame(frame);\n    });\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [strength, idle]);\n\n  React.useEffect(() => {\n    if (!idle || tiles.length === 0) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let n = 0;\n    const timer = window.setInterval(() => {\n      if (user.current || !visible.current) return;\n      n += 1;\n      setDemo(Math.floor(hash(n + 11) * tiles.length));\n    }, 1900);\n    return () => window.clearInterval(timer);\n  }, [idle, tiles.length]);\n\n  const move = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerMove?.(e);\n    const r = e.currentTarget.getBoundingClientRect();\n    if (!r.width || !r.height) return;\n    const s = st.current;\n    s.hover = true;\n    s.tx = clampN(((e.clientX - r.left) / r.width - 0.5) * 2);\n    s.ty = clampN(((e.clientY - r.top) / r.height - 0.5) * 2);\n  };\n\n  const enter = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerEnter?.(e);\n    user.current = true;\n    setDemo(-1);\n  };\n\n  const leave = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerLeave?.(e);\n    st.current.hover = false;\n    user.current = false;\n  };\n\n  const cancel = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerCancel?.(e);\n    st.current.hover = false;\n    user.current = false;\n  };\n\n  const cols = Math.max(1, columns);\n  const lanes: { tile: DriftTile; index: number }[][] = Array.from({ length: cols }, () => []);\n  tiles.forEach((tile, index) => lanes[index % cols].push({ tile, index }));\n\n  return (\n    <div\n      ref={root}\n      className={`hb-qk9 ${className}`}\n      data-demo={demo >= 0 ? \"true\" : \"false\"}\n      style={{ \"--hb-qk9-h\": `${height}px`, \"--hb-qk9-gap\": `${gap}px`, ...style } as React.CSSProperties}\n      onPointerMove={move}\n      onPointerEnter={enter}\n      onPointerLeave={leave}\n      onPointerCancel={cancel}\n      {...rest}\n    >\n      <style href=\"hb-gallery-drift-wall\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qk9-wall\">\n        {lanes.map((lane, c) => (\n          <div\n            className=\"hb-qk9-col\"\n            key={c}\n            style={\n              {\n                \"--hb-qk9-d\": (0.45 + hash(c + 3) * 0.95).toFixed(2),\n                \"--hb-qk9-o\": `${((hash(c + 40) - 0.5) * 14).toFixed(1)}%`,\n              } as React.CSSProperties\n            }\n          >\n            {lane.map(({ tile, index }) => (\n              <figure\n                className=\"hb-qk9-t\"\n                key={`${tile.label ?? \"tile\"}-${index}`}\n                tabIndex={0}\n                aria-label={tile.label}\n                data-v={Math.floor(hash(index + 90) * 4)}\n                data-s={tile.src ? \"true\" : \"false\"}\n                data-lift={demo === index ? \"true\" : \"false\"}\n                style={\n                  {\n                    \"--hb-qk9-c\": tile.color ?? palette[index % palette.length],\n                    \"--hb-qk9-w\": (0.8 + hash(index + 7) * 0.8).toFixed(2),\n                    backgroundImage: tile.src ? `url(${JSON.stringify(tile.src)})` : undefined,\n                  } as React.CSSProperties\n                }\n              >\n                <span className=\"hb-qk9-art\" aria-hidden=\"true\" />\n                {tile.label ? <figcaption className=\"hb-qk9-cap\">{tile.label}</figcaption> : null}\n              </figure>\n            ))}\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}