{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hover-fan-stack",
  "type": "registry:component",
  "title": "Fan Stack",
  "description": "A tidy stack of cards that fans into an arc around a low pivot on hover. The card under the pointer lifts and pushes its neighbours aside, and a click brings it to the front of the stack.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hover",
    "cards",
    "fan",
    "stack",
    "deck",
    "hover",
    "picker"
  ],
  "docs": "https://hyperblur.dev/effects/hover-fan-stack",
  "files": [
    {
      "path": "registry/hyperblur/hover-fan-stack.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hover-fan-stack.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HoverFanStackCard {\n  title: string;\n  meta: string;\n  from: string;\n  to: string;\n}\n\nexport interface HoverFanStackProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  cards?: HoverFanStackCard[];\n  spread?: number;\n  cardWidth?: number;\n  autoPlay?: boolean;\n  defaultSelected?: number;\n  accent?: string;\n  labels?: { selected: string; pick: string };\n  onSelect?: (index: number, card: HoverFanStackCard) => void;\n}\n\nconst defaults: HoverFanStackCard[] = [\n  { title: \"Low Tide\", meta: \"18 tracks\", from: \"#1d6fa3\", to: \"#0b1f3a\" },\n  { title: \"Night Drive\", meta: \"24 tracks\", from: \"#ff5f6d\", to: \"#3a0d3f\" },\n  { title: \"Paper Moon\", meta: \"12 tracks\", from: \"#f2c14e\", to: \"#7a3b12\" },\n  { title: \"Greenhouse\", meta: \"31 tracks\", from: \"#3fbf8a\", to: \"#0c2e25\" },\n  { title: \"Static Bloom\", meta: \"16 tracks\", from: \"#9b7bff\", to: \"#1e1442\" },\n];\n\nconst css = `\n.hb-wg3 { --hb-wg3-accent: #2f7bff; --hb-wg3-w: 96px; position: relative; box-sizing: border-box; width: 100%; height: calc(var(--hb-wg3-w) * 1.78); font-family: inherit; color: #ededed; }\n.hb-wg3 *, .hb-wg3 *::before, .hb-wg3 *::after { box-sizing: border-box; }\n.hb-wg3-deck { position: absolute; left: 50%; top: 8%; width: var(--hb-wg3-w); height: calc(var(--hb-wg3-w) * 1.32); margin-left: calc(var(--hb-wg3-w) / -2); }\n.hb-wg3-card { appearance: none; border: 0; margin: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; position: absolute; inset: 0; border-radius: 12px; overflow: hidden; text-align: left; transform-origin: 50% 165%; transform: translate3d(var(--hb-wg3-x), var(--hb-wg3-y), 0) rotate(var(--hb-wg3-r)) scale(var(--hb-wg3-s)); transition: transform .62s cubic-bezier(.22,1.18,.36,1), box-shadow .4s ease, filter .4s ease; background: linear-gradient(155deg, var(--hb-wg3-from), var(--hb-wg3-to)); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 1px rgba(255,255,255,.06), 0 18px 30px -16px rgba(0,0,0,.9), 0 3px 8px rgba(0,0,0,.45); outline: none; -webkit-tap-highlight-color: transparent; }\n.hb-wg3-card::before { content: \"\"; position: absolute; inset: 0; background: radial-gradient(120% 70% at 20% 0%, rgba(255,255,255,.28), transparent 55%), repeating-linear-gradient(115deg, rgba(255,255,255,.05) 0 2px, transparent 2px 9px); mix-blend-mode: soft-light; }\n.hb-wg3-disc { position: absolute; right: -22%; top: 12%; width: 74%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(0,0,0,.55) 0 12%, rgba(255,255,255,.12) 13% 15%, transparent 16%), repeating-radial-gradient(circle, rgba(255,255,255,.07) 0 1px, transparent 1px 3px); opacity: .7; }\n.hb-wg3-text { position: absolute; left: 10px; right: 10px; bottom: 9px; display: grid; gap: 2px; }\n.hb-wg3-title { font-size: 12.5px; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; text-shadow: 0 1px 2px rgba(0,0,0,.35); }\n.hb-wg3-meta { font-size: 9.5px; color: rgba(255,255,255,.72); letter-spacing: .02em; }\n.hb-wg3-check { position: absolute; left: 9px; top: 9px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--hb-wg3-accent); box-shadow: 0 0 0 2px rgba(10,10,10,.6); transform: scale(0); transition: transform .45s cubic-bezier(.3,1.6,.4,1); }\n.hb-wg3-check svg { width: 10px; height: 10px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }\n.hb-wg3-card[aria-pressed=\"true\"] .hb-wg3-check { transform: scale(1); }\n.hb-wg3[data-open=\"true\"] .hb-wg3-card:not([data-hot=\"true\"]) { filter: saturate(.8) brightness(.82); }\n.hb-wg3[data-open=\"true\"] .hb-wg3-card[data-hot=\"true\"] { box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 1px rgba(255,255,255,.14), 0 26px 40px -16px rgba(0,0,0,.95), 0 0 34px -10px var(--hb-wg3-from); }\n.hb-wg3-card:focus-visible { box-shadow: 0 0 0 2px #0a0a0a, 0 0 0 4px var(--hb-wg3-accent), 0 18px 30px -16px rgba(0,0,0,.9); }\n.hb-wg3-hint { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 10.5px; color: #8f8f8f; letter-spacing: .01em; transition: opacity .3s ease, transform .4s cubic-bezier(.2,.7,.2,1); }\n.hb-wg3-hint b { color: #ededed; font-weight: 600; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wg3-card, .hb-wg3-check, .hb-wg3-hint { transition: none; }\n}\n`;\n\nexport function HoverFanStack({\n  cards = defaults,\n  spread = 10,\n  cardWidth = 96,\n  autoPlay = false,\n  defaultSelected = 1,\n  accent = \"#2f7bff\",\n  labels = { selected: \"now playing\", pick: \"select\" },\n  onSelect,\n  className = \"\",\n  style,\n  ...rest\n}: HoverFanStackProps) {\n  const [hoverOpen, setHoverOpen] = React.useState(false);\n  const [tapOpen, setTapOpen] = React.useState(false);\n  const [autoOpen, setAutoOpen] = React.useState(false);\n  const [hot, setHot] = React.useState(-1);\n  const [selected, setSelected] = React.useState(defaultSelected);\n  const [touched, setTouched] = React.useState(false);\n  const btns = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const lastPointer = React.useRef(\"mouse\");\n  const n = cards.length;\n  const open = hoverOpen || tapOpen || (autoPlay && !touched && autoOpen);\n\n  React.useEffect(() => {\n    if (!autoPlay || touched) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const id = window.setInterval(() => setAutoOpen((v) => !v), 2400);\n    return () => window.clearInterval(id);\n  }, [autoPlay, touched]);\n\n  const mid = (n - 1) / 2;\n  const front = Math.min(Math.max(selected, 0), n - 1);\n\n  const pose = (i: number) => {\n    const o = i - mid;\n    if (!open) {\n      const depth = i === front ? 0 : 1 + Math.abs(i - front);\n      return { x: 0, y: -depth * 2.2, r: o * 2.4, s: 1 - depth * 0.018 };\n    }\n    let push = 0;\n    if (hot >= 0 && i !== hot) push = i < hot ? -1 : 1;\n    const r = o * spread + push * 4;\n    const x = o * cardWidth * 0.2 + push * 6;\n    const y = i === hot ? -cardWidth * 0.2 : Math.abs(o) * 3;\n    return { x, y, r, s: i === hot ? 1.07 : 1 };\n  };\n\n  const choose = (i: number) => {\n    setSelected(i);\n    onSelect?.(i, cards[i]);\n  };\n\n  const onKey = (e: React.KeyboardEvent<HTMLButtonElement>, i: number) => {\n    let next = -1;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") next = (i + 1) % n;\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\") next = (i - 1 + n) % n;\n    if (e.key === \"Home\") next = 0;\n    if (e.key === \"End\") next = n - 1;\n    if (e.key === \"Escape\") {\n      setTapOpen(false);\n      setHoverOpen(false);\n      return;\n    }\n    if (next >= 0) {\n      e.preventDefault();\n      btns.current[next]?.focus();\n    }\n  };\n\n  const vars = { \"--hb-wg3-accent\": accent, \"--hb-wg3-w\": `${cardWidth}px` } as React.CSSProperties;\n  const label = hot >= 0 ? cards[hot] : cards[front];\n\n  return (\n    <div\n      className={`hb-wg3 ${className}`}\n      style={{ ...vars, ...style }}\n      data-open={open ? \"true\" : \"false\"}\n      onPointerEnter={(e) => {\n        lastPointer.current = e.pointerType;\n        if (e.pointerType === \"mouse\") {\n          setTouched(true);\n          setHoverOpen(true);\n        }\n      }}\n      onPointerLeave={(e) => {\n        if (e.pointerType === \"mouse\") {\n          setHoverOpen(false);\n          setHot(-1);\n        }\n      }}\n      onFocus={() => {\n        setTouched(true);\n        setHoverOpen(true);\n      }}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node | null)) {\n          setHoverOpen(false);\n          setTapOpen(false);\n          setHot(-1);\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-hover-fan-stack\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wg3-deck\" role=\"group\" aria-label=\"Collection\">\n        {cards.map((c, i) => {\n          const p = pose(i);\n          const z = open ? 10 + i : i === front ? 50 : 20 - Math.abs(i - front);\n          return (\n            <button\n              key={`${c.title}-${i}`}\n              ref={(el) => {\n                btns.current[i] = el;\n              }}\n              type=\"button\"\n              className=\"hb-wg3-card\"\n              aria-pressed={i === selected}\n              aria-label={`${c.title}, ${c.meta}`}\n              data-hot={i === hot ? \"true\" : \"false\"}\n              onPointerDown={(e) => {\n                lastPointer.current = e.pointerType;\n              }}\n              onPointerEnter={(e) => {\n                if (e.pointerType === \"mouse\") setHot(i);\n              }}\n              onFocus={() => setHot(i)}\n              onKeyDown={(e) => onKey(e, i)}\n              onClick={() => {\n                if (lastPointer.current !== \"mouse\" && !open) {\n                  setTouched(true);\n                  setTapOpen(true);\n                  return;\n                }\n                if (lastPointer.current !== \"mouse\" && hot !== i) {\n                  setHot(i);\n                  return;\n                }\n                choose(i);\n                if (lastPointer.current !== \"mouse\") {\n                  setTapOpen(false);\n                  setHot(-1);\n                }\n              }}\n              style={\n                {\n                  \"--hb-wg3-x\": `${p.x.toFixed(1)}px`,\n                  \"--hb-wg3-y\": `${p.y.toFixed(1)}px`,\n                  \"--hb-wg3-r\": `${p.r.toFixed(2)}deg`,\n                  \"--hb-wg3-s\": p.s.toFixed(3),\n                  \"--hb-wg3-from\": c.from,\n                  \"--hb-wg3-to\": c.to,\n                  zIndex: z,\n                } as React.CSSProperties\n              }\n            >\n              <span className=\"hb-wg3-disc\" aria-hidden=\"true\" />\n              <span className=\"hb-wg3-check\" aria-hidden=\"true\">\n                <svg viewBox=\"0 0 12 12\">\n                  <path d=\"M2.5 6.2l2.3 2.3 4.7-5\" />\n                </svg>\n              </span>\n              <span className=\"hb-wg3-text\">\n                <span className=\"hb-wg3-title\">{c.title}</span>\n                <span className=\"hb-wg3-meta\">{c.meta}</span>\n              </span>\n            </button>\n          );\n        })}\n      </div>\n      <p className=\"hb-wg3-hint\" aria-live=\"polite\">\n        {label ? (\n          <>\n            <b>{label.title}</b> · {hot >= 0 && hot !== selected ? labels.pick : labels.selected}\n          </>\n        ) : null}\n      </p>\n    </div>\n  );\n}\n"
    }
  ]
}