{
  "id": "staggered-grid-reveal",
  "kind": "element",
  "title": "Staggered grid reveal",
  "summary": "A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.",
  "url": "https://enrichr.dev/elements/staggered-grid-reveal.html",
  "section": "gallery",
  "techniques": [
    "stagger",
    "reveal",
    "3d-css"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "playful",
    "modern"
  ],
  "intents": [
    "staggered grid animation",
    "tiles flip in on scroll",
    "random stagger reveal",
    "grid entrance animation",
    "card grid intro animation"
  ],
  "status": "tested",
  "params": [
    {
      "key": "count",
      "label": "Tiles",
      "type": "range",
      "min": 4,
      "max": 16,
      "step": 1,
      "value": 12
    },
    {
      "key": "columns",
      "label": "Columns",
      "type": "range",
      "min": 2,
      "max": 6,
      "step": 1,
      "value": 4
    },
    {
      "key": "order",
      "label": "Order",
      "type": "select",
      "options": [
        [
          "random",
          "Random"
        ],
        [
          "start",
          "Reading order"
        ],
        [
          "center",
          "Centre out"
        ],
        [
          "edges",
          "Edges in"
        ]
      ],
      "value": "random"
    },
    {
      "key": "stagger",
      "label": "Stagger (ms)",
      "type": "range",
      "min": 20,
      "max": 200,
      "step": 10,
      "value": 70
    },
    {
      "key": "words",
      "label": "Tile words (comma separated)",
      "type": "text",
      "value": "Motion, Form, Direction, Rhythm"
    },
    {
      "key": "accent",
      "label": "Accent colour",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "background",
      "label": "Background",
      "type": "color",
      "value": "#0c1e18"
    }
  ],
  "license": "Free to use in personal and client projects during the preview. Final licence terms will be published here before any paid tier starts; ask before reselling the code as a collection.",
  "contract": "function mount(root, opts) -> { update(partialOpts), destroy() }; root must contain the element markup",
  "exports": {
    "claude": "Add the \"Staggered grid reveal\" element to this project.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSteps:\n1. Look at the project first to see its framework and where components, styles and static files live. Follow its conventions.\n2. Fetch https://enrichr.dev/elements/staggered-grid-reveal.json if you can read URLs (fields: source.markup, source.css, source.js, params); otherwise use the source at the end of this message.\n3. Add the files, mount it where I tell you (default: the top of the home page), and pass the settings below as the opts.\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n5. Run the dev server and check it. with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "chatgpt": "I want the \"Staggered grid reveal\" element on my website. Below is its complete source. Please:\n1. Build one self-contained index.html that I can open locally to see it working (put the CSS in a <style> tag and the JavaScript in a <script> tag, with the markup in the body).\n2. Then explain, step by step, which parts go where in my own site, and how to mount it. My stack is: [tell me yours, or say \"plain HTML\"].\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "cursor": "Add the \"Staggered grid reveal\" element to this codebase.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nUse Composer / agent mode. First search the repo for how components, styles and scripts are organised, then add the files in the matching places, mount it on the page I name, and run the app to confirm it works. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nOptional: save this as .cursor/rules/enrichr-staggered-grid-reveal.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Staggered grid reveal element\nalwaysApply: false\n---\nmount(root, opts) expects the element markup inside root and returns { update, destroy }. Always call destroy() on unmount and never edit the ef- class names.",
    "v0": "Create a Next.js (App Router) client component for the \"Staggered grid reveal\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- staggered-grid-reveal.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nUse this component as the wrapper (adjust the import paths):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./staggered-grid-reveal\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function StaggeredGridReveal(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRender it on the home page so I can see it. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "lovable": "Add the \"Staggered grid reveal\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- staggered-grid-reveal.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nWrapper component (src/components/StaggeredGridReveal.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./staggered-grid-reveal\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function StaggeredGridReveal(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRemove the \"use client\" line if it is not needed. Show it on the home page. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "bolt": "Create a small Vite project (vanilla JavaScript, no framework unless I already have one) that shows the \"Staggered grid reveal\" element.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, then a script tag), style.css (the CSS below), staggered-grid-reveal.js (the JavaScript below) and main.js that sets the container's innerHTML to the markup and calls mount(container, opts) with the settings below. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "replit": "Create a new HTML, CSS and JavaScript Repl that shows the \"Staggered grid reveal\" element. No packages, no server code.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, link style.css, load staggered-grid-reveal.js and then main.js), style.css (the CSS below), staggered-grid-reveal.js (the JavaScript below), main.js (sets the container's innerHTML to the markup, then calls mount(container, opts) with the settings below). Press Run to preview. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "figma": "Designer handoff notes for the \"Staggered grid reveal\" element (Enrichr Library). Figma cannot run this JavaScript inside a design file, so use it as a motion reference and hand the code to a developer.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nWhat it does: Each tile gets a rank from the chosen order: its index for reading order, its distance from the grid's centre for centre-out (reversed for edges-in), or a shuffle for random. The Web Animations API then flips each tile up from below, rotated back on its bottom edge and scaled down, delayed by its rank times the stagger. A second, overshooting animation spins the tile's glyph in a little later. Fill mode backwards keeps a tile hidden only while it waits, so once it finishes the tile is an ordinary element with no lingering styles. An IntersectionObserver starts the reveal the first time a quarter of the grid is visible.\nAccessibility: Tiles are articles whose text is in the page from the start, and the glyphs are decorative and hidden from assistive technology. Replay is a real button. With prefers-reduced-motion the tiles are shown at once and Replay only does a short fade.\n\nTunable settings:\n- Tiles: range 4 to 16, step 1, default 12\n- Columns: range 2 to 6, step 1, default 4\n- Order: select (Random / Reading order / Centre out / Edges in), default random\n- Stagger (ms): range 20 to 200, step 10, default 70\n- Tile words (comma separated): text, default Motion, Form, Direction, Rhythm\n- Accent colour: color, default #e6ff55\n- Background: color, default #0c1e18\n\nCurrent settings:\n{{SETTINGS}}\n\nFor the developer: Element contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nIn Figma:\n- Draw the resting state as a frame and the end state as a second frame; link them with Smart Animate to show the motion in a prototype.\n- Put the settings above in the frame's notes or Dev Mode annotations so the developer matches them.\n- Link https://enrichr.dev/elements/staggered-grid-reveal.html in the handoff: the live demo and the copy-ready code are there. Developers can paste the prompts for Claude, Cursor or v0 from the Export menu.\nNothing is copied from another designer's file; this is original code from Enrichr.",
    "framer": "Add the \"Staggered grid reveal\" element to Framer as a code component. Framer code components are React, so wrap the vanilla code like this. Check it in the Framer editor, as Framer's component API can change.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. In Framer: Assets > Code > New component. Name it StaggeredGridReveal.\n2. Paste the JavaScript below into a separate code file named staggered-grid-reveal.js in the same project, with  export { mount };  and  export const markup = \"<the markup string>\";  added. Put the CSS into the component as a <style> tag.\n3. Component:\n```tsx\nimport { addPropertyControls, ControlType } from \"framer\"\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./staggered-grid-reveal\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function StaggeredGridReveal(props: any) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n\naddPropertyControls(StaggeredGridReveal, {\n  count: { type: ControlType.Number, title: \"Tiles\", min: 4, max: 16, step: 1, defaultValue: 12 },\n  columns: { type: ControlType.Number, title: \"Columns\", min: 2, max: 6, step: 1, defaultValue: 4 },\n  order: { type: ControlType.Enum, title: \"Order\", options: [\"random\",\"start\",\"center\",\"edges\"], optionTitles: [\"Random\",\"Reading order\",\"Centre out\",\"Edges in\"], defaultValue: \"random\" },\n  stagger: { type: ControlType.Number, title: \"Stagger\", min: 20, max: 200, step: 10, defaultValue: 70 },\n  words: { type: ControlType.String, title: \"Tile words (comma separated)\", defaultValue: \"Motion, Form, Direction, Rhythm\" },\n  accent: { type: ControlType.Color, title: \"Accent colour\", defaultValue: \"#e6ff55\" },\n  background: { type: ControlType.Color, title: \"Background\", defaultValue: \"#0c1e18\" },\n})\n```\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "webflow": "Add the \"Staggered grid reveal\" element to a Webflow site with an Embed element. Test it on the published or preview site: scripts in embeds may not run inside the Designer canvas.\n\nThis is the \"Staggered grid reveal\" element from the Enrichr Library: A grid of tiles that flip up one after another in random, reading, centre-out or edges-in order, then spin their glyphs into place.\nPage: https://enrichr.dev/elements/staggered-grid-reveal.html\nMachine-readable spec: https://enrichr.dev/elements/staggered-grid-reveal.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. Add an Embed element where it should appear. Paste a <style> block with the CSS, one container <div id=\"enrichr-staggered-grid-reveal\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-staggered-grid-reveal\"), { ...your settings... });\n   (set the container's innerHTML to the markup first, as in the contract).\n2. Embed elements have a size limit (check Webflow's current number). If the code is longer, host the JS and CSS as files and link them from Custom code in the page settings, then keep only the container and the mount call in the Embed.\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}"
  },
  "exportTools": [
    "claude",
    "chatgpt",
    "cursor",
    "v0",
    "lovable",
    "bolt",
    "replit",
    "figma",
    "framer",
    "webflow"
  ],
  "accessibility": "Tiles are articles whose text is in the page from the start, and the glyphs are decorative and hidden from assistive technology. Replay is a real button. With prefers-reduced-motion the tiles are shown at once and Replay only does a short fade.",
  "performance": "Only transform and opacity are animated, on the compositor, and nothing runs once the reveal has finished. The observer disconnects after the first play.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-sgr\">\n  <div class=\"ef-sgr__bar\">\n    <p class=\"ef-sgr__cap\">One timeline, many orders.</p>\n    <button type=\"button\" class=\"ef-sgr__btn\">Replay reveal</button>\n  </div>\n  <div class=\"ef-sgr__grid\"></div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-sgr { --ef-sgr-bg: #0c1e18; --ef-sgr-acc: #e6ff55; --ef-sgr-ink: #fbf8f1; --ef-sgr-cols: 4; width: 100%; box-sizing: border-box; padding: 1.2rem; border-radius: 1rem; background: var(--ef-sgr-bg); color: var(--ef-sgr-ink); font-family: \"Helvetica Neue\", Arial, \"Segoe UI\", system-ui, sans-serif; }\n.ef-sgr__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem; margin: 0 0 1rem; }\n.ef-sgr__cap { margin: 0; font-size: 0.95rem; opacity: 0.8; }\n.ef-sgr__btn { padding: 0.7rem 1.2rem; border: 1px solid color-mix(in srgb, var(--ef-sgr-ink) 40%, transparent); border-radius: 999px; background: transparent; color: inherit; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background 200ms, color 200ms; }\n.ef-sgr__btn:hover { background: var(--ef-sgr-acc); color: var(--ef-sgr-bg); border-color: var(--ef-sgr-acc); }\n.ef-sgr__btn:focus-visible { outline: 3px solid var(--ef-sgr-acc); outline-offset: 3px; }\n.ef-sgr__grid { display: grid; grid-template-columns: repeat(var(--ef-sgr-cols), minmax(0, 1fr)); gap: 0.75rem; perspective: 900px; }\n.ef-sgr__tile { position: relative; aspect-ratio: 1; box-sizing: border-box; padding: 0.8rem; border-radius: 0.75rem; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; background: color-mix(in srgb, var(--ef-sgr-bg) 60%, #2c6b4a); color: var(--ef-sgr-ink); transform-origin: 50% 100%; backface-visibility: hidden; container-type: inline-size; }\n.ef-sgr__tile:nth-child(4n+2) { background: var(--ef-sgr-acc); color: var(--ef-sgr-bg); }\n.ef-sgr__tile:nth-child(4n+3) { background: var(--ef-sgr-ink); color: var(--ef-sgr-bg); }\n.ef-sgr__tile:nth-child(4n) { background: color-mix(in srgb, var(--ef-sgr-acc) 30%, #3d6b52); }\n.ef-sgr__n { font: 600 0.62rem/1 ui-monospace, \"SFMono-Regular\", Menlo, monospace; letter-spacing: 0.1em; opacity: 0.75; }\n.ef-sgr__g { display: block; width: 46%; margin: 0 auto; height: auto; }\n.ef-sgr__w { font: 700 clamp(0.55rem, 9cqi, 0.8rem)/1 ui-monospace, \"SFMono-Regular\", Menlo, monospace; letter-spacing: 0.14em; text-transform: uppercase; }\n.ef-sgr.is-pending .ef-sgr__tile { opacity: 0; }\n@media (max-width: 520px) { .ef-sgr__grid { grid-template-columns: repeat(min(var(--ef-sgr-cols), 3), minmax(0, 1fr)); } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Staggered grid reveal: a grid of tiles that flip up out of the floor one after another, in random, reading, centre-out or\n// edges-in order, and then spin their glyphs into place. It plays once when the grid scrolls into view and again from the\n// Replay button. Built with the Web Animations API; fill \"backwards\" keeps each tile hidden only during its own delay,\n// so once the animation ends the tiles are plain, unanimated elements again.\n// mount(root, { count (4-16 tiles), columns (2-6), order (\"random\", \"start\", \"center\", \"edges\"), stagger (ms between tiles),\n//               words (comma separated), accent, background })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var box = root.querySelector(\".ef-sgr\");\n  var grid = root.querySelector(\".ef-sgr__grid\");\n  var btn = root.querySelector(\".ef-sgr__btn\");\n  var opts = {}, tiles = [], anims = [], io = null, played = false;\n  var NS = \"http://www.w3.org/2000/svg\";\n  var GLYPHS = [\n    '<path d=\"M50 8V92M8 50H92M20 20L80 80M80 20L20 80\" stroke-width=\"11\" stroke-linecap=\"round\"/>',\n    '<circle cx=\"50\" cy=\"50\" r=\"40\" stroke-width=\"8\"/><path d=\"M50 10a40 40 0 0 1 0 80z\" stroke=\"none\" fill=\"currentColor\"/>',\n    '<path d=\"M22 78L78 22M36 22h42v42\" stroke-width=\"11\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>',\n    '<circle cx=\"50\" cy=\"50\" r=\"40\" stroke-width=\"7\"/><circle cx=\"50\" cy=\"50\" r=\"20\" stroke-width=\"7\"/>',\n    '<path d=\"M50 6L94 50L50 94L6 50Z\" stroke-width=\"8\" stroke-linejoin=\"round\"/>',\n    '<path d=\"M10 70Q30 30 50 70T90 70\" stroke-width=\"10\" stroke-linecap=\"round\"/>'\n  ];\n\n  function stop() { anims.forEach(function (a) { try { a.cancel(); } catch (e) {} }); anims = []; }\n  function build() {\n    stop();\n    grid.textContent = \"\";\n    tiles = [];\n    var words = String(opts.words).split(\",\").map(function (w) { return w.trim(); }).filter(Boolean);\n    if (!words.length) words = [\"Tile\"];\n    for (var i = 0; i < opts.count; i++) {\n      var t = document.createElement(\"article\"); t.className = \"ef-sgr__tile\";\n      var n = document.createElement(\"span\"); n.className = \"ef-sgr__n\"; n.textContent = String(i + 1).padStart(2, \"0\");\n      var g = document.createElementNS(NS, \"svg\"); g.setAttribute(\"viewBox\", \"0 0 100 100\"); g.setAttribute(\"class\", \"ef-sgr__g\");\n      g.setAttribute(\"aria-hidden\", \"true\"); g.setAttribute(\"focusable\", \"false\"); g.setAttribute(\"fill\", \"none\"); g.setAttribute(\"stroke\", \"currentColor\");\n      g.innerHTML = GLYPHS[i % GLYPHS.length];\n      var w = document.createElement(\"b\"); w.className = \"ef-sgr__w\"; w.textContent = words[i % words.length];\n      t.appendChild(n); t.appendChild(g); t.appendChild(w);\n      grid.appendChild(t);\n      tiles.push({ el: t, g: g, i: i });\n    }\n  }\n  // Rank each tile by the chosen order; tiles with equal rank start together.\n  function ranks() {\n    var cols = opts.columns, n = tiles.length, rows = Math.ceil(n / cols);\n    var cx = (cols - 1) / 2, cy = (rows - 1) / 2;\n    var dist = tiles.map(function (t) { var x = t.i % cols, y = Math.floor(t.i / cols); return Math.hypot(x - cx, y - cy); });\n    if (opts.order === \"start\") return tiles.map(function (t) { return t.i; });\n    if (opts.order === \"center\" || opts.order === \"edges\") {\n      var max = Math.max.apply(null, dist) || 1;\n      return dist.map(function (d) { var k = d / max * (Math.max(cols, rows) - 1); return opts.order === \"center\" ? k : (Math.max(cols, rows) - 1) - k; });\n    }\n    var idx = tiles.map(function (t) { return t.i; });\n    for (var i = idx.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var s = idx[i]; idx[i] = idx[j]; idx[j] = s; }\n    var r = []; idx.forEach(function (ti, k) { r[ti] = k; });\n    return r;\n  }\n  function play() {\n    stop();\n    box.classList.remove(\"is-pending\");\n    if (!tiles.length || !tiles[0].el.animate) return;\n    if (reduce) {\n      anims.push(grid.animate([{ opacity: 0.35 }, { opacity: 1 }], { duration: 400, easing: \"ease-out\" }));\n      return;\n    }\n    var r = ranks(), step = Number(opts.stagger);\n    tiles.forEach(function (t, k) {\n      var d = r[k] * step;\n      anims.push(t.el.animate([\n        { opacity: 0, transform: \"translateY(55%) rotateX(-60deg) scale(0.8)\" },\n        { opacity: 1, transform: \"none\" }\n      ], { duration: 850, delay: d, easing: \"cubic-bezier(0.22, 1, 0.36, 1)\", fill: \"backwards\" }));\n      anims.push(t.g.animate([\n        { transform: \"rotate(-90deg) scale(0.3)\" },\n        { transform: \"none\" }\n      ], { duration: 750, delay: d + 220, easing: \"cubic-bezier(0.34, 1.56, 0.64, 1)\", fill: \"backwards\" }));\n    });\n  }\n  btn.addEventListener(\"click\", play);\n\n  function update(next) {\n    opts = Object.assign({ count: 12, columns: 4, order: \"random\", stagger: 70, words: \"Motion, Form, Direction, Rhythm\", accent: \"#e6ff55\", background: \"#0c1e18\" }, opts, next || {});\n    opts.count = Math.min(16, Math.max(4, Number(opts.count) || 12));\n    opts.columns = Math.min(6, Math.max(2, Number(opts.columns) || 4));\n    box.style.setProperty(\"--ef-sgr-cols\", opts.columns);\n    box.style.setProperty(\"--ef-sgr-acc\", opts.accent);\n    box.style.setProperty(\"--ef-sgr-bg\", opts.background);\n    build();\n    if (played) play();\n    else if (!reduce && tiles[0].el.animate) box.classList.add(\"is-pending\");\n  }\n  update(o);\n  if (\"IntersectionObserver\" in window) {\n    io = new IntersectionObserver(function (e) { if (e[0].isIntersecting && !played) { played = true; play(); io.disconnect(); } }, { threshold: 0.25 });\n    io.observe(grid);\n  } else { played = true; play(); }\n  return { update: update, destroy: function () { stop(); if (io) io.disconnect(); btn.removeEventListener(\"click\", play); } };\n}"
  }
}