{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "waitlist-capacity-countdown",
  "type": "registry:component",
  "title": "Waitlist Capacity Countdown",
  "description": "A dark launch panel with a rolling four-unit countdown, a striped capacity bar that fills toward the seat limit, a spots-left counter that ticks as people join and an email form that reserves a numbered seat.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "waitlist",
    "waitlist",
    "countdown",
    "capacity",
    "progress bar",
    "scarcity",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/waitlist-capacity-countdown",
  "files": [
    {
      "path": "registry/hyperblur/waitlist-capacity-countdown.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/waitlist-capacity-countdown.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface WaitlistCapacityValues {\n  email: string;\n}\n\nexport interface WaitlistCapacityCountdownProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"onSubmit\"> {\n  cohort?: string;\n  title?: string;\n  subtitle?: string;\n  launchAt?: string;\n  initialSeconds?: number;\n  capacity?: number;\n  claimed?: number;\n  liveSignups?: boolean;\n  ctaLabel?: string;\n  onSubmit?: (values: WaitlistCapacityValues) => void | Promise<void>;\n  accent?: string;\n}\n\nconst css = `\n@keyframes hb-yg8-roll {\n  from { transform: translateY(-60%); opacity: 0; }\n  to { transform: none; opacity: 1; }\n}\n@keyframes hb-yg8-stripes { to { background-position: 28px 0; } }\n@keyframes hb-yg8-fill { from { transform: scaleX(0); } }\n@keyframes hb-yg8-blink { 50% { opacity: 0.25; } }\n@keyframes hb-yg8-spin { to { transform: rotate(360deg); } }\n@keyframes hb-yg8-bump {\n  0% { transform: none; }\n  35% { transform: translateY(-3px) scale(1.06); color: var(--hb-yg8-accent); }\n  100% { transform: none; }\n}\n@keyframes hb-yg8-in {\n  from { opacity: 0; transform: translateY(8px); }\n  to { opacity: 1; transform: none; }\n}\n.hb-yg8 {\n  --hb-yg8-accent: #fbbf24;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yg8 *, .hb-yg8 *::before, .hb-yg8 *::after { box-sizing: border-box; }\n.hb-yg8-bg {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  background:\n    radial-gradient(50% 40% at 50% 0%, color-mix(in srgb, var(--hb-yg8-accent) 14%, transparent), transparent 70%),\n    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 120px);\n  mask-image: linear-gradient(180deg, #000, transparent 90%);\n  -webkit-mask-image: linear-gradient(180deg, #000, transparent 90%);\n}\n.hb-yg8-in {\n  position: relative;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: 80px 24px 96px;\n}\n.hb-yg8-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }\n.hb-yg8-cohort {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  color: var(--hb-yg8-accent);\n  font-family: ui-monospace, \"Geist Mono\", Menlo, monospace;\n  font-size: 12.5px;\n  letter-spacing: 0.08em;\n  text-transform: uppercase;\n}\n.hb-yg8-cohort i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: hb-yg8-blink 1.4s steps(2) infinite; }\n.hb-yg8-title {\n  max-width: 620px;\n  margin: 14px 0 0;\n  font-size: clamp(32px, 4.8cqw, 52px);\n  font-weight: 650;\n  line-height: 1.03;\n  letter-spacing: -0.045em;\n  text-wrap: balance;\n}\n.hb-yg8-sub { max-width: 420px; margin: 0; color: #8f8f8f; font-size: 15.5px; line-height: 1.6; }\n.hb-yg8-panel {\n  margin-top: 40px;\n  padding: clamp(18px, 3cqw, 32px);\n  border: 1px solid rgba(255, 255, 255, 0.08);\n  border-radius: 24px;\n  background: linear-gradient(180deg, #131313, #0e0e0e);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 40px 80px -50px rgba(0, 0, 0, 0.9);\n}\n.hb-yg8-clock { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 1.6cqw, 16px); }\n.hb-yg8-unit {\n  position: relative;\n  padding: clamp(12px, 2cqw, 22px) 8px clamp(10px, 1.6cqw, 16px);\n  overflow: hidden;\n  border: 1px solid rgba(255, 255, 255, 0.07);\n  border-radius: 16px;\n  background: #0b0b0b;\n  text-align: center;\n}\n.hb-yg8-unit::after {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 50%;\n  height: 1px;\n  background: rgba(255, 255, 255, 0.05);\n}\n.hb-yg8-digits {\n  display: flex;\n  justify-content: center;\n  font-family: ui-monospace, \"Geist Mono\", Menlo, monospace;\n  font-size: clamp(34px, 7cqw, 72px);\n  font-weight: 600;\n  line-height: 1;\n  letter-spacing: -0.04em;\n  font-variant-numeric: tabular-nums;\n}\n.hb-yg8-digit { display: inline-block; animation: hb-yg8-roll 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }\n.hb-yg8-unit span { display: block; margin-top: 8px; color: #6f6f6f; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }\n.hb-yg8-cap { margin-top: 28px; }\n.hb-yg8-cap-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }\n.hb-yg8-cap-top strong { font-size: 15px; font-weight: 600; }\n.hb-yg8-left { color: #a1a1a1; font-size: 14px; }\n.hb-yg8-left b { display: inline-block; color: #ededed; font-weight: 650; font-variant-numeric: tabular-nums; }\n.hb-yg8-left b[data-bump] { animation: hb-yg8-bump 0.6s ease; }\n.hb-yg8-bar {\n  position: relative;\n  height: 14px;\n  margin-top: 12px;\n  overflow: hidden;\n  border-radius: 999px;\n  background: #1a1a1a;\n  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);\n}\n.hb-yg8-fill {\n  position: absolute;\n  inset: 0 auto 0 0;\n  border-radius: 999px;\n  background:\n    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.16) 0 7px, transparent 7px 14px),\n    linear-gradient(90deg, color-mix(in srgb, var(--hb-yg8-accent) 70%, #000), var(--hb-yg8-accent));\n  background-size: 28px 100%, 100% 100%;\n  box-shadow: 0 0 20px color-mix(in srgb, var(--hb-yg8-accent) 50%, transparent);\n  transform-origin: left;\n  animation: hb-yg8-fill 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) both, hb-yg8-stripes 1s linear infinite;\n  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-yg8-ticks { position: relative; height: 22px; margin-top: 6px; color: #5f5f5f; font-size: 11.5px; font-variant-numeric: tabular-nums; }\n.hb-yg8-ticks span { position: absolute; top: 0; transform: translateX(-50%); }\n.hb-yg8-ticks span:first-child { transform: none; }\n.hb-yg8-ticks span:last-child { transform: translateX(-100%); }\n.hb-yg8-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }\n.hb-yg8-field { flex: 1 1 240px; }\n.hb-yg8-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n.hb-yg8-input {\n  width: 100%;\n  height: 50px;\n  padding: 0 16px;\n  border: 1px solid rgba(255, 255, 255, 0.1);\n  border-radius: 14px;\n  background: #0b0b0b;\n  color: #ededed;\n  font: inherit;\n  font-size: 15px;\n  outline: none;\n  transition: border-color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-yg8-input::placeholder { color: #5f5f5f; }\n.hb-yg8-input:focus { border-color: color-mix(in srgb, var(--hb-yg8-accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-yg8-accent) 18%, transparent); }\n.hb-yg8-input[aria-invalid=\"true\"] { border-color: rgba(248, 113, 113, 0.7); }\n.hb-yg8-err { min-height: 18px; margin: 6px 0 0; color: #f87171; font-size: 12.5px; }\n.hb-yg8-btn {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  flex: 0 0 auto;\n  height: 50px;\n  padding: 0 22px;\n  border: 0;\n  border-radius: 14px;\n  background: var(--hb-yg8-accent);\n  color: #1a1203;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 650;\n  cursor: pointer;\n  transition: filter 0.2s ease, transform 0.15s ease;\n}\n.hb-yg8-btn:hover:not(:disabled) { filter: brightness(1.08); }\n.hb-yg8-btn:active:not(:disabled) { transform: scale(0.98); }\n.hb-yg8-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-yg8-btn:disabled { cursor: progress; }\n.hb-yg8-spin {\n  width: 16px;\n  height: 16px;\n  border: 2px solid rgba(26, 18, 3, 0.25);\n  border-top-color: #1a1203;\n  border-radius: 50%;\n  animation: hb-yg8-spin 0.7s linear infinite;\n}\n.hb-yg8-done {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  margin-top: 18px;\n  padding: 16px 18px;\n  border: 1px solid color-mix(in srgb, var(--hb-yg8-accent) 35%, transparent);\n  border-radius: 14px;\n  background: color-mix(in srgb, var(--hb-yg8-accent) 8%, #0e0e0e);\n  animation: hb-yg8-in 0.5s ease both;\n  outline: none;\n}\n.hb-yg8-done strong { display: block; font-size: 15px; }\n.hb-yg8-done span { display: block; margin-top: 2px; color: #a1a1a1; font-size: 13.5px; }\n.hb-yg8-seat {\n  font-family: ui-monospace, \"Geist Mono\", Menlo, monospace;\n  color: var(--hb-yg8-accent);\n  font-size: 22px;\n  font-weight: 600;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yg8-digit, .hb-yg8-fill, .hb-yg8-cohort i, .hb-yg8-left b[data-bump], .hb-yg8-done { animation: none; }\n  .hb-yg8-fill, .hb-yg8-input, .hb-yg8-btn { transition: none; }\n}\n`;\n\nconst emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\n\nfunction pad(n: number) {\n  return String(Math.max(0, n)).padStart(2, \"0\");\n}\n\nfunction Digits({ value }: { value: string }) {\n  return (\n    <span className=\"hb-yg8-digits\" aria-hidden=\"true\">\n      {value.split(\"\").map((d, i) => (\n        <span key={`${i}-${d}`} className=\"hb-yg8-digit\">{d}</span>\n      ))}\n    </span>\n  );\n}\n\nexport function WaitlistCapacityCountdown({\n  cohort = \"Cohort 03 · Founding batch\",\n  title = \"Two weeks until doors open. 500 seats.\",\n  subtitle = \"Northstar onboards in small cohorts so every team gets a real setup call. When the bar fills, the next cohort opens in January.\",\n  launchAt,\n  initialSeconds = 13 * 86400 + 7 * 3600 + 42 * 60 + 18,\n  capacity = 500,\n  claimed = 412,\n  liveSignups = true,\n  ctaLabel = \"Reserve my seat\",\n  onSubmit,\n  accent = \"#fbbf24\",\n  className = \"\",\n  style,\n  ...rest\n}: WaitlistCapacityCountdownProps) {\n  const id = React.useId();\n  const [seconds, setSeconds] = React.useState(initialSeconds);\n  const [taken, setTaken] = React.useState(Math.min(claimed, capacity));\n  const [bump, setBump] = React.useState(0);\n  const [email, setEmail] = React.useState(\"\");\n  const [error, setError] = React.useState(\"\");\n  const [status, setStatus] = React.useState<\"idle\" | \"loading\" | \"done\">(\"idle\");\n  const [seat, setSeat] = React.useState(0);\n  const doneRef = React.useRef<HTMLDivElement>(null);\n\n  React.useEffect(() => {\n    const target = launchAt ? new Date(launchAt).getTime() : NaN;\n    const tick = () => {\n      if (!Number.isNaN(target)) setSeconds(Math.max(0, Math.floor((target - Date.now()) / 1000)));\n      else setSeconds((s) => Math.max(0, s - 1));\n    };\n    const first = window.setTimeout(tick, 0);\n    const t = window.setInterval(tick, 1000);\n    return () => {\n      window.clearTimeout(first);\n      window.clearInterval(t);\n    };\n  }, [launchAt]);\n\n  React.useEffect(() => {\n    if (!liveSignups) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const gaps = [4200, 6800, 3500, 9100, 5600];\n    let n = 0;\n    let t = 0;\n    const next = () => {\n      t = window.setTimeout(() => {\n        setTaken((v) => (v < capacity - 1 ? v + 1 : v));\n        setBump((b) => b + 1);\n        n += 1;\n        next();\n      }, gaps[n % gaps.length]);\n    };\n    next();\n    return () => window.clearTimeout(t);\n  }, [liveSignups, capacity]);\n\n  const days = Math.floor(seconds / 86400);\n  const hours = Math.floor((seconds % 86400) / 3600);\n  const minutes = Math.floor((seconds % 3600) / 60);\n  const secs = seconds % 60;\n  const left = Math.max(0, capacity - taken);\n  const pct = Math.min(100, (taken / capacity) * 100);\n  const full = left === 0;\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    const value = email.trim();\n    if (!emailRe.test(value)) {\n      setError(value ? \"That email does not look right.\" : \"Enter your email to reserve a seat.\");\n      return;\n    }\n    setError(\"\");\n    setStatus(\"loading\");\n    try {\n      await Promise.all([onSubmit?.({ email: value }), new Promise((r) => setTimeout(r, 900))]);\n      setSeat(taken + 1);\n      setTaken((v) => Math.min(capacity, v + 1));\n      setBump((b) => b + 1);\n      setStatus(\"done\");\n      requestAnimationFrame(() => doneRef.current?.focus());\n    } catch {\n      setStatus(\"idle\");\n      setError(\"Something went wrong. Please try again.\");\n    }\n  };\n\n  const units: [string, number][] = [[\"Days\", days], [\"Hours\", hours], [\"Minutes\", minutes], [\"Seconds\", secs]];\n\n  return (\n    <section className={`hb-yg8 ${className}`} style={{ \"--hb-yg8-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-waitlist-capacity-countdown\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yg8-bg\" aria-hidden=\"true\" />\n      <div className=\"hb-yg8-in\">\n        <div className=\"hb-yg8-head\">\n          <div>\n            <span className=\"hb-yg8-cohort\"><i aria-hidden=\"true\" />{cohort}</span>\n            <h2 className=\"hb-yg8-title\">{title}</h2>\n          </div>\n          <p className=\"hb-yg8-sub\">{subtitle}</p>\n        </div>\n        <div className=\"hb-yg8-panel\">\n          <div className=\"hb-yg8-clock\" role=\"timer\" aria-label={`${days} days, ${hours} hours, ${minutes} minutes until launch`}>\n            {units.map(([label, v]) => (\n              <div key={label} className=\"hb-yg8-unit\">\n                <Digits value={pad(v)} />\n                <span>{label}</span>\n              </div>\n            ))}\n          </div>\n          <div className=\"hb-yg8-cap\">\n            <div className=\"hb-yg8-cap-top\">\n              <strong>{taken.toLocaleString(\"en-US\")} of {capacity.toLocaleString(\"en-US\")} seats claimed</strong>\n              <span className=\"hb-yg8-left\" aria-live=\"polite\">\n                <b key={bump} data-bump={bump > 0 ? \"\" : undefined}>{left.toLocaleString(\"en-US\")}</b> {left === 1 ? \"spot\" : \"spots\"} left\n              </span>\n            </div>\n            <div className=\"hb-yg8-bar\" role=\"progressbar\" aria-valuemin={0} aria-valuemax={capacity} aria-valuenow={taken} aria-label=\"Seats claimed\">\n              <div className=\"hb-yg8-fill\" style={{ width: `${pct.toFixed(2)}%` }} />\n            </div>\n            <div className=\"hb-yg8-ticks\" aria-hidden=\"true\">\n              {[0, 25, 50, 75, 100].map((p) => (\n                <span key={p} style={{ left: `${p}%` }}>{Math.round((capacity * p) / 100)}</span>\n              ))}\n            </div>\n          </div>\n          {status === \"done\" ? (\n            <div ref={doneRef} className=\"hb-yg8-done\" role=\"status\" tabIndex={-1}>\n              <div>\n                <strong>Seat reserved</strong>\n                <span>Confirmation sent to {email.trim()}. See you on launch day.</span>\n              </div>\n              <span className=\"hb-yg8-seat\">#{String(seat).padStart(3, \"0\")}</span>\n            </div>\n          ) : (\n            <form className=\"hb-yg8-form\" onSubmit={submit} noValidate>\n              <div className=\"hb-yg8-field\">\n                <label htmlFor={`${id}-email`} className=\"hb-yg8-sr\">Email address</label>\n                <input\n                  id={`${id}-email`}\n                  className=\"hb-yg8-input\"\n                  type=\"email\"\n                  autoComplete=\"email\"\n                  placeholder=\"you@studio.com\"\n                  value={email}\n                  onChange={(e) => { setEmail(e.target.value); if (error) setError(\"\"); }}\n                  aria-invalid={error ? true : undefined}\n                  aria-describedby={`${id}-err`}\n                  disabled={status === \"loading\" || full}\n                />\n                <p id={`${id}-err`} className=\"hb-yg8-err\" role=\"alert\">{full ? \"This cohort is full. Join the next one.\" : error}</p>\n              </div>\n              <button type=\"submit\" className=\"hb-yg8-btn\" disabled={status === \"loading\" || full}>\n                {status === \"loading\" ? <><span className=\"hb-yg8-spin\" aria-hidden=\"true\" />Reserving</> : ctaLabel}\n              </button>\n            </form>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}