{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"spotlight-card","type":"registry:block","title":"Spotlight card","description":"A card that catches the pointer: a soft spotlight follows the cursor across the surface and lights a thin border around the edge.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/spotlight-card/spotlight-card.tsx","type":"registry:component","content":"\"use client\";\n\nimport {\n  useEffect,\n  useRef,\n  type CSSProperties,\n  type PointerEvent as ReactPointerEvent,\n  type ReactNode,\n} from \"react\";\nimport { useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\n/* The spotlight reads its position from two custom properties on the card.\n   Pointer moves are coalesced into one animation frame, so React never\n   re-renders while the light travels across the surface. */\nconst SPOTLIGHT_CSS = `\n.prequel-spotlight-surface {\n  background: radial-gradient(\n    circle var(--spot-radius, 260px) at var(--spot-x, 50%) var(--spot-y, 50%),\n    color-mix(in oklab, var(--card-foreground) 9%, transparent),\n    transparent 72%\n  );\n  opacity: 0;\n  transition: opacity 320ms ease-out;\n}\n.prequel-spotlight-border {\n  padding: 1px;\n  background: radial-gradient(\n    circle calc(var(--spot-radius, 260px) * 0.72) at var(--spot-x, 50%) var(--spot-y, 50%),\n    color-mix(in oklab, var(--card-foreground) 58%, transparent),\n    color-mix(in oklab, var(--card-foreground) 16%, transparent) 56%,\n    transparent 76%\n  );\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 320ms ease-out;\n}\n.prequel-spotlight:hover .prequel-spotlight-surface,\n.prequel-spotlight:focus-visible .prequel-spotlight-surface,\n.prequel-spotlight:focus-within .prequel-spotlight-surface {\n  opacity: 1;\n}\n.prequel-spotlight:hover .prequel-spotlight-border,\n.prequel-spotlight:focus-visible .prequel-spotlight-border,\n.prequel-spotlight:focus-within .prequel-spotlight-border {\n  opacity: 1;\n}\n@media (prefers-reduced-motion: reduce) {\n  .prequel-spotlight-surface,\n  .prequel-spotlight-border {\n    transition: none;\n  }\n  .prequel-spotlight:hover .prequel-spotlight-surface,\n  .prequel-spotlight:focus-visible .prequel-spotlight-surface,\n  .prequel-spotlight:focus-within .prequel-spotlight-surface {\n    opacity: 0;\n  }\n  .prequel-spotlight:hover .prequel-spotlight-border,\n  .prequel-spotlight:focus-visible .prequel-spotlight-border,\n  .prequel-spotlight:focus-within .prequel-spotlight-border {\n    opacity: 0.45;\n  }\n}\n`;\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type SpotlightCardProps = {\n  className?: string;\n  /** Replaces the default demo body. */\n  children?: ReactNode;\n  /** Headline shown in the default demo body. */\n  title?: string;\n  /** Supporting sentence shown in the default demo body. */\n  description?: string;\n  /** Radius of the spotlight and border light, in pixels. Defaults to 260. */\n  radius?: number;\n  /** Accessible name for the card region. */\n  ariaLabel?: string;\n};\n\ntype SpotlightStyle = CSSProperties & {\n  \"--spot-radius\": string;\n};\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function SpotlightCard({\n  className,\n  children,\n  title = \"Every request, in one calm view.\",\n  description = \"Traces, logs and latency for Northwind Labs' edge services, without opening four tabs.\",\n  radius = 260,\n  ariaLabel = \"Spotlight card\",\n}: SpotlightCardProps) {\n  const reduce = Boolean(useReducedMotion());\n  const ref = useRef<HTMLDivElement | null>(null);\n  const frame = useRef<number | null>(null);\n  const point = useRef({ x: 0, y: 0 });\n\n  useEffect(() => {\n    return () => {\n      if (frame.current !== null) window.cancelAnimationFrame(frame.current);\n    };\n  }, []);\n\n  const follow = (event: ReactPointerEvent<HTMLDivElement>) => {\n    if (reduce) return;\n    const element = ref.current;\n    if (!element) return;\n\n    const rect = element.getBoundingClientRect();\n    point.current = {\n      x: event.clientX - rect.left,\n      y: event.clientY - rect.top,\n    };\n\n    if (frame.current !== null) return;\n    frame.current = window.requestAnimationFrame(() => {\n      frame.current = null;\n      const node = ref.current;\n      if (!node) return;\n      node.style.setProperty(\"--spot-x\", `${point.current.x}px`);\n      node.style.setProperty(\"--spot-y\", `${point.current.y}px`);\n    });\n  };\n\n  return (\n    <div\n      ref={ref}\n      tabIndex={0}\n      role=\"group\"\n      aria-label={ariaLabel}\n      onPointerEnter={follow}\n      onPointerMove={follow}\n      style={{ \"--spot-radius\": `${Math.max(120, radius)}px` } as SpotlightStyle}\n      className={cn(\n        \"prequel-spotlight relative isolate overflow-hidden rounded-xl border border-border bg-card text-card-foreground\",\n        \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        className\n      )}\n    >\n      <style>{SPOTLIGHT_CSS}</style>\n\n      <span\n        aria-hidden=\"true\"\n        className=\"prequel-spotlight-surface pointer-events-none absolute inset-0 rounded-[inherit]\"\n      />\n      <span\n        aria-hidden=\"true\"\n        className=\"prequel-spotlight-border pointer-events-none absolute inset-0 rounded-[inherit]\"\n      />\n\n      <div className=\"relative\">\n        {children ?? (\n          <div className=\"p-6 sm:p-7\">\n            <div className=\"flex flex-wrap items-start justify-between gap-x-6 gap-y-4\">\n              <div className=\"min-w-0\">\n                <div className=\"flex items-center gap-2 text-[12px] font-medium text-muted-foreground\">\n                  <span className=\"relative flex h-2 w-2 flex-none\">\n                    <span className=\"absolute inset-0 rounded-full bg-success/25\" />\n                    <span className=\"absolute inset-[3px] rounded-full bg-success\" />\n                  </span>\n                  All systems normal\n                </div>\n                <h3 className=\"mt-3 max-w-[26ch] text-balance text-[20px] font-semibold leading-snug tracking-[-0.02em] sm:text-[22px]\">\n                  {title}\n                </h3>\n                <p className=\"mt-2 max-w-[46ch] text-[13.5px] leading-relaxed text-muted-foreground\">\n                  {description}\n                </p>\n              </div>\n\n              <div className=\"flex-none text-left sm:text-right\">\n                <div className=\"text-[11.5px] text-muted-foreground\">p95 latency</div>\n                <div className=\"mt-0.5 text-[26px] font-semibold leading-none tracking-tight tabular-nums\">\n                  48\n                  <span className=\"ml-1 text-[13px] font-medium text-muted-foreground\">\n                    ms\n                  </span>\n                </div>\n              </div>\n            </div>\n\n            <dl className=\"mt-6 grid grid-cols-3 divide-x divide-border overflow-hidden rounded-lg border border-border bg-background/50\">\n              <div className=\"min-w-0 px-3 py-3 sm:px-4\">\n                <dt className=\"truncate text-[11px] text-muted-foreground\">Requests</dt>\n                <dd className=\"mt-0.5 text-[15px] font-semibold tabular-nums\">2.84M</dd>\n              </div>\n              <div className=\"min-w-0 px-3 py-3 sm:px-4\">\n                <dt className=\"truncate text-[11px] text-muted-foreground\">Errors</dt>\n                <dd className=\"mt-0.5 text-[15px] font-semibold tabular-nums\">0.03%</dd>\n              </div>\n              <div className=\"min-w-0 px-3 py-3 sm:px-4\">\n                <dt className=\"truncate text-[11px] text-muted-foreground\">Regions</dt>\n                <dd className=\"mt-0.5 text-[15px] font-semibold tabular-nums\">14</dd>\n              </div>\n            </dl>\n\n            <div className=\"mt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-[11.5px] text-muted-foreground\">\n              <span>Updated 42 seconds ago</span>\n              <span className=\"tabular-nums\">312 traces · 1.4 GB logs today</span>\n            </div>\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n\n/* The default card on its own, handy for previews. */\nexport function SpotlightCardDemo() {\n  return <SpotlightCard />;\n}\n\nexport default SpotlightCard;\n"}]}