{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shop-product-detail",
  "type": "registry:component",
  "title": "Shop Product Detail",
  "description": "A product page section with a switchable gallery and hover zoom, rating, price with savings, color swatches, size chips, a quantity stepper and an add to bag button that morphs into a confirmation.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ecommerce",
    "ecommerce",
    "product",
    "gallery",
    "swatches",
    "add to cart",
    "shop"
  ],
  "docs": "https://hyperblur.dev/effects/shop-product-detail",
  "files": [
    {
      "path": "registry/hyperblur/shop-product-detail.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/shop-product-detail.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ProductColor {\n  name: string;\n  value: string;\n}\n\nexport interface ProductSize {\n  label: string;\n  available?: boolean;\n}\n\nexport interface ProductSelection {\n  color: string;\n  size: string;\n  quantity: number;\n}\n\nexport interface ShopProductDetailProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  name?: string;\n  badge?: string;\n  price?: number;\n  compareAtPrice?: number;\n  currency?: string;\n  rating?: number;\n  reviewCount?: number;\n  description?: string;\n  colors?: ProductColor[];\n  defaultColor?: string;\n  sizes?: ProductSize[];\n  defaultSize?: string;\n  maxQuantity?: number;\n  deliveryNotes?: string[];\n  addLabel?: string;\n  addedLabel?: string;\n  onAddToBag?: (selection: ProductSelection) => void;\n  accent?: string;\n}\n\nconst views = [\"Front\", \"Back\", \"Detail\", \"Flat lay\"] as const;\n\nconst css = `\n.hb-ki5 {\n  --hb-ki5-accent: #2f7bff;\n  --hb-ki5-c: #5b6b4a;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-ki5 *, .hb-ki5 *::before, .hb-ki5 *::after { box-sizing: border-box; }\n.hb-ki5-inner {\n  display: grid;\n  gap: 32px;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: clamp(40px, 6cqi, 96px) clamp(16px, 4cqi, 40px);\n}\n.hb-ki5-gallery { display: grid; gap: 12px; min-width: 0; }\n.hb-ki5-stage {\n  position: relative;\n  aspect-ratio: 1;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 22px;\n  overflow: hidden;\n  cursor: zoom-in;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);\n}\n.hb-ki5-photo {\n  position: absolute;\n  inset: 0;\n  display: grid;\n  place-items: center;\n  animation: hb-ki5-swap .55s cubic-bezier(.2,.7,.2,1) both;\n}\n.hb-ki5-zoomer {\n  width: 100%;\n  height: 100%;\n  display: grid;\n  place-items: center;\n  transform-origin: var(--hb-ki5-mx, 50%) var(--hb-ki5-my, 50%);\n  transition: transform .45s cubic-bezier(.2,.7,.2,1);\n}\n.hb-ki5-stage:hover .hb-ki5-zoomer { transform: scale(1.55); }\n.hb-ki5-svg { width: 78%; height: 78%; overflow: visible; filter: drop-shadow(0 30px 30px rgba(0,0,0,.35)); }\n.hb-ki5-cloth { fill: var(--hb-ki5-c); transition: fill .45s ease; }\n.hb-ki5-seam { fill: none; stroke: color-mix(in srgb, var(--hb-ki5-c) 55%, #000); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: stroke .45s ease; }\n.hb-ki5-pocket { fill: color-mix(in srgb, var(--hb-ki5-c) 88%, #000); stroke: color-mix(in srgb, var(--hb-ki5-c) 55%, #000); stroke-width: 1.2; transition: fill .45s ease; }\n.hb-ki5-btnc { fill: color-mix(in srgb, var(--hb-ki5-c) 40%, #f5efe0); }\n.hb-ki5-shade { fill: rgba(0,0,0,.16); }\n.hb-ki5-light { fill: rgba(255,255,255,.08); }\n.hb-ki5-tagl { fill: #f5efe0; }\n.hb-ki5-badges {\n  position: absolute;\n  left: 14px;\n  top: 14px;\n  display: flex;\n  gap: 6px;\n  pointer-events: none;\n}\n.hb-ki5-badge {\n  height: 26px;\n  padding: 0 11px;\n  border-radius: 999px;\n  background: rgba(10,10,10,.55);\n  backdrop-filter: blur(10px);\n  -webkit-backdrop-filter: blur(10px);\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);\n  color: #fff;\n  font-size: 12px;\n  font-weight: 600;\n  line-height: 26px;\n}\n.hb-ki5-viewname {\n  position: absolute;\n  right: 14px;\n  bottom: 14px;\n  color: rgba(255,255,255,.7);\n  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);\n  font-size: 11px;\n  letter-spacing: .06em;\n  text-transform: uppercase;\n  pointer-events: none;\n}\n.hb-ki5-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }\n.hb-ki5-thumb {\n  position: relative;\n  aspect-ratio: 1;\n  margin: 0;\n  padding: 0;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 14px;\n  overflow: hidden;\n  cursor: pointer;\n  opacity: .62;\n  transition: opacity .2s ease, border-color .2s ease, transform .2s ease;\n}\n.hb-ki5-thumb .hb-ki5-svg { width: 70%; height: 70%; filter: none; }\n.hb-ki5-thumb:hover { opacity: .9; }\n.hb-ki5-thumb[aria-pressed=\"true\"] { opacity: 1; border-color: var(--hb-ki5-accent); box-shadow: 0 0 0 1px var(--hb-ki5-accent); }\n.hb-ki5-thumb:focus-visible { outline: 2px solid var(--hb-ki5-accent); outline-offset: 2px; }\n.hb-ki5-info { display: flex; flex-direction: column; gap: 22px; min-width: 0; }\n.hb-ki5-brand {\n  margin: 0 0 8px;\n  color: #8f8f8f;\n  font-size: 13px;\n  font-weight: 500;\n  letter-spacing: .02em;\n}\n.hb-ki5-name {\n  margin: 0;\n  font-size: clamp(26px, 3.6cqi, 36px);\n  font-weight: 650;\n  line-height: 1.08;\n  letter-spacing: -.03em;\n  text-wrap: balance;\n}\n.hb-ki5-rate {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  margin-top: 12px;\n  color: #8f8f8f;\n  font-size: 13px;\n}\n.hb-ki5-stars { position: relative; display: inline-flex; color: #333; }\n.hb-ki5-stars svg { width: 15px; height: 15px; flex: none; }\n.hb-ki5-stars-fill { position: absolute; inset: 0; display: inline-flex; overflow: hidden; color: #fbbf24; }\n.hb-ki5-rate b { color: #ededed; font-weight: 600; }\n.hb-ki5-rate a { color: #8f8f8f; text-decoration: underline; text-decoration-color: rgba(255,255,255,.2); text-underline-offset: 3px; }\n.hb-ki5-rate a:hover { color: #ededed; }\n.hb-ki5-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }\n.hb-ki5-now { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }\n.hb-ki5-was { color: #6b6b6b; font-size: 16px; text-decoration: line-through; }\n.hb-ki5-save {\n  height: 22px;\n  padding: 0 8px;\n  border-radius: 6px;\n  background: color-mix(in srgb, #22c55e 14%, transparent);\n  color: #4ade80;\n  font-size: 12px;\n  font-weight: 600;\n  line-height: 22px;\n}\n.hb-ki5-desc { margin: 0; color: #a1a1a1; font-size: 14.5px; line-height: 1.6; }\n.hb-ki5-group { display: grid; gap: 10px; }\n.hb-ki5-label {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  font-size: 13px;\n  color: #8f8f8f;\n}\n.hb-ki5-label b { color: #ededed; font-weight: 500; }\n.hb-ki5-label a { color: #8f8f8f; font-size: 12.5px; }\n.hb-ki5-label a:hover { color: #ededed; }\n.hb-ki5-swatches { display: flex; flex-wrap: wrap; gap: 10px; }\n.hb-ki5-swatch {\n  width: 34px;\n  height: 34px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 0 0 3px #0a0a0a, 0 0 0 4px transparent;\n  cursor: pointer;\n  transition: box-shadow .2s ease, transform .2s cubic-bezier(.2,.7,.2,1);\n}\n.hb-ki5-swatch:hover { transform: scale(1.08); }\n.hb-ki5-swatch[aria-checked=\"true\"] { box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 0 0 3px #0a0a0a, 0 0 0 4.5px #ededed; }\n.hb-ki5-swatch:focus-visible { outline: 2px solid var(--hb-ki5-accent); outline-offset: 5px; }\n.hb-ki5-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }\n.hb-ki5-sizes[data-error=\"true\"] { animation: hb-ki5-shake .4s ease; }\n.hb-ki5-size {\n  position: relative;\n  height: 40px;\n  margin: 0;\n  border: 1px solid rgba(255,255,255,.1);\n  border-radius: 10px;\n  background: #111;\n  color: #ededed;\n  font: inherit;\n  font-size: 13.5px;\n  font-weight: 500;\n  cursor: pointer;\n  overflow: hidden;\n  transition: border-color .2s ease, background-color .2s ease, color .2s ease;\n}\n.hb-ki5-size:hover:not(:disabled) { border-color: rgba(255,255,255,.28); }\n.hb-ki5-size[aria-checked=\"true\"] { border-color: #ededed; background: #ededed; color: #0a0a0a; }\n.hb-ki5-size:disabled { color: #4a4a4a; cursor: not-allowed; background: #0d0d0d; }\n.hb-ki5-size:disabled::after {\n  content: \"\";\n  position: absolute;\n  left: -10%;\n  top: 50%;\n  width: 120%;\n  height: 1px;\n  background: #2a2a2a;\n  transform: rotate(-18deg);\n}\n.hb-ki5-size:focus-visible { outline: 2px solid var(--hb-ki5-accent); outline-offset: 2px; }\n.hb-ki5-error { margin: 0; color: #f87171; font-size: 12.5px; }\n.hb-ki5-buy { display: flex; gap: 10px; }\n.hb-ki5-qty {\n  display: inline-flex;\n  align-items: center;\n  flex: none;\n  height: 50px;\n  border: 1px solid rgba(255,255,255,.1);\n  border-radius: 14px;\n  background: #111;\n}\n.hb-ki5-qty button {\n  display: grid;\n  place-items: center;\n  width: 40px;\n  height: 100%;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  background: transparent;\n  color: #ededed;\n  cursor: pointer;\n  border-radius: 14px;\n}\n.hb-ki5-qty button:disabled { color: #4a4a4a; cursor: default; }\n.hb-ki5-qty button:focus-visible { outline: 2px solid var(--hb-ki5-accent); outline-offset: -4px; }\n.hb-ki5-qty svg { width: 14px; height: 14px; }\n.hb-ki5-qty output { min-width: 22px; text-align: center; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-ki5-add {\n  position: relative;\n  flex: 1;\n  height: 50px;\n  margin: 0;\n  border: 0;\n  border-radius: 14px;\n  background: var(--hb-ki5-accent);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 10px 30px -12px var(--hb-ki5-accent);\n  color: #fff;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  cursor: pointer;\n  overflow: hidden;\n  transition: background-color .4s ease, box-shadow .4s ease, transform .15s ease;\n}\n.hb-ki5-add:active { transform: scale(.985); }\n.hb-ki5-add:focus-visible { outline: 2px solid #ededed; outline-offset: 3px; }\n.hb-ki5-add[data-state=\"done\"] { background: #16a34a; box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 10px 30px -12px #16a34a; }\n.hb-ki5-add-row {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  gap: 10px;\n  transition: transform .45s cubic-bezier(.7,0,.2,1), opacity .3s ease;\n}\n.hb-ki5-add-row svg { width: 18px; height: 18px; }\n.hb-ki5-add-row[data-row=\"done\"] { transform: translateY(110%); opacity: 0; }\n.hb-ki5-add[data-state=\"done\"] .hb-ki5-add-row[data-row=\"idle\"] { transform: translateY(-110%); opacity: 0; }\n.hb-ki5-add[data-state=\"done\"] .hb-ki5-add-row[data-row=\"done\"] { transform: none; opacity: 1; }\n.hb-ki5-check { stroke-dasharray: 20; stroke-dashoffset: 20; }\n.hb-ki5-add[data-state=\"done\"] .hb-ki5-check { animation: hb-ki5-draw .45s .2s ease forwards; }\n.hb-ki5-spin {\n  width: 18px;\n  height: 18px;\n  border: 2px solid rgba(255,255,255,.35);\n  border-top-color: #fff;\n  border-radius: 50%;\n  animation: hb-ki5-rot .7s linear infinite;\n}\n.hb-ki5-delivery {\n  display: grid;\n  margin: 0;\n  padding: 4px 16px;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 16px;\n  background: linear-gradient(180deg, #121212, #0e0e0e);\n  list-style: none;\n}\n.hb-ki5-delivery li {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  padding: 12px 0;\n  color: #c9c9c9;\n  font-size: 13.5px;\n}\n.hb-ki5-delivery li + li { border-top: 1px solid rgba(255,255,255,.06); }\n.hb-ki5-delivery svg { width: 18px; height: 18px; flex: none; color: var(--hb-ki5-accent); }\n.hb-ki5-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@container (min-width: 820px) {\n  .hb-ki5-inner { grid-template-columns: 1.1fr 1fr; gap: clamp(32px, 5cqi, 64px); align-items: start; }\n  .hb-ki5-gallery { grid-template-columns: 76px 1fr; }\n  .hb-ki5-thumbs { grid-template-columns: 1fr; order: -1; align-content: start; }\n}\n@keyframes hb-ki5-swap {\n  from { opacity: 0; transform: scale(1.04); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ki5-shake {\n  0%, 100% { transform: none; }\n  25% { transform: translateX(-6px); }\n  50% { transform: translateX(5px); }\n  75% { transform: translateX(-3px); }\n}\n@keyframes hb-ki5-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-ki5-rot { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-ki5-photo, .hb-ki5-sizes[data-error=\"true\"], .hb-ki5-spin { animation: none; }\n  .hb-ki5-add[data-state=\"done\"] .hb-ki5-check { animation: none; stroke-dashoffset: 0; }\n  .hb-ki5-zoomer, .hb-ki5-cloth, .hb-ki5-seam, .hb-ki5-pocket, .hb-ki5-swatch, .hb-ki5-size, .hb-ki5-thumb, .hb-ki5-add, .hb-ki5-add-row { transition: none; }\n  .hb-ki5-stage:hover .hb-ki5-zoomer { transform: none; }\n}\n`;\n\nfunction backdrop(view: number) {\n  const sets = [\n    \"radial-gradient(70% 60% at 50% 40%, color-mix(in srgb, var(--hb-ki5-c) 30%, #2a2a2a) 0%, transparent 70%), linear-gradient(160deg, #1d1d1f, #121214)\",\n    \"radial-gradient(60% 50% at 30% 20%, rgba(255,255,255,.12), transparent 60%), linear-gradient(200deg, color-mix(in srgb, var(--hb-ki5-c) 25%, #1a1a1a), #101010)\",\n    \"radial-gradient(90% 80% at 70% 30%, color-mix(in srgb, var(--hb-ki5-c) 45%, #222) 0%, transparent 70%), #141414\",\n    \"linear-gradient(135deg, #e7dfcf 0%, #cfc4ad 100%)\",\n  ];\n  return sets[view] ?? sets[0];\n}\n\nfunction Garment({ view }: { view: number }) {\n  const body = \"M70 40 L52 47 L30 62 L17 122 L36 127 L47 86 L49 172 L151 172 L153 86 L164 127 L183 122 L170 62 L148 47 L130 40 Q100 58 70 40 Z\";\n  const transform =\n    view === 2 ? \"translate(100 100) scale(2.4) translate(-73 -103)\" : view === 3 ? \"translate(100 100) rotate(-14) scale(.9) translate(-100 -106)\" : undefined;\n  return (\n    <svg className=\"hb-ki5-svg\" viewBox=\"0 0 200 200\" aria-hidden=\"true\">\n      <g transform={transform}>\n        {view === 3 && <path d={body} transform=\"translate(5 7)\" fill=\"rgba(60,40,20,.25)\" />}\n        <path className=\"hb-ki5-cloth\" d={body} />\n        <path className=\"hb-ki5-shade\" d=\"M100 56 L130 40 L148 47 L170 62 L183 122 L164 127 L153 86 L151 172 L118 172 Z\" />\n        <path className=\"hb-ki5-light\" d=\"M70 40 L52 47 L30 62 L22 98 L44 70 Z\" />\n        <path className=\"hb-ki5-seam\" d=\"M47 86 L49 60 M153 86 L151 60 M36 127 L38 118 L19 113 M164 127 L162 118 L181 113\" />\n        {view === 1 ? (\n          <>\n            <path className=\"hb-ki5-seam\" d=\"M52 62 Q100 76 148 62\" />\n            <path className=\"hb-ki5-seam\" d=\"M100 70 L100 82\" />\n            <rect className=\"hb-ki5-tagl\" x=\"93\" y=\"45\" width=\"14\" height=\"6\" rx=\"1\" />\n          </>\n        ) : (\n          <>\n            <path className=\"hb-ki5-seam\" d=\"M70 40 L86 64 L100 52 L114 64 L130 40\" />\n            <path className=\"hb-ki5-seam\" d=\"M100 52 L100 172 M106 56 L106 172\" />\n            <path className=\"hb-ki5-pocket\" d=\"M60 92 h26 v22 q-13 5 -26 0 Z\" />\n            <path className=\"hb-ki5-pocket\" d=\"M114 92 h26 v22 q-13 5 -26 0 Z\" />\n            <path className=\"hb-ki5-seam\" d=\"M60 98 h26 M114 98 h26\" />\n            {[74, 98, 122, 146].map((y) => (\n              <circle key={y} className=\"hb-ki5-btnc\" cx=\"103\" cy={y} r=\"2.6\" />\n            ))}\n            <circle className=\"hb-ki5-btnc\" cx=\"73\" cy=\"95\" r=\"1.8\" />\n            <circle className=\"hb-ki5-btnc\" cx=\"127\" cy=\"95\" r=\"1.8\" />\n          </>\n        )}\n      </g>\n    </svg>\n  );\n}\n\nfunction Star() {\n  return (\n    <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\">\n      <path d=\"M10 1.6l2.5 5.3 5.8.7-4.3 4 1.1 5.7L10 14.5l-5.1 2.8L6 11.6l-4.3-4 5.8-.7L10 1.6z\" />\n    </svg>\n  );\n}\n\nfunction money(value: number, currency: string) {\n  const [whole, cents] = value.toFixed(2).split(\".\");\n  const grouped = whole.replace(/\\B(?=(\\d{3})+$)/g, \",\");\n  return cents === \"00\" ? `${currency}${grouped}` : `${currency}${grouped}.${cents}`;\n}\n\nconst deliveryIcons = [\n  \"M2 6h11v9H2zM13 9h4l3 3v3h-7M5.5 18a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM16.5 18a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z\",\n  \"M4 9a7 7 0 1 1 1.6 5.4M4 4v5h5\",\n  \"M5 19c0-8 5-13 14-14-1 9-6 14-14 14zM5 19l7-7\",\n];\n\nexport function ShopProductDetail({\n  brand = \"Northwind Supply Co.\",\n  name = \"Ridgeline Wool Overshirt\",\n  badge = \"New season\",\n  price = 168,\n  compareAtPrice = 210,\n  currency = \"$\",\n  rating = 4.8,\n  reviewCount = 2146,\n  description = \"Brushed recycled wool with a cotton twill lining, corozo buttons and two bellowed chest pockets. Cut roomy to layer over a knit.\",\n  colors = [\n    { name: \"Moss\", value: \"#5b6b4a\" },\n    { name: \"Ink\", value: \"#2b3247\" },\n    { name: \"Clay\", value: \"#a85d43\" },\n    { name: \"Oat\", value: \"#cdbf9f\" },\n  ],\n  defaultColor,\n  sizes = [\n    { label: \"XS\" },\n    { label: \"S\" },\n    { label: \"M\" },\n    { label: \"L\" },\n    { label: \"XL\" },\n    { label: \"XXL\", available: false },\n  ],\n  defaultSize = \"M\",\n  maxQuantity = 10,\n  deliveryNotes = [\"Free delivery by Thursday, Nov 6\", \"Free 30-day returns and exchanges\", \"Carbon neutral shipping from Portland, OR\"],\n  addLabel = \"Add to bag\",\n  addedLabel = \"Added to bag\",\n  onAddToBag,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: ShopProductDetailProps) {\n  const [view, setView] = React.useState(0);\n  const [color, setColor] = React.useState(defaultColor ?? colors[0]?.name ?? \"\");\n  const [size, setSize] = React.useState<string | null>(defaultSize ?? null);\n  const [qty, setQty] = React.useState(1);\n  const [status, setStatus] = React.useState<\"idle\" | \"loading\" | \"done\">(\"idle\");\n  const [error, setError] = React.useState(0);\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  const zoomRef = React.useRef<HTMLDivElement>(null);\n  const uid = React.useId();\n  const colorLabel = `${uid}-color`;\n  const sizeLabel = `${uid}-size`;\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach(clearTimeout);\n  }, []);\n\n  const current = colors.find((item) => item.name === color) ?? colors[0];\n  const filled = Math.max(0, Math.min(5, rating)) / 5;\n  const save = compareAtPrice && compareAtPrice > price ? Math.round((1 - price / compareAtPrice) * 100) : 0;\n\n  const add = () => {\n    if (status !== \"idle\") return;\n    if (!size) {\n      setError((n) => n + 1);\n      return;\n    }\n    setStatus(\"loading\");\n    timers.current.push(\n      setTimeout(() => {\n        setStatus(\"done\");\n        onAddToBag?.({ color, size, quantity: qty });\n      }, 650),\n      setTimeout(() => setStatus(\"idle\"), 2600),\n    );\n  };\n\n  const onMove = (event: React.PointerEvent<HTMLDivElement>) => {\n    const node = zoomRef.current;\n    if (!node) return;\n    const rect = event.currentTarget.getBoundingClientRect();\n    node.style.setProperty(\"--hb-ki5-mx\", `${(((event.clientX - rect.left) / rect.width) * 100).toFixed(1)}%`);\n    node.style.setProperty(\"--hb-ki5-my\", `${(((event.clientY - rect.top) / rect.height) * 100).toFixed(1)}%`);\n  };\n\n  const radioKeys = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    const keys = [\"ArrowRight\", \"ArrowDown\", \"ArrowLeft\", \"ArrowUp\"];\n    if (!keys.includes(event.key)) return;\n    const buttons = Array.from(event.currentTarget.querySelectorAll<HTMLButtonElement>(\"button:not(:disabled)\"));\n    const index = buttons.indexOf(document.activeElement as HTMLButtonElement);\n    if (index < 0) return;\n    event.preventDefault();\n    const step = event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? 1 : -1;\n    const next = buttons[(index + step + buttons.length) % buttons.length];\n    next.focus();\n    next.click();\n  };\n\n  return (\n    <section\n      className={className ? `hb-ki5 ${className}` : \"hb-ki5\"}\n      style={{ \"--hb-ki5-accent\": accent, \"--hb-ki5-c\": current?.value ?? \"#5b6b4a\", ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-shop-product-detail\" precedence=\"default\">{css}</style>\n      <div className=\"hb-ki5-inner\">\n        <div className=\"hb-ki5-gallery\">\n          <div className=\"hb-ki5-stage\" onPointerMove={onMove}>\n            <div className=\"hb-ki5-photo\" key={view} style={{ background: backdrop(view) }}>\n              <div className=\"hb-ki5-zoomer\" ref={zoomRef}>\n                <Garment view={view} />\n              </div>\n            </div>\n            {badge && (\n              <div className=\"hb-ki5-badges\">\n                <span className=\"hb-ki5-badge\">{badge}</span>\n              </div>\n            )}\n            <span className=\"hb-ki5-viewname\">\n              {views[view]} · {view + 1}/{views.length}\n            </span>\n          </div>\n          <div className=\"hb-ki5-thumbs\" role=\"group\" aria-label=\"Product photos\">\n            {views.map((label, i) => (\n              <button\n                key={label}\n                type=\"button\"\n                className=\"hb-ki5-thumb\"\n                aria-pressed={view === i}\n                aria-label={`Show ${label.toLowerCase()} photo`}\n                onClick={() => setView(i)}\n                style={{ background: backdrop(i) }}\n              >\n                <Garment view={i} />\n              </button>\n            ))}\n          </div>\n        </div>\n        <div className=\"hb-ki5-info\">\n          <div>\n            <p className=\"hb-ki5-brand\">{brand}</p>\n            <h2 className=\"hb-ki5-name\">{name}</h2>\n            <div className=\"hb-ki5-rate\">\n              <span className=\"hb-ki5-stars\" aria-hidden=\"true\">\n                <Star /><Star /><Star /><Star /><Star />\n                <span className=\"hb-ki5-stars-fill\" style={{ width: `${(filled * 100).toFixed(1)}%` }}>\n                  <Star /><Star /><Star /><Star /><Star />\n                </span>\n              </span>\n              <span className=\"hb-ki5-sr\">Rated {rating} out of 5.</span>\n              <b>{rating.toFixed(1)}</b>\n              <a href=\"#reviews\">{reviewCount.toLocaleString(\"en-US\")} reviews</a>\n            </div>\n          </div>\n          <div className=\"hb-ki5-price\">\n            <span className=\"hb-ki5-now\">{money(price, currency)}</span>\n            {save > 0 && compareAtPrice && (\n              <>\n                <span className=\"hb-ki5-was\">{money(compareAtPrice, currency)}</span>\n                <span className=\"hb-ki5-save\">Save {save}%</span>\n              </>\n            )}\n          </div>\n          {description && <p className=\"hb-ki5-desc\">{description}</p>}\n          <div className=\"hb-ki5-group\">\n            <span className=\"hb-ki5-label\" id={colorLabel}>\n              <span>\n                Color <b>{color}</b>\n              </span>\n            </span>\n            <div className=\"hb-ki5-swatches\" role=\"radiogroup\" aria-labelledby={colorLabel} onKeyDown={radioKeys}>\n              {colors.map((item) => (\n                <button\n                  key={item.name}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={item.name === color}\n                  aria-label={item.name}\n                  tabIndex={item.name === color ? 0 : -1}\n                  className=\"hb-ki5-swatch\"\n                  style={{ background: item.value }}\n                  onClick={() => setColor(item.name)}\n                />\n              ))}\n            </div>\n          </div>\n          <div className=\"hb-ki5-group\">\n            <span className=\"hb-ki5-label\" id={sizeLabel}>\n              <span>\n                Size {size && <b>{size}</b>}\n              </span>\n              <a href=\"#size-guide\">Size guide</a>\n            </span>\n            <div\n              className=\"hb-ki5-sizes\"\n              role=\"radiogroup\"\n              aria-labelledby={sizeLabel}\n              data-error={error > 0 && !size}\n              key={error}\n              onKeyDown={radioKeys}\n            >\n              {sizes.map((item) => {\n                const checked = item.label === size;\n                const disabled = item.available === false;\n                const focusable = checked || (!size && item === sizes.find((s) => s.available !== false));\n                return (\n                  <button\n                    key={item.label}\n                    type=\"button\"\n                    role=\"radio\"\n                    aria-checked={checked}\n                    disabled={disabled}\n                    tabIndex={focusable ? 0 : -1}\n                    className=\"hb-ki5-size\"\n                    aria-label={disabled ? `${item.label}, sold out` : item.label}\n                    onClick={() => setSize(item.label)}\n                  >\n                    {item.label}\n                  </button>\n                );\n              })}\n            </div>\n            {error > 0 && !size && <p className=\"hb-ki5-error\" role=\"alert\">Choose a size first.</p>}\n          </div>\n          <div className=\"hb-ki5-buy\">\n            <div className=\"hb-ki5-qty\" role=\"group\" aria-label=\"Quantity\">\n              <button type=\"button\" aria-label=\"Decrease quantity\" disabled={qty <= 1} onClick={() => setQty((q) => Math.max(1, q - 1))}>\n                <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M3 7h8\" /></svg>\n              </button>\n              <output aria-live=\"polite\">{qty}</output>\n              <button type=\"button\" aria-label=\"Increase quantity\" disabled={qty >= maxQuantity} onClick={() => setQty((q) => Math.min(maxQuantity, q + 1))}>\n                <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M3 7h8M7 3v8\" /></svg>\n              </button>\n            </div>\n            <button type=\"button\" className=\"hb-ki5-add\" data-state={status} onClick={add}>\n              <span className=\"hb-ki5-add-row\" data-row=\"idle\">\n                {status === \"loading\" ? (\n                  <span className=\"hb-ki5-spin\" aria-hidden=\"true\" />\n                ) : (\n                  <>\n                    <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                      <path d=\"M4 6h12l-1 11H5L4 6zM7.5 6V5a2.5 2.5 0 0 1 5 0v1\" />\n                    </svg>\n                    {addLabel} · {money(price * qty, currency)}\n                  </>\n                )}\n              </span>\n              <span className=\"hb-ki5-add-row\" data-row=\"done\" aria-hidden={status !== \"done\"}>\n                <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path className=\"hb-ki5-check\" d=\"M4.5 10.5l3.5 3.5 7.5-8\" />\n                </svg>\n                {addedLabel}\n              </span>\n            </button>\n          </div>\n          <span className=\"hb-ki5-sr\" aria-live=\"polite\">\n            {status === \"loading\" ? \"Adding to bag\" : status === \"done\" ? addedLabel : \"\"}\n          </span>\n          {deliveryNotes.length > 0 && (\n            <ul className=\"hb-ki5-delivery\">\n              {deliveryNotes.map((note, i) => (\n                <li key={note}>\n                  <svg viewBox=\"0 0 22 22\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d={deliveryIcons[i % deliveryIcons.length]} />\n                  </svg>\n                  {note}\n                </li>\n              ))}\n            </ul>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}