{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "blog-carousel",
  "type": "registry:component",
  "title": "Blog Carousel",
  "description": "A horizontal row of post cards with native scroll snapping, previous and next buttons, a position counter, a progress meter and fading edges.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "blog",
    "blog",
    "carousel",
    "slider",
    "scroll snap",
    "posts",
    "cards"
  ],
  "docs": "https://hyperblur.dev/effects/blog-carousel",
  "files": [
    {
      "path": "registry/hyperblur/blog-carousel.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/blog-carousel.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CarouselPost {\n  title: string;\n  category: string;\n  author: string;\n  date: string;\n  readTime: string;\n  href: string;\n  cover?: string;\n}\n\nexport interface BlogCarouselProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  posts?: CarouselPost[];\n  cta?: { label: string; href: string } | null;\n  accent?: string;\n  label?: string;\n}\n\nconst defaultPosts: CarouselPost[] = [\n  { title: \"Inside the redesign of our mobile checkout\", category: \"Case study\", author: \"Hana Ito\", date: \"Oct 30\", readTime: \"9 min\", href: \"#\" },\n  { title: \"Five SQL habits that saved us 40 hours a month\", category: \"Engineering\", author: \"Marcus Bell\", date: \"Oct 27\", readTime: \"7 min\", href: \"#\" },\n  { title: \"Onboarding emails people actually open\", category: \"Growth\", author: \"Sofia Marín\", date: \"Oct 23\", readTime: \"6 min\", href: \"#\" },\n  { title: \"Building a design system with three people\", category: \"Design\", author: \"Tomás Álvarez\", date: \"Oct 18\", readTime: \"11 min\", href: \"#\" },\n  { title: \"What 2,000 support tickets taught us about docs\", category: \"Support\", author: \"Elin Berg\", date: \"Oct 12\", readTime: \"8 min\", href: \"#\" },\n  { title: \"Incident review: the 14-minute search outage\", category: \"Reliability\", author: \"Priya Raman\", date: \"Oct 6\", readTime: \"10 min\", href: \"#\" },\n  { title: \"Hiring our first developer advocate\", category: \"Company\", author: \"Noah Fischer\", date: \"Sep 30\", readTime: \"5 min\", href: \"#\" },\n];\n\nconst tones = [\n  [\"#1f1302\", \"#b45309\", \"#fcd34d\"],\n  [\"#071a22\", \"#0e7490\", \"#67e8f9\"],\n  [\"#1b0b22\", \"#9333ea\", \"#f0abfc\"],\n  [\"#06190f\", \"#15803d\", \"#86efac\"],\n  [\"#200a0a\", \"#dc2626\", \"#fda4af\"],\n  [\"#0b1022\", \"#1d4ed8\", \"#93c5fd\"],\n];\n\nfunction hash(value: string) {\n  let h = 2166136261;\n  for (let i = 0; i < value.length; i++) {\n    h ^= value.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\nfunction initials(name: string) {\n  return name\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((part) => part[0]?.toUpperCase() ?? \"\")\n    .join(\"\");\n}\n\nconst css = `\n.hb-ki4 {\n  --hb-ki4-accent: #f5a524;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  overflow: hidden;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-ki4 *, .hb-ki4 *::before, .hb-ki4 *::after { box-sizing: border-box; }\n.hb-ki4-inner {\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: clamp(56px, 9cqi, 104px) clamp(18px, 4cqi, 40px) 0;\n}\n.hb-ki4-head {\n  display: grid;\n  gap: 20px;\n  margin-bottom: clamp(24px, 3.6cqi, 40px);\n}\n.hb-ki4-eyebrow {\n  margin: 0 0 12px;\n  color: var(--hb-ki4-accent);\n  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);\n  font-size: 12px;\n  letter-spacing: .08em;\n  text-transform: uppercase;\n}\n.hb-ki4-title {\n  margin: 0;\n  font-size: clamp(30px, 4.6cqi, 46px);\n  font-weight: 650;\n  line-height: 1.05;\n  letter-spacing: -.035em;\n  text-wrap: balance;\n}\n.hb-ki4-sub {\n  margin: 12px 0 0;\n  max-width: 460px;\n  color: #8f8f8f;\n  font-size: 15px;\n  line-height: 1.6;\n}\n.hb-ki4-controls {\n  display: flex;\n  align-items: center;\n  gap: 14px;\n}\n.hb-ki4-count {\n  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);\n  font-size: 13px;\n  color: #8f8f8f;\n  font-variant-numeric: tabular-nums;\n  white-space: nowrap;\n}\n.hb-ki4-count b { color: #ededed; font-weight: 500; }\n.hb-ki4-meter {\n  position: relative;\n  flex: 1;\n  min-width: 80px;\n  height: 2px;\n  border-radius: 2px;\n  background: rgba(255,255,255,.1);\n  overflow: hidden;\n}\n.hb-ki4-meter span {\n  position: absolute;\n  inset: 0;\n  background: var(--hb-ki4-accent);\n  transform-origin: left;\n  transform: scaleX(var(--hb-ki4-p, .2));\n  transition: transform .2s linear;\n}\n.hb-ki4-btns { display: flex; gap: 8px; }\n.hb-ki4-btn {\n  display: grid;\n  place-items: center;\n  width: 42px;\n  height: 42px;\n  margin: 0;\n  padding: 0;\n  border: 1px solid rgba(255,255,255,.12);\n  border-radius: 50%;\n  background: #111;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);\n  color: #ededed;\n  cursor: pointer;\n  transition: border-color .2s ease, background-color .2s ease, opacity .2s ease, transform .15s ease;\n}\n.hb-ki4-btn svg { width: 16px; height: 16px; }\n.hb-ki4-btn:hover:not(:disabled) { border-color: var(--hb-ki4-accent); background: color-mix(in srgb, var(--hb-ki4-accent) 12%, #111); }\n.hb-ki4-btn:active:not(:disabled) { transform: scale(.94); }\n.hb-ki4-btn:disabled { opacity: .35; cursor: default; }\n.hb-ki4-btn:focus-visible { outline: 2px solid var(--hb-ki4-accent); outline-offset: 2px; }\n.hb-ki4-viewport {\n  position: relative;\n  padding-bottom: clamp(56px, 9cqi, 104px);\n  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--hb-ki4-l, 0px), #000 calc(100% - var(--hb-ki4-r, 72px)), transparent 100%);\n  mask-image: linear-gradient(90deg, transparent 0, #000 var(--hb-ki4-l, 0px), #000 calc(100% - var(--hb-ki4-r, 72px)), transparent 100%);\n}\n.hb-ki4-viewport[data-start=\"false\"] { --hb-ki4-l: 72px; }\n.hb-ki4-viewport[data-end=\"true\"] { --hb-ki4-r: 0px; }\n.hb-ki4-track {\n  display: flex;\n  gap: 18px;\n  margin: 0;\n  padding: 4px max(clamp(18px, 4cqi, 40px), calc((100cqi - 1120px) / 2 + clamp(18px, 4cqi, 40px))) 8px;\n  list-style: none;\n  overflow-x: auto;\n  scroll-snap-type: x mandatory;\n  scroll-padding-inline: max(clamp(18px, 4cqi, 40px), calc((100cqi - 1120px) / 2 + clamp(18px, 4cqi, 40px)));\n  scrollbar-width: none;\n  overscroll-behavior-x: contain;\n}\n.hb-ki4-track::-webkit-scrollbar { display: none; }\n.hb-ki4-track:focus-visible { outline: 2px solid var(--hb-ki4-accent); outline-offset: -2px; border-radius: 12px; }\n.hb-ki4-slide {\n  flex: none;\n  width: clamp(250px, 31cqi, 340px);\n  scroll-snap-align: start;\n  animation: hb-ki4-in .8s cubic-bezier(.2,.7,.2,1) both;\n  animation-delay: var(--hb-ki4-d, 0ms);\n}\n.hb-ki4-card {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 20px;\n  background: #111;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);\n  color: inherit;\n  text-decoration: none;\n  overflow: hidden;\n  transition: border-color .25s ease, transform .4s cubic-bezier(.2,.7,.2,1), box-shadow .3s ease;\n}\n.hb-ki4-card:hover {\n  border-color: color-mix(in srgb, var(--hb-ki4-accent) 45%, rgba(255,255,255,.08));\n  transform: translateY(-4px);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 18px 40px -20px color-mix(in srgb, var(--hb-ki4-accent) 50%, transparent);\n}\n.hb-ki4-card:focus-visible { outline: 2px solid var(--hb-ki4-accent); outline-offset: 3px; }\n.hb-ki4-cover {\n  position: relative;\n  aspect-ratio: 4 / 3;\n  overflow: hidden;\n}\n.hb-ki4-layer {\n  position: absolute;\n  inset: -8%;\n  transition: transform .7s cubic-bezier(.2,.7,.2,1);\n}\n.hb-ki4-card:hover .hb-ki4-layer { transform: translate3d(-3%, -2%, 0) scale(1.04); }\n.hb-ki4-glyph {\n  position: absolute;\n  right: 16px;\n  bottom: 6px;\n  color: rgba(255,255,255,.9);\n  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n  font-size: 92px;\n  line-height: 1;\n  letter-spacing: -.04em;\n  mix-blend-mode: overlay;\n  transition: transform .7s cubic-bezier(.2,.7,.2,1);\n}\n.hb-ki4-card:hover .hb-ki4-glyph { transform: translate3d(4%, -4%, 0); }\n.hb-ki4-cat {\n  position: absolute;\n  left: 14px;\n  top: 14px;\n  height: 24px;\n  padding: 0 10px;\n  border-radius: 999px;\n  background: rgba(10,10,10,.5);\n  backdrop-filter: blur(8px);\n  -webkit-backdrop-filter: blur(8px);\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);\n  color: #fff;\n  font-size: 11.5px;\n  font-weight: 600;\n  line-height: 24px;\n}\n.hb-ki4-body { display: flex; flex: 1; flex-direction: column; gap: 14px; padding: 16px 18px 18px; }\n.hb-ki4-ptitle {\n  margin: 0;\n  font-size: 17px;\n  font-weight: 600;\n  line-height: 1.3;\n  letter-spacing: -.015em;\n  text-wrap: pretty;\n}\n.hb-ki4-meta {\n  display: flex;\n  align-items: center;\n  gap: 9px;\n  margin-top: auto;\n  min-width: 0;\n  color: #8f8f8f;\n  font-size: 12.5px;\n  white-space: nowrap;\n}\n.hb-ki4-meta > span:not(.hb-ki4-sep):not(.hb-ki4-av):not(.hb-ki4-author) { flex: none; }\n.hb-ki4-av {\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 24px;\n  height: 24px;\n  border-radius: 50%;\n  color: #fff;\n  font-size: 10px;\n  font-weight: 700;\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);\n}\n.hb-ki4-meta > .hb-ki4-author { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #d4d4d4; font-weight: 500; }\n.hb-ki4-sep { flex: none; width: 3px; height: 3px; border-radius: 50%; background: #4a4a4a; }\n.hb-ki4-more {\n  display: grid;\n  place-items: center;\n  height: 100%;\n  min-height: 280px;\n  border: 1px dashed rgba(255,255,255,.14);\n  border-radius: 20px;\n  color: #ededed;\n  font-size: 15px;\n  font-weight: 500;\n  text-decoration: none;\n  transition: border-color .25s ease, background-color .25s ease;\n}\n.hb-ki4-more span { display: inline-flex; align-items: center; gap: 8px; }\n.hb-ki4-more svg { width: 16px; height: 16px; color: var(--hb-ki4-accent); transition: transform .25s ease; }\n.hb-ki4-more:hover { border-color: var(--hb-ki4-accent); background: color-mix(in srgb, var(--hb-ki4-accent) 6%, transparent); }\n.hb-ki4-more:hover svg { transform: translateX(4px); }\n.hb-ki4-more:focus-visible { outline: 2px solid var(--hb-ki4-accent); outline-offset: 3px; }\n@container (min-width: 720px) {\n  .hb-ki4-head { grid-template-columns: 1fr minmax(260px, 340px); align-items: end; }\n}\n@keyframes hb-ki4-in {\n  from { opacity: 0; transform: translateX(48px); }\n  to { opacity: 1; transform: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ki4-slide { animation: none; }\n  .hb-ki4-card, .hb-ki4-layer, .hb-ki4-glyph, .hb-ki4-btn, .hb-ki4-meter span, .hb-ki4-more svg { transition: none; }\n  .hb-ki4-track { scroll-behavior: auto; }\n}\n`;\n\nfunction Arrow({ flip }: { flip?: boolean }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" style={flip ? { transform: \"scaleX(-1)\" } : undefined}>\n      <path d=\"M3 8h10M9 4l4 4-4 4\" />\n    </svg>\n  );\n}\n\nexport function BlogCarousel({\n  eyebrow = \"Latest stories\",\n  title = \"Fresh from the team\",\n  subtitle = \"Case studies, incident reviews and the occasional strong opinion, written by the people who build Northwind.\",\n  posts = defaultPosts,\n  cta = { label: \"Browse the archive\", href: \"#\" },\n  accent = \"#f5a524\",\n  label = \"Latest stories\",\n  className,\n  style,\n  ...rest\n}: BlogCarouselProps) {\n  const trackRef = React.useRef<HTMLUListElement>(null);\n  const [state, setState] = React.useState({ start: true, end: false, progress: 0, index: 0 });\n  const total = posts.length;\n\n  React.useEffect(() => {\n    const track = trackRef.current;\n    if (!track) return;\n    let frame = 0;\n    const measure = () => {\n      frame = 0;\n      const max = track.scrollWidth - track.clientWidth;\n      const first = track.querySelector<HTMLElement>(\"li\");\n      const step = first ? first.offsetWidth + 18 : track.clientWidth;\n      const progress = max > 0 ? track.scrollLeft / max : 1;\n      const end = track.scrollLeft >= max - 2;\n      const index = end ? Math.max(0, total - 1) : Math.min(total - 1, Math.round(track.scrollLeft / step));\n      setState((prev) => {\n        const next = { start: track.scrollLeft <= 2, end, progress, index };\n        return prev.start === next.start && prev.end === next.end && prev.index === next.index && Math.abs(prev.progress - next.progress) < 0.002 ? prev : next;\n      });\n    };\n    const schedule = () => {\n      if (!frame) frame = requestAnimationFrame(measure);\n    };\n    schedule();\n    track.addEventListener(\"scroll\", schedule, { passive: true });\n    const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(schedule) : null;\n    observer?.observe(track);\n    return () => {\n      track.removeEventListener(\"scroll\", schedule);\n      observer?.disconnect();\n      if (frame) cancelAnimationFrame(frame);\n    };\n  }, [total]);\n\n  const go = (direction: 1 | -1) => {\n    const track = trackRef.current;\n    if (!track) return;\n    const first = track.querySelector<HTMLElement>(\"li\");\n    const step = first ? first.offsetWidth + 18 : track.clientWidth * 0.8;\n    const reduce = typeof window !== \"undefined\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    track.scrollBy({ left: step * direction, behavior: reduce ? \"auto\" : \"smooth\" });\n  };\n\n  const onKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {\n    if (event.target !== event.currentTarget) return;\n    if (event.key === \"ArrowRight\") {\n      event.preventDefault();\n      go(1);\n    } else if (event.key === \"ArrowLeft\") {\n      event.preventDefault();\n      go(-1);\n    }\n  };\n\n  const shown = Math.max(state.progress, total > 0 ? 1 / total : 0);\n\n  return (\n    <section\n      className={className ? `hb-ki4 ${className}` : \"hb-ki4\"}\n      style={{ \"--hb-ki4-accent\": accent, ...style } as React.CSSProperties}\n      aria-roledescription=\"carousel\"\n      aria-label={label}\n      {...rest}\n    >\n      <style href=\"hb-blog-carousel\" precedence=\"default\">{css}</style>\n      <div className=\"hb-ki4-inner\">\n        <header className=\"hb-ki4-head\">\n          <div>\n            {eyebrow && <p className=\"hb-ki4-eyebrow\">{eyebrow}</p>}\n            <h2 className=\"hb-ki4-title\">{title}</h2>\n            {subtitle && <p className=\"hb-ki4-sub\">{subtitle}</p>}\n          </div>\n          <div className=\"hb-ki4-controls\">\n            <span className=\"hb-ki4-count\" aria-live=\"polite\">\n              <b>{String(state.index + 1).padStart(2, \"0\")}</b> / {String(total).padStart(2, \"0\")}\n            </span>\n            <span className=\"hb-ki4-meter\" aria-hidden=\"true\">\n              <span style={{ \"--hb-ki4-p\": shown.toFixed(4) } as React.CSSProperties} />\n            </span>\n            <div className=\"hb-ki4-btns\">\n              <button type=\"button\" className=\"hb-ki4-btn\" aria-label=\"Previous stories\" disabled={state.start} onClick={() => go(-1)}>\n                <Arrow flip />\n              </button>\n              <button type=\"button\" className=\"hb-ki4-btn\" aria-label=\"Next stories\" disabled={state.end} onClick={() => go(1)}>\n                <Arrow />\n              </button>\n            </div>\n          </div>\n        </header>\n      </div>\n      <div className=\"hb-ki4-viewport\" data-start={state.start} data-end={state.end}>\n        <ul ref={trackRef} className=\"hb-ki4-track\" tabIndex={0} aria-label=\"Stories, use arrow keys to scroll\" onKeyDown={onKeyDown}>\n          {posts.map((post, i) => {\n            const seed = hash(post.title);\n            const [deep, mid, light] = tones[(seed + i) % tones.length];\n            const avatar = tones[hash(post.author) % tones.length];\n            return (\n              <li\n                key={`${post.title}-${i}`}\n                className=\"hb-ki4-slide\"\n                aria-roledescription=\"slide\"\n                aria-label={`${i + 1} of ${total}`}\n                style={{ \"--hb-ki4-d\": `${(Math.min(i, 4) * 80).toFixed(0)}ms` } as React.CSSProperties}\n              >\n                <a className=\"hb-ki4-card\" href={post.href}>\n                  <div className=\"hb-ki4-cover\">\n                    <div\n                      className=\"hb-ki4-layer\"\n                      style={{\n                        background:\n                          post.cover ??\n                          `radial-gradient(80% 70% at ${(20 + (seed % 50)).toFixed(0)}% 20%, ${light} 0%, transparent 55%), conic-gradient(from ${(seed % 360).toFixed(0)}deg at 70% 80%, ${mid}, ${deep}, ${mid}), ${deep}`,\n                      }}\n                    />\n                    {!post.cover && <span className=\"hb-ki4-glyph\" aria-hidden=\"true\">{String(i + 1).padStart(2, \"0\")}</span>}\n                    <span className=\"hb-ki4-cat\">{post.category}</span>\n                  </div>\n                  <div className=\"hb-ki4-body\">\n                    <h3 className=\"hb-ki4-ptitle\">{post.title}</h3>\n                    <div className=\"hb-ki4-meta\">\n                      <span className=\"hb-ki4-av\" style={{ background: `linear-gradient(135deg, ${avatar[1]}, ${avatar[0]})` }} aria-hidden=\"true\">\n                        {initials(post.author)}\n                      </span>\n                      <span className=\"hb-ki4-author\">{post.author}</span>\n                      <span className=\"hb-ki4-sep\" aria-hidden=\"true\" />\n                      <span>{post.date}</span>\n                      <span className=\"hb-ki4-sep\" aria-hidden=\"true\" />\n                      <span>{post.readTime}</span>\n                    </div>\n                  </div>\n                </a>\n              </li>\n            );\n          })}\n          {cta && (\n            <li className=\"hb-ki4-slide\" style={{ \"--hb-ki4-d\": \"400ms\" } as React.CSSProperties}>\n              <a className=\"hb-ki4-more\" href={cta.href}>\n                <span>\n                  {cta.label}\n                  <Arrow />\n                </span>\n              </a>\n            </li>\n          )}\n        </ul>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}