{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"terracotta-poster-block-with-coarse-canvas-grain","type":"registry:block","title":"Terracotta Poster Block With Coarse Canvas Grain","description":"","dependencies":[],"files":[{"path":"components/we-inc/terracotta-poster-block-with-coarse-canvas-grain.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst TILE = 180; // size of the grain tile in pixels\nconst SPECKS = 0.22; // share of pixels that get a speck (0.1 sparse, 0.4 dense)\nconst CLUMP = 2; // speck size in pixels: 1 fine, 2 coarse, 3 very coarse\n\nconst css = `\n  .w4ter { --w4ter-clay: #9f4528; --w4ter-cream: #f3e4cc; --w4ter-dark: #3a1b10; --w4ter-grain: .42;\n    position: relative; isolation: isolate; overflow: hidden; background: var(--w4ter-clay); color: var(--w4ter-cream); font-family: ui-sans-serif, system-ui, sans-serif; }\n  .w4ter-art { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }\n  .w4ter-sun { position: absolute; right: 8%; top: 12%; width: min(46vw, 420px); aspect-ratio: 1; border-radius: 50%; background: #e7a34d; }\n  .w4ter-arch { position: absolute; right: 2%; bottom: -2px; width: min(58vw, 540px); height: 72%; border-radius: 999px 999px 0 0; background: #7c3119; }\n  .w4ter-arch::after { content: \"\"; position: absolute; left: 22%; right: 22%; bottom: 0; height: 58%; border-radius: 999px 999px 0 0; background: var(--w4ter-dark); }\n  .w4ter-fade { position: absolute; inset: 0; background: linear-gradient(90deg, var(--w4ter-clay) 0%, rgba(159, 69, 40, .92) 34%, rgba(159, 69, 40, 0) 62%); }\n  /* grain: an SVG noise tile by default, swapped for a coarser canvas tile by the script */\n  .w4ter-art::after { content: \"\"; position: absolute; inset: -140px; opacity: var(--w4ter-grain);\n    background-image: var(--w4ter-tile, url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .08 0 0 0 0 .03 0 0 0 2 -1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23t)'/%3E%3C/svg%3E\"));\n    animation: w4ter-grain .5s steps(1) infinite; }\n  .w4ter[data-w4ter-off] .w4ter-art::after { animation-play-state: paused; }\n  @keyframes w4ter-grain { 0% { transform: translate(0, 0); } 20% { transform: translate(-53px, 41px); } 40% { transform: translate(37px, -67px); } 60% { transform: translate(-88px, -19px); } 80% { transform: translate(74px, 58px); } }\n  .w4ter-inner { position: relative; max-width: 68rem; margin: 0 auto; padding: 72px 24px 80px; }\n  .w4ter-tag { display: inline-block; padding: 7px 12px; border: 1.5px solid var(--w4ter-cream); border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }\n  .w4ter-title { margin: 26px 0 0; max-width: 11ch; font-size: clamp(48px, 9vw, 112px); font-weight: 800; line-height: .9; letter-spacing: -.035em; text-transform: uppercase; }\n  .w4ter-copy { margin: 22px 0 0; max-width: 26rem; font-size: 17px; line-height: 1.6; color: #fbeedd; }\n  .w4ter-facts { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 15px; font-weight: 600; }\n  .w4ter-facts span { display: inline-block; min-width: 5.5em; font-weight: 500; color: #f7dcc0; }\n  .w4ter-cta { display: inline-flex; align-items: center; min-height: 48px; margin-top: 30px; padding: 0 24px; border-radius: 999px; background: var(--w4ter-cream);\n    color: var(--w4ter-dark); font-size: 15px; font-weight: 700; text-decoration: none; }\n  .w4ter-cta:hover { background: #fff6ea; }\n  .w4ter-cta:focus-visible { outline: 3px solid var(--w4ter-cream); outline-offset: 3px; }\n  @media (max-width: 640px) { .w4ter-sun { right: -18%; top: 4%; opacity: .55; } .w4ter-arch { right: -30%; opacity: .5; } }\n  @media (prefers-reduced-motion: reduce) { .w4ter-art::after { animation: none !important; } }\n`;\n\n/** Draws one tile of warm dark and pale specks and returns it as a CSS url(), or null if canvas is unavailable. */\nfunction grainTile(): string | null {\n  const c = document.createElement(\"canvas\");\n  c.width = c.height = TILE;\n  const g = c.getContext(\"2d\");\n  if (!g) return null;\n  for (let y = 0; y < TILE; y += CLUMP) {\n    for (let x = 0; x < TILE; x += CLUMP) {\n      if (Math.random() > SPECKS) continue;\n      g.fillStyle = Math.random() < 0.6 ? `rgba(58,27,16,${(0.35 + Math.random() * 0.5).toFixed(2)})` : `rgba(255,240,220,${(0.2 + Math.random() * 0.4).toFixed(2)})`;\n      g.fillRect(x, y, CLUMP, CLUMP);\n    }\n  }\n  try { return `url(${c.toDataURL(\"image/png\")})`; } catch { return null; }\n}\n\nexport default function TerracottaPosterBlockWithCoarseCanvasGrain() {\n  const rootRef = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    const tile = grainTile();\n    if (tile) root.style.setProperty(\"--w4ter-tile\", tile);\n    // Pauses the grain while the poster is off screen.\n    const io = new IntersectionObserver(([en]) => root.toggleAttribute(\"data-w4ter-off\", !en.isIntersecting));\n    io.observe(root);\n    return () => io.disconnect();\n  }, []);\n\n  return (\n    <section ref={rootRef} className=\"w4ter\">\n      <style>{css}</style>\n      <div className=\"w4ter-art\" aria-hidden=\"true\">\n        <div className=\"w4ter-sun\" />\n        <div className=\"w4ter-arch\" />\n        <div className=\"w4ter-fade\" />\n      </div>\n      <div className=\"w4ter-inner\">\n        <span className=\"w4ter-tag\">Kiln Lane Pottery</span>\n        <h2 className=\"w4ter-title\">Open studio weekend</h2>\n        <p className=\"w4ter-copy\">Walk round the wheels and the kiln room, watch a firing being unpacked, and take home a seconds bowl straight off the shelf.</p>\n        <ul className=\"w4ter-facts\">\n          <li><span>When</span>Sat 8 and Sun 9 November</li>\n          <li><span>Hours</span>10:00 to 16:00</li>\n          <li><span>Where</span>22 Tanner Lane, unit 4</li>\n        </ul>\n        <a href=\"#\" className=\"w4ter-cta\">Plan your visit</a>\n      </div>\n    </section>\n  );\n}\n"}]}
