{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-safety-cover",
  "type": "registry:component",
  "title": "Button Safety Cover",
  "description": "A red button sealed under a hazard-striped glass cover. The first press flips the cover up on its hinge, the second press within the time window confirms.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "double click",
    "confirm",
    "hazard",
    "3d",
    "destructive"
  ],
  "docs": "https://hyperblur.dev/effects/button-safety-cover",
  "files": [
    {
      "path": "registry/hyperblur/button-safety-cover.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-safety-cover.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSafetyCoverProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"onClick\" | \"color\"> {\n  children?: React.ReactNode;\n  armedLabel?: React.ReactNode;\n  doneLabel?: React.ReactNode;\n  armTimeout?: number;\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  resetAfter?: number;\n  onArm?: () => void;\n  onConfirm?: () => void;\n}\n\nconst css = `\n.hb-xd4 {\n  --hb-xd4-h: 2.75rem;\n  --hb-xd4-fs: 0.875rem;\n  position: relative;\n  display: inline-flex;\n  flex-direction: column;\n  box-sizing: border-box;\n  font-family: inherit;\n  font-size: var(--hb-xd4-fs);\n  perspective: 520px;\n  perspective-origin: 50% 0%;\n}\n.hb-xd4 *, .hb-xd4 *::before, .hb-xd4 *::after { box-sizing: border-box; }\n.hb-xd4[data-size=\"sm\"] { --hb-xd4-h: 2.25rem; --hb-xd4-fs: 0.8125rem; }\n.hb-xd4[data-size=\"lg\"] { --hb-xd4-h: 3.25rem; --hb-xd4-fs: 1rem; }\n.hb-xd4-well {\n  position: relative;\n  padding: 4px;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #0b0b0b, #151515);\n  box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.05);\n}\n.hb-xd4-btn {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: 100%;\n  height: var(--hb-xd4-h);\n  margin: 0;\n  padding: 0 1.5em;\n  font: inherit;\n  font-weight: 700;\n  letter-spacing: 0.01em;\n  color: #fff;\n  white-space: nowrap;\n  border: 0;\n  border-radius: 10px;\n  background:\n    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.28), rgba(255,255,255,0) 55%),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-xd4-c) 92%, #fff), color-mix(in srgb, var(--hb-xd4-c) 80%, #000));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -3px 0 rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.5);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: transform 0.15s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.15s ease, filter 0.3s ease;\n}\n.hb-xd4[data-phase=\"armed\"] .hb-xd4-btn { animation: hb-xd4-glow 1.1s ease-in-out infinite; }\n.hb-xd4-btn:active:not(:disabled) { transform: translateY(1.5px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), inset 0 -1px 0 rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.5); }\n.hb-xd4-btn:focus-visible { outline: none; }\n.hb-xd4-well:has(.hb-xd4-btn:focus-visible) { outline: 2px solid color-mix(in srgb, var(--hb-xd4-c) 70%, #fff); outline-offset: 3px; }\n.hb-xd4-btn:disabled { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }\n.hb-xd4[data-phase=\"done\"] .hb-xd4-btn { filter: saturate(0.6) brightness(0.8); }\n.hb-xd4-lbl {\n  grid-area: 1 / 1;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.5em;\n  text-shadow: 0 1px 0 rgba(0,0,0,0.3);\n  opacity: 0;\n  transform: scale(0.92);\n  transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);\n}\n.hb-xd4[data-phase=\"idle\"] .hb-xd4-l1, .hb-xd4[data-phase=\"armed\"] .hb-xd4-l2, .hb-xd4[data-phase=\"done\"] .hb-xd4-l3 { opacity: 1; transform: none; }\n.hb-xd4-cover {\n  position: absolute;\n  inset: 0;\n  z-index: 2;\n  display: grid;\n  place-items: center;\n  padding: 4px;\n  border-radius: 14px;\n  background: repeating-linear-gradient(-45deg, #f5c518 0 7px, #121212 7px 14px);\n  box-shadow: 0 6px 14px -6px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(0,0,0,0.6);\n  transform-origin: 50% 0;\n  transform: rotateX(0deg);\n  pointer-events: none;\n  transition: transform 0.6s cubic-bezier(0.34, 1.45, 0.55, 1), filter 0.6s ease;\n}\n.hb-xd4-glass {\n  display: grid;\n  place-items: center;\n  width: 100%;\n  height: 100%;\n  border-radius: 10px;\n  color: #e9e9e9;\n  font-weight: 600;\n  background:\n    linear-gradient(115deg, rgba(255,255,255,0.16) 0 18%, rgba(255,255,255,0) 18% 34%, rgba(255,255,255,0.07) 34% 40%, rgba(255,255,255,0) 40%),\n    linear-gradient(180deg, rgba(36,36,36,0.92), rgba(18,18,18,0.94));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 0 0 1px rgba(255,255,255,0.05);\n}\n.hb-xd4-glass > span { display: inline-flex; align-items: center; gap: 0.5em; white-space: nowrap; }\n.hb-xd4-glass svg { color: #f5c518; }\n.hb-xd4-hinge {\n  position: absolute;\n  top: -3px;\n  left: 50%;\n  width: 46%;\n  height: 6px;\n  margin-left: -23%;\n  border-radius: 3px;\n  background: linear-gradient(180deg, #5a5a5a, #2a2a2a);\n  box-shadow: 0 1px 2px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.25);\n}\n.hb-xd4[data-phase=\"armed\"] .hb-xd4-cover, .hb-xd4[data-phase=\"done\"] .hb-xd4-cover {\n  transform: rotateX(116deg);\n  filter: brightness(0.55);\n}\n.hb-xd4-timer {\n  height: 2px;\n  margin: 7px 10px 0;\n  border-radius: 2px;\n  background: rgba(255,255,255,0.06);\n  overflow: hidden;\n}\n.hb-xd4-timer > span {\n  display: block;\n  height: 100%;\n  background: var(--hb-xd4-c);\n  transform: scaleX(0);\n  transform-origin: left;\n}\n.hb-xd4[data-phase=\"armed\"] .hb-xd4-timer > span { animation: hb-xd4-drain var(--hb-xd4-t) linear forwards; }\n.hb-xd4-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-xd4-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }\n@keyframes hb-xd4-glow {\n  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -3px 0 rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.5), 0 0 0 0 color-mix(in srgb, var(--hb-xd4-c) 0%, transparent); }\n  50% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -3px 0 rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.5), 0 0 22px 2px color-mix(in srgb, var(--hb-xd4-c) 55%, transparent); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd4-btn, .hb-xd4-lbl, .hb-xd4-cover { transition: none; }\n  .hb-xd4[data-phase=\"armed\"] .hb-xd4-btn { animation: none; }\n  .hb-xd4[data-phase=\"armed\"] .hb-xd4-timer > span { animation: none; transform: scaleX(1); }\n}\n`;\n\nexport function ButtonSafetyCover({\n  children = \"Delete project\",\n  armedLabel = \"Press to confirm\",\n  doneLabel = \"Project deleted\",\n  armTimeout = 4000,\n  accent = \"#e5383b\",\n  size = \"md\",\n  resetAfter = 2600,\n  onArm,\n  onConfirm,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  onKeyDown,\n  onBlur,\n  ...rest\n}: ButtonSafetyCoverProps) {\n  const [phase, setPhase] = React.useState<\"idle\" | \"armed\" | \"done\">(\"idle\");\n  const latest = React.useRef({ onArm, onConfirm });\n\n  React.useEffect(() => {\n    latest.current = { onArm, onConfirm };\n  }, [onArm, onConfirm]);\n\n  React.useEffect(() => {\n    if (phase === \"armed\" && armTimeout > 0) {\n      const t = window.setTimeout(() => setPhase(\"idle\"), armTimeout);\n      return () => window.clearTimeout(t);\n    }\n    if (phase === \"done\" && resetAfter > 0) {\n      const t = window.setTimeout(() => setPhase(\"idle\"), resetAfter);\n      return () => window.clearTimeout(t);\n    }\n  }, [phase, armTimeout, resetAfter]);\n\n  const status = phase === \"armed\" ? \"Safety cover open. Press again to confirm.\" : phase === \"done\" ? (typeof doneLabel === \"string\" ? doneLabel : \"Confirmed\") : \"\";\n\n  return (\n    <span\n      className={`hb-xd4 ${className}`.trim()}\n      data-size={size}\n      data-phase={phase}\n      style={{ \"--hb-xd4-c\": accent, \"--hb-xd4-t\": `${armTimeout}ms`, ...style } as React.CSSProperties}\n    >\n      <style href=\"hb-button-safety-cover\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xd4-well\">\n        <button\n          type={type}\n          className=\"hb-xd4-btn\"\n          disabled={disabled}\n          aria-disabled={phase === \"done\" || undefined}\n          onClick={() => {\n            if (phase === \"idle\") {\n              setPhase(\"armed\");\n              latest.current.onArm?.();\n            } else if (phase === \"armed\") {\n              setPhase(\"done\");\n              latest.current.onConfirm?.();\n            }\n          }}\n          onKeyDown={(e) => {\n            onKeyDown?.(e);\n            if (e.key === \"Escape\" && phase === \"armed\") setPhase(\"idle\");\n          }}\n          onBlur={(e) => {\n            onBlur?.(e);\n            if (phase === \"armed\") setPhase(\"idle\");\n          }}\n          {...rest}\n        >\n          <span className=\"hb-xd4-lbl hb-xd4-l1\" aria-hidden={phase !== \"idle\"}>{children}</span>\n          <span className=\"hb-xd4-lbl hb-xd4-l2\" aria-hidden={phase !== \"armed\"}>\n            <svg viewBox=\"0 0 24 24\" width=\"1.05em\" height=\"1.05em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M12 3l9.5 17h-19z\" />\n              <path d=\"M12 10v4.5M12 17.5v.01\" />\n            </svg>\n            {armedLabel}\n          </span>\n          <span className=\"hb-xd4-lbl hb-xd4-l3\" aria-hidden={phase !== \"done\"}>\n            <svg viewBox=\"0 0 24 24\" width=\"1.05em\" height=\"1.05em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M5 12.5l4.5 4.5L19 7.5\" />\n            </svg>\n            {doneLabel}\n          </span>\n        </button>\n        <span className=\"hb-xd4-cover\" aria-hidden=\"true\">\n          <span className=\"hb-xd4-hinge\" />\n          <span className=\"hb-xd4-glass\">\n            <span>\n              <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                <rect x=\"5\" y=\"11\" width=\"14\" height=\"9\" rx=\"2\" />\n                <path d=\"M8 11V8a4 4 0 0 1 8 0v3\" />\n              </svg>\n              {children}\n            </span>\n          </span>\n        </span>\n      </span>\n      <span className=\"hb-xd4-timer\" aria-hidden=\"true\"><span /></span>\n      <span className=\"hb-xd4-sr\" role=\"status\" aria-live=\"polite\">{status}</span>\n    </span>\n  );\n}\n"
    }
  ]
}