{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "black-box-hero",
  "type": "registry:block",
  "title": "Black Box Hero",
  "description": "Hero Section built with Black Box (3D product explainer box) and Odometer (animated number counter): a black box opens to show how it answered. A take on the 3D (three dimensional), flow diagram (flowchart) and number counter (count up). A hero for an AI product that shows its work. A question drops down a wire into a glossy black box, its three faces open in turn with what each part did for that question, and the answer comes back up beside it. Point at a face to hold it open. Under it, four numbers in oversized type roll into place.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "hero-sections",
    "hero",
    "3d",
    "flow-diagram",
    "number-counter"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/hero-sections/black-box-hero",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://keyframeui.com/r/black-box.json",
    "https://keyframeui.com/r/odometer.json",
    "utils"
  ],
  "files": [
    {
      "path": "components/black-box-hero.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { animate, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { BlackBox, type BlackBoxFace } from \"@/components/ui/black-box\";\nimport { Odometer } from \"@/components/ui/odometer\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the hero yours: the palette,\n * the nav, the copy, the questions the box answers and the\n * numbers under it. Each question drops into the box, its three\n * faces open in turn with what that part did for this question,\n * and the answer comes back out. Point at a face to hold it open;\n * click one and the questions stop on their answer.\n * ─────────────────────────────────────────────────────────── */\n\n/**\n * Crisp paper and ink, and one electric blue: the light inside the box,\n * the agent's avatar and the working dot. Dark mode turns the box to glass.\n */\nconst PALETTE = {\n  light: { paper: \"#fbfbfc\", ink: \"#0a0a0b\", accent: \"#3355ff\" },\n  dark: { paper: \"#060709\", ink: \"#f4f5f7\", accent: \"#7088ff\" },\n};\n\nconst BRAND = { name: \"Basalt\", handle: \"@basalt\", href: \"#\" };\nconst NAV_LINKS = [\n  { label: \"Product\", href: \"#product\" },\n  { label: \"Customers\", href: \"#customers\" },\n  { label: \"Pricing\", href: \"#pricing\" },\n  { label: \"Docs\", href: \"#docs\" },\n];\nconst NAV_ACTIONS = {\n  demo: { label: \"Book a demo\", href: \"#demo\" },\n  signIn: { label: \"Sign in\", href: \"#sign-in\" },\n  signUp: { label: \"Start free\", href: \"#start\" },\n};\n\nconst HEADLINE = [\"Books that close\", \"themselves.\"];\nconst SUBLINE =\n  \"Basalt reconciles every account overnight. Ask it anything about your numbers and it opens up to show where each answer came from.\";\nconst PRIMARY_CTA = { label: \"Start closing\", href: \"#start\" };\nconst SECONDARY_CTA = { label: \"Talk to an accountant\", href: \"#talk\" };\n\n/** The person asking, shown as initials beside each question. */\nconst ASKER = \"MO\";\n\n/** The three parts of the box, in the order they work: top, left, right. */\nconst PARTS = [\n  {\n    id: \"pull\",\n    label: \"Pull\",\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    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: \"explain\",\n    label: \"Explain\",\n    icon: (\n      <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.6} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <path d=\"M5 6h14M5 11h14M5 16h8\" />\n      </svg>\n    ),\n  },\n] as const;\n\ntype PartId = (typeof PARTS)[number][\"id\"];\n\n/** Each question, what every part of the box did for it, and the answer that comes back. */\nconst QUESTIONS: { ask: string; steps: Record<PartId, string>; answer: React.ReactNode }[] = [\n  {\n    ask: \"Why is software spend up 22% in October?\",\n    steps: {\n      pull: \"1,284 October transactions, and September's to compare.\",\n      match: \"41 charges tied to invoices. Two are annual renewals.\",\n      explain: \"Without the renewals, software is down 3%.\",\n    },\n    answer: (\n      <>\n        Two annual renewals landed in October: Northwind CRM (<b>$14,400</b>) and Tinta (<b>$6,100</b>). Without them,\n        software is down 3%.\n      </>\n    ),\n  },\n  {\n    ask: \"Are we still on track for 18 months of runway?\",\n    steps: {\n      pull: \"Cash in 3 accounts, 6 payroll runs, every contract.\",\n      match: \"Forecast within 2% of the last 90 days of actuals.\",\n      explain: \"Two March hires raised burn; runway was 19 months.\",\n    },\n    answer: (\n      <>\n        Yes, just: <b>18.4 months</b>, down from 19 after the two March hires. A third hire takes it to 16.9.\n      </>\n    ),\n  },\n  {\n    ask: \"What's still blocking the September close?\",\n    steps: {\n      pull: \"14 accounts, 2,031 September transactions.\",\n      match: \"2,024 matched on their own. 7 have no receipt.\",\n      explain: \"The 7 belong to three people. Each has been asked.\",\n    },\n    answer: (\n      <>\n        <b>Seven card charges</b> without receipts, from three people. I&apos;ve messaged each of them; the books close\n        when they reply.\n      </>\n    ),\n  },\n];\n\n/** The numbers under the hero. `value` rolls in when the strip scrolls into view. */\nconst STATS: { value: number; format?: Intl.NumberFormatOptions; suffix?: string; caption: string }[] = [\n  { value: 2400000, format: { notation: \"compact\", maximumFractionDigits: 1 }, caption: \"transactions matched last month\" },\n  { value: 4, suffix: \" hrs\", caption: \"to close the month, down from six days\" },\n  { value: 0.997, format: { style: \"percent\", maximumFractionDigits: 1 }, caption: \"of transactions matched without a person\" },\n  { value: 1900, suffix: \"+\", caption: \"finance teams closing on Basalt\" },\n];\n\n/** How long each beat of a question plays, in ms: asked, the three parts at work, answered, cleared. */\nconst BEATS = [900, 2600, 2600, 2600, 5200, 450];\nconst ANSWERED = 4;\n\n/* ── Section ─────────────────────────────────────────────── */\n\nexport function BlackBoxHero() {\n  const reduced = useReducedMotion();\n  const [question, setQuestion] = React.useState(0);\n  const [beat, setBeat] = React.useState(0);\n  const [visitor, setVisitor] = React.useState<string | null>(null);\n  const [picked, setPicked] = React.useState(false);\n  const pulseRef = React.useRef<HTMLSpanElement>(null);\n\n  // The questions play on their own until the visitor picks a face; pointing at one holds the\n  // current beat. Under reduced motion the first question rests on its answer.\n  React.useEffect(() => {\n    if (reduced) {\n      const timer = window.setTimeout(() => setBeat(ANSWERED), 0);\n      return () => window.clearTimeout(timer);\n    }\n    if (picked || visitor !== null) return;\n    const timer = window.setTimeout(() => {\n      if (beat + 1 < BEATS.length) setBeat(beat + 1);\n      else {\n        setBeat(0);\n        setQuestion((question + 1) % QUESTIONS.length);\n      }\n    }, BEATS[beat]);\n    return () => window.clearTimeout(timer);\n  }, [beat, question, visitor, picked, reduced]);\n\n  // A pulse runs down the wire into the box as a question is asked, and back up with the answer.\n  React.useEffect(() => {\n    const pulse = pulseRef.current;\n    if (!pulse || reduced || (beat !== 0 && beat !== ANSWERED)) return;\n    const down = beat === 0;\n    const run = animate(\n      pulse,\n      { transform: down ? [\"translateY(-100%)\", \"translateY(300%)\"] : [\"translateY(300%)\", \"translateY(-100%)\"], opacity: [1, 1] },\n      { duration: 0.55, ease: [0.65, 0, 0.35, 1], delay: down ? 0.25 : 0 },\n    );\n    return () => run.stop();\n  }, [beat, question, reduced]);\n\n  const current = QUESTIONS[question];\n  const faces: BlackBoxFace[] = PARTS.map((part) => ({ ...part, detail: current.steps[part.id] }));\n  const working = beat >= 1 && beat <= 3;\n  const value = visitor ?? (working ? PARTS[beat - 1].id : null);\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=\"relative overflow-hidden 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      <header className=\"mx-auto flex h-14 max-w-6xl items-center gap-8 px-6\">\n        <a\n          href={BRAND.href}\n          className=\"flex items-center gap-2 rounded-md text-[15px] font-semibold tracking-[-0.02em] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-(--accent)\"\n        >\n          <BasaltMark className=\"size-5\" />\n          {BRAND.name}\n        </a>\n        <nav aria-label=\"Main\" className=\"hidden items-center gap-6 text-[13px] text-zinc-600 md:flex dark:text-zinc-400\">\n          {NAV_LINKS.map((link) => (\n            <a\n              key={link.label}\n              href={link.href}\n              className=\"rounded-sm transition-colors duration-150 hover:text-(--ink) focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-(--accent)\"\n            >\n              {link.label}\n            </a>\n          ))}\n        </nav>\n        <div className=\"ml-auto flex items-center gap-2 text-[13px] font-medium\">\n          <a\n            href={NAV_ACTIONS.demo.href}\n            className=\"hidden rounded-full px-3.5 py-1.5 ring-1 ring-zinc-950/10 transition-colors duration-150 hover:bg-zinc-950/[0.04] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) sm:block dark:ring-white/15 dark:hover:bg-white/[0.06]\"\n          >\n            {NAV_ACTIONS.demo.label}\n          </a>\n          <a\n            href={NAV_ACTIONS.signIn.href}\n            className=\"rounded-full px-3 py-1.5 text-zinc-700 transition-colors duration-150 hover:text-(--ink) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:text-zinc-300\"\n          >\n            {NAV_ACTIONS.signIn.label}\n          </a>\n          <a\n            href={NAV_ACTIONS.signUp.href}\n            className=\"rounded-full bg-(--ink) px-3.5 py-1.5 text-(--paper) transition-opacity duration-150 hover:opacity-85 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent)\"\n          >\n            {NAV_ACTIONS.signUp.label}\n          </a>\n        </div>\n      </header>\n\n      <div className=\"mx-auto grid max-w-6xl items-center gap-x-10 gap-y-12 px-6 pt-14 pb-6 sm:pt-20 lg:grid-cols-[minmax(0,44fr)_minmax(0,56fr)] lg:pt-16\">\n        <div>\n          <h1 className=\"text-[2.6rem] leading-[1.02] font-medium tracking-[-0.045em] sm:text-6xl lg:text-[3.6rem]\">\n            <span className=\"block\">{HEADLINE[0]}</span>{\" \"}\n            <span className=\"block\">{HEADLINE[1]}</span>\n          </h1>\n          <p className=\"mt-6 max-w-md text-base leading-relaxed text-pretty text-zinc-600 sm:text-[17px] dark:text-zinc-400\">\n            {SUBLINE}\n          </p>\n          <div className=\"mt-8 flex flex-wrap items-center gap-3 text-sm font-medium\">\n            <a\n              href={PRIMARY_CTA.href}\n              className=\"rounded-full bg-(--ink) px-5 py-2.5 text-(--paper) transition-opacity duration-150 hover:opacity-85 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent)\"\n            >\n              {PRIMARY_CTA.label}\n            </a>\n            <a\n              href={SECONDARY_CTA.href}\n              className=\"rounded-full bg-white px-5 py-2.5 ring-1 ring-zinc-950/10 transition-colors duration-150 hover:bg-zinc-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:bg-white/[0.04] dark:ring-white/15 dark:hover:bg-white/[0.08]\"\n            >\n              {SECONDARY_CTA.label}\n            </a>\n          </div>\n        </div>\n\n        <div className=\"relative min-w-0\">\n          {/* The thread: every question and answer share one cell, so the tallest holds the space. */}\n          <div className=\"mx-auto grid max-w-[27rem] text-[13px] leading-5\">\n            {QUESTIONS.map((item, i) => {\n              const asked = i === question && beat < BEATS.length - 1;\n              const answered = asked && beat >= ANSWERED;\n              return (\n                <div key={item.ask} aria-hidden={i !== question} className=\"col-start-1 row-start-1 flex flex-col gap-2.5\">\n                  <div\n                    className={cn(\n                      \"flex origin-bottom-right items-start gap-2.5 self-end rounded-2xl rounded-br-md bg-white py-2.5 pr-3.5 pl-2.5 shadow-sm ring-1 ring-zinc-950/[0.07] transition-[opacity,transform] ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-opacity dark:bg-zinc-900 dark:ring-white/10\",\n                      asked ? \"translate-y-0 scale-100 opacity-100 duration-300\" : \"translate-y-1.5 scale-[0.98] opacity-0 duration-200 motion-reduce:translate-y-0 motion-reduce:scale-100\",\n                    )}\n                  >\n                    <span className=\"grid size-5 shrink-0 place-items-center rounded-full bg-zinc-200 text-[9px] font-semibold text-zinc-700 dark:bg-zinc-700 dark:text-zinc-200\">\n                      {ASKER}\n                    </span>\n                    <p className=\"text-zinc-700 dark:text-zinc-300\">\n                      <b className=\"font-semibold text-(--ink)\">{BRAND.handle}</b> {item.ask}\n                    </p>\n                  </div>\n                  <div className=\"grid\">\n                    {/* Dots where the answer will land while the box works. */}\n                    <div\n                      className={cn(\n                        \"col-start-1 row-start-1 flex origin-top-left items-center gap-2.5 self-start justify-self-start rounded-2xl rounded-tl-md bg-white py-2.5 pr-3.5 pl-2.5 shadow-sm ring-1 ring-zinc-950/[0.07] transition-[opacity,transform] ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-opacity dark:bg-zinc-900 dark:ring-white/10\",\n                        asked && !answered && beat >= 1 ? \"scale-100 opacity-100 duration-300\" : \"scale-95 opacity-0 duration-150 motion-reduce:scale-100\",\n                      )}\n                    >\n                      <AgentAvatar />\n                      <span className=\"flex h-5 items-center gap-1 pr-0.5\">\n                        {[0, 1, 2].map((dot) => (\n                          <span\n                            key={dot}\n                            className=\"size-1.5 animate-pulse rounded-full bg-zinc-400 motion-reduce:animate-none dark:bg-zinc-500\"\n                            style={{ animationDelay: `${dot * 160}ms` }}\n                          />\n                        ))}\n                      </span>\n                    </div>\n                    <div\n                      className={cn(\n                        \"col-start-1 row-start-1 flex origin-top-left items-start gap-2.5 self-start justify-self-start rounded-2xl rounded-tl-md bg-white py-2.5 pr-3.5 pl-2.5 shadow-sm ring-1 ring-zinc-950/[0.07] transition-[opacity,transform] ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-opacity dark:bg-zinc-900 dark:ring-white/10\",\n                        answered ? \"translate-y-0 scale-100 opacity-100 delay-100 duration-300\" : \"-translate-y-1 scale-[0.98] opacity-0 duration-200 motion-reduce:translate-y-0 motion-reduce:scale-100\",\n                      )}\n                    >\n                      <AgentAvatar />\n                      <p className=\"text-zinc-700 dark:text-zinc-300 [&_b]:font-semibold [&_b]:text-(--ink)\">{item.answer}</p>\n                    </div>\n                  </div>\n                </div>\n              );\n            })}\n          </div>\n\n          {/* The wire between the thread and the box, with the pulse that travels it. */}\n          <div aria-hidden className=\"relative mx-auto mt-2 h-16 w-px overflow-hidden bg-linear-to-b from-zinc-950/5 to-zinc-950/20 dark:from-white/5 dark:to-white/25\">\n            <span\n              ref={pulseRef}\n              className=\"absolute inset-x-0 top-0 h-1/3 bg-linear-to-b from-transparent via-(--accent) to-transparent opacity-0 will-change-transform\"\n            />\n          </div>\n\n          <BlackBox\n            faces={faces}\n            value={value}\n            autoplay={false}\n            onValueChange={(id, reason) => {\n              if (reason === \"autoplay\") return;\n              setVisitor(id);\n              if (reason === \"pick\") {\n                setPicked(true);\n                setBeat(ANSWERED);\n              }\n            }}\n            className=\"-mt-9 [--black-box-light:var(--accent)]\"\n            aria-label={`How ${BRAND.name} answers`}\n          />\n        </div>\n      </div>\n\n      <div className=\"mx-auto max-w-6xl px-6 pt-10 pb-24 sm:pb-28\">\n        <dl className=\"grid grid-cols-2 gap-x-8 gap-y-12 lg:grid-cols-4\">\n          {STATS.map((stat) => (\n            <div key={stat.caption} className=\"flex flex-col-reverse justify-end\">\n              <dt className=\"mt-3 max-w-[15rem] text-[13px] leading-5 text-pretty text-zinc-500 dark:text-zinc-400\">\n                {stat.caption}\n              </dt>\n              <dd className=\"text-5xl leading-none font-normal tracking-[-0.045em] tabular-nums sm:text-6xl\">\n                <Odometer value={stat.value} format={stat.format} rollOnView />\n                {stat.suffix ? <span>{stat.suffix}</span> : null}\n              </dd>\n            </div>\n          ))}\n        </dl>\n      </div>\n    </section>\n  );\n}\n\n/* ── Marks ─────────────────────────────────────────────────── */\n\nfunction AgentAvatar() {\n  return (\n    <span className=\"grid size-5 shrink-0 place-items-center rounded-full bg-(--accent) text-white\">\n      <BasaltMark className=\"size-3\" cut=\"var(--accent)\" />\n    </span>\n  );\n}\n\n\n// A basalt column seen end-on: a hexagon with the three edges of a cube's near corner.\nfunction BasaltMark({ className, cut = \"var(--paper)\" }: { className?: string; cut?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden className={className}>\n      <path d=\"M12 2.5 20.5 7.25v9.5L12 21.5l-8.5-4.75v-9.5z\" fill=\"currentColor\" />\n      <path d=\"M12 12v9.5M12 12l8.5-4.75M12 12 3.5 7.25\" stroke={cut} strokeWidth={1.4} strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n"
    }
  ]
}