{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-hand-fan",
  "type": "registry:component",
  "title": "Card Hand Fan",
  "description": "A loose pile of cards that fans into an arc like a hand of playing cards. Hovered cards rise and push their neighbors aside, and picking one lifts it to the front while the rest fold back.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "components",
    "cards",
    "fan",
    "stack",
    "arc",
    "picker",
    "spring"
  ],
  "docs": "https://hyperblur.dev/effects/card-hand-fan",
  "files": [
    {
      "path": "registry/hyperblur/card-hand-fan.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/card-hand-fan.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HandCard {\n  title: string;\n  subtitle: string;\n  colors?: [string, string, string];\n}\n\nexport interface CardHandFanProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  cards?: HandCard[];\n  cardWidth?: number;\n  spread?: number;\n  defaultOpen?: boolean;\n  accent?: string;\n  onOpenChange?: (open: boolean) => void;\n  onSelect?: (index: number | null) => void;\n}\n\nconst defaultCards: HandCard[] = [\n  { title: \"Desert Modern\", subtitle: \"42 pins\", colors: [\"#c8754a\", \"#efd2b0\", \"#3b2a22\"] },\n  { title: \"Nordic Cabin\", subtitle: \"36 pins\", colors: [\"#5d7a73\", \"#d9e3dd\", \"#1f2b28\"] },\n  { title: \"Tokyo Night\", subtitle: \"58 pins\", colors: [\"#6b5bff\", \"#ff6fae\", \"#14122b\"] },\n  { title: \"Riviera\", subtitle: \"27 pins\", colors: [\"#2f7bff\", \"#f4e6c8\", \"#0f2140\"] },\n  { title: \"Brutal Print\", subtitle: \"19 pins\", colors: [\"#e8e3d6\", \"#ff4b2b\", \"#161616\"] },\n];\n\nfunction hash(n: number) {\n  let x = Math.imul(n ^ 0x2c1b3c6d, 0x297a2d39) >>> 0;\n  x = Math.imul(x ^ (x >>> 15), 0x85ebca6b) >>> 0;\n  return ((x ^ (x >>> 13)) >>> 0) / 4294967295;\n}\n\nconst css = `\n.hb-vl11 {\n  position: relative;\n  width: 100%;\n  height: calc(var(--hb-vl11-w) * 1.333 * 1.45);\n  color: #ededed;\n  font-family: inherit;\n  box-sizing: border-box;\n}\n.hb-vl11 *, .hb-vl11 *::before, .hb-vl11 *::after { box-sizing: border-box; }\n.hb-vl11-c {\n  position: absolute;\n  left: 50%;\n  bottom: 4%;\n  width: var(--hb-vl11-w);\n  aspect-ratio: 3 / 4;\n  margin: 0 0 0 calc(var(--hb-vl11-w) * -0.5);\n  padding: 0;\n  overflow: hidden;\n  border: 0;\n  border-radius: calc(var(--hb-vl11-w) * 0.09);\n  background: #141416;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transform-origin: 50% 190%;\n  transform: translate(var(--hb-vl11-tx), var(--hb-vl11-ty)) rotate(var(--hb-vl11-r)) scale(var(--hb-vl11-s));\n  opacity: var(--hb-vl11-o);\n  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 30px -14px rgba(0, 0, 0, 0.85);\n  transition:\n    transform 0.7s cubic-bezier(0.34, 1.28, 0.64, 1) var(--hb-vl11-d),\n    opacity 0.4s ease,\n    box-shadow 0.3s ease;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-vl11-c:focus-visible { outline: 2px solid var(--hb-vl11-a); outline-offset: 3px; }\n.hb-vl11-c[data-picked=\"true\"] { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 30px 50px -18px rgba(0, 0, 0, 0.95), 0 0 0 1px color-mix(in srgb, var(--hb-vl11-a) 50%, transparent); }\n.hb-vl11-art {\n  position: absolute;\n  inset: 0 0 34% 0;\n  overflow: hidden;\n  background: linear-gradient(160deg, var(--hb-vl11-c0), var(--hb-vl11-c2));\n}\n.hb-vl11-art::before {\n  content: \"\";\n  position: absolute;\n  left: 14%;\n  top: 18%;\n  width: 52%;\n  aspect-ratio: 1;\n  border-radius: 50%;\n  background: var(--hb-vl11-c1);\n  opacity: 0.9;\n}\n.hb-vl11-art::after {\n  content: \"\";\n  position: absolute;\n  right: -10%;\n  bottom: -20%;\n  width: 70%;\n  height: 70%;\n  border-radius: 40% 40% 0 0;\n  background: color-mix(in srgb, var(--hb-vl11-c2) 80%, #000000);\n  transform: rotate(-12deg);\n}\n.hb-vl11-art[data-v=\"1\"]::before { border-radius: 30% 70% 50% 50%; left: 40%; top: 10%; }\n.hb-vl11-art[data-v=\"2\"]::before { border-radius: 8%; transform: rotate(18deg); left: 28%; }\n.hb-vl11-art[data-v=\"2\"]::after { border-radius: 50%; right: 30%; }\n.hb-vl11-art[data-v=\"3\"]::after { border-radius: 0; transform: rotate(0deg); height: 28%; right: 0; width: 100%; bottom: 0; }\n.hb-vl11-meta {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  flex-direction: column;\n  gap: calc(var(--hb-vl11-w) * 0.02);\n  height: 34%;\n  padding: calc(var(--hb-vl11-w) * 0.07);\n  background: linear-gradient(180deg, #19191c, #121214);\n}\n.hb-vl11-t { overflow: hidden; font-size: calc(var(--hb-vl11-w) * 0.095); font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; text-overflow: ellipsis; }\n.hb-vl11-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }\n.hb-vl11-sub { font-size: calc(var(--hb-vl11-w) * 0.072); color: #8f8f8f; white-space: nowrap; }\n.hb-vl11-sw { display: flex; }\n.hb-vl11-sw span {\n  width: calc(var(--hb-vl11-w) * 0.085);\n  height: calc(var(--hb-vl11-w) * 0.085);\n  margin-left: calc(var(--hb-vl11-w) * -0.02);\n  border-radius: 50%;\n  box-shadow: 0 0 0 1.5px #141416;\n}\n.hb-vl11-hint {\n  position: absolute;\n  left: 50%;\n  top: 0;\n  padding: 3px 9px;\n  border-radius: 999px;\n  background: rgba(255, 255, 255, 0.05);\n  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: 10px;\n  letter-spacing: 0.06em;\n  color: #8f8f8f;\n  white-space: nowrap;\n  transform: translateX(-50%);\n  pointer-events: none;\n  transition: opacity 0.3s ease;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-vl11-c { transition: opacity 0.2s ease; }\n}\n`;\n\nexport function CardHandFan({\n  cards = defaultCards,\n  cardWidth = 150,\n  spread = 11,\n  defaultOpen = false,\n  accent = \"#2f7bff\",\n  onOpenChange,\n  onSelect,\n  className,\n  style,\n  ...rest\n}: CardHandFanProps) {\n  const [open, setOpen] = React.useState(defaultOpen);\n  const [picked, setPicked] = React.useState<number | null>(null);\n  const [hover, setHover] = React.useState<number | null>(null);\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const n = cards.length;\n  const mid = (n - 1) / 2;\n\n  const setOpenState = (next: boolean) => {\n    setOpen(next);\n    onOpenChange?.(next);\n  };\n\n  const pick = (index: number | null) => {\n    setPicked(index);\n    onSelect?.(index);\n  };\n\n  const press = (i: number) => {\n    if (!open) {\n      setOpenState(true);\n      return;\n    }\n    if (picked === null) pick(i);\n    else if (picked === i) pick(null);\n    else pick(i);\n  };\n\n  const layout = (i: number) => {\n    const w = cardWidth;\n    if (!open) {\n      const jitter = (hash(i + 3) - 0.5) * 7;\n      return { tx: (i - mid) * 2, ty: -i * 2.5, r: jitter, s: 1, o: 1, z: i, d: 0 };\n    }\n    if (picked !== null) {\n      if (i === picked) return { tx: 0, ty: -w * 0.06, r: 0, s: 1.06, o: 1, z: n + 2, d: 0 };\n      const side = i < picked ? -1 : 1;\n      return { tx: side * w * 0.08, ty: w * 0.05, r: side * 4 + (i - mid) * 2, s: 0.86, o: 0.35, z: i, d: 0 };\n    }\n    let r = (i - mid) * spread;\n    let ty = 0;\n    if (hover !== null) {\n      if (i === hover) ty = -w * 0.16;\n      else r += i < hover ? -2.5 : 2.5;\n    }\n    return { tx: 0, ty, r, s: 1, o: 1, z: i === hover ? n + 1 : i, d: open ? Math.abs(i - mid) * 0.03 : 0 };\n  };\n\n  const onKey = (event: React.KeyboardEvent, i: number) => {\n    if (event.key === \"Escape\") {\n      event.preventDefault();\n      if (picked !== null) pick(null);\n      else if (open) setOpenState(false);\n      return;\n    }\n    if (!open) return;\n    let next = -1;\n    if (event.key === \"ArrowRight\") next = Math.min(n - 1, i + 1);\n    else if (event.key === \"ArrowLeft\") next = Math.max(0, i - 1);\n    if (next < 0) return;\n    event.preventDefault();\n    refs.current[next]?.focus();\n    if (picked !== null) pick(next);\n  };\n\n  const hint = !open ? \"Click to fan out\" : picked === null ? \"Pick a board\" : `${cards[picked]?.title} selected`;\n\n  return (\n    <div\n      className={[\"hb-vl11\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-vl11-a\": accent, \"--hb-vl11-w\": `${cardWidth}px`, ...style } as React.CSSProperties}\n      role=\"group\"\n      aria-label=\"Boards\"\n      onPointerLeave={() => setHover(null)}\n      {...rest}\n    >\n      <style href=\"hb-card-hand-fan\" precedence=\"default\">{css}</style>\n      <span className=\"hb-vl11-hint\" aria-live=\"polite\">\n        {hint}\n      </span>\n      {cards.map((card, i) => {\n        const l = layout(i);\n        const [c0, c1, c2] = card.colors ?? [\"#c8754a\", \"#efd2b0\", \"#3b2a22\"];\n        return (\n          <button\n            key={card.title + i}\n            ref={(node) => {\n              refs.current[i] = node;\n            }}\n            type=\"button\"\n            className=\"hb-vl11-c\"\n            data-picked={picked === i ? \"true\" : \"false\"}\n            aria-pressed={picked === i}\n            aria-label={`${card.title}, ${card.subtitle}`}\n            tabIndex={!open ? (i === n - 1 ? 0 : -1) : 0}\n            style={\n              {\n                \"--hb-vl11-tx\": `${l.tx.toFixed(1)}px`,\n                \"--hb-vl11-ty\": `${l.ty.toFixed(1)}px`,\n                \"--hb-vl11-r\": `${l.r.toFixed(2)}deg`,\n                \"--hb-vl11-s\": l.s,\n                \"--hb-vl11-o\": l.o,\n                \"--hb-vl11-d\": `${l.d.toFixed(2)}s`,\n                \"--hb-vl11-c0\": c0,\n                \"--hb-vl11-c1\": c1,\n                \"--hb-vl11-c2\": c2,\n                zIndex: l.z,\n              } as React.CSSProperties\n            }\n            onPointerEnter={() => open && picked === null && setHover(i)}\n            onFocus={() => open && picked === null && setHover(i)}\n            onBlur={() => setHover(null)}\n            onClick={() => press(i)}\n            onKeyDown={(event) => onKey(event, i)}\n          >\n            <span className=\"hb-vl11-art\" data-v={i % 4} />\n            <span className=\"hb-vl11-meta\">\n              <span className=\"hb-vl11-t\">{card.title}</span>\n              <span className=\"hb-vl11-row\">\n                <span className=\"hb-vl11-sub\">{card.subtitle}</span>\n                <span className=\"hb-vl11-sw\" aria-hidden=\"true\">\n                  <span style={{ background: c0 }} />\n                  <span style={{ background: c1 }} />\n                  <span style={{ background: c2 }} />\n                </span>\n              </span>\n            </span>\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}