{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-chroma-grid",
  "type": "registry:component",
  "title": "Chroma Grid",
  "description": "A grid of cards that stays grayscale except under a soft spotlight that follows the pointer, where each card lights up in its own accent.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "components",
    "grid",
    "cards",
    "spotlight",
    "grayscale",
    "color",
    "pointer"
  ],
  "docs": "https://hyperblur.dev/effects/card-chroma-grid",
  "files": [
    {
      "path": "registry/hyperblur/card-chroma-grid.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/card-chroma-grid.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ChromaItem {\n  title: string;\n  subtitle?: string;\n  tag?: string;\n  accent?: string;\n  href?: string;\n}\n\nexport interface CardChromaGridProps extends React.HTMLAttributes<HTMLDivElement> {\n  items?: ChromaItem[];\n  columns?: number;\n  radius?: number;\n  gap?: number;\n  idle?: boolean;\n}\n\nconst css = `\n.hb-qk7 {\n  --hb-qk7-x: 50%;\n  --hb-qk7-y: 50%;\n  position: relative;\n  display: grid;\n  width: 100%;\n  grid-template-columns: repeat(var(--hb-qk7-cols), minmax(0, 1fr));\n  gap: var(--hb-qk7-gap);\n  font-family: inherit;\n  box-sizing: border-box;\n  touch-action: pan-y;\n}\n.hb-qk7 *, .hb-qk7 *::before, .hb-qk7 *::after { box-sizing: border-box; }\n.hb-qk7-card {\n  --hb-qk7-n: 0;\n  --hb-qk7-mx: 50%;\n  --hb-qk7-my: 50%;\n  position: relative;\n  display: flex;\n  min-width: 0;\n  flex-direction: column;\n  gap: 6px;\n  padding: 10px;\n  overflow: hidden;\n  border-radius: 14px;\n  border: 1px solid color-mix(in srgb, var(--hb-qk7-a) calc(var(--hb-qk7-n) * 75%), #262626);\n  background:\n    radial-gradient(150px circle at var(--hb-qk7-mx) var(--hb-qk7-my), color-mix(in srgb, var(--hb-qk7-a) calc(var(--hb-qk7-n) * 30%), transparent), transparent 72%),\n    #101010;\n  box-shadow: 0 0 calc(var(--hb-qk7-n) * 22px) -8px color-mix(in srgb, var(--hb-qk7-a) 70%, transparent);\n  color: #ededed;\n  text-decoration: none;\n  outline: none;\n}\n.hb-qk7-card:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; }\n.hb-qk7-row {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: 6px;\n}\n.hb-qk7-av {\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 30px;\n  height: 30px;\n  border-radius: 10px;\n  background: linear-gradient(145deg, var(--hb-qk7-a), color-mix(in srgb, var(--hb-qk7-a) 45%, #000000));\n  font-size: 12px;\n  font-weight: 700;\n  color: #ffffff;\n}\n.hb-qk7-tag {\n  overflow: hidden;\n  padding: 3px 7px;\n  border-radius: 999px;\n  border: 1px solid #2a2a2a;\n  font-size: 9.5px;\n  line-height: 1;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  color: color-mix(in srgb, var(--hb-qk7-a) 70%, #bdbdbd);\n}\n.hb-qk7-name {\n  margin: 0;\n  overflow: hidden;\n  font-size: 13px;\n  font-weight: 600;\n  line-height: 1.2;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  color: #f2f2f2;\n}\n.hb-qk7-sub {\n  margin: 1px 0 0;\n  overflow: hidden;\n  font-size: 11px;\n  line-height: 1.25;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  color: #8f8f8f;\n}\n.hb-qk7-veil {\n  position: absolute;\n  inset: -2px;\n  z-index: 3;\n  pointer-events: none;\n  background: rgba(10, 10, 10, 0.28);\n  backdrop-filter: grayscale(1) brightness(0.9);\n  -webkit-backdrop-filter: grayscale(1) brightness(0.9);\n  -webkit-mask-image: radial-gradient(circle var(--hb-qk7-rad) at var(--hb-qk7-x) var(--hb-qk7-y), transparent 0%, transparent 32%, rgba(0, 0, 0, 0.6) 68%, #000000 100%);\n  mask-image: radial-gradient(circle var(--hb-qk7-rad) at var(--hb-qk7-x) var(--hb-qk7-y), transparent 0%, transparent 32%, rgba(0, 0, 0, 0.6) 68%, #000000 100%);\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qk7-card { transition: none; }\n}\n`;\n\nconst defaultItems: ChromaItem[] = [\n  { title: \"Ada Okafor\", subtitle: \"Core runtime\", tag: \"412\", accent: \"#ff6a5c\" },\n  { title: \"Ben Hartley\", subtitle: \"Docs and DX\", tag: \"186\", accent: \"#ffb020\" },\n  { title: \"Chloe Tran\", subtitle: \"Design system\", tag: \"304\", accent: \"#35c98f\" },\n  { title: \"Dario Silva\", subtitle: \"Build tooling\", tag: \"97\", accent: \"#3b8cff\" },\n  { title: \"Elin Berg\", subtitle: \"Accessibility\", tag: \"228\", accent: \"#a56bff\" },\n  { title: \"Farah Nasser\", subtitle: \"Release lead\", tag: \"351\", accent: \"#ff5fa8\" },\n];\n\nfunction initials(name: string) {\n  return name\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((w) => w[0])\n    .join(\"\")\n    .toUpperCase();\n}\n\nexport function CardChromaGrid({\n  items = defaultItems,\n  columns = 3,\n  radius = 130,\n  gap = 8,\n  idle = true,\n  className = \"\",\n  style,\n  onPointerMove,\n  onPointerLeave,\n  onPointerCancel,\n  ...rest\n}: CardChromaGridProps) {\n  const root = React.useRef<HTMLDivElement>(null);\n  const cards = React.useRef<(HTMLElement | null)[]>([]);\n  const st = React.useRef({ tx: 0, ty: 0, x: 0, y: 0, hover: false, focus: -1, ready: false });\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    const paint = () => {\n      el.style.setProperty(\"--hb-qk7-x\", `${s.x.toFixed(1)}px`);\n      el.style.setProperty(\"--hb-qk7-y\", `${s.y.toFixed(1)}px`);\n      const reach = radius * 1.25;\n      for (const card of cards.current) {\n        if (!card) continue;\n        const cx = card.offsetLeft + card.offsetWidth / 2;\n        const cy = card.offsetTop + card.offsetHeight / 2;\n        const d = Math.hypot(cx - s.x, cy - s.y);\n        const n = Math.max(0, 1 - d / reach);\n        card.style.setProperty(\"--hb-qk7-n\", (n * n).toFixed(3));\n        card.style.setProperty(\"--hb-qk7-mx\", `${(s.x - card.offsetLeft).toFixed(1)}px`);\n        card.style.setProperty(\"--hb-qk7-my\", `${(s.y - card.offsetTop).toFixed(1)}px`);\n      }\n    };\n    const home = () => {\n      s.x = el.clientWidth * 0.3;\n      s.y = el.clientHeight * 0.35;\n      s.tx = s.x;\n      s.ty = s.y;\n    };\n    if (!s.ready) {\n      home();\n      s.ready = true;\n    }\n    if (reduce) {\n      paint();\n      const ro = new ResizeObserver(() => {\n        home();\n        paint();\n      });\n      ro.observe(el);\n      return () => ro.disconnect();\n    }\n    let raf = 0;\n    const frame = (ms: number) => {\n      const t = ms / 1000;\n      const w = el.clientWidth;\n      const h = el.clientHeight;\n      const f = s.focus >= 0 ? cards.current[s.focus] : null;\n      if (f && !s.hover) {\n        s.tx = f.offsetLeft + f.offsetWidth / 2;\n        s.ty = f.offsetTop + f.offsetHeight / 2;\n      } else if (!s.hover) {\n        if (idle) {\n          s.tx = w * (0.5 + 0.42 * Math.sin(t * 0.7));\n          s.ty = h * (0.5 + 0.36 * Math.sin(t * 0.53 + 1));\n        } else {\n          s.tx = w * 0.5;\n          s.ty = h * 0.5;\n        }\n      }\n      s.x += (s.tx - s.x) * 0.14;\n      s.y += (s.ty - s.y) * 0.14;\n      paint();\n      raf = requestAnimationFrame(frame);\n    };\n    const io = new IntersectionObserver(([entry]) => {\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  }, [radius, idle, items.length]);\n\n  const move = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerMove?.(e);\n    const r = e.currentTarget.getBoundingClientRect();\n    const s = st.current;\n    s.hover = true;\n    s.tx = e.clientX - r.left;\n    s.ty = e.clientY - r.top;\n  };\n\n  const leave = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerLeave?.(e);\n    st.current.hover = false;\n  };\n\n  const cancel = (e: React.PointerEvent<HTMLDivElement>) => {\n    onPointerCancel?.(e);\n    st.current.hover = false;\n  };\n\n  return (\n    <div\n      ref={root}\n      className={`hb-qk7 ${className}`}\n      style={\n        {\n          \"--hb-qk7-cols\": columns,\n          \"--hb-qk7-gap\": `${gap}px`,\n          \"--hb-qk7-rad\": `${radius}px`,\n          ...style,\n        } as React.CSSProperties\n      }\n      onPointerMove={move}\n      onPointerLeave={leave}\n      onPointerCancel={cancel}\n      {...rest}\n    >\n      <style href=\"hb-card-chroma-grid\" precedence=\"default\">{css}</style>\n      {items.map((item, i) => {\n        const Tag = (item.href ? \"a\" : \"div\") as \"a\";\n        return (\n          <Tag\n            key={`${item.title}-${i}`}\n            ref={(node) => {\n              cards.current[i] = node;\n            }}\n            className=\"hb-qk7-card\"\n            href={item.href}\n            tabIndex={0}\n            style={{ \"--hb-qk7-a\": item.accent ?? \"#2f7bff\" } as React.CSSProperties}\n            onFocus={() => {\n              st.current.focus = i;\n            }}\n            onBlur={() => {\n              st.current.focus = -1;\n            }}\n          >\n            <div className=\"hb-qk7-row\">\n              <span className=\"hb-qk7-av\" aria-hidden=\"true\">\n                {initials(item.title)}\n              </span>\n              {item.tag ? <span className=\"hb-qk7-tag\">{item.tag}</span> : null}\n            </div>\n            <div style={{ minWidth: 0 }}>\n              <h3 className=\"hb-qk7-name\">{item.title}</h3>\n              {item.subtitle ? <p className=\"hb-qk7-sub\">{item.subtitle}</p> : null}\n            </div>\n          </Tag>\n        );\n      })}\n      <div className=\"hb-qk7-veil\" aria-hidden=\"true\" />\n    </div>\n  );\n}\n"
    }
  ]
}