{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "showcase-case-rail",
  "type": "registry:component",
  "title": "Showcase Case Rail",
  "description": "A light horizontal rail of case-study cards with a chapter index whose underline slides continuously with the scroll position. Cards snap, can be dragged with the mouse, and their art drifts with parallax as they pass.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "showcase",
    "showcase",
    "case studies",
    "carousel",
    "drag",
    "parallax",
    "light"
  ],
  "docs": "https://hyperblur.dev/effects/showcase-case-rail",
  "files": [
    {
      "path": "registry/hyperblur/showcase-case-rail.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/showcase-case-rail.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CaseRailItem {\n  client: string;\n  title: string;\n  sector: string;\n  metric: string;\n  metricLabel: string;\n  hue: number;\n  href: string;\n}\n\nexport interface ShowcaseCaseRailProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  cases?: CaseRailItem[];\n  accent?: string;\n  onCaseSelect?: (item: CaseRailItem, index: number) => void;\n}\n\nconst defaultCases: CaseRailItem[] = [\n  { client: \"Fieldnote\", title: \"Rebuilding onboarding for a field research app\", sector: \"SaaS\", metric: \"+38%\", metricLabel: \"week-one activation\", hue: 18, href: \"#\" },\n  { client: \"Brightwater\", title: \"A utility bill people actually understand\", sector: \"Energy\", metric: \"-52%\", metricLabel: \"billing support calls\", hue: 196, href: \"#\" },\n  { client: \"Kestrel Air\", title: \"Rebooking a missed flight in under a minute\", sector: \"Travel\", metric: \"47s\", metricLabel: \"median rebooking time\", hue: 228, href: \"#\" },\n  { client: \"Oakline\", title: \"From paper forms to a mortgage in nine screens\", sector: \"Fintech\", metric: \"3.1x\", metricLabel: \"completed applications\", hue: 142, href: \"#\" },\n  { client: \"Parcel & Pine\", title: \"A storefront that sells furniture by the room\", sector: \"Retail\", metric: \"+24%\", metricLabel: \"average order value\", hue: 34, href: \"#\" },\n  { client: \"Lumen Schools\", title: \"Report cards parents read to the end\", sector: \"Education\", metric: \"91%\", metricLabel: \"parent open rate\", hue: 280, href: \"#\" },\n];\n\nconst css = `\n.hb-we2 {\n  --hb-we2-accent: #ff5a1f;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #f4f1ea;\n  color: #141414;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n  overflow: hidden;\n}\n.hb-we2 *, .hb-we2 *::before, .hb-we2 *::after { box-sizing: border-box; }\n.hb-we2-inner { max-width: 1120px; margin: 0 auto; padding: clamp(56px, 8cqi, 104px) clamp(18px, 4cqi, 40px) 0; }\n.hb-we2-top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 20px; }\n.hb-we2-eyebrow { margin: 0 0 14px; color: #6b665c; font-size: 13px; font-weight: 500; }\n.hb-we2-title { margin: 0; max-width: 18ch; font-family: var(--font-grotesk, inherit); font-size: clamp(28px, 4.6cqi, 50px); font-weight: 600; line-height: 1.04; letter-spacing: -.035em; text-wrap: balance; }\n.hb-we2-nav { display: flex; align-items: center; gap: 10px; }\n.hb-we2-count { min-width: 64px; color: #6b665c; font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; font-variant-numeric: tabular-nums; }\n.hb-we2-count b { color: #141414; font-weight: 600; }\n.hb-we2-btn {\n  width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;\n  background: #fff; color: #141414; box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 0 0 1px rgba(20,20,20,.1), 0 8px 20px -10px rgba(20,20,20,.3);\n  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .2s ease, color .2s ease, opacity .2s ease;\n}\n.hb-we2-btn:hover:not(:disabled) { background: #141414; color: #f4f1ea; transform: translateY(-1px); }\n.hb-we2-btn:active:not(:disabled) { transform: scale(.94); }\n.hb-we2-btn:disabled { opacity: .35; cursor: default; }\n.hb-we2-btn:focus-visible { outline: 2px solid var(--hb-we2-accent); outline-offset: 3px; }\n.hb-we2-btn svg { width: 16px; height: 16px; }\n.hb-we2-chapters { position: relative; display: flex; gap: clamp(12px, 3cqi, 28px); margin-top: clamp(26px, 4cqi, 40px); padding-bottom: 12px; border-bottom: 1px solid rgba(20,20,20,.12); overflow-x: auto; scrollbar-width: none; }\n.hb-we2-chapters::-webkit-scrollbar { display: none; }\n.hb-we2-chap {\n  flex: none; display: inline-flex; align-items: baseline; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer;\n  color: #8a857a; font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; transition: color .25s ease;\n}\n.hb-we2-chap span { font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; }\n.hb-we2-chap[aria-current=\"true\"] { color: #141414; }\n.hb-we2-chap:hover { color: #141414; }\n.hb-we2-chap:focus-visible { outline: 2px solid var(--hb-we2-accent); outline-offset: 4px; border-radius: 3px; }\n.hb-we2-bar { position: absolute; left: 0; bottom: -1px; height: 2px; width: var(--hb-we2-w, 40px); background: var(--hb-we2-accent); transform: translateX(var(--hb-we2-l, 0px)); border-radius: 2px; }\n.hb-we2-rail {\n  position: relative; display: flex; gap: clamp(14px, 2cqi, 22px); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; cursor: grab;\n  padding: clamp(28px, 4cqi, 40px) max(clamp(18px, 4cqi, 40px), calc((100cqi - 1120px) / 2 + 40px)) clamp(56px, 8cqi, 104px);\n  scroll-padding-inline: max(clamp(18px, 4cqi, 40px), calc((100cqi - 1120px) / 2 + 40px));\n  outline: none;\n}\n.hb-we2-rail::-webkit-scrollbar { display: none; }\n.hb-we2-rail[data-drag=\"true\"] { cursor: grabbing; scroll-snap-type: none; user-select: none; }\n.hb-we2-rail:focus-visible { box-shadow: inset 0 0 0 2px var(--hb-we2-accent); }\n.hb-we2-card {\n  flex: none; width: clamp(272px, 42cqi, 460px); scroll-snap-align: start; display: flex; flex-direction: column;\n  border-radius: 22px; background: #fff; color: inherit; text-decoration: none; overflow: hidden;\n  box-shadow: 0 0 0 1px rgba(20,20,20,.08), 0 1px 0 rgba(0,0,0,.03), 0 26px 50px -34px rgba(20,20,20,.45);\n  transition: transform .45s cubic-bezier(.2,.8,.2,1), box-shadow .45s ease;\n}\n.hb-we2-card:hover { transform: translateY(-6px); box-shadow: 0 0 0 1px rgba(20,20,20,.1), 0 34px 60px -30px rgba(20,20,20,.5); }\n.hb-we2-card:focus-visible { outline: 2px solid var(--hb-we2-accent); outline-offset: 4px; }\n.hb-we2-art { position: relative; aspect-ratio: 16 / 11; overflow: hidden; background: hsl(var(--hb-we2-h) 50% 88%); }\n.hb-we2-layer { position: absolute; inset: -8% -14%; transform: translateX(calc(var(--hb-we2-p, 0) * var(--hb-we2-d, 20px))); transition: transform .12s linear; }\n.hb-we2-layer svg { width: 100%; height: 100%; display: block; }\n.hb-we2-chip {\n  position: absolute; left: 14px; top: 14px; height: 26px; padding: 0 11px; border-radius: 999px; background: rgba(255,255,255,.82);\n  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #141414; font-size: 12px; font-weight: 500; line-height: 26px;\n}\n.hb-we2-body { display: grid; gap: 16px; padding: 20px 22px 22px; }\n.hb-we2-client { display: flex; align-items: center; justify-content: space-between; color: #6b665c; font-size: 13px; font-weight: 500; }\n.hb-we2-client svg { width: 16px; height: 16px; transition: transform .35s cubic-bezier(.2,.8,.2,1); }\n.hb-we2-card:hover .hb-we2-client svg { transform: translate(3px, -3px); }\n.hb-we2-ctitle { margin: 0; font-size: clamp(17px, 1.9cqi, 20px); font-weight: 600; line-height: 1.3; letter-spacing: -.015em; text-wrap: balance; }\n.hb-we2-metric { display: flex; align-items: baseline; gap: 10px; padding-top: 14px; border-top: 1px dashed rgba(20,20,20,.14); }\n.hb-we2-metric b { font-family: var(--font-grotesk, inherit); font-size: clamp(30px, 4cqi, 40px); font-weight: 600; letter-spacing: -.04em; color: hsl(var(--hb-we2-h) 70% 34%); }\n.hb-we2-metric span { color: #6b665c; font-size: 13px; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-we2 *, .hb-we2 *::before, .hb-we2 *::after { transition: none !important; animation: none !important; }\n  .hb-we2-layer { transform: none; }\n}\n`;\n\nfunction CaseArt({ item, index }: { item: CaseRailItem; index: number }) {\n  const h = item.hue;\n  const deep = `hsl(${h} 55% 30%)`;\n  const mid = `hsl(${h} 70% 55%)`;\n  const soft = `hsl(${h} 60% 76%)`;\n  const kind = index % 3;\n  return (\n    <svg viewBox=\"0 0 520 340\" preserveAspectRatio=\"xMidYMid slice\" aria-hidden=\"true\">\n      <circle cx=\"430\" cy=\"60\" r=\"120\" fill={soft} />\n      <circle cx=\"80\" cy=\"320\" r=\"90\" fill={soft} opacity=\".7\" />\n      {kind === 0 && (\n        <g>\n          <rect x=\"150\" y=\"56\" width=\"220\" height=\"300\" rx=\"30\" fill=\"#141414\" />\n          <rect x=\"164\" y=\"72\" width=\"192\" height=\"270\" rx=\"20\" fill=\"#fafaf7\" />\n          <rect x=\"184\" y=\"100\" width=\"90\" height=\"10\" rx=\"5\" fill={deep} />\n          <rect x=\"184\" y=\"120\" width=\"140\" height=\"7\" rx=\"3.5\" fill=\"#d9d5cb\" />\n          {[0, 1, 2].map((k) => (\n            <g key={k}>\n              <rect x=\"184\" y={150 + k * 48} width=\"152\" height=\"38\" rx=\"10\" fill={k === 0 ? mid : \"#efece4\"} />\n              <circle cx=\"202\" cy={169 + k * 48} r=\"7\" fill={k === 0 ? \"#fff\" : soft} />\n              <rect x=\"216\" y={165 + k * 48} width={70 - k * 12} height=\"7\" rx=\"3.5\" fill={k === 0 ? \"#fff\" : \"#bdb8ac\"} />\n            </g>\n          ))}\n        </g>\n      )}\n      {kind === 1 && (\n        <g>\n          <rect x=\"70\" y=\"70\" width=\"380\" height=\"230\" rx=\"18\" fill=\"#fafaf7\" stroke=\"rgba(0,0,0,.08)\" />\n          <rect x=\"70\" y=\"70\" width=\"380\" height=\"34\" rx=\"18\" fill=\"#efece4\" />\n          <circle cx=\"92\" cy=\"87\" r=\"5\" fill=\"#d9d5cb\" />\n          <circle cx=\"108\" cy=\"87\" r=\"5\" fill=\"#d9d5cb\" />\n          {[0, 1, 2, 3, 4, 5, 6].map((k) => {\n            const hgt = [60, 92, 74, 120, 102, 140, 128][k];\n            return <rect key={k} x={104 + k * 46} y={270 - hgt} width=\"28\" height={hgt} rx=\"6\" fill={k === 5 ? mid : soft} />;\n          })}\n          <path d=\"M104 210 L150 186 L196 196 L242 150 L288 162 L334 120 L380 128\" fill=\"none\" stroke={deep} strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n        </g>\n      )}\n      {kind === 2 && (\n        <g>\n          <rect x=\"90\" y=\"96\" width=\"250\" height=\"160\" rx=\"18\" fill={deep} />\n          <rect x=\"112\" y=\"122\" width=\"44\" height=\"32\" rx=\"7\" fill={soft} />\n          <rect x=\"112\" y=\"200\" width=\"150\" height=\"10\" rx=\"5\" fill=\"rgba(255,255,255,.55)\" />\n          <rect x=\"112\" y=\"220\" width=\"96\" height=\"8\" rx=\"4\" fill=\"rgba(255,255,255,.3)\" />\n          <rect x=\"250\" y=\"150\" width=\"190\" height=\"130\" rx=\"18\" fill=\"#fafaf7\" stroke=\"rgba(0,0,0,.08)\" />\n          <circle cx=\"345\" cy=\"205\" r=\"34\" fill=\"none\" stroke=\"#e7e3da\" strokeWidth=\"10\" />\n          <circle cx=\"345\" cy=\"205\" r=\"34\" fill=\"none\" stroke={mid} strokeWidth=\"10\" strokeDasharray=\"160 214\" strokeLinecap=\"round\" transform=\"rotate(-90 345 205)\" />\n        </g>\n      )}\n    </svg>\n  );\n}\n\nexport function ShowcaseCaseRail({\n  eyebrow = \"Case studies\",\n  title = \"Six problems, six measurable outcomes\",\n  cases = defaultCases,\n  accent = \"#ff5a1f\",\n  onCaseSelect,\n  className,\n  style,\n  ...rest\n}: ShowcaseCaseRailProps) {\n  const railRef = React.useRef<HTMLDivElement | null>(null);\n  const chapRef = React.useRef<HTMLDivElement | null>(null);\n  const barRef = React.useRef<HTMLSpanElement | null>(null);\n  const drag = React.useRef({ on: false, x: 0, left: 0, moved: false });\n  const [index, setIndex] = React.useState(0);\n  const [dragging, setDragging] = React.useState(false);\n  const [edges, setEdges] = React.useState({ start: true, end: false });\n\n  const sync = React.useCallback(() => {\n    const rail = railRef.current;\n    const chaps = chapRef.current;\n    const bar = barRef.current;\n    if (!rail) return;\n    const cards = Array.from(rail.querySelectorAll<HTMLElement>(\"[data-hb-we2-card]\"));\n    if (!cards.length) return;\n    const max = rail.scrollWidth - rail.clientWidth;\n    const f = max > 0 ? Math.max(0, Math.min(1, rail.scrollLeft / max)) * (cards.length - 1) : 0;\n    const center = rail.scrollLeft + rail.clientWidth / 2;\n    cards.forEach((c) => {\n      const mid = c.offsetLeft + c.offsetWidth / 2;\n      const p = Math.max(-1.5, Math.min(1.5, (mid - center) / rail.clientWidth));\n      c.style.setProperty(\"--hb-we2-p\", p.toFixed(3));\n    });\n    if (chaps && bar) {\n      const btns = Array.from(chaps.querySelectorAll<HTMLElement>(\"[data-hb-we2-chap]\"));\n      const a = Math.floor(f);\n      const b = Math.min(btns.length - 1, a + 1);\n      const t = f - a;\n      if (btns[a] && btns[b]) {\n        const l = btns[a].offsetLeft + (btns[b].offsetLeft - btns[a].offsetLeft) * t;\n        const w = btns[a].offsetWidth + (btns[b].offsetWidth - btns[a].offsetWidth) * t;\n        bar.style.setProperty(\"--hb-we2-l\", `${l.toFixed(1)}px`);\n        bar.style.setProperty(\"--hb-we2-w\", `${w.toFixed(1)}px`);\n      }\n    }\n    const next = Math.round(f);\n    setIndex((v) => (v === next ? v : next));\n    const start = rail.scrollLeft < 4;\n    const end = rail.scrollLeft > max - 4;\n    setEdges((e) => (e.start === start && e.end === end ? e : { start, end }));\n  }, []);\n\n  React.useEffect(() => {\n    const rail = railRef.current;\n    if (!rail) return;\n    let raf = 0;\n    const on = () => {\n      if (!raf) raf = requestAnimationFrame(() => {\n        raf = 0;\n        sync();\n      });\n    };\n    on();\n    rail.addEventListener(\"scroll\", on, { passive: true });\n    window.addEventListener(\"resize\", on);\n    return () => {\n      cancelAnimationFrame(raf);\n      rail.removeEventListener(\"scroll\", on);\n      window.removeEventListener(\"resize\", on);\n    };\n  }, [sync]);\n\n  const goTo = (i: number) => {\n    const rail = railRef.current;\n    if (!rail) return;\n    const cards = rail.querySelectorAll<HTMLElement>(\"[data-hb-we2-card]\");\n    const c = cards[Math.max(0, Math.min(cards.length - 1, i))];\n    if (!c) return;\n    const pad = parseFloat(getComputedStyle(rail).paddingLeft) || 0;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    rail.scrollTo({ left: c.offsetLeft - pad, behavior: reduce ? \"auto\" : \"smooth\" });\n  };\n\n  const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (e.pointerType !== \"mouse\" || e.button !== 0) return;\n    const rail = railRef.current;\n    if (!rail) return;\n    drag.current = { on: true, x: e.clientX, left: rail.scrollLeft, moved: false };\n  };\n  const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    const rail = railRef.current;\n    if (!d.on || !rail) return;\n    const dx = e.clientX - d.x;\n    if (!d.moved && Math.abs(dx) > 5) {\n      d.moved = true;\n      setDragging(true);\n      rail.setPointerCapture(e.pointerId);\n    }\n    if (d.moved) rail.scrollLeft = d.left - dx;\n  };\n  const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    if (!d.on) return;\n    d.on = false;\n    if (d.moved) {\n      setDragging(false);\n      const rail = railRef.current;\n      if (rail && rail.hasPointerCapture(e.pointerId)) rail.releasePointerCapture(e.pointerId);\n      if (rail) {\n        const max = rail.scrollWidth - rail.clientWidth;\n        goTo(max > 0 ? Math.round((rail.scrollLeft / max) * (cases.length - 1)) : 0);\n      }\n    }\n  };\n\n  return (\n    <section\n      className={[\"hb-we2\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-we2-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-showcase-case-rail\" precedence=\"default\">{css}</style>\n      <div className=\"hb-we2-inner\">\n        <div className=\"hb-we2-top\">\n          <div>\n            {eyebrow ? <p className=\"hb-we2-eyebrow\">{eyebrow}</p> : null}\n            <h2 className=\"hb-we2-title\">{title}</h2>\n          </div>\n          <div className=\"hb-we2-nav\">\n            <span className=\"hb-we2-count\" aria-live=\"polite\">\n              <b>{String(index + 1).padStart(2, \"0\")}</b> / {String(cases.length).padStart(2, \"0\")}\n            </span>\n            <button type=\"button\" className=\"hb-we2-btn\" aria-label=\"Previous case\" disabled={edges.start} onClick={() => goTo(index - 1)}>\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M13 8H3m4-4L3 8l4 4\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n            </button>\n            <button type=\"button\" className=\"hb-we2-btn\" aria-label=\"Next case\" disabled={edges.end} onClick={() => goTo(index + 1)}>\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M3 8h10M9 4l4 4-4 4\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n            </button>\n          </div>\n        </div>\n        <div ref={chapRef} className=\"hb-we2-chapters\" role=\"group\" aria-label=\"Jump to a case\">\n          {cases.map((c, i) => (\n            <button key={c.client} type=\"button\" data-hb-we2-chap=\"\" className=\"hb-we2-chap\" aria-current={index === i ? \"true\" : undefined} onClick={() => goTo(i)}>\n              <span>{String(i + 1).padStart(2, \"0\")}</span>\n              {c.client}\n            </button>\n          ))}\n          <span ref={barRef} className=\"hb-we2-bar\" aria-hidden=\"true\" />\n        </div>\n      </div>\n      <div\n        ref={railRef}\n        className=\"hb-we2-rail\"\n        data-drag={dragging ? \"true\" : \"false\"}\n        tabIndex={0}\n        role=\"region\"\n        aria-label=\"Case studies, scroll horizontally\"\n        onPointerDown={onDown}\n        onPointerMove={onMove}\n        onPointerUp={onUp}\n        onPointerCancel={onUp}\n        onKeyDown={(e) => {\n          if (e.key === \"ArrowRight\") {\n            e.preventDefault();\n            goTo(index + 1);\n          } else if (e.key === \"ArrowLeft\") {\n            e.preventDefault();\n            goTo(index - 1);\n          }\n        }}\n        onClickCapture={(e) => {\n          if (drag.current.moved) {\n            e.preventDefault();\n            e.stopPropagation();\n            drag.current.moved = false;\n          }\n        }}\n      >\n        {cases.map((c, i) => (\n          <a\n            key={c.client}\n            data-hb-we2-card=\"\"\n            className=\"hb-we2-card\"\n            href={c.href}\n            draggable={false}\n            style={{ \"--hb-we2-h\": c.hue } as React.CSSProperties}\n            onClick={() => onCaseSelect?.(c, i)}\n          >\n            <div className=\"hb-we2-art\">\n              <div className=\"hb-we2-layer\" style={{ \"--hb-we2-d\": \"-40px\" } as React.CSSProperties}>\n                <CaseArt item={c} index={i} />\n              </div>\n              <span className=\"hb-we2-chip\">{c.sector}</span>\n            </div>\n            <div className=\"hb-we2-body\">\n              <div className=\"hb-we2-client\">\n                <span>{c.client}</span>\n                <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M5 11l6-6M6 5h5v5\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n              </div>\n              <h3 className=\"hb-we2-ctitle\">{c.title}</h3>\n              <div className=\"hb-we2-metric\">\n                <b>{c.metric}</b>\n                <span>{c.metricLabel}</span>\n              </div>\n            </div>\n          </a>\n        ))}\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}