{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-card-preview",
  "type": "registry:component",
  "title": "Pay Card Preview",
  "description": "A payment card that shows live number, name and expiry, and flips in 3D to the back when the CVC field is focused.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "card",
    "payment",
    "credit card",
    "flip",
    "checkout",
    "3d"
  ],
  "docs": "https://hyperblur.dev/effects/pay-card-preview",
  "files": [
    {
      "path": "registry/hyperblur/pay-card-preview.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-card-preview.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PayCardTheme = \"midnight\" | \"aurora\" | \"ember\" | \"graphite\" | \"lagoon\";\nexport type PayCardField = \"number\" | \"name\" | \"expiry\" | \"cvc\";\nexport type PayCardNetwork = \"none\" | \"twin\" | \"tri\" | \"arc\";\n\nexport interface PayCardPreviewProps extends React.HTMLAttributes<HTMLDivElement> {\n  number?: string;\n  name?: string;\n  expiry?: string;\n  cvc?: string;\n  focusField?: PayCardField | null;\n  flipped?: boolean;\n  theme?: PayCardTheme;\n  network?: PayCardNetwork;\n  bank?: string;\n}\n\nconst css = `\n.hb-qf1 {\n  box-sizing: border-box;\n  container-type: inline-size;\n  width: 100%;\n  max-width: 420px;\n  font-family: inherit;\n  perspective: 1200px;\n}\n.hb-qf1 *, .hb-qf1 *::before, .hb-qf1 *::after { box-sizing: border-box; }\n.hb-qf1-sway {\n  transform-style: preserve-3d;\n  animation: hb-qf1-sway 8s ease-in-out infinite;\n}\n.hb-qf1-card {\n  position: relative;\n  width: 100%;\n  aspect-ratio: 1.586;\n  transform-style: preserve-3d;\n  transition: transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-qf1[data-flipped=\"true\"] .hb-qf1-card { transform: rotateY(180deg); }\n.hb-qf1-face {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  color: #fff;\n  border-radius: 5.2cqw;\n  background:\n    radial-gradient(120% 90% at 0% 0%, var(--hb-qf1-a), transparent 62%),\n    linear-gradient(135deg, var(--hb-qf1-b), var(--hb-qf1-c));\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 3cqw 7cqw -2cqw rgba(0, 0, 0, 0.65);\n  backface-visibility: hidden;\n  -webkit-backface-visibility: hidden;\n}\n.hb-qf1[data-theme=\"midnight\"] { --hb-qf1-a: #3b6dff; --hb-qf1-b: #14214f; --hb-qf1-c: #070b1c; }\n.hb-qf1[data-theme=\"aurora\"] { --hb-qf1-a: #2dd4a8; --hb-qf1-b: #3b2f8f; --hb-qf1-c: #0e0a2a; }\n.hb-qf1[data-theme=\"ember\"] { --hb-qf1-a: #ff8a4c; --hb-qf1-b: #8a1f3d; --hb-qf1-c: #1c0810; }\n.hb-qf1[data-theme=\"graphite\"] { --hb-qf1-a: #8a8f9c; --hb-qf1-b: #2b2e36; --hb-qf1-c: #0d0e12; }\n.hb-qf1[data-theme=\"lagoon\"] { --hb-qf1-a: #35d0ff; --hb-qf1-b: #0b5d8a; --hb-qf1-c: #04202e; }\n.hb-qf1-face::after {\n  content: \"\";\n  position: absolute;\n  inset: -20%;\n  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.14) 50%, transparent 60%);\n  transform: translateX(-60%);\n  animation: hb-qf1-sheen 6s ease-in-out infinite;\n  pointer-events: none;\n}\n.hb-qf1-front {\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  padding: 6.4cqw 7cqw 6cqw;\n}\n.hb-qf1-top {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n.hb-qf1-bank {\n  font-size: 4.2cqw;\n  font-weight: 700;\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  opacity: 0.92;\n}\n.hb-qf1-nfc { width: 6.4cqw; height: 6.4cqw; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; opacity: 0.85; }\n.hb-qf1-chip {\n  position: relative;\n  width: 12.6cqw;\n  height: 9.6cqw;\n  overflow: hidden;\n  border-radius: 1.8cqw;\n  background: linear-gradient(135deg, #f5dc9a, #c8a24e 55%, #efd58f);\n  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;\n}\n.hb-qf1-chip::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background:\n    linear-gradient(90deg, transparent 32%, rgba(80, 55, 10, 0.5) 32% 34%, transparent 34% 66%, rgba(80, 55, 10, 0.5) 66% 68%, transparent 68%),\n    linear-gradient(0deg, transparent 46%, rgba(80, 55, 10, 0.5) 46% 54%, transparent 54%);\n}\n.hb-qf1-mid { display: flex; align-items: center; justify-content: space-between; }\n.hb-qf1-f {\n  min-width: 0;\n  margin: -1cqw -1.4cqw;\n  padding: 1cqw 1.4cqw;\n  border-radius: 1.6cqw;\n  transition: background-color 0.3s ease, box-shadow 0.3s ease;\n}\n.hb-qf1-f[data-active=\"true\"] {\n  background: rgba(255, 255, 255, 0.14);\n  box-shadow: 0 0 0 0.45cqw rgba(255, 255, 255, 0.6);\n}\n.hb-qf1-f[data-empty=\"true\"] .hb-qf1-v, .hb-qf1-f[data-empty=\"true\"] .hb-qf1-num { opacity: 0.45; }\n.hb-qf1-num {\n  display: flex;\n  gap: 3.4cqw;\n  font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n  font-size: 6.2cqw;\n  font-weight: 500;\n  letter-spacing: 0.04em;\n  line-height: 1.1;\n  font-variant-numeric: tabular-nums;\n  text-shadow: 0 0.3cqw 0.8cqw rgba(0, 0, 0, 0.35);\n  transition: opacity 0.3s ease;\n}\n.hb-qf1-bot { display: flex; align-items: flex-end; justify-content: space-between; gap: 3cqw; }\n.hb-qf1-meta { display: flex; min-width: 0; flex: 1; align-items: flex-end; gap: 5cqw; }\n.hb-qf1-lab {\n  display: block;\n  margin-bottom: 0.6cqw;\n  font-size: 2.5cqw;\n  letter-spacing: 0.12em;\n  text-transform: uppercase;\n  opacity: 0.6;\n}\n.hb-qf1-v {\n  display: block;\n  overflow: hidden;\n  font-size: 4cqw;\n  font-weight: 500;\n  letter-spacing: 0.08em;\n  line-height: 1.2;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n  text-transform: uppercase;\n  transition: opacity 0.3s ease;\n}\n.hb-qf1-net { width: 14cqw; height: 9.6cqw; flex: none; }\n.hb-qf1-back { transform: rotateY(180deg); }\n.hb-qf1-stripe { position: absolute; left: 0; right: 0; top: 10cqw; height: 14cqw; background: #08080a; }\n.hb-qf1-sign {\n  position: absolute;\n  left: 7cqw;\n  right: 7cqw;\n  top: 31cqw;\n  display: flex;\n  align-items: center;\n  height: 10cqw;\n  overflow: hidden;\n  background: repeating-linear-gradient(135deg, #f1efe8 0 1.4cqw, #dcd9cf 1.4cqw 2.8cqw);\n  border-radius: 1.2cqw;\n}\n.hb-qf1-sign .hb-qf1-f { margin: 0 0 0 auto; padding: 1cqw 2.4cqw; border-radius: 0; background: #fff; box-shadow: none; }\n.hb-qf1-sign .hb-qf1-f[data-active=\"true\"] { box-shadow: 0 0 0 0.6cqw var(--hb-qf1-a) inset; }\n.hb-qf1-cvc {\n  display: block;\n  min-width: 11cqw;\n  color: #14151a;\n  font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n  font-size: 5cqw;\n    font-weight: 600;\n  letter-spacing: 0.1em;\n  text-align: right;\n}\n.hb-qf1-fine {\n  position: absolute;\n  left: 7cqw;\n  right: 7cqw;\n  bottom: 6cqw;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  font-size: 2.6cqw;\n  letter-spacing: 0.1em;\n  text-transform: uppercase;\n  opacity: 0.6;\n}\n@keyframes hb-qf1-sway {\n  0%, 100% { transform: rotateX(2deg) rotateY(-4deg); }\n  50% { transform: rotateX(-2deg) rotateY(4deg); }\n}\n@keyframes hb-qf1-sheen {\n  0%, 55% { transform: translateX(-60%); }\n  85%, 100% { transform: translateX(60%); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qf1-sway, .hb-qf1-face::after { animation: none; }\n  .hb-qf1-card { transition: none; }\n}\n`;\n\nfunction groupDigits(raw: string) {\n  const digits = raw.replace(/\\D/g, \"\").slice(0, 19);\n  const len = Math.max(16, digits.length);\n  const chars = digits.padEnd(len, \"•\").split(\"\");\n  const out: string[] = [];\n  for (let i = 0; i < len; i += 4) out.push(chars.slice(i, i + 4).join(\"\"));\n  return out;\n}\n\nfunction mergeExpiry(raw: string) {\n  const digits = raw.replace(/\\D/g, \"\").slice(0, 4);\n  const slots = \"MM/YY\".split(\"\");\n  const at = [0, 1, 3, 4];\n  for (let i = 0; i < digits.length; i += 1) slots[at[i]] = digits[i];\n  return slots.join(\"\");\n}\n\nfunction NetworkMark({ kind }: { kind: PayCardNetwork }) {\n  if (kind === \"none\") return null;\n  return (\n    <svg className=\"hb-qf1-net\" viewBox=\"0 0 56 38\" aria-hidden=\"true\">\n      {kind === \"twin\" && (\n        <>\n          <circle cx=\"20\" cy=\"19\" r=\"14\" fill=\"#fff\" fillOpacity=\"0.7\" />\n          <circle cx=\"36\" cy=\"19\" r=\"14\" fill=\"#fff\" fillOpacity=\"0.38\" />\n        </>\n      )}\n      {kind === \"tri\" && (\n        <>\n          <path d=\"M6 33 L16 5 H24 L14 33 Z\" fill=\"#fff\" fillOpacity=\"0.4\" />\n          <path d=\"M20 33 L30 5 H38 L28 33 Z\" fill=\"#fff\" fillOpacity=\"0.62\" />\n          <path d=\"M34 33 L44 5 H52 L42 33 Z\" fill=\"#fff\" fillOpacity=\"0.85\" />\n        </>\n      )}\n      {kind === \"arc\" && (\n        <>\n          <path d=\"M8 31 A22 22 0 0 1 48 31\" fill=\"none\" stroke=\"#fff\" strokeOpacity=\"0.45\" strokeWidth=\"5\" strokeLinecap=\"round\" />\n          <path d=\"M16 31 A14 14 0 0 1 40 31\" fill=\"none\" stroke=\"#fff\" strokeOpacity=\"0.85\" strokeWidth=\"5\" strokeLinecap=\"round\" />\n        </>\n      )}\n    </svg>\n  );\n}\n\nexport function PayCardPreview({\n  number = \"\",\n  name = \"\",\n  expiry = \"\",\n  cvc = \"\",\n  focusField = null,\n  flipped,\n  theme = \"midnight\",\n  network = \"arc\",\n  bank = \"Northvale\",\n  className = \"\",\n  style,\n  ...rest\n}: PayCardPreviewProps) {\n  const isBack = flipped ?? focusField === \"cvc\";\n  const digits = number.replace(/\\D/g, \"\");\n  const groups = groupDigits(number);\n  const shownName = name.trim().slice(0, 26);\n  const cvcText = cvc.replace(/\\D/g, \"\").slice(0, 4);\n  const summary = `Payment card ${digits.length >= 4 ? `ending ${digits.slice(-4)}` : \"preview\"}`;\n\n  return (\n    <div\n      role=\"img\"\n      aria-label={summary}\n      className={`hb-qf1 ${className}`}\n      style={style}\n      data-theme={theme}\n      data-flipped={isBack}\n      {...rest}\n    >\n      <style href=\"hb-pay-card-preview\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qf1-sway\">\n        <div className=\"hb-qf1-card\">\n          <div className=\"hb-qf1-face hb-qf1-front\">\n            <div className=\"hb-qf1-top\">\n              <span className=\"hb-qf1-bank\">{bank}</span>\n              <svg className=\"hb-qf1-nfc\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                <path d=\"M6 9.5a4 4 0 0 1 0 5M9.5 7a8 8 0 0 1 0 10M13 4.5a12 12 0 0 1 0 15M16.5 2a16 16 0 0 1 0 20\" />\n              </svg>\n            </div>\n            <div className=\"hb-qf1-mid\">\n              <span className=\"hb-qf1-chip\" />\n            </div>\n            <div className=\"hb-qf1-f\" data-active={focusField === \"number\"} data-empty={digits.length === 0}>\n              <div className=\"hb-qf1-num\">\n                {groups.map((g, i) => (\n                  <span key={i}>{g}</span>\n                ))}\n              </div>\n            </div>\n            <div className=\"hb-qf1-bot\">\n              <div className=\"hb-qf1-meta\">\n                <div className=\"hb-qf1-f\" data-active={focusField === \"name\"} data-empty={shownName.length === 0} style={{ flex: 1 }}>\n                  <span className=\"hb-qf1-lab\">Card holder</span>\n                  <span className=\"hb-qf1-v\">{shownName || \"Full name\"}</span>\n                </div>\n                <div className=\"hb-qf1-f\" data-active={focusField === \"expiry\"} data-empty={expiry.replace(/\\D/g, \"\").length === 0}>\n                  <span className=\"hb-qf1-lab\">Expires</span>\n                  <span className=\"hb-qf1-v\">{mergeExpiry(expiry)}</span>\n                </div>\n              </div>\n              <NetworkMark kind={network} />\n            </div>\n          </div>\n          <div className=\"hb-qf1-face hb-qf1-back\">\n            <div className=\"hb-qf1-stripe\" />\n            <div className=\"hb-qf1-sign\">\n              <div className=\"hb-qf1-f\" data-active={focusField === \"cvc\"}>\n                <span className=\"hb-qf1-cvc\">{cvcText || \"•••\"}</span>\n              </div>\n            </div>\n            <div className=\"hb-qf1-fine\">\n              <span>{bank}</span>\n              <span>Security code</span>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}