{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "black-box-feature",
  "type": "registry:block",
  "title": "Black Box Feature",
  "description": "Feature Section built with Black Box (3D product explainer box): a black box opens one face per step. A take on the 3D (three dimensional) and flow diagram (flowchart). A how-it-works section with the product as a black box and its steps beside it. The box opens one face per step on its own while a hairline fills under the step that's playing; point at a step and its face opens, point at a face and its step lights up, pick one and it stays.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "feature-sections",
    "features",
    "3d",
    "flow-diagram"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/feature-sections/black-box-feature",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://keyframeui.com/r/black-box.json",
    "utils"
  ],
  "files": [
    {
      "path": "components/black-box-feature.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { animate, useInView } from \"motion/react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { BlackBox, type BlackBoxFace } from \"@/components/ui/black-box\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the section yours: the\n * palette, the copy and the three steps. The box opens one face\n * per step on its own, with a timer line under the step that's\n * playing; point at a step (or a face) and the other follows,\n * pick one and it stays.\n * ─────────────────────────────────────────────────────────── */\n\nconst PALETTE = {\n  light: { paper: \"#ffffff\", ink: \"#0a0a0b\", accent: \"#3355ff\" },\n  dark: { paper: \"#060709\", ink: \"#f4f5f7\", accent: \"#7088ff\" },\n};\n\nconst EYEBROW = \"How Basalt closes\";\nconst HEADLINE = [\"Three passes.\", \"Every one leaves a trail.\"];\nconst SUBLINE =\n  \"Close the month without a spreadsheet in sight, and still open any total down to the receipt behind it.\";\n\n/** Time each step stays open while the section plays on its own, in ms. */\nconst STEP_TIME = 3600;\n\nconst STEPS: (BlackBoxFace & { proof: string; body: string })[] = [\n  {\n    id: \"pull\",\n    label: \"Pull\",\n    detail: \"Bank, card and payroll feeds\",\n    body: \"Read-only feeds from every bank, card program and payroll run, refreshed each night before anyone's up.\",\n    proof: \"3 banks · 2 card programs · payroll\",\n    icon: (\n      <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.6} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <path d=\"M12 4v11M7.5 10.5 12 15l4.5-4.5M5 19h14\" />\n      </svg>\n    ),\n  },\n  {\n    id: \"match\",\n    label: \"Match\",\n    detail: \"Every line to its receipt\",\n    body: \"Each transaction is tied to its invoice, receipt or contract. Anything it can't place goes to the person who spent it.\",\n    proof: \"2,024 of 2,031 matched on their own\",\n    icon: (\n      <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.6} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <circle cx=\"9\" cy=\"12\" r=\"5\" />\n        <circle cx=\"15\" cy=\"12\" r=\"5\" />\n      </svg>\n    ),\n  },\n  {\n    id: \"close\",\n    label: \"Close\",\n    detail: \"Locked, with the working\",\n    body: \"The period locks with a close pack your accountant can read: every adjustment, who approved it and why.\",\n    proof: \"Locked Oct 3, 06:12 · 41-page pack\",\n    icon: (\n      <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.6} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <rect x=\"5\" y=\"10.5\" width=\"14\" height=\"9.5\" rx=\"2\" />\n        <path d=\"M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5\" />\n      </svg>\n    ),\n  },\n];\n\n/* ── Section ─────────────────────────────────────────────── */\n\nexport function BlackBoxFeature() {\n  const [value, setValue] = React.useState<string | null>(null);\n  const [holding, setHolding] = React.useState(false);\n  const [picked, setPicked] = React.useState(false);\n  const [overBox, setOverBox] = React.useState(false); // the box holds its own autoplay; this just hides the timer\n  const playing = !holding && !picked;\n\n  return (\n    <section\n      style={\n        {\n          \"--paper-light\": PALETTE.light.paper,\n          \"--ink-light\": PALETTE.light.ink,\n          \"--accent-light\": PALETTE.light.accent,\n          \"--paper-dark\": PALETTE.dark.paper,\n          \"--ink-dark\": PALETTE.dark.ink,\n          \"--accent-dark\": PALETTE.dark.accent,\n        } as React.CSSProperties\n      }\n      className=\"bg-(--paper) text-(--ink) [--accent:var(--accent-light)] [--ink:var(--ink-light)] [--paper:var(--paper-light)] dark:[--accent:var(--accent-dark)] dark:[--ink:var(--ink-dark)] dark:[--paper:var(--paper-dark)]\"\n    >\n      <div className=\"mx-auto max-w-6xl px-6 py-24 sm:py-32\">\n        <div className=\"max-w-2xl\">\n          <p className=\"text-[13px] font-medium text-(--accent)\">{EYEBROW}</p>\n          <h2 className=\"mt-3 text-4xl leading-[1.05] font-medium tracking-[-0.04em] sm:text-5xl\">\n            <span className=\"block\">{HEADLINE[0]}</span>\n            <span className=\"block text-zinc-400 dark:text-zinc-500\">{HEADLINE[1]}</span>\n          </h2>\n          <p className=\"mt-5 max-w-xl text-base leading-relaxed text-pretty text-zinc-600 sm:text-[17px] dark:text-zinc-400\">\n            {SUBLINE}\n          </p>\n        </div>\n\n        <div className=\"mt-14 grid items-center gap-x-16 gap-y-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]\">\n          <BlackBox\n            faces={STEPS}\n            value={value}\n            onValueChange={(id, reason) => {\n              setValue(id);\n              if (reason === \"pick\") setPicked(true);\n            }}\n            autoplay={playing ? STEP_TIME : false}\n            labels={false}\n            onPointerEnter={(event) => {\n              if (event.pointerType === \"mouse\") setOverBox(true);\n            }}\n            onPointerLeave={() => setOverBox(false)}\n            className=\"mx-auto max-w-[34rem] [--black-box-light:var(--accent)]\"\n            aria-label=\"Basalt's three passes\"\n          />\n\n          <ol\n            className=\"border-t border-zinc-950/10 dark:border-white/10\"\n            onPointerLeave={() => setHolding(false)}\n            onFocus={() => setHolding(true)}\n            onBlur={(event) => {\n              if (!event.currentTarget.contains(event.relatedTarget as Node)) setHolding(false);\n            }}\n          >\n            {STEPS.map((step, i) => {\n              const on = value === step.id;\n              return (\n                <li key={step.id} className=\"relative border-b border-zinc-950/10 dark:border-white/10\">\n                  <button\n                    type=\"button\"\n                    aria-pressed={on}\n                    onPointerEnter={(event) => {\n                      if (event.pointerType !== \"mouse\") return;\n                      setHolding(true);\n                      setValue(step.id);\n                    }}\n                    onFocus={() => setValue(step.id)}\n                    onClick={() => {\n                      setPicked(true);\n                      setValue(step.id);\n                    }}\n                    className=\"grid w-full grid-cols-[2.5rem_minmax(0,1fr)] py-6 text-left outline-none focus-visible:ring-2 focus-visible:ring-(--accent) focus-visible:ring-offset-4 focus-visible:ring-offset-(--paper)\"\n                  >\n                    <span\n                      className={cn(\n                        \"font-mono text-xs leading-7 tabular-nums transition-colors duration-200\",\n                        on ? \"text-(--accent)\" : \"text-zinc-400 dark:text-zinc-500\",\n                      )}\n                    >\n                      0{i + 1}\n                    </span>\n                    <span>\n                      <span\n                        className={cn(\n                          \"block text-xl leading-7 font-medium tracking-[-0.02em] transition-colors duration-200\",\n                          on ? \"text-(--ink)\" : \"text-zinc-400 dark:text-zinc-500\",\n                        )}\n                      >\n                        {step.label}\n                      </span>\n                      <span\n                        className={cn(\n                          \"mt-2 block text-[15px] leading-6 text-pretty transition-colors duration-200\",\n                          on ? \"text-zinc-600 dark:text-zinc-300\" : \"text-zinc-400 dark:text-zinc-500\",\n                        )}\n                      >\n                        {step.body}\n                      </span>\n                      <span className=\"mt-3 block font-mono text-xs text-zinc-500 dark:text-zinc-400\">{step.proof}</span>\n                    </span>\n                  </button>\n                  {on && playing && !overBox ? <TimerLine key={step.id} duration={STEP_TIME} /> : null}\n                </li>\n              );\n            })}\n          </ol>\n        </div>\n      </div>\n    </section>\n  );\n}\n\n/* ── TimerLine ─────────────────────────────────────────────── */\n\n// A hairline under the step that's playing, filling over the step's time. It starts again\n// whenever it comes back into view, as the box's own timer does.\nfunction TimerLine({ duration }: { duration: number }) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  const inView = useInView(ref);\n  React.useEffect(() => {\n    const line = ref.current;\n    if (!line || !inView) return;\n    const run = animate(line, { transform: [\"scaleX(0)\", \"scaleX(1)\"] }, { duration: duration / 1000, ease: \"linear\" });\n    return () => run.stop();\n  }, [inView, duration]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden\n      style={{ transform: \"scaleX(0)\" }}\n      className=\"absolute inset-x-0 -bottom-px h-px origin-left bg-(--accent) will-change-transform motion-reduce:hidden\"\n    />\n  );\n}\n"
    }
  ]
}