{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"line-monogram-draws-then-fills-on-intro-card","type":"registry:component","title":"Line Monogram That Draws Then Fills","description":"","dependencies":[],"files":[{"path":"components/we-inc/line-monogram-draws-then-fills-on-intro-card.tsx","type":"registry:component","content":"import { useEffect, useLayoutEffect, useRef } from \"react\";\n\n// Edit these first: the four colours at the top of .m1mon, and the draw speed in the m1mon-draw rules.\nconst CSS = `\n.m1mon { --m1mon-bg: #efe7da; --m1mon-card: #fbf7ef; --m1mon-ink: #2a2420; --m1mon-quiet: #66594c; --m1mon-line: #d8ccb9; --m1mon-focus: #8a4b2a; }\n.m1mon { position: relative; box-sizing: border-box; overflow: hidden; font-family: \"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; -webkit-font-smoothing: antialiased; }\n.m1mon *, .m1mon *::before, .m1mon *::after { box-sizing: border-box; }\n.m1mon-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }\n.m1mon-replay { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--m1mon-line); border-radius: 999px; background: transparent; color: var(--m1mon-quiet); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }\n.m1mon-replay svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.m1mon-replay:hover { color: var(--m1mon-ink); }\n.m1mon-replay:focus-visible { outline: 2px solid var(--m1mon-focus); outline-offset: 2px; }\n/* Reduced motion: no movement at all, the finished logo shows straight away. */\n@media (prefers-reduced-motion: reduce) {\n  .m1mon *, .m1mon *::before, .m1mon *::after { animation: none !important; transition: none !important; }\n  .m1mon-replay { display: none; }\n}\n\n.m1mon { min-height: 460px; display: flex; align-items: center; justify-content: center; padding: 56px 20px 72px; background: var(--m1mon-bg); color: var(--m1mon-ink); }\n.m1mon-card { position: relative; width: 100%; max-width: 720px; display: flex; gap: 44px; align-items: center; padding: 44px 48px; background: var(--m1mon-card); border: 1px solid var(--m1mon-line); border-radius: 6px; box-shadow: 0 1px 0 rgba(42, 36, 32, .04), 0 26px 50px -30px rgba(42, 36, 32, .38); }\n.m1mon-mark { flex: none; width: 150px; height: 150px; overflow: visible; }\n.m1mon-mark .m1mon-s { fill: none; stroke: var(--m1mon-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }\n.m1mon-fill .m1mon-disc { fill: var(--m1mon-ink); }\n.m1mon-fill .m1mon-ring { fill: none; stroke: var(--m1mon-card); stroke-width: .9; opacity: .55; }\n.m1mon-fill .m1mon-l path { fill: none; stroke: var(--m1mon-card); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }\n.m1mon-eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--m1mon-quiet); }\n.m1mon-name { margin: 0; font-family: Georgia, \"Times New Roman\", serif; font-weight: 400; font-size: clamp(32px, 4.4vw, 44px); line-height: 1.05; letter-spacing: -.01em; }\n.m1mon-copy { margin: 14px 0 0; max-width: 30em; font-size: 15.5px; line-height: 1.6; color: var(--m1mon-quiet); }\n.m1mon-link { display: inline-flex; align-items: center; min-height: 40px; margin-top: 8px; color: var(--m1mon-ink); font-weight: 600; font-size: 14.5px; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: #b9aa94; }\n.m1mon-link:focus-visible { outline: 2px solid var(--m1mon-focus); outline-offset: 3px; border-radius: 2px; }\n@media (max-width: 620px) {\n  .m1mon-card { flex-direction: column; align-items: flex-start; gap: 26px; padding: 32px 24px; }\n  .m1mon-mark { width: 108px; height: 108px; }\n}\n@media (prefers-reduced-motion: no-preference) {\n  .m1mon.is-js:not([data-run]) .m1mon-mark .m1mon-s { stroke-dashoffset: 1; }\n  .m1mon.is-js:not([data-run]) .m1mon-fill, .m1mon.is-js:not([data-run]) .m1mon-txt { opacity: 0; }\n}\n.m1mon[data-run] .m1mon-mark .m1mon-s { animation: m1mon-draw .62s cubic-bezier(.65, 0, .35, 1) both; }\n.m1mon[data-run] .m1mon-mark .m1mon-d1 { animation-delay: .14s; }\n.m1mon[data-run] .m1mon-mark .m1mon-d2 { animation-delay: .24s; }\n.m1mon[data-run] .m1mon-mark .m1mon-d3 { animation-delay: .36s; animation-duration: .4s; }\n.m1mon[data-run] .m1mon-mark .m1mon-d4 { animation-delay: .46s; }\n.m1mon[data-run] .m1mon-mark .m1mon-d5 { animation-delay: .58s; }\n.m1mon[data-run] .m1mon-fill { animation: m1mon-fade .42s ease-out 1.02s both; }\n.m1mon[data-run] .m1mon-txt { animation: m1mon-rise .7s cubic-bezier(.2, .7, .2, 1) .3s both; }\n@keyframes m1mon-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }\n@keyframes m1mon-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes m1mon-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }\n`;\n\n// Runs before paint in the browser so the logo never flashes before its reveal.\nconst useBrowserLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\nexport default function LineMonogramDrawsThenFillsOn() {\n  const rootRef = useRef<HTMLElement>(null);\n\n  // Plays once when the piece scrolls into view (works inside a scrolling box too), then stops.\n  // With prefers-reduced-motion the CSS shows the finished logo and hides the Replay button.\n  useBrowserLayoutEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    root.classList.add(\"is-js\");\n    const play = () => {\n      root.removeAttribute(\"data-run\");\n      void root.offsetWidth; // restart the keyframes\n      root.setAttribute(\"data-run\", \"\");\n    };\n    const btn = root.querySelector(\".m1mon-replay\");\n    btn?.addEventListener(\"click\", play);\n    if (typeof IntersectionObserver === \"undefined\") {\n      play();\n      return () => btn?.removeEventListener(\"click\", play);\n    }\n    const io = new IntersectionObserver((entries) => {\n      if (entries[0].isIntersecting) {\n        play();\n        io.disconnect();\n      }\n    }, { threshold: 0.3 });\n    io.observe(root);\n    return () => {\n      io.disconnect();\n      btn?.removeEventListener(\"click\", play);\n    };\n  }, []);\n\n  return (\n    <section ref={rootRef} className=\"m1mon\">\n      <style>{CSS}</style>\n<div className=\"m1mon-card\">\n  <svg className=\"m1mon-mark\" viewBox=\"0 0 100 100\" role=\"img\" aria-label=\"Hartwell Bindery monogram\" focusable=\"false\">\n    <g className=\"m1mon-lines\">\n      <circle className=\"m1mon-s m1mon-d0\" cx=\"50\" cy=\"50\" r=\"44\" pathLength=\"1\" transform=\"rotate(-90 50 50)\"/>\n      <g transform=\"translate(-2 0)\">\n        <path className=\"m1mon-s m1mon-d1\" d=\"M32 30V70\" pathLength=\"1\"/>\n        <path className=\"m1mon-s m1mon-d2\" d=\"M50 30V70\" pathLength=\"1\"/>\n        <path className=\"m1mon-s m1mon-d3\" d=\"M32 50H50\" pathLength=\"1\"/>\n        <path className=\"m1mon-s m1mon-d4\" d=\"M50 30H60A10 10 0 0 1 60 50H50\" pathLength=\"1\"/>\n        <path className=\"m1mon-s m1mon-d5\" d=\"M50 50H62A10 10 0 0 1 62 70H50\" pathLength=\"1\"/>\n      </g>\n    </g>\n    <g className=\"m1mon-fill\">\n      <circle cx=\"50\" cy=\"50\" r=\"45.5\" className=\"m1mon-disc\"/>\n      <circle cx=\"50\" cy=\"50\" r=\"39.5\" className=\"m1mon-ring\"/>\n      <g transform=\"translate(-2 0)\" className=\"m1mon-l\">\n        <path d=\"M32 30V70M50 30V70M32 50H50M50 30H60A10 10 0 0 1 60 50H50M50 50H62A10 10 0 0 1 62 70H50\"/>\n      </g>\n    </g>\n  </svg>\n  <div className=\"m1mon-txt\">\n    <p className=\"m1mon-eyebrow\">Bookbinding and repair</p>\n    <h2 className=\"m1mon-name\">Hartwell Bindery</h2>\n    <p className=\"m1mon-copy\">Hand-sewn journals, rebacked family bibles and short-run editions, bound at the bench on Cobb Lane.</p>\n    <a className=\"m1mon-link\" href=\"#\">Visit the workshop</a>\n  </div>\n</div>\n<button type=\"button\" className=\"m1mon-replay\" aria-label=\"Replay logo animation\"><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4.5 11a5.5 5.5 0 1 0 1.8-4.6\"/><path d=\"M5 3.2v3.6h3.6\"/></svg>Replay</button>\n    </section>\n  );\n}\n"}]}
