{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notfound-letter",
  "type": "registry:component",
  "title": "404 Apology Letter",
  "description": "A light 404 page written as a typed letter on airmail paper. The apology types itself out, then a red 404 return to sender stamp thumps onto the sheet.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "not-found",
    "404",
    "letter",
    "typewriter",
    "paper",
    "stamp",
    "light"
  ],
  "docs": "https://hyperblur.dev/effects/notfound-letter",
  "files": [
    {
      "path": "registry/hyperblur/notfound-letter.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/notfound-letter.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface NotfoundLetterLink {\n  label: string;\n  href: string;\n}\n\nexport interface NotfoundLetterProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  code?: string;\n  salutation?: string;\n  paragraphs?: string[];\n  signature?: string;\n  signatureRole?: string;\n  dateline?: string;\n  stampLabel?: string;\n  primary?: NotfoundLetterLink;\n  secondary?: NotfoundLetterLink;\n  typingSpeed?: number;\n  accent?: string;\n  onTypingComplete?: () => void;\n}\n\nconst css = `\n.hb-yj2 {\n  --hb-yj2-accent: #c2412d;\n  --hb-yj2-ink: #26231d;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  isolation: isolate;\n  container-type: inline-size;\n  background:\n    radial-gradient(60% 50% at 50% 0%, rgba(255, 255, 255, .7), transparent 70%),\n    repeating-linear-gradient(90deg, rgba(38, 35, 29, .025) 0 1px, transparent 1px 4px),\n    #efe9dc;\n  color: var(--hb-yj2-ink);\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yj2 *, .hb-yj2 *::before, .hb-yj2 *::after { box-sizing: border-box; }\n.hb-yj2-inner {\n  display: grid;\n  justify-items: center;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: 64px 16px 72px;\n}\n@container (min-width: 760px) { .hb-yj2-inner { padding: 96px 32px 104px; } }\n.hb-yj2-sheet {\n  position: relative;\n  width: 100%;\n  max-width: 720px;\n  padding: 48px 26px 40px;\n  background: linear-gradient(180deg, #fffefa, #fbf8f0);\n  border-radius: 3px;\n  box-shadow:\n    0 1px 0 rgba(255, 255, 255, .9) inset,\n    0 2px 4px rgba(38, 35, 29, .06),\n    0 24px 60px -24px rgba(38, 35, 29, .35);\n  transform: rotate(-.6deg);\n}\n@container (min-width: 760px) { .hb-yj2-sheet { padding: 60px 64px 48px; } }\n.hb-yj2-sheet::before {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 0;\n  height: 8px;\n  background: repeating-linear-gradient(135deg, var(--hb-yj2-accent) 0 14px, #fffdf7 14px 22px, #2f5ca0 22px 36px, #fffdf7 36px 44px);\n  border-radius: 3px 3px 0 0;\n}\n.hb-yj2-sheet::after {\n  content: \"\";\n  position: absolute;\n  inset: auto 6% -10px 6%;\n  height: 20px;\n  z-index: -1;\n  background: rgba(38, 35, 29, .18);\n  filter: blur(14px);\n}\n.hb-yj2-head {\n  display: flex;\n  justify-content: space-between;\n  align-items: flex-start;\n  gap: 20px;\n  margin-bottom: 26px;\n}\n.hb-yj2-date {\n  margin: 0;\n  color: #7b7466;\n  font: 500 12px/1.5 ui-monospace, \"Courier New\", monospace;\n  letter-spacing: .08em;\n  text-transform: uppercase;\n}\n.hb-yj2-postage {\n  position: relative;\n  flex: none;\n  width: 74px;\n  height: 88px;\n  padding: 6px;\n  background: #fffdf7;\n  filter: drop-shadow(0 2px 3px rgba(38, 35, 29, .18));\n  -webkit-mask: radial-gradient(circle at 4px 4px, transparent 2.6px, #000 3px) -4px -4px / 9px 9px;\n  mask: radial-gradient(circle at 4px 4px, transparent 2.6px, #000 3px) -4px -4px / 9px 9px;\n  transform: rotate(4deg);\n}\n.hb-yj2-postage-art {\n  display: grid;\n  place-items: end start;\n  width: 100%;\n  height: 100%;\n  padding: 6px;\n  background:\n    radial-gradient(circle at 70% 30%, #f6c76b 0 14%, transparent 15%),\n    linear-gradient(180deg, transparent 55%, #2f5ca0 55% 70%, #24497f 70%),\n    linear-gradient(180deg, #f3d9b1, #e9a77e);\n  color: #fffdf7;\n  font: 700 11px/1 ui-monospace, \"Courier New\", monospace;\n}\n.hb-yj2-text {\n  min-height: 300px;\n  font: 400 clamp(14px, 2.1cqw, 16.5px)/32px \"Courier Prime\", \"Courier New\", ui-monospace, monospace;\n  color: var(--hb-yj2-ink);\n}\n.hb-yj2-text p { margin: 0 0 32px; white-space: pre-wrap; }\n.hb-yj2-text p:last-child { margin-bottom: 0; }\n.hb-yj2-caret {\n  display: inline-block;\n  width: .55em;\n  height: 1.05em;\n  margin-left: 1px;\n  vertical-align: -.15em;\n  background: var(--hb-yj2-ink);\n  animation: hb-yj2-caret 1s steps(1) infinite;\n}\n.hb-yj2-sign {\n  margin-top: 8px;\n  font: italic 400 26px/32px \"Snell Roundhand\", \"Brush Script MT\", \"Segoe Script\", cursive;\n  color: #2f5ca0;\n  opacity: 0;\n  transition: opacity .8s ease .2s;\n}\n.hb-yj2-role {\n  margin: 0;\n  color: #7b7466;\n  font: 500 12px/32px ui-monospace, \"Courier New\", monospace;\n  letter-spacing: .06em;\n  text-transform: uppercase;\n  opacity: 0;\n  transition: opacity .8s ease .5s;\n}\n.hb-yj2-done .hb-yj2-sign, .hb-yj2-done .hb-yj2-role { opacity: 1; }\n.hb-yj2-stamp {\n  position: absolute;\n  right: 6%;\n  bottom: 18%;\n  display: grid;\n  place-items: center;\n  width: 150px;\n  height: 150px;\n  border: 4px double var(--hb-yj2-accent);\n  border-radius: 50%;\n  color: var(--hb-yj2-accent);\n  text-align: center;\n  opacity: 0;\n  transform: rotate(-16deg) scale(1.6);\n  mix-blend-mode: multiply;\n  pointer-events: none;\n  -webkit-mask: repeating-radial-gradient(circle at 30% 40%, #000 0 3px, rgba(0, 0, 0, .78) 3px 4px);\n  mask: repeating-radial-gradient(circle at 30% 40%, #000 0 3px, rgba(0, 0, 0, .78) 3px 4px);\n}\n.hb-yj2-stamp::before {\n  content: \"\";\n  position: absolute;\n  inset: 8px;\n  border: 1.5px solid currentColor;\n  border-radius: 50%;\n}\n.hb-yj2-stamp b { display: block; font: 800 46px/1 ui-monospace, \"Courier New\", monospace; letter-spacing: -.02em; }\n.hb-yj2-stamp span { display: block; margin-top: 4px; font: 700 10px/1.2 ui-monospace, \"Courier New\", monospace; letter-spacing: .18em; text-transform: uppercase; }\n.hb-yj2-done .hb-yj2-stamp { animation: hb-yj2-thunk .42s cubic-bezier(.3, 1.5, .5, 1) forwards; }\n.hb-yj2-actions {\n  display: flex;\n  flex-wrap: wrap;\n  justify-content: center;\n  gap: 12px;\n  margin-top: 40px;\n}\n.hb-yj2-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 44px;\n  padding: 0 20px;\n  border: 1px solid rgba(38, 35, 29, .18);\n  border-radius: 999px;\n  color: var(--hb-yj2-ink);\n  font-size: 14px;\n  font-weight: 500;\n  text-decoration: none;\n  transition: background .2s ease, transform .2s ease, border-color .2s ease;\n}\n.hb-yj2-btn:hover { background: rgba(38, 35, 29, .05); border-color: rgba(38, 35, 29, .3); }\n.hb-yj2-btn:focus-visible { outline: 2px solid var(--hb-yj2-accent); outline-offset: 3px; }\n.hb-yj2-btn-primary { background: var(--hb-yj2-ink); color: #fffdf7; border-color: var(--hb-yj2-ink); }\n.hb-yj2-btn-primary:hover { background: #000; transform: translateY(-1px); }\n.hb-yj2-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@keyframes hb-yj2-caret { 50% { opacity: 0; } }\n@keyframes hb-yj2-thunk {\n  0% { opacity: 0; transform: rotate(-16deg) scale(1.6); }\n  60% { opacity: .92; transform: rotate(-12deg) scale(.94); }\n  100% { opacity: .86; transform: rotate(-12deg) scale(1); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yj2 *, .hb-yj2 *::before, .hb-yj2 *::after { animation: none !important; transition: none !important; }\n  .hb-yj2-done .hb-yj2-stamp { opacity: .86; transform: rotate(-12deg); }\n}\n`;\n\nconst defaultParagraphs = [\n  \"We are terribly sorry. The page you came looking for is not at this address. It may have moved when we reorganised the archive last spring, or the link that brought you here had a small typo in it.\",\n  \"Please do not hold it against the rest of the site. Everything else is exactly where we left it, and the front desk is happy to point you in the right direction.\",\n];\n\nexport function NotfoundLetter({\n  code = \"404\",\n  salutation = \"Dear reader,\",\n  paragraphs = defaultParagraphs,\n  signature = \"Margot Lindqvist\",\n  signatureRole = \"Head of the Lost & Found desk\",\n  dateline = \"Stockholm · Returned to sender\",\n  stampLabel = \"Return to sender\",\n  primary = { label: \"Back to the homepage\", href: \"/\" },\n  secondary = { label: \"Report a broken link\", href: \"/contact\" },\n  typingSpeed = 1,\n  accent = \"#c2412d\",\n  onTypingComplete,\n  className,\n  style,\n  ...rest\n}: NotfoundLetterProps) {\n  const blocks = React.useMemo(() => [salutation, ...paragraphs], [salutation, paragraphs]);\n  const total = React.useMemo(() => blocks.reduce((n, b) => n + b.length, 0), [blocks]);\n  const [count, setCount] = React.useState(0);\n  const doneCb = React.useRef(onTypingComplete);\n\n  React.useEffect(() => {\n    doneCb.current = onTypingComplete;\n  }, [onTypingComplete]);\n\n  React.useEffect(() => {\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let n = 0;\n    let id = 0;\n    const step = () => {\n      n = reduce ? total : Math.min(total, n + 2);\n      setCount(n);\n      if (n >= total) {\n        window.clearInterval(id);\n        doneCb.current?.();\n      }\n    };\n    id = window.setInterval(step, Math.round(24 / Math.max(0.2, typingSpeed)));\n    return () => window.clearInterval(id);\n  }, [total, typingSpeed]);\n\n  const done = count >= total;\n  let left = count;\n  const shown = blocks.map((b) => {\n    const take = Math.max(0, Math.min(b.length, left));\n    left -= take;\n    return b.slice(0, take);\n  });\n  let caretAt = shown.findIndex((s, i) => s.length < blocks[i].length);\n  if (caretAt === -1) caretAt = blocks.length - 1;\n\n  return (\n    <section\n      className={[\"hb-yj2\", done ? \"hb-yj2-done\" : \"\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-yj2-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-notfound-letter\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yj2-inner\">\n        <article className=\"hb-yj2-sheet\">\n          <div className=\"hb-yj2-head\">\n            <p className=\"hb-yj2-date\">\n              Error {code}\n              <br />\n              {dateline}\n            </p>\n            <div className=\"hb-yj2-postage\" aria-hidden=\"true\">\n              <div className=\"hb-yj2-postage-art\">{code}</div>\n            </div>\n          </div>\n          <h1 className=\"hb-yj2-sr\">Page not found</h1>\n          <div className=\"hb-yj2-sr\">{blocks.join(\" \")}</div>\n          <div className=\"hb-yj2-text\" aria-hidden=\"true\">\n            {shown.map((s, i) =>\n              i <= caretAt ? (\n                <p key={i}>\n                  {s}\n                  {i === caretAt && !done ? <span className=\"hb-yj2-caret\" /> : null}\n                </p>\n              ) : null,\n            )}\n            <div className=\"hb-yj2-sign\">{signature}</div>\n            <p className=\"hb-yj2-role\">{signatureRole}</p>\n          </div>\n          <div className=\"hb-yj2-stamp\" aria-hidden=\"true\">\n            <div>\n              <b>{code}</b>\n              <span>{stampLabel}</span>\n            </div>\n          </div>\n        </article>\n        <div className=\"hb-yj2-actions\">\n          <a className=\"hb-yj2-btn hb-yj2-btn-primary\" href={primary.href}>\n            {primary.label}\n          </a>\n          <a className=\"hb-yj2-btn\" href={secondary.href}>\n            {secondary.label}\n          </a>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}