{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spotlight-cursor-hero",
  "title": "Spotlight Cursor Hero",
  "description": "A hero in a dark room: the pointer carries a soft light that lights up the headline and uncovers notes hidden around it. Left alone, the light wanders by itself.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/spotlight-cursor-hero/spotlight-cursor-hero.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type SpotlightHeroTheme = \"dark\" | \"light\";\n\nexport interface SpotlightFinding {\n  /** Position in percent of the hero. */\n  x: number;\n  y: number;\n  label: string;\n  value: string;\n}\n\nexport interface SpotlightCursorHeroProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: SpotlightHeroTheme;\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  primaryAction?: { label: string; href?: string; onClick?: () => void } | null;\n  secondaryAction?: {\n    label: string;\n    href?: string;\n    onClick?: () => void;\n  } | null;\n  /** Notes that only show inside the light. */\n  findings?: SpotlightFinding[];\n  /** Radius of the light, in px. */\n  radius?: number;\n  /** The light keeps wandering when nothing is steering it. */\n  wander?: boolean;\n  /** Colour of the light. */\n  color?: string;\n  /** Height from tablet width up, in px. */\n  minHeight?: number;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#08080A\",\n    dim: \"#2E2E33\",\n    lit: \"#FFFFFF\",\n    text: \"#F2F2F3\",\n    sub: \"rgba(242,242,243,0.6)\",\n    grid: \"rgba(255,255,255,0.035)\",\n    gridLit: \"rgba(255,255,255,0.16)\",\n    note: \"rgba(255,255,255,0.05)\",\n    noteBorder: \"rgba(255,255,255,0.2)\",\n    btn: \"#F2F2F3\",\n    btnText: \"#08080A\",\n    ghost: \"rgba(255,255,255,0.08)\",\n    light: \"#FFD79A\",\n  },\n  light: {\n    bg: \"#EFEDE7\",\n    dim: \"#CFCCC3\",\n    lit: \"#14130F\",\n    text: \"#14130F\",\n    sub: \"rgba(20,19,15,0.62)\",\n    grid: \"rgba(20,19,15,0.05)\",\n    gridLit: \"rgba(20,19,15,0.2)\",\n    note: \"rgba(255,255,255,0.7)\",\n    noteBorder: \"rgba(20,19,15,0.2)\",\n    btn: \"#14130F\",\n    btnText: \"#EFEDE7\",\n    ghost: \"rgba(20,19,15,0.07)\",\n    light: \"#FFFFFF\",\n  },\n};\n\nconst DEFAULT_FINDINGS: SpotlightFinding[] = [\n  { x: 13, y: 20, label: \"Silent retries\", value: \"41,208\" },\n  { x: 74, y: 15, label: \"Orphaned jobs\", value: \"312\" },\n  { x: 84, y: 49, label: \"Slowest query\", value: \"2.4 s\" },\n  { x: 8, y: 66, label: \"Unused indexes\", value: \"27\" },\n  { x: 80, y: 73, label: \"Wasted spend\", value: \"$18,400\" },\n  { x: 14, y: 88, label: \"Stale secrets\", value: \"9\" },\n];\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction Action({\n  action,\n  fill,\n  color,\n}: {\n  action: { label: string; href?: string; onClick?: () => void };\n  fill: string;\n  color: string;\n}) {\n  const cls =\n    \"inline-flex h-11 cursor-pointer items-center rounded-full px-6 text-[14px] font-semibold no-underline transition-opacity hover:opacity-85\";\n  return action.href ? (\n    <a href={action.href} className={cls} style={{ background: fill, color }}>\n      {action.label}\n    </a>\n  ) : (\n    <button\n      type=\"button\"\n      onClick={action.onClick}\n      className={cls}\n      style={{ background: fill, color }}\n    >\n      {action.label}\n    </button>\n  );\n}\n\nconst headline =\n  \"m-0 max-w-[13ch] text-center text-[46px] leading-[0.98] font-semibold tracking-[-0.04em] @[640px]:text-[84px]\";\n\nexport function SpotlightCursorHero({\n  theme = \"dark\",\n  eyebrow = \"Lantern for production systems\",\n  title = \"See what your stack is hiding\",\n  description = \"Point it at any service and it finds the slow, the stale and the forgotten before your customers do.\",\n  primaryAction = { label: \"Start a scan\" },\n  secondaryAction = { label: \"Read the docs\" },\n  findings = DEFAULT_FINDINGS,\n  radius = 240,\n  wander = true,\n  color,\n  minHeight = 720,\n  className,\n  style,\n  ...props\n}: SpotlightCursorHeroProps) {\n  const pal = PALETTES[theme];\n  const glow = color ?? pal.light;\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const steer = React.useRef({ x: 0, y: 0, at: -1e9 });\n\n  // The light eases after the pointer, then drifts on a slow figure of eight once it is left alone.\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    if (reduce) {\n      el.style.setProperty(\"--lx\", \"50%\");\n      el.style.setProperty(\"--ly\", \"42%\");\n      return;\n    }\n    let raf = 0;\n    let prev = 0;\n    let x = el.clientWidth * 0.5;\n    let y = el.clientHeight * 0.36;\n    const frame = (now: number) => {\n      const dt = Math.min(0.05, prev ? (now - prev) / 1000 : 1 / 60);\n      prev = now;\n      const w = el.clientWidth;\n      const h = el.clientHeight;\n      const held = now - steer.current.at < 1800;\n      if (held || wander) {\n        const tx = held\n          ? steer.current.x\n          : w * (0.5 + 0.34 * Math.sin(now / 2300));\n        const ty = held\n          ? steer.current.y\n          : h * (0.44 + 0.3 * Math.sin(now / 1150));\n        const k = 1 - Math.exp(-dt * (held ? 11 : 2.4));\n        x += (tx - x) * k;\n        y += (ty - y) * k;\n      }\n      el.style.setProperty(\"--lx\", `${x.toFixed(1)}px`);\n      el.style.setProperty(\"--ly\", `${y.toFixed(1)}px`);\n      raf = requestAnimationFrame(frame);\n    };\n    const io = new IntersectionObserver(([entry]) => {\n      cancelAnimationFrame(raf);\n      prev = 0;\n      if (entry.isIntersecting) raf = requestAnimationFrame(frame);\n    });\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [reduce, wander]);\n\n  const onMove = (e: React.PointerEvent<HTMLElement>) => {\n    const r = e.currentTarget.getBoundingClientRect();\n    steer.current = {\n      x: e.clientX - r.left,\n      y: e.clientY - r.top,\n      at: e.timeStamp,\n    };\n  };\n\n  const mask = `radial-gradient(circle ${radius}px at var(--lx) var(--ly), #000 0%, rgba(0,0,0,0.9) 34%, rgba(0,0,0,0.34) 66%, transparent 100%)`;\n  const grid = (line: string) => ({\n    backgroundImage: `linear-gradient(${line} 1px, transparent 1px), linear-gradient(90deg, ${line} 1px, transparent 1px)`,\n    backgroundSize: \"56px 56px\",\n  });\n  const layout =\n    \"absolute inset-0 flex flex-col items-center justify-center px-5 pb-[136px] @[640px]:pb-[150px]\";\n\n  return (\n    <section\n      ref={rootRef}\n      onPointerMove={onMove}\n      onPointerDown={onMove}\n      className={cn(\n        \"@container relative w-full touch-pan-y overflow-hidden\",\n        className,\n      )}\n      style={\n        {\n          \"--lx\": \"50%\",\n          \"--ly\": \"36%\",\n          \"--h\": `${minHeight}px`,\n          background: pal.bg,\n          color: pal.text,\n          fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div className=\"relative isolate min-h-[620px] @[640px]:min-h-[var(--h)]\">\n        <div\n          aria-hidden=\"true\"\n          className=\"absolute inset-0\"\n          style={grid(pal.grid)}\n        />\n        <div className={layout}>\n          <h1 className={headline} style={{ color: pal.dim }}>\n            {title}\n          </h1>\n        </div>\n\n        {/* The same headline over again, plus the findings, shown only where the light falls. */}\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0\"\n          style={{\n            background: `radial-gradient(circle ${radius * 1.5}px at var(--lx) var(--ly), ${glow}26, transparent 72%)`,\n          }}\n        />\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0\"\n          style={{ WebkitMaskImage: mask, maskImage: mask }}\n        >\n          <div className=\"absolute inset-0\" style={grid(pal.gridLit)} />\n          <div className={layout}>\n            <p className={headline} style={{ color: pal.lit }}>\n              {title}\n            </p>\n          </div>\n          {findings.map((f) => (\n            <div\n              key={f.label}\n              className={cn(\n                \"absolute w-max -translate-x-1/2 -translate-y-1/2 rounded-xl px-3 py-2\",\n                // On a phone only the notes above the headline have room.\n                f.y > 30 && \"hidden @[640px]:block\",\n              )}\n              style={{\n                left: `${f.x}%`,\n                top: `${f.y}%`,\n                background: pal.note,\n                boxShadow: `inset 0 0 0 1px ${pal.noteBorder}`,\n              }}\n            >\n              <p\n                className=\"m-0 text-[11px] font-medium\"\n                style={{ color: pal.sub }}\n              >\n                {f.label}\n              </p>\n              <p\n                className=\"m-0 text-[17px] font-semibold tracking-[-0.02em] tabular-nums\"\n                style={{ color: pal.lit }}\n              >\n                {f.value}\n              </p>\n            </div>\n          ))}\n        </div>\n\n        <div className=\"absolute inset-x-0 top-0 p-6 text-center @[640px]:top-5\">\n          <p\n            className=\"m-0 text-[13.5px] font-medium\"\n            style={{ color: pal.sub }}\n          >\n            {eyebrow}\n          </p>\n        </div>\n        <div className=\"absolute inset-x-0 bottom-0 flex flex-col items-center gap-5 p-6 pb-9\">\n          <p\n            className=\"m-0 max-w-[46ch] text-center text-[15px] leading-snug\"\n            style={{ color: pal.sub }}\n          >\n            {description}\n          </p>\n          <div className=\"flex flex-wrap justify-center gap-2.5\">\n            {primaryAction && (\n              <Action\n                action={primaryAction}\n                fill={pal.btn}\n                color={pal.btnText}\n              />\n            )}\n            {secondaryAction && (\n              <Action\n                action={secondaryAction}\n                fill={pal.ghost}\n                color={pal.text}\n              />\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}