{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spotlight-cards",
  "type": "registry:component",
  "title": "Spotlight Cards",
  "description": "A grid of cards whose borders light up wherever the cursor passes, driven by a single shared light.",
  "author": "Marcelo Treviño Velázquez <https://furin.dev>",
  "dependencies": [],
  "categories": [
    "Interaction"
  ],
  "docs": "Installed in components/furin/spotlight-cards/. Docs, live controls and props table: https://furin.dev/components/spotlight-cards/",
  "files": [
    {
      "path": "registry/spotlight-cards/SpotlightCards.tsx",
      "content": "\"use client\";\nimport { Children, useEffect, useRef } from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport \"./SpotlightCards.css\";\n\nexport interface SpotlightCardsItem {\n  /** Título de la tarjeta. */\n  title: string;\n  /** Texto de apoyo debajo del título. */\n  text: string;\n  /** Ícono opcional que se dibuja arriba del título. */\n  icon?: ReactNode;\n}\n\nexport interface SpotlightCardsProps {\n  /** Tarjetas a mostrar. Si no hay `items` ni `children`, se muestran 6 de ejemplo. */\n  items?: SpotlightCardsItem[];\n  /** Título y texto de cada una de las 6 tarjetas de ejemplo (solo se ven si omites items y children). */\n  sample?: { title?: string; text?: string }[];\n  /** Cuántas columnas tiene la rejilla (en pantallas angostas se reducen solas). */\n  columns?: number;\n  /** Color de la luz (cualquier color CSS). */\n  color?: string;\n  /** Radio de la luz, en px. */\n  radius?: number;\n  /** Espacio entre tarjetas, en px. */\n  gap?: number;\n  /** Clase extra para el contenedor. */\n  className?: string;\n  /** Estilos extra para el contenedor. */\n  style?: CSSProperties;\n  /** Tarjetas propias: cada hijo se envuelve en una tarjeta. Tiene prioridad menor que `items`. */\n  children?: ReactNode;\n}\n\n/** Ícono de línea de 24 px; solo recibe el trazo. */\nconst Icon = ({ path }: { path: string }) => (\n  <svg viewBox=\"0 0 24 24\" width=\"22\" height=\"22\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n    <path d={path} />\n  </svg>\n);\n\n/** Contenido de una tarjeta hecha a partir de un item. */\nconst CardBody = ({ item }: { item: SpotlightCardsItem }) => (\n  <>\n    {item.icon && <span className=\"furin-spotlight-cards__icon\">{item.icon}</span>}\n    <h3 className=\"furin-spotlight-cards__title\">{item.title}</h3>\n    <p className=\"furin-spotlight-cards__text\">{item.text}</p>\n  </>\n);\n\nconst DEFAULT_ITEMS: SpotlightCardsItem[] = [\n  {\n    title: \"Zero dependencies\",\n    text: \"Just React. No GSAP, no Three, and no surprises in your page weight.\",\n    icon: <Icon path=\"M12 3 3 7.5v9L12 21l9-4.5v-9L12 3Zm0 0v18M3 7.5l9 4.5 9-4.5\" />,\n  },\n  {\n    title: \"Real TypeScript\",\n    text: \"Typed props and code that's a pleasure to read.\",\n    icon: <Icon path=\"m8 8-4 4 4 4m8-8 4 4-4 4m-3-10-2 12\" />,\n  },\n  {\n    title: \"Light on mobile\",\n    text: \"It pauses off-screen and looks after your visitors' battery.\",\n    icon: <Icon path=\"M13 3 5 13.5h6L10 21l9-11h-6.5L13 3Z\" />,\n  },\n  {\n    title: \"See it before you copy it\",\n    text: \"Tweak every prop live and copy the code once you love it.\",\n    icon: <Icon path=\"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Zm10 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\" />,\n  },\n  {\n    title: \"Respects reduced motion\",\n    text: \"Anyone who asks for it gets a still frame, just as pretty.\",\n    icon: <Icon path=\"M12 3 5 6v5.5c0 4.2 2.9 7.6 7 9 4.1-1.4 7-4.8 7-9V6l-7-3Zm-3 9 2 2 4-4\" />,\n  },\n  {\n    title: \"Yours forever\",\n    text: \"MIT license on the free ones and unlimited projects with Pro.\",\n    icon: <Icon path=\"M12 12c-2-2.5-3.5-4-5.5-4a4 4 0 1 0 0 8c2 0 3.5-1.5 5.5-4Zm0 0c2 2.5 3.5 4 5.5 4a4 4 0 1 0 0-8c-2 0-3.5 1.5-5.5 4Z\" />,\n  },\n];\n\n/** Rejilla de tarjetas con una sola luz compartida: el borde se ilumina donde está el cursor. */\nexport function SpotlightCards({ items, sample, columns = 3, color = \"#7C8BFF\", radius = 260, gap = 16, className = \"\", style, children }: SpotlightCardsProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n\n    // Última posición del puntero en la ventana; null mientras no hay puntero.\n    let pointer: { x: number; y: number } | null = null;\n    let frameId = 0;\n    // La luz se nota un poco antes de que el cursor entre al componente.\n    const reach = radius * 0.6;\n\n    /** Calcula, para cada tarjeta, dónde cae la luz respecto a su esquina. */\n    const paint = () => {\n      frameId = 0;\n      if (!pointer) return;\n      const { x, y } = pointer;\n      const area = root.getBoundingClientRect();\n      const near = x > area.left - reach && x < area.right + reach && y > area.top - reach && y < area.bottom + reach;\n      root.dataset.lit = String(near);\n      if (!near) return;\n\n      const cards = root.querySelectorAll<HTMLElement>(\".furin-spotlight-cards__card\");\n      // Primero se leen todas las posiciones y después se escribe, para no forzar recálculos de más.\n      const rects = Array.from(cards, (card) => card.getBoundingClientRect());\n      cards.forEach((card, i) => {\n        card.style.setProperty(\"--x\", `${x - rects[i].left}px`);\n        card.style.setProperty(\"--y\", `${y - rects[i].top}px`);\n      });\n    };\n\n    const schedule = () => {\n      if (!frameId) frameId = requestAnimationFrame(paint);\n    };\n    const onPointerMove = (event: PointerEvent) => {\n      pointer = { x: event.clientX, y: event.clientY };\n      schedule();\n    };\n    const turnOff = () => {\n      pointer = null;\n      root.dataset.lit = \"false\";\n    };\n    // Con el dedo, soltar apaga la luz; con el mouse solo cuenta salir de la ventana.\n    const onPointerUp = (event: PointerEvent) => {\n      if (event.pointerType !== \"mouse\") turnOff();\n    };\n\n    window.addEventListener(\"pointermove\", onPointerMove, { passive: true });\n    window.addEventListener(\"pointerdown\", onPointerMove, { passive: true });\n    window.addEventListener(\"pointerup\", onPointerUp);\n    window.addEventListener(\"pointercancel\", turnOff);\n    document.documentElement.addEventListener(\"pointerleave\", turnOff);\n    // Si la página se desplaza con el cursor quieto, las tarjetas se mueven bajo la luz.\n    window.addEventListener(\"scroll\", schedule, { passive: true, capture: true });\n\n    return () => {\n      cancelAnimationFrame(frameId);\n      window.removeEventListener(\"pointermove\", onPointerMove);\n      window.removeEventListener(\"pointerdown\", onPointerMove);\n      window.removeEventListener(\"pointerup\", onPointerUp);\n      window.removeEventListener(\"pointercancel\", turnOff);\n      document.documentElement.removeEventListener(\"pointerleave\", turnOff);\n      window.removeEventListener(\"scroll\", schedule, { capture: true });\n    };\n  }, [radius]);\n\n  const cssVars = {\n    \"--furin-spotlight-cards-color\": color,\n    \"--furin-spotlight-cards-radius\": `${radius}px`,\n    \"--furin-spotlight-cards-gap\": `${gap}px`,\n    \"--furin-spotlight-cards-columns\": Math.max(1, columns),\n    \"--furin-spotlight-cards-columns-medium\": Math.max(1, Math.min(columns, 2)),\n  } as CSSProperties;\n\n  // Prioridad: items propios, luego children, y si no hay nada, los de ejemplo.\n  const entries = items ?? (children === undefined ? DEFAULT_ITEMS.map((d, k) => ({ ...d, ...sample?.[k] })) : null);\n  const cards: ReactNode[] = entries ? entries.map((item) => <CardBody item={item} />) : Children.toArray(children);\n\n  return (\n    <div ref={rootRef} className={`furin-spotlight-cards ${className}`.trim()} style={{ ...cssVars, ...style }}>\n      <div className=\"furin-spotlight-cards__grid\">\n        {cards.map((content, i) => (\n          <div key={i} className=\"furin-spotlight-cards__card\">\n            <div className=\"furin-spotlight-cards__content\">{content}</div>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nexport default SpotlightCards;\n",
      "type": "registry:component",
      "target": "components/furin/spotlight-cards/SpotlightCards.tsx"
    },
    {
      "path": "registry/spotlight-cards/SpotlightCards.css",
      "content": ".furin-spotlight-cards {\n  /* Valores por defecto; el componente los reemplaza con sus props. */\n  --furin-spotlight-cards-color: #7c8bff;\n  --furin-spotlight-cards-radius: 260px;\n  --furin-spotlight-cards-gap: 16px;\n  --furin-spotlight-cards-columns: 3;\n  --furin-spotlight-cards-columns-medium: 2;\n  /* Ajustables desde fuera con la prop style. */\n  --furin-spotlight-cards-card-bg: rgba(255, 255, 255, 0.035);\n  --furin-spotlight-cards-border: rgba(255, 255, 255, 0.09);\n  --furin-spotlight-cards-title: #f4f4f8;\n  --furin-spotlight-cards-text: rgba(244, 244, 248, 0.62);\n\n  width: 100%;\n  container-type: inline-size;\n}\n\n.furin-spotlight-cards__grid {\n  display: grid;\n  grid-template-columns: repeat(var(--furin-spotlight-cards-columns), minmax(0, 1fr));\n  gap: var(--furin-spotlight-cards-gap);\n}\n\n/* Según el ancho del propio componente (no de la ventana): menos columnas. */\n@container (max-width: 720px) {\n  .furin-spotlight-cards__grid {\n    grid-template-columns: repeat(var(--furin-spotlight-cards-columns-medium), minmax(0, 1fr));\n  }\n}\n\n@container (max-width: 440px) {\n  .furin-spotlight-cards__grid {\n    grid-template-columns: minmax(0, 1fr);\n  }\n}\n\n.furin-spotlight-cards__card {\n  /* Dónde cae la luz dentro de esta tarjeta; el script los actualiza. Empiezan lejos. */\n  --x: -1000px;\n  --y: -1000px;\n\n  position: relative;\n  isolation: isolate;\n  border-radius: 16px;\n  padding: 24px;\n  background: var(--furin-spotlight-cards-card-bg);\n  box-shadow: inset 0 0 0 1px var(--furin-spotlight-cards-border);\n}\n\n/* Borde luminoso: un degradado radial recortado para que solo se vea el anillo de 1.5 px. */\n.furin-spotlight-cards__card::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  padding: 1.5px;\n  background:\n    radial-gradient(\n      calc(var(--furin-spotlight-cards-radius) * 0.55) circle at var(--x) var(--y),\n      color-mix(in srgb, var(--furin-spotlight-cards-color) 35%, white),\n      transparent\n    ),\n    radial-gradient(var(--furin-spotlight-cards-radius) circle at var(--x) var(--y), var(--furin-spotlight-cards-color), transparent 80%);\n  -webkit-mask:\n    linear-gradient(#000 0 0) content-box,\n    linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor;\n  mask:\n    linear-gradient(#000 0 0) content-box,\n    linear-gradient(#000 0 0);\n  mask-composite: exclude;\n  opacity: 0;\n  transition: opacity 0.35s ease;\n  pointer-events: none;\n}\n\n/* Halo tenue dentro de la tarjeta, de la misma luz. */\n.furin-spotlight-cards__card::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  background: radial-gradient(\n    var(--furin-spotlight-cards-radius) circle at var(--x) var(--y),\n    color-mix(in srgb, var(--furin-spotlight-cards-color) 26%, transparent),\n    transparent 68%\n  );\n  opacity: 0;\n  transition: opacity 0.35s ease;\n  pointer-events: none;\n}\n\n.furin-spotlight-cards[data-lit=\"true\"] .furin-spotlight-cards__card::before,\n.furin-spotlight-cards[data-lit=\"true\"] .furin-spotlight-cards__card::after {\n  opacity: 1;\n}\n\n.furin-spotlight-cards__content {\n  position: relative;\n  z-index: 1;\n}\n\n.furin-spotlight-cards__icon {\n  display: inline-grid;\n  place-items: center;\n  width: 40px;\n  height: 40px;\n  margin-bottom: 18px;\n  border-radius: 12px;\n  color: color-mix(in srgb, var(--furin-spotlight-cards-color) 55%, white);\n  background: color-mix(in srgb, var(--furin-spotlight-cards-color) 14%, transparent);\n  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--furin-spotlight-cards-color) 28%, transparent);\n}\n\n.furin-spotlight-cards__title {\n  margin: 0 0 8px;\n  font-size: 17px;\n  font-weight: 600;\n  line-height: 1.3;\n  letter-spacing: -0.01em;\n  color: var(--furin-spotlight-cards-title);\n}\n\n.furin-spotlight-cards__text {\n  margin: 0;\n  font-size: 14.5px;\n  line-height: 1.55;\n  color: var(--furin-spotlight-cards-text);\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .furin-spotlight-cards__card::before,\n  .furin-spotlight-cards__card::after {\n    transition: none;\n  }\n}\n",
      "type": "registry:file",
      "target": "components/furin/spotlight-cards/SpotlightCards.css"
    }
  ]
}
