{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ascii-density-nav","type":"registry:component","title":"ASCII Density Nav","description":"A nav whose active link is marked by a band of ASCII density: characters thicken through a ramp under the active link and flow to the next one on a spring, its peak in signal.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/ascii-density-nav.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode, RefObject } from \"react\";\n\n/**\n * AsciiDensityNav — a nav whose active link is marked by a band of ASCII density.\n *\n * Under the links runs a line of mono characters that thicken through a\n * ramp (. · : - = + * # % @) around the active link, densest under its\n * centre; choose another and the band flows there on a spring, its peak in\n * signal, and hover raises a smaller swell. Drawn a frame at a time only\n * while something moves. Controlled or not; folds into a menu when narrow.\n *\n * Part of the Dither & ASCII kit: one ink, paper #f3f0e6, on a warm black\n * ground #0b0b0d, with vermillion #ff4f2b as a second ink inside the\n * pictures and for a live state. Cells snap to whole device pixels;\n * scenes dither in linear light, photographs on a gentler curve. Funnel Display through\n * var(--font-funnel) for display over Geist; Geist Mono for every glyph.\n * Respects prefers-reduced-motion. No dependencies beyond React.\n * Paste it as its own file: it repeats the kit's small helpers, which would\n * clash in one module. Load Funnel Display with next/font (variable:\n * \"--font-funnel\") on a parent, or from Google Fonts or @fontsource.\n * Needs Tailwind v4 (on v3.4, add the @tailwindcss/container-queries plugin).\n */\n\nconst SANS = 'var(--font-sans, \"Geist\", \"Inter\", ui-sans-serif, system-ui, sans-serif)';\n\nconst MONO = 'var(--font-mono, \"Geist Mono\", ui-monospace, \"SFMono-Regular\", Menlo, Consolas, monospace)';\n\nconst DISPLAY = 'var(--font-funnel, \"Funnel Display\", var(--font-sans, \"Geist\"), ui-sans-serif, system-ui, sans-serif)';\n\n/** One ink on a warm black ground, and one signal colour. */\nconst SHEET = {\n  ground: \"#0b0b0d\",\n  panel: \"#121214\",\n  raised: \"#19191c\",\n  paper: \"#f3f0e6\",\n  ink: \"rgba(243,240,230,0.92)\",\n  ink2: \"rgba(243,240,230,0.6)\",\n  ink3: \"rgba(243,240,230,0.38)\",\n  line: \"rgba(243,240,230,0.08)\",\n  line2: \"rgba(243,240,230,0.16)\",\n  signal: \"#ff4f2b\",\n} as const;\n\nfunction clamp(v: number, lo: number, hi: number): number {\n  return v < lo ? lo : v > hi ? hi : v;\n}\n\n/** Links: strip tabs and newlines, refuse backslashes, allow http(s), mailto, tel and same-site paths. */\nfunction safeHref(raw: string): string {\n  const v = raw.replace(/[\\t\\n\\r]/g, \"\").trim();\n  if (!v || v.includes(\"\\\\\")) return \"#\";\n  if (/^(https?:|mailto:|tel:)/i.test(v)) return v;\n  if (/^[/#?]/.test(v) && !/^\\/\\//.test(v)) return v;\n  return \"#\";\n}\n\nfunction subscribeMotion(cb: () => void) {\n  const m = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n}\n\n/** True when the visitor asked for reduced motion. False on the server. */\nfunction useReducedMotion(): boolean {\n  return useSyncExternalStore(\n    subscribeMotion,\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\n/** A spring for one number; returns the new value and velocity. */\nfunction spring(x: number, v: number, target: number, dt: number, k = 260, c = 26): [number, number] {\n  const steps = dt > 1 / 60 ? 2 : 1;\n  const h = dt / steps;\n  for (let i = 0; i < steps; i++) {\n    v += (k * (target - x) - c * v) * h;\n    x += v * h;\n  }\n  return [x, v];\n}\n\n// Each part carries only the CSS it needs, so any one of them works on its own.\n// Nothing is interpolated into these sheets; colours arrive as CSS variables.\n// revert-layer keeps an element's own rounded corners when a host page's focus rule flattens them.\nconst FOCUS_CSS = \".da-scope :focus-visible,.da-scope:focus-visible{outline:2px solid var(--da-ring,#ff4f2b)!important;outline-offset:3px;border-radius:revert-layer}\";\n\n/** The 8x8 Bayer index of a cell (0-63). Recursive, so every 2x2 and 4x4 block is itself in order. */\nfunction bayer8(x: number, y: number): number {\n  let v = 0;\n  for (let bit = 0; bit < 3; bit++) {\n    const xb = (x >> bit) & 1;\n    const yb = (y >> bit) & 1;\n    v |= (((xb ^ yb) << 1) | yb) << (2 * (2 - bit));\n  }\n  return v;\n}\n\nconst daMaskCache = new Map<number, string>();\n\n/** A mask tile with the first `level` of the 64 Bayer cells opaque: 0 shows nothing, 64 shows everything. */\nfunction daBayerMask(level: number): string {\n  const k = clamp(Math.round(level), 0, 64);\n  const hit = daMaskCache.get(k);\n  if (hit) return hit;\n  let d = \"\";\n  for (let y = 0; y < 8; y++) for (let x = 0; x < 8; x++) if (bayer8(x, y) < k) d += `M${x} ${y}h1v1h-1z`;\n  const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'><path d='${d}'/></svg>`;\n  const url = `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`;\n  daMaskCache.set(k, url);\n  return url;\n}\n\n/** The style that masks an element to a Bayer level, tiled at `px` CSS pixels a cell. */\nfunction daMaskStyle(level: number, px: number): CSSProperties {\n  const m = daBayerMask(level);\n  const s = `${px * 8}px ${px * 8}px`;\n  return { maskImage: m, WebkitMaskImage: m, maskSize: s, WebkitMaskSize: s, maskRepeat: \"repeat\", WebkitMaskRepeat: \"repeat\" };\n}\n\n/**\n * A cell size in CSS pixels snapped to whole device pixels for this element\n * (the screen's pixel ratio times any CSS scale on the way), so every dither\n * cell lands on the pixel grid and never blurs into grey.\n */\nfunction useSnappedCell(ref: RefObject<HTMLElement | null>, cell: number): number {\n  const [px, setPx] = useState(cell);\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    let raf = 0;\n    const measure = () => {\n      const k = el.offsetWidth ? el.getBoundingClientRect().width / el.offsetWidth : 1;\n      const dev = (window.devicePixelRatio || 1) * (k || 1);\n      setPx(Math.max(1, Math.round(cell * dev)) / dev);\n    };\n    const ro = new ResizeObserver(() => {\n      measure();\n      cancelAnimationFrame(raf);\n      raf = requestAnimationFrame(measure);\n    });\n    ro.observe(el);\n    return () => {\n      ro.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [ref, cell]);\n  return px;\n}\n\nconst DA_BUTTON_INK = {\n  signal: { fill: SHEET.signal, text: SHEET.ground, border: SHEET.signal, label: SHEET.paper, rest: 5 },\n  paper: { fill: SHEET.paper, text: SHEET.ground, border: \"rgba(243,240,230,0.5)\", label: SHEET.paper, rest: 5 },\n  ghost: { fill: SHEET.paper, text: SHEET.ground, border: SHEET.line2, label: SHEET.ink, rest: 0 },\n} as const;\n\nexport type DaButtonVariant = keyof typeof DA_BUTTON_INK;\n\n/**\n * BayerFillButton — a button whose fill prints in, cell by cell.\n *\n * At rest a few cells of its ink sit in the face. Hover or focus it and the\n * fill develops through the 8x8 Bayer order to solid in about 260ms (and\n * back out in 360ms), while the label inverts exactly where each cell\n * lands, because the inverted label lives inside the masked fill. Press it\n * and the grid halves to a finer screen and the face drops a pixel. Signal,\n * paper and ghost inks; `lit` holds it filled (a chosen option). CSS masks\n * and a few lines of animation, no canvas.\n */\nexport function BayerFillButton({\n  children,\n  href,\n  onClick,\n  type = \"button\",\n  variant = \"paper\",\n  size = \"lg\",\n  lit = false,\n  disabled = false,\n  ariaLabel,\n  ariaPressed,\n  className = \"\",\n}: {\n  children: ReactNode;\n  href?: string;\n  onClick?: () => void;\n  type?: \"button\" | \"submit\";\n  variant?: DaButtonVariant;\n  size?: \"lg\" | \"md\" | \"sm\";\n  /** Hold it filled, for a chosen option. */\n  lit?: boolean;\n  disabled?: boolean;\n  ariaLabel?: string;\n  ariaPressed?: boolean;\n  className?: string;\n}) {\n  const ink = DA_BUTTON_INK[variant] ?? DA_BUTTON_INK.signal;\n  const rootRef = useRef<HTMLElement | null>(null);\n  const fillRef = useRef<HTMLSpanElement>(null);\n  const reduced = useReducedMotion();\n  const px = useSnappedCell(rootRef, 2);\n  const state = useRef({ level: lit ? 64 : ink.rest, hover: false, focus: false, down: false, raf: 0, last: 0 });\n  const [down, setDown] = useState(false);\n  const litRef = useRef(lit);\n  // The mask React renders never changes after the first render: the loop below owns it from then on.\n  const [firstMask] = useState(() => daMaskStyle(lit ? 64 : ink.rest, 2));\n\n  // One small loop: the level walks toward its target (in 260ms, out 360ms) and the mask follows.\n  const run = () => {\n    const s = state.current;\n    if (s.raf) return;\n    s.last = 0;\n    const tick = (now: number) => {\n      s.raf = 0;\n      const el = fillRef.current;\n      if (!el) return;\n      const dt = s.last ? Math.min(0.05, (now - s.last) / 1000) : 1 / 60;\n      s.last = now;\n      const want = litRef.current || s.hover || s.focus || s.down ? 64 : ink.rest;\n      const rate = want > s.level ? 64 / 0.26 : 64 / 0.36;\n      s.level = reduced ? want : want > s.level ? Math.min(want, s.level + rate * dt) : Math.max(want, s.level - rate * dt);\n      Object.assign(el.style, daMaskStyle(s.level, s.down ? px / 2 : px));\n      if (s.level !== want) s.raf = requestAnimationFrame(tick);\n    };\n    s.raf = requestAnimationFrame(tick);\n  };\n  useEffect(() => {\n    litRef.current = lit;\n    run();\n  });\n  // Cancel on unmount and clear the handle, or a remount (StrictMode does one) would never start the loop again.\n  useEffect(() => {\n    const s = state.current;\n    return () => {\n      cancelAnimationFrame(s.raf);\n      s.raf = 0;\n    };\n  }, []);\n\n  const set = (patch: Partial<{ hover: boolean; focus: boolean; down: boolean }>) => {\n    Object.assign(state.current, patch);\n    if (patch.down !== undefined) setDown(patch.down);\n    run();\n  };\n  const pad = size === \"sm\" ? \"h-8 px-3 text-[12px]\" : size === \"md\" ? \"h-10 px-4 text-[13px]\" : \"h-12 px-6 text-[14px]\";\n  const common = {\n    className:\n      \"da-scope relative isolate inline-flex select-none items-center justify-center overflow-hidden rounded-[10px] font-medium no-underline outline-none transition-transform duration-150 \" +\n      pad +\n      (disabled ? \" pointer-events-none opacity-40 \" : \" \") +\n      className,\n    style: {\n      border: `1px solid ${ink.border}`,\n      color: ink.label,\n      background: SHEET.ground,\n      fontFamily: SANS,\n      letterSpacing: \"0.005em\",\n      transform: down ? \"translateY(1px)\" : undefined,\n    } as CSSProperties,\n    \"aria-label\": ariaLabel,\n    onPointerEnter: () => set({ hover: true }),\n    onPointerLeave: () => set({ hover: false, down: false }),\n    onPointerDown: () => set({ down: true }),\n    onPointerUp: () => set({ down: false }),\n    onPointerCancel: () => set({ down: false }),\n    onFocus: () => set({ focus: true }),\n    onBlur: () => set({ focus: false, down: false }),\n    // Enter activates both; Space activates only a button (a link scrolls on Space), so only then does it press.\n    onKeyDown: (e: ReactKeyboardEvent) => {\n      if (e.key === \"Enter\" || (e.key === \" \" && !href)) set({ down: true });\n    },\n    onKeyUp: () => set({ down: false }),\n  };\n  const face = (\n    <>\n      <span className=\"relative whitespace-nowrap\">{children}</span>\n      <span\n        ref={fillRef}\n        aria-hidden\n        className={\"pointer-events-none absolute inset-0 flex items-center justify-center whitespace-nowrap \" + pad}\n        style={{ background: ink.fill, color: ink.text, ...firstMask }}\n      >\n        {children}\n      </span>\n    </>\n  );\n  if (href) {\n    return (\n      <>\n        <style>{FOCUS_CSS}</style>\n        <a ref={(el) => void (rootRef.current = el)} href={safeHref(href)} onClick={onClick} {...common}>\n          {face}\n        </a>\n      </>\n    );\n  }\n  return (\n    <>\n      <style>{FOCUS_CSS}</style>\n      <button ref={(el) => void (rootRef.current = el)} type={type} onClick={onClick} disabled={disabled} aria-pressed={ariaPressed} {...common}>\n        {face}\n      </button>\n    </>\n  );\n}\n\nexport type DaLink = { label: string; href: string };\n\n/** From empty to full: the ramp the density band is set in. */\nconst DA_RAMP = \" .·:-=+*#%@\";\n\n/**\n * AsciiDensityNav — a nav whose active link is marked by a band of ASCII\n * density that flows between links.\n *\n * Under the links runs a line of mono characters. Around the active link\n * the characters thicken through a ramp (. · : - = + * # % @), densest\n * under its centre, and when another link is chosen the band flows there on\n * a spring, its peak in signal; hovering or focusing a link raises a smaller\n * swell under it. The characters are real text drawn a frame at a time only\n * while something moves. Controlled or not; folds into a menu on narrow\n * containers.\n */\nexport function AsciiDensityNav({\n  brand = \"Dotplane\",\n  links,\n  cta,\n  active,\n  defaultActive,\n  onNavigate,\n  className = \"\",\n  style,\n}: {\n  brand?: string;\n  links: DaLink[];\n  cta?: DaLink | null;\n  /** The active link's href, controlled. */\n  active?: string;\n  defaultActive?: string;\n  onNavigate?: (href: string) => void;\n  className?: string;\n  style?: CSSProperties;\n}) {\n  const [own, setOwn] = useState(defaultActive ?? links[0]?.href ?? \"\");\n  const current = active ?? own;\n  const [open, setOpen] = useState(false);\n  const menuId = useId();\n  const reduced = useReducedMotion();\n  const rowRef = useRef<HTMLDivElement>(null);\n  const baseRef = useRef<HTMLSpanElement>(null);\n  const hotRef = useRef<HTMLSpanElement>(null);\n  const menuBtn = useRef<HTMLButtonElement>(null);\n  const panelRef = useRef<HTMLDivElement>(null);\n  const linkRefs = useRef<(HTMLAnchorElement | null)[]>([]);\n  const band = useRef({ x: -1, v: 0, w: 60, hx: -1, hw: 0, ha: 0, raf: 0, last: 0, chars: 0, cw: 7.2 });\n  const [hover, setHover] = useState(-1);\n  const idx = Math.max(0, links.findIndex((l) => l.href === current));\n\n  // Draws the band: each character's density is a Gaussian around the active link, plus the hover swell.\n  useEffect(() => {\n    const row = rowRef.current;\n    const base = baseRef.current;\n    const hot = hotRef.current;\n    if (!row || !base || !hot) return;\n    const b = band.current;\n    const target = () => {\n      const a = linkRefs.current[idx];\n      const h = hover >= 0 ? linkRefs.current[hover] : null;\n      const r0 = row.getBoundingClientRect();\n      const k = row.offsetWidth ? r0.width / row.offsetWidth : 1;\n      const at = (el: HTMLElement | null) => {\n        if (!el) return null;\n        const r = el.getBoundingClientRect();\n        return { x: (r.left - r0.left + r.width / 2) / k, w: r.width / k };\n      };\n      return { a: at(a), h: at(h) };\n    };\n    const draw = () => {\n      let s = \"\";\n      let peak = \"\";\n      for (let i = 0; i < b.chars; i++) {\n        const x = (i + 0.5) * b.cw;\n        const da = (x - b.x) / (b.w * 0.42);\n        const dh = (x - b.hx) / Math.max(1, b.hw * 0.3);\n        const v = Math.min(1, 0.06 + Math.exp(-da * da) + b.ha * 0.55 * Math.exp(-dh * dh));\n        const c = DA_RAMP[Math.min(DA_RAMP.length - 1, Math.floor(v * (DA_RAMP.length - 0.01)))];\n        s += c;\n        peak += v > 0.86 ? c : \" \";\n      }\n      base.textContent = s;\n      hot.textContent = peak;\n    };\n    const tick = (now: number) => {\n      b.raf = 0;\n      const dt = b.last ? Math.min(0.05, (now - b.last) / 1000) : 1 / 60;\n      b.last = now;\n      const t = target();\n      let busy = false;\n      if (t.a) {\n        if (b.x < 0 || reduced) {\n          b.x = t.a.x;\n          b.w = t.a.w;\n        } else {\n          [b.x, b.v] = spring(b.x, b.v, t.a.x, dt, 170, 22);\n          b.w += (t.a.w - b.w) * (1 - Math.exp(-dt * 10));\n          busy = Math.abs(t.a.x - b.x) > 0.3 || Math.abs(b.v) > 0.5;\n        }\n      }\n      const want = t.h ? 1 : 0;\n      if (t.h) {\n        b.hx = t.h.x;\n        b.hw = t.h.w;\n      }\n      b.ha = reduced ? want : b.ha + (want - b.ha) * (1 - Math.exp(-dt * 12));\n      if (Math.abs(want - b.ha) > 0.01) busy = true;\n      draw();\n      if (busy) b.raf = requestAnimationFrame(tick);\n      else b.last = 0;\n    };\n    const measure = () => {\n      const probe = document.createElement(\"span\");\n      probe.textContent = \"0000000000\";\n      probe.style.cssText = \"position:absolute;visibility:hidden;white-space:pre;font:inherit;letter-spacing:inherit\";\n      base.parentElement?.appendChild(probe);\n      b.cw = probe.getBoundingClientRect().width / 10 / (row.offsetWidth ? row.getBoundingClientRect().width / row.offsetWidth : 1) || 7.2;\n      probe.remove();\n      b.chars = Math.max(0, Math.floor(row.offsetWidth / b.cw));\n      if (!b.raf) b.raf = requestAnimationFrame(tick);\n    };\n    const ro = new ResizeObserver(measure);\n    ro.observe(row);\n    if (!b.raf) b.raf = requestAnimationFrame(tick);\n    return () => {\n      ro.disconnect();\n      cancelAnimationFrame(b.raf);\n      b.raf = 0;\n    };\n  }, [idx, hover, reduced, links.length]);\n\n  // The menu closes on Escape (focus back to its button) and on a click outside.\n  useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setOpen(false);\n        menuBtn.current?.focus();\n      }\n    };\n    const onDown = (e: PointerEvent) => {\n      const t = e.target as Node;\n      if (!panelRef.current?.contains(t) && !menuBtn.current?.contains(t)) setOpen(false);\n    };\n    document.addEventListener(\"keydown\", onKey);\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      document.removeEventListener(\"pointerdown\", onDown);\n    };\n  }, [open]);\n\n  const go = (href: string) => {\n    if (active === undefined) setOwn(href);\n    onNavigate?.(href);\n    setOpen(false);\n  };\n\n  return (\n    <header className={\"da-scope relative w-full @container \" + className} style={{ fontFamily: SANS, color: SHEET.ink, ...style }}>\n      <style>{FOCUS_CSS}</style>\n      <nav\n        aria-label=\"Main\"\n        className=\"flex h-16 items-center gap-6 px-5 @3xl:px-8\"\n        style={{ background: \"rgba(11,11,13,0.82)\", backdropFilter: \"blur(12px)\", WebkitBackdropFilter: \"blur(12px)\", borderBottom: `1px solid ${SHEET.line}` }}\n      >\n        <a href={safeHref(links[0]?.href ?? \"#\")} className=\"flex shrink-0 items-center gap-2.5 no-underline\" style={{ color: SHEET.paper }} onClick={() => go(links[0]?.href ?? \"#\")}>\n          <span aria-hidden className=\"grid h-[18px] w-[18px] grid-cols-3 gap-[2px]\">\n            {[1, 0, 1, 0, 1, 0, 1, 0, 1].map((on, i) => (\n              <span key={i} style={{ background: on ? (i === 4 ? SHEET.signal : SHEET.paper) : \"transparent\" }} />\n            ))}\n          </span>\n          <span className=\"text-[16px] font-semibold\" style={{ fontFamily: DISPLAY, letterSpacing: \"-0.02em\" }}>\n            {brand}\n          </span>\n        </a>\n        <div ref={rowRef} className=\"relative mx-auto hidden h-full min-w-0 flex-1 @3xl:block\">\n          <ul className=\"m-0 flex h-full list-none items-center justify-center gap-1 p-0\">\n            {links.map((l, i) => (\n              <li key={l.href}>\n                <a\n                  ref={(el) => void (linkRefs.current[i] = el)}\n                  href={safeHref(l.href)}\n                  aria-current={l.href === current ? \"page\" : undefined}\n                  onClick={() => go(l.href)}\n                  onPointerEnter={() => setHover(i)}\n                  onPointerLeave={() => setHover(-1)}\n                  onFocus={() => setHover(i)}\n                  onBlur={() => setHover(-1)}\n                  className=\"relative block rounded-[8px] px-3.5 py-2 text-[13.5px] no-underline transition-colors duration-200\"\n                  style={{ color: l.href === current ? SHEET.paper : SHEET.ink2 }}\n                >\n                  {l.label}\n                </a>\n              </li>\n            ))}\n          </ul>\n          <span\n            aria-hidden\n            className=\"pointer-events-none absolute inset-x-0 bottom-[7px] block overflow-hidden whitespace-pre text-[11px] leading-none\"\n            style={{ fontFamily: MONO, letterSpacing: \"0.04em\", color: SHEET.ink3 }}\n          >\n            <span ref={baseRef} className=\"block\" />\n            <span ref={hotRef} className=\"absolute inset-0 block\" style={{ color: SHEET.signal }} />\n          </span>\n        </div>\n        <div className=\"ml-auto flex shrink-0 items-center gap-2 @3xl:ml-0\">\n          {cta ? (\n            <BayerFillButton href={cta.href} size=\"md\" variant=\"paper\" onClick={() => go(cta.href)}>\n              {cta.label}\n            </BayerFillButton>\n          ) : null}\n          <button\n            ref={menuBtn}\n            type=\"button\"\n            aria-expanded={open}\n            aria-controls={menuId}\n            onClick={() => setOpen((v) => !v)}\n            className=\"grid h-10 w-10 place-items-center rounded-[10px] @3xl:hidden\"\n            style={{ border: `1px solid ${SHEET.line2}`, background: \"transparent\", color: SHEET.paper }}\n          >\n            <span className=\"sr-only\">Menu</span>\n            <span aria-hidden className=\"text-[13px]\" style={{ fontFamily: MONO }}>\n              {open ? \"×\" : \"≡\"}\n            </span>\n          </button>\n        </div>\n      </nav>\n      {open ? (\n        <div ref={panelRef} id={menuId} className=\"absolute inset-x-3 top-[68px] z-20 rounded-[14px] p-2 @3xl:hidden\" style={{ background: SHEET.panel, border: `1px solid ${SHEET.line2}` }}>\n          <ul className=\"m-0 list-none p-0\">\n            {links.map((l) => (\n              <li key={l.href}>\n                <a\n                  href={safeHref(l.href)}\n                  aria-current={l.href === current ? \"page\" : undefined}\n                  onClick={() => go(l.href)}\n                  className=\"flex items-center justify-between rounded-[10px] px-3 py-2.5 text-[15px] no-underline\"\n                  style={{ color: l.href === current ? SHEET.paper : SHEET.ink2 }}\n                >\n                  {l.label}\n                  <span aria-hidden className=\"text-[11px]\" style={{ fontFamily: MONO, color: l.href === current ? SHEET.signal : SHEET.ink3 }}>\n                    {l.href === current ? \"#%@\" : \".:-\"}\n                  </span>\n                </a>\n              </li>\n            ))}\n          </ul>\n        </div>\n      ) : null}\n    </header>\n  );\n}\n","type":"registry:component","target":"components/viberdy/ascii-density-nav.tsx"}],"meta":{"tier":"free","tags":["navigation","navbar","ascii","indicator","spring","scroll spy"],"href":"https://viberdy.dev/library/ascii-density-nav","aiPrompt":"Build a React + Tailwind nav, `AsciiDensityNav({ brand, links, cta, active, defaultActive, onNavigate, className, style })`.\n\nFrom @3xl, the links sit centred in a row; under them, an aria-hidden line of 11px mono characters as wide as the row (measure the advance with a ten-character probe). Each character's density is 0.06 + exp(-((x - bandX) / (0.42 x bandWidth))^2) plus a hover swell 0.55 x exp(-((x - hoverX) / (0.3 x hoverWidth))^2), mapped onto the ramp \" .·:-=+*#%@\"; a second copy of the line shows only the characters above 0.86, in signal. bandX follows the active link's centre on a spring (stiffness 170, damping 22) and bandWidth eases to its width; the line is rewritten in a requestAnimationFrame loop that stops when settled. A brand mark (a 3x3 grid of cells, the centre in signal), the kit's BayerFillButton as the call to action, and below @3xl a Menu disclosure (Escape and outside click close it). A dark bar at 82% with a 12px backdrop blur and a hairline.\n\nDither & ASCII grammar: a warm black ground #0b0b0d (panels #121214, raised #19191c), one ink, paper #f3f0e6 (text at 92/60/38%, hairlines at 8% and 16%), and one signal colour, vermillion #ff4f2b, used as a second ink inside the pictures (the sun, a glint, a ball, a newly lit dot, a wordmark) and for a live state confined to a small mark (a square that lights, a peak character), never as a panel fill; a primary control's ink is paper, with signal kept for a momentary action. Every picture is computed and printed on purpose: rendered scenes dither in linear light and photographs on a gentler 1.5 curve so their midtones stay full, cells snap to whole device pixels (never blurred into grey), the 8x8 Bayer matrix for anything CSS, 64x64 void-and-cluster blue noise for the signature pictures, true error diffusion only on the CPU. Type stays crisp and undithered: Funnel Display through var(--font-funnel, \"Funnel Display\", ...) at 600-700 with -0.035em tracking for display, Geist for reading, Geist Mono uppercase with +0.14em tracking for labels and for every glyph an ASCII transform draws. Radii 10px controls, 14px cards, 18px panels. Motion: a transform change dissolves through blue noise in ~450ms, a fill prints in Bayer order in ~260ms and out in ~360ms, pictures print in on first view over ~900ms, ambient scenes loop over 30s or more. Respect prefers-reduced-motion (the picture still, changes instant). No dependencies beyond React.","license":"https://viberdy.dev/license"}}