{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"lit-bento","type":"registry:ui","title":"Lit Bento","description":"Bento grid whose cards light up with a cursor-following border glow, tilt gently and fill with drifting particles on hover.","dependencies":["lucide-react"],"registryDependencies":[],"files":[{"path":"registry/ui/lit-bento.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useRef, type CSSProperties, type PointerEvent, type ReactNode } from \"react\";\nimport { BarChart3, LayoutDashboard, Plug, ShieldCheck, Users, Workflow } from \"lucide-react\";\n\nexport interface BentoItem {\n  label: string;\n  title: string;\n  description: string;\n  icon?: ReactNode;\n}\n\nexport interface LitBentoProps {\n  items?: BentoItem[];\n  /** Glow, spotlight and particle color. */\n  glowColor?: string;\n  /** Px radius of the cursor spotlight. */\n  spotlightRadius?: number;\n  /** Max card tilt in degrees (0 disables). */\n  tilt?: number;\n  /** Floating particles inside the hovered card. */\n  particles?: boolean;\n  /** Particles per card. */\n  particleCount?: number;\n  className?: string;\n}\n\nconst DEFAULT_ITEMS: BentoItem[] = [\n  { label: \"Insights\", title: \"Analytics\", description: \"Track every signal in real time and spot trends before they become problems.\", icon: <BarChart3 /> },\n  { label: \"Overview\", title: \"Dashboard\", description: \"One calm view of everything.\", icon: <LayoutDashboard /> },\n  { label: \"Teamwork\", title: \"Collaboration\", description: \"Work together, live.\", icon: <Users /> },\n  { label: \"Efficiency\", title: \"Automation\", description: \"Hand the busywork to workflows that run while you sleep.\", icon: <Workflow /> },\n  { label: \"Connectivity\", title: \"Integrations\", description: \"Plug into 200+ tools.\", icon: <Plug /> },\n  { label: \"Protection\", title: \"Security\", description: \"Encrypted at rest and in transit, audited by default.\", icon: <ShieldCheck /> },\n];\n\n// Grid placement for the 4-column layout: a hero tile, two squares, two wide tiles.\nconst SPANS = [\n  \"col-span-2 md:row-span-2\",\n  \"\",\n  \"\",\n  \"md:col-span-2\",\n  \"md:col-span-2\",\n  \"col-span-2\",\n];\n\nfunction hexToRgb(hex: string) {\n  const h = hex.replace(\"#\", \"\");\n  const n = parseInt(h.length === 3 ? h.replace(/./g, \"$&$&\") : h.padEnd(6, \"0\").slice(0, 6), 16);\n  return `${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}`;\n}\n\n// Deterministic pseudo-random so SSR and client agree.\n// Integer hash (mulberry32 step), identical on server and client.\nconst rand = (seed: number) => {\n  let t = Math.imul(seed + 1, 0x6d2b79f5);\n  t = Math.imul(t ^ (t >>> 15), t | 1);\n  t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n  return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n};\nconst f = (n: number) => n.toFixed(2);\n\nconst css = `\n.mb-card{--mx:50%;--my:50%;--glow:0;--hover:0;transition:transform .45s cubic-bezier(.2,.7,.2,1),box-shadow .45s}\n.mb-card::before,.mb-card::after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none}\n.mb-card::before{background:radial-gradient(var(--r) circle at var(--mx) var(--my),rgba(var(--c),.16),transparent 70%);opacity:var(--glow)}\n.mb-card::after{padding:1.5px;background:radial-gradient(calc(var(--r)*.8) circle at var(--mx) var(--my),rgba(var(--c),1),rgba(var(--c),.55) 40%,transparent 75%);opacity:var(--glow);\n  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}\n.mb-card:hover{box-shadow:0 20px 50px -20px rgba(var(--c),.35)}\n.mb-dot{position:absolute;border-radius:9999px;background:rgb(var(--c));box-shadow:0 0 8px rgba(var(--c),.9);opacity:0;transition:opacity .5s;animation:mb-float var(--d) ease-in-out var(--delay) infinite alternate}\n.mb-card:hover .mb-dot{opacity:var(--o)}\n@keyframes mb-float{to{transform:translate(var(--tx),var(--ty)) scale(.4)}}\n@media (prefers-reduced-motion:reduce){.mb-card{transition:none}.mb-dot{animation:none}}\n`;\n\nexport function LitBento({\n  items = DEFAULT_ITEMS,\n  glowColor = \"#a78bfa\",\n  spotlightRadius = 320,\n  tilt = 6,\n  particles = true,\n  particleCount = 10,\n  className,\n}: LitBentoProps) {\n  const cards = useRef<(HTMLElement | null)[]>([]);\n\n  // One listener on the grid feeds every card, so neighbours glow as the cursor approaches.\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    for (const el of cards.current) {\n      if (!el) continue;\n      const r = el.getBoundingClientRect();\n      const x = e.clientX - r.left;\n      const y = e.clientY - r.top;\n      const dx = Math.max(0, -x, x - r.width);\n      const dy = Math.max(0, -y, y - r.height);\n      const glow = Math.max(0, 1 - Math.hypot(dx, dy) / (spotlightRadius * 0.6));\n      el.style.setProperty(\"--mx\", `${x}px`);\n      el.style.setProperty(\"--my\", `${y}px`);\n      el.style.setProperty(\"--glow\", glow.toFixed(3));\n      const inside = dx === 0 && dy === 0;\n      if (tilt && inside && !matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n        const rx = (0.5 - y / r.height) * tilt;\n        const ry = (x / r.width - 0.5) * tilt;\n        el.style.transform = `perspective(900px) rotateX(${rx}deg) rotateY(${ry}deg) translateZ(0)`;\n      } else el.style.transform = \"\";\n    }\n  };\n\n  const onLeave = () => {\n    for (const el of cards.current) {\n      if (!el) continue;\n      el.style.setProperty(\"--glow\", \"0\");\n      el.style.transform = \"\";\n    }\n  };\n\n  return (\n    <div\n      onPointerMove={onMove}\n      onPointerLeave={onLeave}\n      className={`grid w-full max-w-4xl grid-cols-2 gap-3 md:auto-rows-[8rem] md:grid-cols-4 ${className ?? \"\"}`}\n      style={{ [\"--c\" as string]: hexToRgb(glowColor), [\"--r\" as string]: `${spotlightRadius}px` }}\n    >\n      <style href=\"lit-bento\" precedence=\"default\">\n        {css}\n      </style>\n      {items.map((item, i) => (\n        <article\n          key={item.title + i}\n          ref={(el) => {\n            cards.current[i] = el;\n          }}\n          className={`mb-card group relative flex min-h-32 flex-col justify-between overflow-hidden rounded-2xl border border-border bg-card p-5 ${SPANS[i % SPANS.length]}`}\n        >\n          {particles &&\n            Array.from({ length: particleCount }, (_, k) => {\n              const s = i * 97 + k * 13;\n              const size = f(2 + rand(s) * 3);\n              return (\n                <span\n                  key={k}\n                  aria-hidden\n                  className=\"mb-dot\"\n                  style={\n                    {\n                      left: `${f(rand(s + 1) * 100)}%`,\n                      top: `${f(rand(s + 2) * 100)}%`,\n                      width: `${size}px`,\n                      height: `${size}px`,\n                      \"--o\": f(0.4 + rand(s + 3) * 0.6),\n                      \"--tx\": `${f((rand(s + 4) - 0.5) * 60)}px`,\n                      \"--ty\": `${f((rand(s + 5) - 0.5) * 60)}px`,\n                      \"--d\": `${f(2.5 + rand(s + 6) * 3)}s`,\n                      \"--delay\": `${f(-rand(s + 7) * 4)}s`,\n                    } as CSSProperties\n                  }\n                />\n              );\n            })}\n          <div className=\"relative flex items-center justify-between\">\n            <span className=\"rounded-full border border-border bg-muted/60 px-2.5 py-1 text-xs font-medium text-muted-foreground\">\n              {item.label}\n            </span>\n            {item.icon && <span className=\"text-muted-foreground [&>svg]:size-5\">{item.icon}</span>}\n          </div>\n          <div className=\"relative\">\n            <h3 className={`font-semibold tracking-tight text-foreground ${i === 0 ? \"text-2xl md:text-3xl\" : \"text-base\"}`}>\n              {item.title}\n            </h3>\n            <p className={`mt-1 text-muted-foreground ${i === 0 ? \"max-w-xs text-sm\" : \"text-xs leading-relaxed\"}`}>\n              {item.description}\n            </p>\n          </div>\n        </article>\n      ))}\n    </div>\n  );\n}\n"}]}