{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"spindrift-footer","type":"registry:component","title":"Spindrift Footer","description":"A footer that sets the name edge to edge and lets the wind take sand off the top of every letter, the way spindrift streams off a dune crest.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/spindrift-footer.tsx","content":"\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\n\n/**\n * SPINDRIFT FOOTER.\n * A footer that sets the name edge to edge and lets the wind take sand off the\n * top of every letter, the way spindrift streams off a dune crest.\n *\n * FONTS. Archivo with its width axis for display, Instrument Serif italic for\n * the accent word, Geist Mono for labels. In Next: Archivo({ subsets:\n * [\"latin\"], axes: [\"wdth\"], variable: \"--font-ae\" }), Instrument_Serif({\n * subsets: [\"latin\"], weight: \"400\", style: \"italic\", variable:\n * \"--font-ae-serif\" }) and Geist_Mono({ subsets: [\"latin\"], variable:\n * \"--font-ae-mono\" }) on <html>. Without them it falls back to system fonts.\n *\n * CLIENT. The file starts with \"use client\".\n *\n * WIND. Every Aeolian entry reads one page-wide wind (aeWind on globalThis),\n * so separately pasted entries still turn together.\n */\n\n/** The deepest ground: dusk, the footer. */\nconst AE_NIGHT = \"#150E0A\";\n\n/** Ink on the light grounds. */\nconst AE_UMBER = \"#2B1B12\";\n\n/** Lit sand: marks on the night ground. */\nconst AE_SAND = \"#DDAA72\";\n\n/** The pale ground, and the colour a sandstorm turns everything. */\nconst AE_HAZE = \"#EFE2CD\";\n\n/**\n * The display face: Archivo, wide and light. Set its width with font-stretch\n * (112.5% or 125%), not font-variation-settings, so a canvas can paint the\n * same instance. In Next: Archivo({ subsets: [\"latin\"], axes: [\"wdth\"], variable: \"--font-ae\" }).\n */\nconst AE_DISPLAY = 'var(--font-ae, var(--font-display, \"Archivo\")), \"Archivo\", ui-sans-serif, system-ui, sans-serif';\n\n/** Labels and readouts. */\nconst AE_MONO = 'var(--font-ae-mono, var(--font-geist-mono, \"Geist Mono\")), \"Geist Mono\", ui-monospace, \"SFMono-Regular\", Menlo, monospace';\n\nconst aeReducedSnap = () => typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n/**\n * The scrolling box an element lives in: the nearest ancestor that actually\n * scrolls, or null for the window. Resolved on every frame, because a box only\n * becomes a scroller once its content is taller than it.\n */\nfunction aeScrollParent(el: Element | null): HTMLElement | null {\n  let n = el?.parentElement ?? null;\n  while (n && n !== document.body && n !== document.documentElement) {\n    const oy = getComputedStyle(n).overflowY;\n    if ((oy === \"auto\" || oy === \"scroll\" || oy === \"overlay\") && n.scrollHeight > n.clientHeight + 1) return n;\n    n = n.parentElement;\n  }\n  return null;\n}\n\n/** Links built from props: https, http, mailto, same-site paths and anchors only (tabs and newlines stripped, backslashes refused). */\nfunction aeSafeHref(href: string): string {\n  const h = href.replace(/[\\t\\n\\r]/g, \"\").trim();\n  if (!h || h.includes(String.fromCharCode(92))) return \"#\";\n  if (h.startsWith(\"#\") || (h.startsWith(\"/\") && !h.startsWith(\"//\"))) return h;\n  return /^(https?:|mailto:|tel:)/i.test(h) ? h : \"#\";\n}\n\n/** Scroll whatever scrolls the link to a same-page anchor ([data-ae-anchor]); anything else is left to the browser. */\nfunction aeGo(e: { currentTarget: HTMLAnchorElement; preventDefault: () => void }) {\n  const href = e.currentTarget.getAttribute(\"href\") ?? \"\";\n  if (!href.startsWith(\"#\") || href.length < 2) return;\n  const root = e.currentTarget.closest(\"[data-ae-site]\") ?? document;\n  const target = root.querySelector<HTMLElement>('[data-ae-anchor=\"' + CSS.escape(href.slice(1)) + '\"]');\n  if (!target) return;\n  e.preventDefault();\n  const sp = aeScrollParent(target);\n  const smooth: ScrollBehavior = aeReducedSnap() ? \"auto\" : \"smooth\";\n  if (sp) sp.scrollTo({ top: sp.scrollTop + target.getBoundingClientRect().top - sp.getBoundingClientRect().top, behavior: smooth });\n  else window.scrollTo({ top: window.scrollY + target.getBoundingClientRect().top, behavior: smooth });\n}\n\n/**\n * The kit's scoped CSS: one focus ring (2px, offset 3px, sand on night and\n * umber on haze), tabular figures, the press, and transitions off for\n * anything a frame loop writes.\n */\nconst AE_CSS =\n  \".ae-scope{--ae-ring:\" + AE_SAND + \"}\" +\n  \".ae-scope[data-ae-ground=haze],.ae-scope [data-ae-ground=haze]{--ae-ring:\" + AE_UMBER + \"}\" +\n  \".ae-scope :focus-visible{outline:2px solid var(--ae-ring)!important;outline-offset:3px!important}\" +\n  \".ae-scope .ae-num{font-variant-numeric:tabular-nums}\" +\n  \".ae-scope [data-ae-live]{transition:none!important}\" +\n  \".ae-scope .ae-press{transition:transform 180ms cubic-bezier(.2,.8,.2,1),background-color 180ms,color 180ms,border-color 180ms}\" +\n  \".ae-scope .ae-press:active{transform:scale(.97)}\" +\n  \".ae-scope .ae-arr{transition:transform 240ms cubic-bezier(.2,.8,.2,1)}.ae-scope a:hover .ae-arr,.ae-scope button:hover .ae-arr{transform:translateX(3px)}\" +\n  \"@media (prefers-reduced-motion:reduce){.ae-scope .ae-press,.ae-scope .ae-arr{transition:none}}\";\n\n/** Barchan's mark: a crescent dune seen from above, horns downwind. Takes the current colour. */\nfunction AeMark({ size = 22 }: { size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden>\n      <path d=\"M3 5.5C9.5 5.2 14.6 7.6 17 12c-2.4 4.4-7.5 6.8-14 6.5 4.6-1.6 7-3.9 7-6.5S7.6 7.1 3 5.5Z\" fill=\"currentColor\" />\n      <path d=\"M17 12c1.6-.2 2.9-.9 4-2.1-.4 1.6-.4 2.6 0 4.2-1.1-1.2-2.4-1.9-4-2.1Z\" fill=\"currentColor\" opacity=\".55\" />\n    </svg>\n  );\n}\n\n/**\n * The page's wind. `angle` is the way it blows TOWARD, in degrees on the\n * ground: 0 = to the right (east), 90 = away from you (north), 180 = left,\n * 270 = toward you. `speed` is in km/h. The dune stage, the grains, the dust\n * of every dissolve, the nav's vane and the footer all read this one store,\n * so turning the rose in the hero turns every grain on the page. It lives on\n * globalThis, so entries pasted as separate files still share one wind.\n */\nconst aeWind: { angle: number; speed: number; subs: Set<() => void> } = ((globalThis as unknown as { __aeolianWind?: { angle: number; speed: number; subs: Set<() => void> } }).__aeolianWind ??= { angle: 55, speed: 30, subs: new Set() });\n\n/**\n * The wind as a direction on a flat screen: x right, y down. Wind blowing\n * away from you reads as rising, toward you as falling, a little flattened\n * (the ground is seen at a low angle). Unit length.\n */\nfunction aeWindScreen(angle = aeWind.angle): [number, number] {\n  const a = (angle * Math.PI) / 180;\n  const x = Math.cos(a);\n  const y = -Math.sin(a) * 0.55;\n  const l = Math.hypot(x, y) || 1;\n  return [x / l, y / l];\n}\n\ninterface AeRaster {\n  canvas: HTMLCanvasElement;\n  /** The element's layout size in CSS pixels (unscaled by any transform above it). */\n  w: number;\n  h: number;\n  /** Resolves once inline SVGs (decoded as images) are painted in too. */\n  ready: Promise<void>;\n}\n\nconst AE_STRETCH: Record<string, string> = {\n  \"50%\": \"ultra-condensed\",\n  \"62.5%\": \"extra-condensed\",\n  \"75%\": \"condensed\",\n  \"87.5%\": \"semi-condensed\",\n  \"100%\": \"normal\",\n  \"112.5%\": \"semi-expanded\",\n  \"125%\": \"expanded\",\n  \"150%\": \"extra-expanded\",\n  \"200%\": \"ultra-expanded\",\n};\n\nfunction aeAlpha(color: string): number {\n  if (!color || color === \"transparent\") return 0;\n  const m = color.match(/rgba?\\(([^)]+)\\)/);\n  if (!m || !m[1]) return 1;\n  const parts = m[1].split(/[\\s,/]+/).filter(Boolean);\n  return parts.length > 3 ? parseFloat(parts[3] ?? \"1\") : 1;\n}\n\nfunction aeRadius(v: string, w: number, h: number): number {\n  const n = parseFloat(v) || 0;\n  return v.trim().endsWith(\"%\") ? (n / 100) * Math.min(w, h) : n;\n}\n\nfunction aeRoundRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: [number, number, number, number]) {\n  const m = Math.min(w, h) / 2;\n  const [a, b, c, d] = r.map((v) => Math.max(0, Math.min(v, m))) as [number, number, number, number];\n  ctx.beginPath();\n  ctx.moveTo(x + a, y);\n  ctx.lineTo(x + w - b, y);\n  ctx.arcTo(x + w, y, x + w, y + b, b);\n  ctx.lineTo(x + w, y + h - c);\n  ctx.arcTo(x + w, y + h, x + w - c, y + h, c);\n  ctx.lineTo(x + d, y + h);\n  ctx.arcTo(x, y + h, x, y + h - d, d);\n  ctx.lineTo(x, y + a);\n  ctx.arcTo(x, y, x + a, y, a);\n  ctx.closePath();\n}\n\n/**\n * Paint `el` into a canvas at `res` pixels per CSS pixel: background colours,\n * borders and radii, overflow clips, child canvases, inline SVGs, input\n * values, and text, one character at a time at the exact place the browser\n * laid it out (read with Range rects), in the element's own font. That is\n * enough for anything built from flat fills and type, which is what every\n * Aeolian surface is. Everything is read synchronously at the call, so the\n * snapshot is of the element as it is now even if React redraws it a moment\n * later. The element's own opacity is ignored (a hidden element can still be\n * painted, ready to be built out of sand); nodes marked data-ae-skip are left out.\n */\nfunction aeRasterize(el: HTMLElement, res: number): AeRaster | null {\n  const R = el.getBoundingClientRect();\n  const w = el.offsetWidth;\n  const h = el.offsetHeight;\n  if (!w || !h || !R.width) return null;\n  const s = R.width / w;\n  const canvas = document.createElement(\"canvas\");\n  canvas.width = Math.max(1, Math.ceil(w * res));\n  canvas.height = Math.max(1, Math.ceil(h * res));\n  const ctx = canvas.getContext(\"2d\");\n  if (!ctx) return null;\n  ctx.scale(res, res);\n  const X = (x: number) => (x - R.left) / s;\n  const Y = (y: number) => (y - R.top) / s;\n  const range = document.createRange();\n  const svgs: Promise<void>[] = [];\n\n  const text = (t: Text, cs: CSSStyleDeclaration, alpha: number) => {\n    const data = t.data;\n    if (!data.trim()) return;\n    ctx.globalAlpha = alpha * aeAlpha(cs.color);\n    ctx.fillStyle = cs.color;\n    ctx.font = cs.fontStyle + \" \" + cs.fontWeight + \" \" + cs.fontSize + \" \" + cs.fontFamily;\n    const c2 = ctx as unknown as { fontStretch?: string; letterSpacing?: string };\n    if (\"fontStretch\" in c2) c2.fontStretch = AE_STRETCH[cs.fontStretch] ?? \"normal\";\n    if (\"letterSpacing\" in c2) c2.letterSpacing = \"0px\";\n    ctx.textBaseline = \"alphabetic\";\n    const m = ctx.measureText(\"Hg\");\n    const asc = m.fontBoundingBoxAscent || parseFloat(cs.fontSize) * 0.8;\n    const desc = m.fontBoundingBoxDescent || parseFloat(cs.fontSize) * 0.2;\n    const upper = cs.textTransform === \"uppercase\";\n    for (let i = 0; i < data.length; i++) {\n      const code = data.charCodeAt(i);\n      const n = code >= 0xd800 && code <= 0xdbff ? 2 : 1;\n      let ch = data.slice(i, i + n);\n      if (/\\s/.test(ch)) continue;\n      range.setStart(t, i);\n      range.setEnd(t, i + n);\n      i += n - 1;\n      const rect = range.getClientRects()[0];\n      if (!rect || !rect.width) continue;\n      if (upper) ch = ch.toUpperCase();\n      const rh = rect.height / s;\n      ctx.fillText(ch, X(rect.left), Y(rect.top) + (rh - (asc + desc)) / 2 + asc);\n    }\n  };\n\n  const paint = (node: Element, alpha: number, root: boolean) => {\n    if (!root && node.hasAttribute(\"data-ae-skip\")) return;\n    const cs = getComputedStyle(node);\n    if (cs.display === \"none\" || (!root && cs.visibility === \"hidden\")) return;\n    const a = root ? alpha : alpha * (parseFloat(cs.opacity) || 0);\n    if (a < 0.01) return;\n    const r = node.getBoundingClientRect();\n    const x = X(r.left);\n    const y = Y(r.top);\n    const bw = r.width / s;\n    const bh = r.height / s;\n    const radii: [number, number, number, number] = [\n      aeRadius(cs.borderTopLeftRadius, bw, bh),\n      aeRadius(cs.borderTopRightRadius, bw, bh),\n      aeRadius(cs.borderBottomRightRadius, bw, bh),\n      aeRadius(cs.borderBottomLeftRadius, bw, bh),\n    ];\n    if (node instanceof SVGSVGElement) {\n      const clone = node.cloneNode(true) as SVGSVGElement;\n      clone.setAttribute(\"width\", String(bw));\n      clone.setAttribute(\"height\", String(bh));\n      clone.setAttribute(\"color\", cs.color);\n      clone.style.color = cs.color;\n      const img = new Image();\n      const src = \"data:image/svg+xml;charset=utf-8,\" + encodeURIComponent(new XMLSerializer().serializeToString(clone));\n      svgs.push(\n        new Promise<void>((done) => {\n          img.onload = () => {\n            ctx.save();\n            ctx.globalAlpha = a;\n            ctx.drawImage(img, x, y, bw, bh);\n            ctx.restore();\n            done();\n          };\n          img.onerror = () => done();\n          img.src = src;\n        }),\n      );\n      return;\n    }\n    ctx.save();\n    if (aeAlpha(cs.backgroundColor) > 0) {\n      ctx.globalAlpha = a * aeAlpha(cs.backgroundColor);\n      ctx.fillStyle = cs.backgroundColor;\n      aeRoundRect(ctx, x, y, bw, bh, radii);\n      ctx.fill();\n    }\n    const bt = parseFloat(cs.borderTopWidth) || 0;\n    const br = parseFloat(cs.borderRightWidth) || 0;\n    const bb = parseFloat(cs.borderBottomWidth) || 0;\n    const bl = parseFloat(cs.borderLeftWidth) || 0;\n    if (bt || br || bb || bl) {\n      const uniform = bt === br && br === bb && bb === bl && cs.borderTopColor === cs.borderBottomColor && cs.borderLeftColor === cs.borderRightColor && cs.borderTopColor === cs.borderLeftColor;\n      if (uniform && cs.borderTopStyle !== \"none\") {\n        ctx.globalAlpha = a * aeAlpha(cs.borderTopColor);\n        ctx.strokeStyle = cs.borderTopColor;\n        ctx.lineWidth = bt;\n        aeRoundRect(ctx, x + bt / 2, y + bt / 2, bw - bt, bh - bt, radii.map((v) => Math.max(0, v - bt / 2)) as [number, number, number, number]);\n        ctx.stroke();\n      } else {\n        const side = (on: number, color: string, style: string, sx: number, sy: number, sw: number, sh: number) => {\n          if (!on || style === \"none\" || aeAlpha(color) === 0) return;\n          ctx.globalAlpha = a * aeAlpha(color);\n          ctx.fillStyle = color;\n          ctx.fillRect(sx, sy, sw, sh);\n        };\n        side(bt, cs.borderTopColor, cs.borderTopStyle, x, y, bw, bt);\n        side(bb, cs.borderBottomColor, cs.borderBottomStyle, x, y + bh - bb, bw, bb);\n        side(bl, cs.borderLeftColor, cs.borderLeftStyle, x, y, bl, bh);\n        side(br, cs.borderRightColor, cs.borderRightStyle, x + bw - br, y, br, bh);\n      }\n    }\n    if (node instanceof HTMLCanvasElement) {\n      try {\n        ctx.globalAlpha = a;\n        ctx.drawImage(node, x, y, bw, bh);\n      } catch {\n        // A canvas we may not read (tainted): leave its box empty.\n      }\n    }\n    if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement) {\n      const isSelect = node instanceof HTMLSelectElement;\n      // Secrets never reach the sand: passwords, one-time codes and card fields paint as dots.\n      const secret = node instanceof HTMLInputElement && (node.type === \"password\" || /^(one-time-code|cc-)/.test(node.autocomplete));\n      const value = isSelect ? (node.selectedOptions[0]?.text ?? \"\") : secret ? \"•\".repeat(node.value.length) : node.value;\n      const shown = value || (isSelect ? \"\" : node.placeholder);\n      if (shown && !(node instanceof HTMLInputElement && /^(checkbox|radio|range|color|file|hidden)$/.test(node.type))) {\n        ctx.globalAlpha = a * (value ? 1 : 0.5);\n        ctx.fillStyle = cs.color;\n        ctx.font = cs.fontStyle + \" \" + cs.fontWeight + \" \" + cs.fontSize + \" \" + cs.fontFamily;\n        ctx.textBaseline = \"middle\";\n        const pl = (parseFloat(cs.paddingLeft) || 0) + bl;\n        const lineY = node instanceof HTMLTextAreaElement ? y + (parseFloat(cs.paddingTop) || 0) + bt + (parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.3) / 2 : y + bh / 2;\n        ctx.fillText(shown, x + pl, lineY, Math.max(1, bw - pl * 2));\n      }\n    }\n    if (cs.overflow !== \"visible\" && cs.overflow !== \"\") {\n      aeRoundRect(ctx, x, y, bw, bh, radii);\n      ctx.clip();\n    }\n    for (const c of Array.from(node.childNodes)) {\n      if (c.nodeType === 3) text(c as Text, cs, a);\n      else if (c.nodeType === 1) paint(c as Element, a, false);\n    }\n    ctx.restore();\n  };\n\n  paint(el, 1, true);\n  range.detach();\n  return { canvas, w, h, ready: Promise.all(svgs).then(() => undefined) };\n}\n\nexport interface SpindriftFooterProps {\n  brand?: string;\n  columns?: { title: string; links: { label: string; href: string }[] }[];\n  note?: string;\n  /** Grains in the air off the wordmark (a phone-width footer uses half). */\n  grains?: number;\n  className?: string;\n  style?: CSSProperties;\n}\n\n/**\n * SpindriftFooter — the site's name set edge to edge, with sand streaming\n * off the top of every letter the way spindrift leaves a dune crest: grains\n * lift from the letters' upper edges and blow downwind with the page's\n * wind. Move the pointer through it and it gusts.\n */\nexport function SpindriftFooter({\n  brand = \"Barchan\",\n  columns = [\n    { title: \"Camp\", links: [{ label: \"The dune\", href: \"#camp\" }, { label: \"Forty years\", href: \"#camp\" }] },\n    { title: \"Go\", links: [{ label: \"Routes\", href: \"#routes\" }, { label: \"Stays\", href: \"#stays\" }] },\n    { title: \"Ask\", links: [{ label: \"Request a stay\", href: \"#request\" }, { label: \"Back to the top\", href: \"#top\" }] },\n  ],\n  note = \"A camp that moves with the dunes.\",\n  grains = 1100,\n  className = \"\",\n  style,\n}: SpindriftFooterProps) {\n  const markRef = useRef<HTMLDivElement>(null);\n  const wordRef = useRef<HTMLSpanElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const live = useRef({ grains });\n  useEffect(() => {\n    live.current.grains = grains;\n  });\n\n  // Set the name edge to edge: measured at 100px, scaled to the box.\n  useEffect(() => {\n    const box = markRef.current;\n    const word = wordRef.current;\n    if (!box || !word) return;\n    const fit = () => {\n      word.style.fontSize = \"100px\";\n      const w = word.getBoundingClientRect().width / (box.getBoundingClientRect().width / (box.clientWidth || 1));\n      if (w > 0) word.style.fontSize = ((box.clientWidth / w) * 100 * 0.995).toFixed(2) + \"px\";\n      box.dispatchEvent(new Event(\"ae-fit\"));\n    };\n    fit();\n    const ro = new ResizeObserver(fit);\n    ro.observe(box);\n    void document.fonts?.ready.then(fit);\n    return () => ro.disconnect();\n  }, [brand]);\n\n  // The spindrift: emitters on the top edge of every letter, read from a snapshot of the word itself.\n  useEffect(() => {\n    const box = markRef.current;\n    const word = wordRef.current;\n    const canvas = canvasRef.current;\n    if (!box || !word || !canvas) return;\n    const c2 = canvas.getContext(\"2d\");\n    if (!c2) return;\n    const ctx = c2;\n    const still = aeReducedSnap();\n    let emit: [number, number][] = [];\n    let ox = 0;\n    let oy = 0;\n    type G = { x: number; y: number; px: number; py: number; vx: number; vy: number; life: number; lt: number; w: number };\n    const pool: G[] = [];\n    let raf = 0;\n    let on = false;\n    let last = 0;\n    const gust = { x: -1e4, y: 0, vx: 0, vy: 0 };\n    const scan = () => {\n      const r = aeRasterize(word, 1);\n      if (!r) return;\n      const d = r.canvas.getContext(\"2d\")?.getImageData(0, 0, r.canvas.width, r.canvas.height).data;\n      if (!d) return;\n      const W = r.canvas.width;\n      const H = r.canvas.height;\n      const out: [number, number][] = [];\n      for (let x = 0; x < W; x += 2) {\n        let prev = 0;\n        for (let y = 0; y < H; y++) {\n          const a = d[(y * W + x) * 4 + 3] ?? 0;\n          // Every edge where sand faces the sky: a filled pixel with air above it.\n          if (a > 120 && prev <= 120) out.push([x, y]);\n          prev = a;\n        }\n      }\n      emit = out;\n      const wb = word.getBoundingClientRect();\n      const cb = canvas.getBoundingClientRect();\n      const s = cb.width / (canvas.clientWidth || 1);\n      ox = (wb.left - cb.left) / s;\n      oy = (wb.top - cb.top) / s;\n    };\n    const size = () => {\n      const dpr = Math.min(2, window.devicePixelRatio || 1);\n      const W = Math.round(canvas.clientWidth * dpr);\n      const H = Math.round(canvas.clientHeight * dpr);\n      if (canvas.width !== W || canvas.height !== H) {\n        canvas.width = W;\n        canvas.height = H;\n      }\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    };\n    const spawn = (g: G) => {\n      const e = emit[Math.floor(Math.random() * emit.length)];\n      if (!e) return;\n      g.x = g.px = ox + e[0] + (Math.random() - 0.5) * 2;\n      g.y = g.py = oy + e[1];\n      const [wx, wy] = aeWindScreen();\n      const s = 0.4 + aeWind.speed / 60;\n      g.vx = wx * s * (20 + 40 * Math.random());\n      g.vy = wy * s * 20 - (10 + 30 * Math.random()) * s;\n      g.lt = 1.1 + Math.random() * 1.8;\n      g.life = 1;\n      g.w = Math.random();\n    };\n    const frame = (now: number) => {\n      raf = 0;\n      if (!on) return;\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 1 / 60;\n      last = now;\n      size();\n      const w = canvas.clientWidth;\n      const h = canvas.clientHeight;\n      ctx.clearRect(0, 0, w, h);\n      const n = Math.round(live.current.grains * (w < 700 ? 0.5 : 1) * (0.25 + aeWind.speed / 40));\n      while (pool.length < n) {\n        const g: G = { x: 0, y: 0, px: 0, py: 0, vx: 0, vy: 0, life: Math.random(), lt: 1, w: 0 };\n        spawn(g);\n        g.life = Math.random();\n        pool.push(g);\n      }\n      if (pool.length > n) pool.length = n;\n      const [wx, wy] = aeWindScreen();\n      const ws = 18 + aeWind.speed * 3.2;\n      gust.vx *= Math.exp(-dt * 3);\n      gust.vy *= Math.exp(-dt * 3);\n      ctx.lineCap = \"round\";\n      for (const g of pool) {\n        g.life -= dt / g.lt;\n        if (g.life <= 0) {\n          spawn(g);\n          continue;\n        }\n        const k = 1 - Math.exp(-dt * 2.2);\n        const tx = wx * ws * (0.6 + g.w * 0.8) + Math.sin(now / 420 + g.w * 40) * 10;\n        const ty = wy * ws * 0.6 - 8 + Math.cos(now / 530 + g.w * 31) * 8;\n        g.vx += (tx - g.vx) * k;\n        g.vy += (ty - g.vy) * k + 14 * dt * g.w;\n        const dx = g.x - gust.x;\n        const dy = g.y - gust.y;\n        const f = Math.exp(-(dx * dx + dy * dy) / 9000);\n        g.vx += gust.vx * f * dt * 6;\n        g.vy += gust.vy * f * dt * 6;\n        g.px = g.x;\n        g.py = g.y;\n        g.x += g.vx * dt;\n        g.y += g.vy * dt;\n        const a = Math.min(1, g.life * 2.4) * Math.min(1, (1 - g.life) * 8) * (0.35 + 0.5 * g.w);\n        ctx.strokeStyle = \"rgba(221,170,114,\" + a.toFixed(3) + \")\";\n        ctx.lineWidth = 0.7 + g.w * 0.9;\n        ctx.beginPath();\n        ctx.moveTo(g.px - (g.x - g.px) * 1.5, g.py - (g.y - g.py) * 1.5);\n        ctx.lineTo(g.x, g.y);\n        ctx.stroke();\n      }\n      raf = requestAnimationFrame(frame);\n    };\n    const begin = () => {\n      scan();\n      if (!still && on && !raf) raf = requestAnimationFrame(frame);\n    };\n    const io = new IntersectionObserver((es) => {\n      on = !!es[es.length - 1]?.isIntersecting;\n      last = 0;\n      if (on) begin();\n      else if (raf) {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n    });\n    io.observe(canvas);\n    const refit = () => {\n      pool.length = 0;\n      scan();\n    };\n    box.addEventListener(\"ae-fit\", refit);\n    const move = (e: PointerEvent) => {\n      const cb = canvas.getBoundingClientRect();\n      const s = cb.width / (canvas.clientWidth || 1);\n      const x = (e.clientX - cb.left) / s;\n      const y = (e.clientY - cb.top) / s;\n      if (gust.x > -1e3) {\n        gust.vx += (x - gust.x) * 6;\n        gust.vy += (y - gust.y) * 6;\n      }\n      gust.x = x;\n      gust.y = y;\n    };\n    const leave = () => {\n      gust.x = -1e4;\n    };\n    box.addEventListener(\"pointermove\", move, { passive: true });\n    box.addEventListener(\"pointerleave\", leave);\n    return () => {\n      io.disconnect();\n      if (raf) cancelAnimationFrame(raf);\n      box.removeEventListener(\"ae-fit\", refit);\n      box.removeEventListener(\"pointermove\", move);\n      box.removeEventListener(\"pointerleave\", leave);\n    };\n  }, []);\n\n  return (\n    <footer data-ae-ground=\"night\" className={\"ae-scope @container relative w-full overflow-hidden \" + className} style={{ background: AE_NIGHT, color: AE_HAZE, fontFamily: AE_DISPLAY, ...style }}>\n      <style>{AE_CSS}</style>\n      <div className=\"grid grid-cols-2 gap-x-6 gap-y-10 px-5 pb-10 pt-20 @3xl:grid-cols-[1.4fr_repeat(3,1fr)] @3xl:px-[5.5cqw] @3xl:pt-[8cqw]\">\n        <div className=\"col-span-2 @3xl:col-span-1\">\n          <span style={{ color: AE_SAND }}>\n            <AeMark size={28} />\n          </span>\n          <p className=\"m-0 mt-4 max-w-[22rem] text-[15px] leading-[1.6]\" style={{ opacity: 0.72, fontStretch: \"100%\" }}>\n            {note}\n          </p>\n        </div>\n        {columns.map((c) => (\n          <nav key={c.title} aria-label={c.title}>\n            <p className=\"m-0 text-[11px] uppercase tracking-[0.16em]\" style={{ fontFamily: AE_MONO, opacity: 0.55 }}>\n              {c.title}\n            </p>\n            <ul className=\"m-0 mt-4 list-none p-0\">\n              {c.links.map((l) => (\n                <li key={l.label} className=\"py-1.5\">\n                  <a href={aeSafeHref(l.href)} onClick={aeGo} className=\"text-[15px] no-underline hover:underline hover:underline-offset-4\" style={{ color: \"inherit\", fontStretch: \"100%\" }}>\n                    {l.label}\n                  </a>\n                </li>\n              ))}\n            </ul>\n          </nav>\n        ))}\n      </div>\n      <div ref={markRef} className=\"relative mx-5 pt-[9cqw] @3xl:mx-[5.5cqw]\">\n        <canvas ref={canvasRef} aria-hidden className=\"pointer-events-none absolute inset-x-[-6%] top-0 h-full w-[112%]\" />\n        <span ref={wordRef} className=\"relative inline-block whitespace-nowrap uppercase leading-[0.8]\" style={{ fontSize: 100, fontStretch: \"125%\", fontWeight: 560, letterSpacing: \"-0.01em\", color: AE_SAND }}>\n          {brand}\n        </span>\n      </div>\n      <div className=\"flex flex-wrap items-center justify-between gap-3 px-5 pb-8 pt-6 text-[12px] @3xl:px-[5.5cqw]\" style={{ fontFamily: AE_MONO, opacity: 0.55 }}>\n        <span className=\"uppercase tracking-[0.14em]\">© {brand}</span>\n        <span className=\"uppercase tracking-[0.14em]\">Wind and sand, rendered live</span>\n      </div>\n    </footer>\n  );\n}\n","type":"registry:component","target":"components/viberdy/spindrift-footer.tsx"}],"meta":{"tier":"free","tags":["footer","wordmark","particles","canvas","sand","wind","pointer interaction","section"],"href":"https://viberdy.dev/library/spindrift-footer","aiPrompt":"Build SpindriftFooter, a footer that sets the name edge to edge and lets the wind take sand off the top of every letter, the way spindrift streams off a dune crest. Style: Aeolian (wind-blown sand as a material, warm, cinematic, low sun). Fixed palette, no theming: night #150E0A (deepest ground, dusk, footer), umber #2B1B12 (ink on light grounds), dune #B8743F (mid sand, marks on haze), sand #DDAA72 (lit sand, marks on night), haze #EFE2CD (the pale ground, and the colour a sandstorm turns everything), ember #E0602C (the one filled accent: CTA, knob, active; its label ink is #1A0E07). Umber on haze is 12.9:1, haze on night 15.6:1. Type: Archivo variable loaded with its wdth axis (next/font: Archivo({ subsets: [\"latin\"], axes: [\"wdth\"], variable: \"--font-ae\" })) and read as var(--font-ae, var(--font-display, \"Archivo\")); display is wide and light: weight 300-360 (320 section headings, 330 hero), font-stretch 112.5% (125% for big numerals, the brand and the footer wordmark), set with the font-stretch property (never font-variation-settings, so the canvas rasterizer can paint the same instance), tracking -0.02em to -0.04em, line-height 1-1.02 (hero 0.98); body copy 14.5-16.5px at stretch 100%. Accent: Instrument Serif italic (var(--font-ae-serif, var(--font-instrument-serif, \"Instrument Serif\")), weight 400, stretch 100%, tracking -0.01em), one word per line at most, sand on night and dune on haze. Labels and readouts: Geist Mono (var(--font-ae-mono, var(--font-geist-mono, \"Geist Mono\"))), 10-12px, uppercase, tracking 0.14-0.16em. Buttons are full pills (48px high, 14.5px, weight 500); cards are radius 22-28px. Every section root carries data-ae-ground=\"night\" | \"haze\" (a nav reads it). One focus ring through a .ae-scope root: 2px solid, offset 3px, !important so site rules cannot beat it, sand on night and umber on haze. Tabular figures on numbers; a press scales to 0.97 in 180ms; arrows slide 3px on hover; anything a frame loop writes carries data-ae-live and has transitions off. Scroll-told parts are driven by one number p (0..1) from the hook useAeDrive(ref, { mode: \"scroll\" | \"auto\", progress, still, period, measure }, render): in scroll mode a document-level capture-phase scroll listener (plus resize and a ResizeObserver, at most once per frame) measures the section and the value chases it, v += (target - v) * 0.14 per frame, snapping when within 0.0004; the nearest ancestor that really scrolls (overflow-y auto/scroll/overlay and scrollHeight > clientHeight) is found every frame, otherwise the window, so the same section works on a page and inside a scrolling box. measure is aePin (a tall pinned block: (view.top - rect.top) / (rect.height - view.height)) or aePass (a block crossing the view: (view.top + view.height - rect.top) / (rect.height + view.height)). Mode \"auto\" (previews, embeds) plays a slow loop once the section has been seen (IntersectionObserver, 200px margin): u = ((now - t0) % period) / period, p = u < 0.55 ? smoothstep(u / 0.55) : u < 0.7 ? 1 : u < 0.95 ? 1 - smoothstep((u - 0.7) / 0.25) : 0 (period default 16000 ms); the progress prop holds one moment; reduced motion renders the settled value still. render writes straight to the DOM; nothing re-renders React per frame. Pinned runs are height calc(var(--ae-vh, 100svh) * N) holding a sticky top-0 box of var(--ae-vh, 100svh), and only when mode is scroll, progress is unset and motion is not reduced; otherwise the section is height ?? var(--ae-vh, 100svh) (one screen) and its box fills it. Each file exports its component, its props interface and the AeGround / AeDriveMode types. Reduced motion (live, via useSyncExternalStore on prefers-reduced-motion) shows each section's settled state and turns every dissolve into a 220ms fade. Same-page links go through a safe-href helper (https, http, mailto, tel, same-site paths and anchors only; tabs and newlines stripped; backslashes and // refused, anything else becomes #) and glide (auto under reduced motion) to the [data-ae-anchor] target inside the nearest [data-ae-site]. React 19, Tailwind v4 with container queries (@container on the root, @3xl = 768px for the desktop layout; JS phone checks use a container width under 700px). No three.js, no images, no assets: everything is hand-written WebGL2 or 2D canvas, WebGL canvases are aria-hidden, and every WebGL part falls back to a painted gradient.\n\nThe wind (shared module store, not React state): aeWind = { angle: 205, speed: 26, subs }. angle is the way it blows TOWARD, in degrees on the ground (0 = right/east, 90 = away from you/north, 180 = left, 270 = toward you), normalised to 0..360; speed is km/h clamped 0..60. aeSetWind({ angle?, speed? }) writes and calls every subscriber; aeOnWind(fn) subscribes and returns an unsubscribe; listeners write to the DOM, never to React state. aeWindScreen(angle) is the wind as a unit vector on the screen: x = cos a, y = -sin a * 0.55 (away from you reads as rising, flattened because the ground is seen low), normalised. aeWindFrom(angle): toward = (90 - angle) mod 360, from = (toward + 180) mod 360, index round(from / 22.5) mod 16 into N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW. aeWindText = \"From ENE · 26 km/h\" (the default 205 reads ENE). The store lives on globalThis.__aeolianWind (created once with ??=, so parts pasted as separate files still share one wind). Every engine on the page reads this one store.\n\nThe rasterizer aeRasterize(el, res) paints a piece of the page into a 2D canvas (width ceil(offsetWidth * res), same for height; res = min(2, max(1, devicePixelRatio))) so it can become sand. The scale of any transform above the element is divided out (s = getBoundingClientRect().width / offsetWidth). It walks the subtree: skips display none, visibility hidden (not on the root), opacity under 0.01 and nodes marked data-ae-skip; the element's own opacity is ignored (a hidden element can still be painted); each node's background-colour (with per-corner radii, % radii use the smaller side), borders (uniform: one stroked rounded rect; otherwise four filled sides), overflow clip (rounded), child canvases (drawImage, tainted ones left blank), inline SVGs (cloned with width, height and the computed colour, serialised to a data: URL, drawn once the Image loads; raster.ready resolves when all have), input/textarea/select values or placeholder at 50% (not checkbox, radio, range, colour, file, hidden; password, one-time-code and cc-* autocomplete fields paint as dots, never their value), and text one character at a time at the exact place the browser laid it out (a Range per character, surrogate pairs kept together, rect centred on the font's ascent plus descent, uppercase applied when text-transform says so) in the element's own font (style, weight, size, family, and font-stretch mapped from percent to the canvas keyword: 62.5% extra-condensed, 75% condensed, 87.5% semi-condensed, 100% normal, 112.5% semi-expanded, 125% expanded, 150% extra-expanded, 200% ultra-expanded; canvas letterSpacing 0). Everything is read synchronously at the call, so the snapshot is the element as it is now even if React redraws it a moment later. It handles flat fills, type, borders and canvases, which is all an Aeolian surface is.\n\nWordmark: a span (inline-block, nowrap, uppercase, leading 0.8, weight 560, stretch 125%, tracking -0.01em, sand) inside a relative box with 9cqw top padding and the page margins (20px, 5.5cqw from @3xl). Fit: set font-size 100px, measure the span's width (divide out transform scale), then set font-size = (box.clientWidth / measured) * 100 * 0.995 px; refit on a ResizeObserver and when document.fonts.ready resolves; after each fit dispatch an \"ae-fit\" event on the box so the emitters are rescanned.\nEmitters: aeRasterize(wordmark, 1) (see the rasterizer above), read its alpha channel; for every second pixel column x, for every y, an emitter is recorded wherever the pixel is filled (alpha > 120) and the one above it is not (alpha <= 120): every edge where sand faces the sky, including the tops of counters inside the letters. Canvas offset (ox, oy) = the wordmark's position within the canvas, which is absolutely positioned at inset-x -6%, top 0, width 112%, height 100%, aria-hidden, pointer-events none.\nGrains (2D canvas, DPR up to 2): the target count is round(grains * (width under 700px ? 0.5 : 1) * (0.25 + speed / 40)) (grains default 1100), so it blows harder as the store's speed rises. Spawn at a random emitter (±1px in x): s = 0.4 + speed / 60; velocity = wind * s * (20 + 40 r) horizontally and vy = wy * s * 20 - (10 + 30 r) * s; life 1.1 + 1.8 r seconds; weight w random. Each frame: ws = 18 + speed * 3.2; target velocity tx = wx * ws * (0.6 + 0.8 w) + sin(now / 420 + 40 w) * 10, ty = wy * ws * 0.6 - 8 + cos(now / 530 + 31 w) * 8; v += (target - v) * (1 - exp(-2.2 dt)); vy += 14 dt w; the pointer gust (pointermove over the box accumulates gust velocity (delta * 6), decays exp(-3 dt), and acts with exp(-d^2 / 9000) * dt * 6) adds to the velocity; dt capped at 0.05. Draw a round-capped streak from (previous - delta * 1.5) to the current position in rgba(221,170,114, a) with a = min(1, life * 2.4) * min(1, (1 - life) * 8) * (0.35 + 0.5 w), line width 0.7 + 0.9 w. The wind is aeWindScreen() from the store. The loop runs only while the canvas is on screen (IntersectionObserver); reduced motion draws nothing.\nFooter: night ground, haze text, overflow hidden, @container. Top grid (2 columns on phones, 1.4fr then three 1fr from @3xl; gap 24px x 40px; padding 80px top (8cqw), 40px bottom, 20px sides (5.5cqw)): the 28px crescent mark in sand and the note (15px / 1.6, max 22rem, 72%) spanning the first column; then three labelled nav landmarks with mono 11px titles at 55% and 15px links (underline on hover, offset 4px, every href through the safe-href helper, anchors glide). Default columns: Camp (The dune #camp, Forty years #camp), Go (Routes #routes, Stays #stays), Ask (Request a stay #request, Back to the top #top). Bottom row (mono 12px, 55%, uppercase, tracking 0.14em): \"© Barchan\" and \"Wind and sand, rendered live\". The name is real text; the canvas is aria-hidden. Props: brand (\"Barchan\"), columns, note (\"A camp that moves with the dunes.\"), grains (1100), className, style.","license":"https://viberdy.dev/license"}}