{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"dusk-set-footer","type":"registry:component","title":"Dusk Set Footer","description":"A footer that sets like the sun: as it scrolls in, a grained halo sinks toward a hairline horizon, warming from gold through rose to ember, behind a giant italic serif wordmark.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/dusk-set-footer.tsx","content":"\"use client\";\n\nimport { createContext, useContext, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, RefObject } from \"react\";\n\n/**\n * DuskFooter — a footer that sets like the sun.\n *\n * As it scrolls into view, a grained halo sinks from high in the jade room\n * toward a hairline horizon, warming from gold through rose to ember,\n * while the room above takes a faint rose wash; the brand stands on the\n * horizon in a giant italic serif, lit from behind where the sun is.\n * Scroll drives it and nothing loops; under reduced motion the sun rests\n * low.\n *\n * Part of the Diffused Glow kit: a warm bone day (#f6f1e6) and a jade room\n * (#0b120f); soft, grained halos in gold, rose or jade (or any #rrggbb), at\n * most two per view; a serif through var(--font-serif) over Geist. Respects\n * prefers-reduced-motion. No dependencies beyond React. Paste it as its own\n * file: it repeats the kit's small helpers, which would clash in one module.\n * For the serif, load Fraunces with next/font (variable: \"--font-serif\") on a parent.\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 SERIF = 'var(--font-serif, \"Fraunces\", \"Iowan Old Style\", \"Palatino Linotype\", Georgia, serif)';\n\nconst HEX = /^#[0-9a-fA-F]{6}$/;\n\n/** The two grounds the kit is set on: the warm day and the jade room. */\nconst TONES = {\n  day: {\n    ground: \"#f6f1e6\",\n    panel: \"#efe7d6\",\n    raised: \"#fbf8f1\",\n    ink: \"rgba(34,31,26,0.92)\",\n    ink2: \"rgba(34,31,26,0.58)\",\n    ink3: \"rgba(34,31,26,0.4)\",\n    line: \"rgba(34,31,26,0.09)\",\n    line2: \"rgba(34,31,26,0.18)\",\n    shadow: \"0 30px 80px -20px rgba(40,30,10,0.14)\",\n  },\n  jewel: {\n    ground: \"#0b120f\",\n    panel: \"#101c17\",\n    raised: \"#16261f\",\n    ink: \"rgba(243,237,226,0.94)\",\n    ink2: \"rgba(243,237,226,0.63)\",\n    ink3: \"rgba(243,237,226,0.4)\",\n    line: \"rgba(243,237,226,0.08)\",\n    line2: \"rgba(243,237,226,0.16)\",\n    shadow: \"0 40px 100px -24px rgba(0,0,0,0.5)\",\n  },\n} as const;\n\n/** The bronze accent, used only as light. */\nconst BRONZE = \"#c9a15e\";\n\n/** The one filled action in the kit: booking. */\nconst JADE_FILL = \"#2f6f57\";\n\n/** Halo colours. Gold and rose belong to the jade room; jade is the day's own light. */\nexport const DG_GLOWS = {\n  gold: \"#f5c48c\",\n  rose: \"#f2a39a\",\n  jade: \"#bcd9c8\",\n} as const;\n\nfunction own<T extends object>(map: T, key: string): key is Extract<keyof T, string> {\n  return Object.prototype.hasOwnProperty.call(map, key);\n}\n\n/** A named glow or a #rrggbb; anything else falls back to gold. */\nfunction glowHex(value: string): string {\n  if (own(DG_GLOWS, value)) return DG_GLOWS[value];\n  return HEX.test(value) ? value : DG_GLOWS.gold;\n}\n\nfunction rgbOf(hex: string): [number, number, number] {\n  const n = parseInt(hex.slice(1), 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\n/**\n * Grain as an SVG turbulence tile. It is only ever laid inside a light (masked\n * to the halo's shape), never over the whole page: grain belongs to the glow.\n */\nconst GRAIN_URL = `url(\"data:image/svg+xml,${encodeURIComponent(\n  \"<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0'/></filter><rect width='160' height='160' filter='url(#g)'/></svg>\",\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/** The element that scrolls: null for the window, or the site itself in \"self\" mode. */\nconst ScrollRootContext = createContext<RefObject<HTMLElement | null> | null>(null);\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 = \".dg-scope :focus-visible,.dg-scope:focus-visible{outline:2px solid var(--dg-ring);outline-offset:3px;border-radius:revert-layer}\";\n\n/** The focus ring colour for a ground: bronze light on the jade room, jade on the day. */\nfunction ringVar(tone: string): CSSProperties {\n  return { \"--dg-ring\": tone === \"jewel\" ? BRONZE : JADE_FILL } as CSSProperties;\n}\n\nexport type DgLink = { label: string; href: string };\n\n/** Blend two #rrggbb colours. */\nfunction mixHex(a: string, b: string, k: number): string {\n  const x = rgbOf(a);\n  const y = rgbOf(b);\n  const c = x.map((v, i) => Math.round(v + (y[i] - v) * k));\n  return `rgb(${c[0]},${c[1]},${c[2]})`;\n}\n\nexport type DuskFooterProps = {\n  brand: string;\n  line?: string;\n  columns: { title: string; lines: (string | DgLink)[] }[];\n  legal?: string;\n  /** The sun's colour at the start of the set, and at dusk. */\n  glow?: string;\n  dusk?: string;\n  className?: string;\n};\n\n/**\n * A footer that sets like the sun. As it scrolls into view, a grained halo\n * sinks from high in the jade room toward a hairline horizon, warming from\n * gold through rose to ember, while the room above takes a faint rose wash.\n * On the horizon stands the brand in a giant italic serif, lit from behind\n * where the sun is. Scroll drives it (nothing loops), and under reduced\n * motion the sun simply rests low.\n */\nexport function DuskFooter({ brand, line, columns, legal, glow = \"gold\", dusk = \"#c9705f\", className }: DuskFooterProps) {\n  const t = TONES.jewel;\n  const reduced = useReducedMotion();\n  const rootRef = useContext(ScrollRootContext);\n  const ref = useRef<HTMLElement>(null);\n  const a = glowHex(glow);\n  const b = glowHex(dusk);\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const scroller: HTMLElement | Window = rootRef?.current ?? window;\n    let raf = 0;\n    const paint = () => {\n      raf = 0;\n      let p = 0.72;\n      if (!reduced) {\n        const r = el.getBoundingClientRect();\n        const top = scroller instanceof Window ? 0 : scroller.getBoundingClientRect().top;\n        const vh = scroller instanceof Window ? window.innerHeight : scroller.clientHeight;\n        // 0 as the footer's top enters, 1 once its bottom is in view.\n        p = Math.max(0, Math.min(1, (vh - (r.top - top)) / Math.max(1, Math.min(r.height, vh))));\n      }\n      const e = p * p * (3 - 2 * p);\n      el.style.setProperty(\"--sy\", `${(30 + e * 56).toFixed(2)}%`);\n      el.style.setProperty(\"--ss\", (1 + e * 0.18).toFixed(3));\n      el.style.setProperty(\"--sun\", e < 0.5 ? mixHex(a, \"#f2a39a\", e * 2) : mixHex(\"#f2a39a\", b, (e - 0.5) * 2));\n      el.style.setProperty(\"--wash\", (e * 0.22).toFixed(3));\n    };\n    const onScroll = () => {\n      if (!raf) raf = requestAnimationFrame(paint);\n    };\n    paint();\n    // Capture, so a scroll anywhere (the window, the site's own scroller, any container it sits in) moves the sun.\n    document.addEventListener(\"scroll\", onScroll, { passive: true, capture: true });\n    window.addEventListener(\"resize\", onScroll);\n    return () => {\n      cancelAnimationFrame(raf);\n      document.removeEventListener(\"scroll\", onScroll, { capture: true });\n      window.removeEventListener(\"resize\", onScroll);\n    };\n  }, [reduced, rootRef, a, b]);\n\n  return (\n    <footer\n      ref={ref}\n      className={\"dg-scope @container relative isolate w-full overflow-hidden\" + (className ? \" \" + className : \"\")}\n      style={{ ...ringVar(\"jewel\"), \"--sy\": \"30%\", \"--ss\": \"1\", \"--sun\": a, \"--wash\": \"0\", background: t.ground, color: t.ink, fontFamily: SANS } as CSSProperties}\n    >\n      <style>{FOCUS_CSS}</style>\n      {/* Dusk: a rose wash over the upper room. */}\n      <div aria-hidden className=\"pointer-events-none absolute inset-0\" style={{ background: \"linear-gradient(180deg, rgba(242,163,154,1), rgba(242,163,154,0) 70%)\", opacity: \"var(--wash)\" }} />\n      {/* The sun, grained, setting toward the horizon. */}\n      <div aria-hidden className=\"pointer-events-none absolute left-1/2 h-[120cqw] w-[120cqw] max-h-[1200px] max-w-[1200px]\" style={{ top: \"var(--sy)\", transform: \"translate(-50%,-50%) scale(var(--ss))\" }}>\n        <span className=\"absolute inset-0 rounded-full\" style={{ background: \"radial-gradient(closest-side, var(--sun), transparent 62%)\", opacity: 0.55 }} />\n        <span\n          className=\"absolute inset-0 rounded-full\"\n          style={{ backgroundImage: GRAIN_URL, mixBlendMode: \"overlay\", opacity: 0.55, WebkitMaskImage: \"radial-gradient(closest-side, #000, transparent 60%)\", maskImage: \"radial-gradient(closest-side, #000, transparent 60%)\" }}\n        />\n      </div>\n      <div className=\"relative mx-auto max-w-[1240px] px-6 pt-24 @3xl:px-12\">\n        <div className=\"grid grid-cols-2 gap-x-6 gap-y-10 @3xl:grid-cols-[1.4fr_repeat(3,1fr)]\">\n          <div className=\"col-span-2 @3xl:col-span-1\">\n            <p className=\"m-0 text-[26px] italic\" style={{ fontFamily: SERIF, fontWeight: 360 }}>\n              {brand}\n            </p>\n            {line && (\n              <p className=\"mt-3 max-w-[30ch] text-[14.5px] leading-[1.6]\" style={{ color: t.ink2 }}>\n                {line}\n              </p>\n            )}\n          </div>\n          {columns.map((c) => (\n            <div key={c.title}>\n              <p className=\"m-0 text-[11px] uppercase tracking-[0.18em]\" style={{ fontFamily: MONO, color: t.ink3 }}>\n                {c.title}\n              </p>\n              <ul className=\"m-0 mt-4 list-none space-y-2 p-0\">\n                {c.lines.map((l) =>\n                  typeof l === \"string\" ? (\n                    <li key={l} className=\"text-[14.5px]\" style={{ color: t.ink2 }}>\n                      {l}\n                    </li>\n                  ) : (\n                    <li key={l.label}>\n                      <a href={safeHref(l.href)} className=\"text-[14.5px] transition-colors hover:text-[#f3ede2]\" style={{ color: t.ink2 }}>\n                        {l.label}\n                      </a>\n                    </li>\n                  ),\n                )}\n              </ul>\n            </div>\n          ))}\n        </div>\n      </div>\n      {/* The brand on the horizon, lit from behind where the sun is. */}\n      <div aria-hidden className=\"relative mt-16 select-none\">\n        <p\n          className=\"m-0 text-center italic leading-[0.82]\"\n          style={{\n            fontFamily: SERIF,\n            fontWeight: 340,\n            fontSize: \"clamp(96px, 24cqw, 360px)\",\n            letterSpacing: \"-0.03em\",\n            color: \"transparent\",\n            backgroundImage: \"radial-gradient(40% 90% at 50% 100%, var(--sun), rgba(243,237,226,0.18) 60%, rgba(243,237,226,0.08))\",\n            WebkitBackgroundClip: \"text\",\n            backgroundClip: \"text\",\n          }}\n        >\n          {brand}\n        </p>\n        <div className=\"h-px w-full\" style={{ background: \"linear-gradient(90deg, transparent, var(--sun) 50%, transparent)\", opacity: 0.6 }} />\n      </div>\n      {legal && (\n        <p className=\"relative m-0 mx-auto max-w-[1240px] px-6 py-6 text-[12px] @3xl:px-12\" style={{ fontFamily: MONO, color: t.ink3 }}>\n          {legal}\n        </p>\n      )}\n    </footer>\n  );\n}\n","type":"registry:component","target":"components/viberdy/dusk-set-footer.tsx"}],"meta":{"tier":"free","tags":["footer","scroll","sunset","glow","grain","wordmark","serif","spa"],"href":"https://viberdy.dev/library/dusk-set-footer","aiPrompt":"Build a React + Tailwind footer, `DuskFooter({ brand, line, columns, legal, glow, dusk })`, that sets like the sun as it scrolls in.\n\nA jade-room footer (@container, isolate, overflow hidden). Progress p = 0 as its top enters the viewport (or the scroll container from context) and 1 once its bottom is in view, smoothed with smoothstep; recompute in a rAF on every scroll event (listen on document in the capture phase so nested scrollers count) and on resize. Write --sy (30% to 86%, the sun's top), --ss (1 to 1.18), --sun (gold to rose #f2a39a over the first half, rose to ember #c9705f over the second) and --wash (0 to 0.22). Layers: a rose linear wash at opacity var(--wash); a 120cqw circle centred on --sy (translate -50%, scale var(--ss); avoid Tailwind translate utilities, which set a separate property) with a closest-side radial in var(--sun) and a masked grain tile. Content: the brand in italic serif, a line, columns of strings or links in mono-titled lists. Then the brand in a giant italic serif (clamp(96px, 24cqw, 360px), 0.82 leading) with background-clip text lit by a radial in var(--sun) at its base, a hairline horizon in var(--sun), and a mono legal line. Reduced motion: p fixed low.\n\nDiffused Glow grammar: two grounds, a warm bone day (#f6f1e6; panels #efe7d6, raised #fbf8f1; ink #221f1a at 92/58/40%; hairlines at 9% and 18%) and a near-black jade room (#0b120f; panels #101c17 and #16261f; ink #f3ede2 at 94/63/40%). Light is soft and grained: halos in gold #f5c48c, rose #f2a39a and, on the day ground, jade #bcd9c8 (or any #rrggbb validated against /^#[0-9a-fA-F]{6}$/), never more than two per view, each a wide gaussian skirt with a warmer core, and the grain lives inside the light (an SVG feTurbulence tile masked to the halo, or noise in the shader), never as a page overlay. In the jade room light is added (screen blend); on the day ground it pools as colour (the paper takes the tint). One bronze accent #c9a15e used as light and one jade fill #2f6f57 kept for the booking action; one filled action per view. A serif (Fraunces by default, through var(--font-serif, \"Fraunces\", Georgia, serif)) at 340-400 for display with 0.98-1.04 leading and *italic* accents, over Geist for UI and Geist Mono uppercase captions. Radii 24-28px on panels, pills for controls; feathered shadows only. Motion is slow: halos breathe on about 10s, drift on 36s or longer and settle toward the pointer over about 900ms (1 - e^(-3dt)); resolves run 700-1100ms out of a blur on cubic-bezier(0.16, 1, 0.3, 1); hovers under 450ms. Keyframes and a focus ring (a .dg-scope rule with border-radius: revert-layer) live in a small static <style> the component renders itself; nothing is interpolated into it. Respect prefers-reduced-motion. No dependencies beyond React.","license":"https://viberdy.dev/license"}}