{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"mono-spotlight","type":"registry:ui","title":"Mono Spotlight","description":"A grid of profile cards drained to grayscale, with a soft spotlight of full color that trails the cursor.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/mono-spotlight.tsx","type":"registry:ui","content":"\"use client\";\n/* eslint-disable @next/next/no-img-element */\n\nimport { useEffect, useRef, type PointerEvent } from \"react\";\n\nexport interface MonoSpotlightItem {\n  image: string;\n  title: string;\n  subtitle?: string;\n  handle?: string;\n  /** Accent used for the card gradient and hover border. */\n  color?: string;\n  url?: string;\n}\n\nexport interface MonoSpotlightProps {\n  items: MonoSpotlightItem[];\n  /** Spotlight radius in px. */\n  radius?: number;\n  /** Cursor follow smoothing, 0-1 (higher = snappier). */\n  smoothing?: number;\n  /** Grid columns on wide screens. */\n  columns?: number;\n  className?: string;\n}\n\nexport function MonoSpotlight({ items, radius = 280, smoothing = 0.12, columns = 3, className }: MonoSpotlightProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const target = useRef({ x: 0, y: 0, r: 0 });\n  const kick = useRef(() => {});\n\n  useEffect(() => {\n    const el = root.current!;\n    const reduce = matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const cur = { x: el.clientWidth / 2, y: el.clientHeight / 2, r: 0 };\n    target.current = { ...cur };\n    let raf = 0;\n    // Ease the spotlight towards the pointer; the loop stops itself once settled.\n    const tick = () => {\n      const t = target.current;\n      const k = reduce ? 1 : smoothing;\n      cur.x += (t.x - cur.x) * k;\n      cur.y += (t.y - cur.y) * k;\n      cur.r += (t.r - cur.r) * (reduce ? 1 : 0.08);\n      el.style.setProperty(\"--cx\", `${cur.x}px`);\n      el.style.setProperty(\"--cy\", `${cur.y}px`);\n      el.style.setProperty(\"--cr\", `${cur.r}px`);\n      raf = Math.abs(t.x - cur.x) + Math.abs(t.y - cur.y) + Math.abs(t.r - cur.r) > 0.3 ? requestAnimationFrame(tick) : 0;\n    };\n    kick.current = () => {\n      if (!raf) raf = requestAnimationFrame(tick);\n    };\n    return () => {\n      cancelAnimationFrame(raf);\n      kick.current = () => {};\n    };\n  }, [smoothing]);\n\n  const moveTo = (x: number, y: number, r: number) => {\n    target.current = { x, y, r };\n    kick.current();\n  };\n\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    const b = e.currentTarget.getBoundingClientRect();\n    moveTo(e.clientX - b.left, e.clientY - b.top, radius);\n  };\n\n  const onCardMove = (e: PointerEvent<HTMLElement>) => {\n    const b = e.currentTarget.getBoundingClientRect();\n    e.currentTarget.style.setProperty(\"--mx\", `${e.clientX - b.left}px`);\n    e.currentTarget.style.setProperty(\"--my\", `${e.clientY - b.top}px`);\n  };\n\n  const mask =\n    \"radial-gradient(circle var(--cr) at var(--cx) var(--cy), transparent 0%, transparent 15%, rgba(0,0,0,.1) 45%, rgba(0,0,0,.35) 60%, rgba(0,0,0,.6) 75%, rgba(0,0,0,.85) 88%, #000 100%)\";\n\n  return (\n    <div\n      ref={root}\n      onPointerMove={onMove}\n      onPointerLeave={() => moveTo(target.current.x, target.current.y, 0)}\n      className={`relative grid w-full gap-3 max-sm:!grid-cols-2 ${className ?? \"\"}`}\n      style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, maxWidth: columns * 260, [\"--cr\" as string]: \"0px\" }}\n    >\n      {items.map((item) => {\n        const Tag = item.url ? \"a\" : \"article\";\n        return (\n          <Tag\n            key={item.title}\n            href={item.url}\n            tabIndex={0}\n            onPointerMove={onCardMove}\n            onFocus={(e) => {\n              const b = e.currentTarget.getBoundingClientRect();\n              const g = root.current!.getBoundingClientRect();\n              moveTo(b.left - g.left + b.width / 2, b.top - g.top + b.height / 2, radius);\n            }}\n            onBlur={() => moveTo(target.current.x, target.current.y, 0)}\n            className=\"group relative flex flex-col overflow-hidden rounded-2xl border border-transparent p-2 outline-none transition-[border-color] duration-300 hover:border-[var(--accent)] focus-visible:border-[var(--accent)]\"\n            style={{\n              [\"--accent\" as string]: item.color ?? \"#8b5cf6\",\n              background: `linear-gradient(160deg, ${item.color ?? \"#8b5cf6\"}, #0a0a0a 70%)`,\n            }}\n          >\n            {/* Per-card glare that follows the pointer. */}\n            <span\n              aria-hidden\n              className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n              style={{ background: \"radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.18), transparent 60%)\" }}\n            />\n            <img src={item.image} alt=\"\" draggable={false} className=\"relative aspect-[4/3] w-full rounded-xl object-cover\" />\n            <footer className=\"relative grid grid-cols-[1fr_auto] gap-x-2 px-2 pb-1 pt-3 text-white\">\n              <h3 className=\"truncate font-semibold\">{item.title}</h3>\n              {item.handle && <span className=\"text-sm text-white/60\">{item.handle}</span>}\n              {item.subtitle && <p className=\"col-span-2 truncate text-sm text-white/75\">{item.subtitle}</p>}\n            </footer>\n          </Tag>\n        );\n      })}\n      {/* Grayscale everything except a soft hole around the spotlight. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute -inset-px z-10 rounded-2xl\"\n        style={{\n          backdropFilter: \"grayscale(1) brightness(.78)\",\n          WebkitBackdropFilter: \"grayscale(1) brightness(.78)\",\n          maskImage: mask,\n          WebkitMaskImage: mask,\n        }}\n      />\n    </div>\n  );\n}\n"}]}