{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bento-light",
  "type": "registry:component",
  "title": "Bento Light",
  "description": "A six-cell bento grid with a light that jumps between cells, following the cursor (or on its own), and spills onto its neighbors.",
  "author": "Marcelo Treviño Velázquez <https://furin.dev>",
  "dependencies": [],
  "categories": [
    "Cards"
  ],
  "docs": "Installed in components/furin/bento-light/. Docs, live controls and props table: https://furin.dev/components/bento-light/",
  "files": [
    {
      "path": "registry/bento-light/BentoLight.tsx",
      "content": "\"use client\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport type { CSSProperties, PointerEvent, ReactNode } from \"react\";\nimport \"./BentoLight.css\";\n\nexport interface BentoLightItem {\n  /** Título de la celda. */\n  title: string;\n  /** Texto de apoyo. */\n  text?: string;\n  /** Cifra grande (solo se muestra en la celda grande). */\n  metric?: string;\n  /** Icono propio; si falta se usa uno de la colección. */\n  icon?: ReactNode;\n}\n\nexport interface BentoLightProps {\n  /** Las seis celdas: la primera es la grande (2×2). */\n  items?: BentoLightItem[];\n  /** Color de la luz. */\n  color?: string;\n  /** Radio de la luz, en px. */\n  radius?: number;\n  /** Cada cuántos segundos salta la luz sola cuando no hay cursor (0 = quieta). */\n  autoplay?: number;\n  /** Separación entre celdas, en px. */\n  gap?: number;\n  /** Ancho máximo de la rejilla, en px. */\n  width?: number;\n  /** Clase extra para el contenedor. */\n  className?: string;\n  /** Estilos extra para el contenedor. */\n  style?: CSSProperties;\n}\n\nconst ICONS: ReactNode[] = [\n  <path key=\"0\" d=\"M13 2.5 4.5 13.5h6.5l-1 8 8.5-11h-6.5z\" />,\n  <g key=\"1\"><path d=\"M12 3 5 6v5.5c0 4.4 2.9 7.4 7 9 4.1-1.6 7-4.6 7-9V6z\" /><path d=\"m9 12 2.2 2.2L15.5 10\" /></g>,\n  <g key=\"2\"><circle cx=\"9\" cy=\"8\" r=\"3.2\" /><path d=\"M3.5 19c.4-3.2 2.7-5 5.5-5s5.1 1.8 5.5 5\" /><path d=\"M16 5.2a3.2 3.2 0 0 1 0 5.6M17.5 14.2c2 .5 3.3 2.2 3.5 4.8\" /></g>,\n  <g key=\"3\"><path d=\"m8 8-4 4 4 4M16 8l4 4-4 4M13.5 5.5l-3 13\" /></g>,\n  <g key=\"4\"><path d=\"M5 20v-7M12 20V5M19 20v-10\" /></g>,\n  <g key=\"5\"><path d=\"M4.5 5.5h15v10.5H10l-5.5 4z\" /></g>,\n];\n\nconst DEFAULT_ITEMS: BentoLightItem[] = [\n  { title: \"Faster, always\", text: \"Every screen loads before you can blink.\", metric: \"2.4×\" },\n  { title: \"Secure\", text: \"End-to-end encryption.\" },\n  { title: \"Built for teams\", text: \"Invite without limits.\" },\n  { title: \"Integrations\", text: \"Connect your apps.\" },\n  { title: \"Analytics\", text: \"Live data.\" },\n  { title: \"Support\", text: \"Humans, around the clock.\" },\n];\n\n/** Rejilla bento con una sola luz que salta entre celdas siguiendo al cursor (o por su cuenta) y se derrama sobre las vecinas. */\nexport function BentoLight({\n  items = DEFAULT_ITEMS,\n  color = \"#8ab4ff\",\n  radius = 230,\n  autoplay = 2.2,\n  gap = 10,\n  width = 440,\n  className = \"\",\n  style,\n}: BentoLightProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const cells = useRef<(HTMLDivElement | null)[]>([]);\n  const rects = useRef<{ x: number; y: number; w: number; h: number }[]>([]);\n  const L = useRef({ x: 0, y: 0, vx: 0, vy: 0, tx: 0, ty: 0, lit: 0, on: false });\n  const raf = useRef(0);\n  const last = useRef(0);\n  const hover = useRef(false);\n  const reduced = useRef(false);\n  const hop = useRef(0);\n  const auto = useRef(autoplay);\n  auto.current = autoplay;\n  const count = Math.min(6, items.length);\n\n  const measure = useCallback(() => {\n    rects.current = cells.current.map((el) => (el ? { x: el.offsetLeft, y: el.offsetTop, w: el.offsetWidth, h: el.offsetHeight } : { x: 0, y: 0, w: 0, h: 0 }));\n  }, []);\n\n  const paint = useCallback(() => {\n    const l = L.current;\n    cells.current.forEach((el, i) => {\n      const r = rects.current[i];\n      if (!el || !r) return;\n      el.style.setProperty(\"--furin-bento-light-lx\", `${(l.x - r.x).toFixed(1)}px`);\n      el.style.setProperty(\"--furin-bento-light-ly\", `${(l.y - r.y).toFixed(1)}px`);\n    });\n  }, []);\n\n  const setLit = useCallback((i: number) => {\n    L.current.lit = i;\n    cells.current.forEach((el, k) => { if (el) el.dataset.lit = k === i ? \"true\" : \"false\"; });\n  }, []);\n\n  const tick = useCallback((now: number) => {\n    raf.current = 0;\n    const dt = Math.min(0.033, (now - last.current) / 1000 || 0.016);\n    last.current = now;\n    const l = L.current;\n    // Resorte con un poco de rebote: el salto entre celdas se nota pero no es brusco.\n    const k = hover.current ? 170 : 95, c = hover.current ? 23 : 12.5;\n    const sub = 2, h = dt / sub;\n    for (let q = 0; q < sub; q++) {\n      l.vx += (k * (l.tx - l.x) - c * l.vx) * h; l.x += l.vx * h;\n      l.vy += (k * (l.ty - l.y) - c * l.vy) * h; l.y += l.vy * h;\n    }\n    paint();\n    const moving = Math.abs(l.tx - l.x) + Math.abs(l.ty - l.y) > 0.3 || Math.abs(l.vx) + Math.abs(l.vy) > 1;\n    if (moving) raf.current = requestAnimationFrame(tick);\n  }, [paint]);\n\n  const wake = useCallback(() => {\n    if (reduced.current) { L.current.x = L.current.tx; L.current.y = L.current.ty; paint(); return; }\n    if (!raf.current) { last.current = performance.now(); raf.current = requestAnimationFrame(tick); }\n  }, [paint, tick]);\n\n  /** Lleva la luz a una celda (hacia su centro, con un tirón opcional hacia el cursor). */\n  const aim = useCallback((i: number, px?: number, py?: number) => {\n    const r = rects.current[i];\n    if (!r) return;\n    const cx = r.x + r.w / 2, cy = r.y + r.h / 2;\n    const pull = px === undefined || py === undefined ? 0 : 0.55;\n    L.current.tx = cx + ((px ?? cx) - cx) * pull;\n    L.current.ty = cy + ((py ?? cy) - cy) * pull;\n    setLit(i);\n    wake();\n  }, [setLit, wake]);\n\n  useEffect(() => {\n    reduced.current = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const root = rootRef.current;\n    if (!root) return;\n    measure();\n    // Arranca ya encendida en la celda grande, sin saltar desde la esquina.\n    const r0 = rects.current[0];\n    if (r0) { L.current.x = L.current.tx = r0.x + r0.w * 0.62; L.current.y = L.current.ty = r0.y + r0.h * 0.4; }\n    setLit(0);\n    paint();\n    const ro = new ResizeObserver(() => { measure(); aim(L.current.lit); });\n    ro.observe(root);\n    let visible = true;\n    const io = new IntersectionObserver((e) => { visible = e[0]?.isIntersecting ?? true; });\n    io.observe(root);\n    // Piloto automático: mientras nadie la guía, la luz recorre las celdas.\n    const seq = [0, 1, 2, 5, 4, 3].filter((i) => i < count);\n    const timer = window.setInterval(() => {\n      if (hover.current || !visible || reduced.current || auto.current <= 0) return;\n      hop.current = (hop.current + 1) % seq.length;\n      aim(seq[hop.current]);\n    }, Math.max(600, auto.current * 1000));\n    return () => { ro.disconnect(); io.disconnect(); window.clearInterval(timer); cancelAnimationFrame(raf.current); raf.current = 0; };\n  }, [measure, aim, paint, setLit, count, autoplay]);\n\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    const root = rootRef.current;\n    if (!root) return;\n    hover.current = true;\n    const b = root.getBoundingClientRect();\n    const px = e.clientX - b.left, py = e.clientY - b.top;\n    // La celda bajo el cursor (o la más cercana, si está en una rendija).\n    let best = L.current.lit, bd = Infinity;\n    rects.current.forEach((r, i) => {\n      if (i >= count) return;\n      const dx = Math.max(r.x - px, 0, px - (r.x + r.w)), dy = Math.max(r.y - py, 0, py - (r.y + r.h));\n      const d = dx * dx + dy * dy;\n      if (d < bd) { bd = d; best = i; }\n    });\n    aim(best, px, py);\n  };\n  const onLeave = () => { hover.current = false; hop.current = Math.max(0, [0, 1, 2, 5, 4, 3].indexOf(L.current.lit)); wake(); };\n\n  const vars = {\n    \"--furin-bento-light-w\": `${width}px`,\n    \"--furin-bento-light-gap\": `${gap}px`,\n    \"--furin-bento-light-color\": color,\n    \"--furin-bento-light-r\": `${radius}px`,\n  } as CSSProperties;\n\n  return (\n    <div ref={rootRef} className={`furin-bento-light ${className}`} style={{ ...vars, ...style }} onPointerMove={onMove} onPointerLeave={onLeave}>\n      {items.slice(0, 6).map((it, i) => (\n        <div\n          key={i}\n          ref={(el) => { cells.current[i] = el; }}\n          className={`furin-bento-light__cell furin-bento-light__cell--${i}`}\n          data-lit={i === 0 ? \"true\" : \"false\"}\n        >\n          <i className=\"furin-bento-light__dots\" />\n          <span className=\"furin-bento-light__icon\">\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">{it.icon ?? ICONS[i % ICONS.length]}</svg>\n          </span>\n          <div className=\"furin-bento-light__body\">\n            {i === 0 && it.metric ? <span className=\"furin-bento-light__metric\">{it.metric}</span> : null}\n            <strong>{it.title}</strong>\n            {it.text ? <span>{it.text}</span> : null}\n          </div>\n        </div>\n      ))}\n    </div>\n  );\n}\n\nexport default BentoLight;\n",
      "type": "registry:component",
      "target": "components/furin/bento-light/BentoLight.tsx"
    },
    {
      "path": "registry/bento-light/BentoLight.css",
      "content": ".furin-bento-light {\n  position: relative;\n  width: min(var(--furin-bento-light-w), calc(100% - 40px));\n  aspect-ratio: 11 / 10;\n  display: grid;\n  grid-template-columns: repeat(3, minmax(0, 1fr));\n  grid-template-rows: repeat(3, minmax(0, 1fr));\n  grid-template-areas: \"a a b\" \"a a c\" \"d e f\";\n  gap: var(--furin-bento-light-gap);\n  font-family: Geist, -apple-system, BlinkMacSystemFont, \"SF Pro Text\", system-ui, sans-serif;\n  touch-action: pan-y;\n}\n.furin-bento-light__cell--0 { grid-area: a; }\n.furin-bento-light__cell--1 { grid-area: b; }\n.furin-bento-light__cell--2 { grid-area: c; }\n.furin-bento-light__cell--3 { grid-area: d; }\n.furin-bento-light__cell--4 { grid-area: e; }\n.furin-bento-light__cell--5 { grid-area: f; }\n\n.furin-bento-light__cell {\n  --furin-bento-light-lx: -999px;\n  --furin-bento-light-ly: -999px;\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  border-radius: 20px;\n  padding: 16px;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  color: rgb(255 255 255 / 0.6);\n  background: linear-gradient(180deg, #14161c, #101216);\n  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);\n  transition: color 0.4s, box-shadow 0.5s;\n}\n/* Derrame de luz sobre la celda: el mismo foco, visto desde el marco de cada celda. */\n.furin-bento-light__cell::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  background: radial-gradient(var(--furin-bento-light-r) circle at var(--furin-bento-light-lx) var(--furin-bento-light-ly), color-mix(in srgb, var(--furin-bento-light-color) 38%, transparent), transparent 70%);\n}\n/* Borde que se enciende cerca de la luz. */\n.furin-bento-light__cell::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  padding: 1px;\n  pointer-events: none;\n  background:\n    radial-gradient(calc(var(--furin-bento-light-r) * 0.9) circle at var(--furin-bento-light-lx) var(--furin-bento-light-ly), color-mix(in srgb, var(--furin-bento-light-color) 80%, #fff), transparent 72%),\n    linear-gradient(rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.08));\n  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor;\n  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);\n}\n.furin-bento-light__cell[data-lit=\"true\"] {\n  color: rgb(255 255 255 / 0.92);\n  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.1), 0 0 44px -10px color-mix(in srgb, var(--furin-bento-light-color) 55%, transparent);\n}\n/* Puntos que solo existen donde llega la luz. */\n.furin-bento-light__dots {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  background: radial-gradient(circle, rgb(255 255 255 / 0.55) 0.9px, transparent 1.3px) 0 0 / 14px 14px;\n  -webkit-mask-image: radial-gradient(calc(var(--furin-bento-light-r) * 0.62) circle at var(--furin-bento-light-lx) var(--furin-bento-light-ly), #000, transparent);\n  mask-image: radial-gradient(calc(var(--furin-bento-light-r) * 0.62) circle at var(--furin-bento-light-lx) var(--furin-bento-light-ly), #000, transparent);\n}\n.furin-bento-light__icon {\n  display: grid;\n  place-items: center;\n  width: 34px;\n  height: 34px;\n  border-radius: 11px;\n  background: rgb(255 255 255 / 0.05);\n  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);\n  transition: color 0.4s, box-shadow 0.4s, background 0.4s;\n}\n.furin-bento-light__cell[data-lit=\"true\"] .furin-bento-light__icon {\n  color: color-mix(in srgb, var(--furin-bento-light-color) 70%, #fff);\n  background: color-mix(in srgb, var(--furin-bento-light-color) 14%, transparent);\n  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--furin-bento-light-color) 45%, transparent), 0 0 18px -2px color-mix(in srgb, var(--furin-bento-light-color) 55%, transparent);\n}\n.furin-bento-light__icon svg { width: 18px; height: 18px; }\n.furin-bento-light__body { display: grid; gap: 4px; }\n.furin-bento-light__body strong { font: 600 15px/1.2 Geist, system-ui, sans-serif; letter-spacing: -0.01em; color: #f4f5f8; }\n.furin-bento-light__body span { font: 400 12.5px/1.4 Geist, system-ui, sans-serif; }\n.furin-bento-light__cell--0 { padding: 22px; }\n.furin-bento-light__cell--0 .furin-bento-light__body strong { font-size: 20px; letter-spacing: -0.02em; }\n.furin-bento-light__cell--0 .furin-bento-light__body span:not(.furin-bento-light__metric) { font-size: 14px; max-width: 24ch; }\n.furin-bento-light__metric {\n  font: 700 clamp(48px, 15cqw, 76px)/1 Geist, system-ui, sans-serif !important;\n  letter-spacing: -0.045em;\n  color: transparent;\n  background: linear-gradient(180deg, #fff 20%, color-mix(in srgb, var(--furin-bento-light-color) 60%, #fff 0%) 120%);\n  -webkit-background-clip: text;\n  background-clip: text;\n  margin-bottom: 8px;\n}\n@media (max-width: 420px) { .furin-bento-light__body span:not(.furin-bento-light__metric) { display: none; } .furin-bento-light__cell--0 .furin-bento-light__body span:not(.furin-bento-light__metric) { display: block; } }\n",
      "type": "registry:file",
      "target": "components/furin/bento-light/BentoLight.css"
    }
  ]
}
