{
  "id": "grid-overlay-explainer",
  "kind": "element",
  "title": "Grid overlay explainer",
  "summary": "Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.",
  "url": "https://enrichr.dev/elements/grid-overlay-explainer.html",
  "section": "page",
  "techniques": [
    "scroll-driven"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "clean",
    "educational"
  ],
  "intents": [
    "show the grid",
    "layout grid overlay",
    "column gutter visualisation",
    "design system grid explainer",
    "teaching layout"
  ],
  "status": "tested",
  "params": [
    {
      "key": "columns",
      "label": "Columns",
      "type": "range",
      "min": 4,
      "max": 12,
      "step": 1,
      "value": 12
    },
    {
      "key": "gutter",
      "label": "Gutter (px)",
      "type": "range",
      "min": 0,
      "max": 48,
      "step": 2,
      "value": 16
    },
    {
      "key": "margin",
      "label": "Margin (px)",
      "type": "range",
      "min": 0,
      "max": 96,
      "step": 4,
      "value": 24
    },
    {
      "key": "maxOpacity",
      "label": "Overlay strength",
      "type": "range",
      "min": 0.1,
      "max": 1,
      "step": 0.05,
      "value": 1
    },
    {
      "key": "manual",
      "label": "Fixed progress % (0 follows scroll)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 5,
      "value": 0
    },
    {
      "key": "bandColor",
      "label": "Band colour",
      "type": "color",
      "value": "#ff5a36"
    },
    {
      "key": "blockColor",
      "label": "Block colour",
      "type": "color",
      "value": "#c6f26b"
    },
    {
      "key": "textColor",
      "label": "Block text colour",
      "type": "color",
      "value": "#10261f"
    }
  ],
  "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 \"Grid overlay explainer\" element to this project.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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/grid-overlay-explainer.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 \"Grid overlay explainer\" 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 \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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 \"Grid overlay explainer\" element to this codebase.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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-grid-overlay-explainer.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Grid overlay explainer 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 \"Grid overlay explainer\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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- grid-overlay-explainer.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 \"./grid-overlay-explainer\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function GridOverlayExplainer(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 \"Grid overlay explainer\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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- grid-overlay-explainer.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/GridOverlayExplainer.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./grid-overlay-explainer\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function GridOverlayExplainer(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 \"Grid overlay explainer\" element.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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), grid-overlay-explainer.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 \"Grid overlay explainer\" element. No packages, no server code.\n\nThis is the \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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 grid-overlay-explainer.js and then main.js), style.css (the CSS below), grid-overlay-explainer.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 \"Grid overlay explainer\" 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 \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.json\n\nWhat it does: The layout and the overlay are two CSS grids that read the same custom properties for column count, gutter and margin, so the bands always sit exactly on the columns and cannot drift out of sync. Scroll progress sets one more property, the overlay opacity, so the bands fade in as the layout moves into view. Changing the columns control changes the grid for both at once.\nAccessibility: The bands are decorative and hidden from assistive technology; the example layout is a labelled group. With reduced motion the overlay is fully visible and does not fade. Do not rely on colour alone to explain the grid in real documentation.\n\nTunable settings:\n- Columns: range 4 to 12, step 1, default 12\n- Gutter (px): range 0 to 48, step 2, default 16\n- Margin (px): range 0 to 96, step 4, default 24\n- Overlay strength: range 0.1 to 1, step 0.05, default 1\n- Fixed progress % (0 follows scroll): range 0 to 100, step 5, default 0\n- Band colour: color, default #ff5a36\n- Block colour: color, default #c6f26b\n- Block text colour: color, default #10261f\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/grid-overlay-explainer.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 \"Grid overlay explainer\" 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 \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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 GridOverlayExplainer.\n2. Paste the JavaScript below into a separate code file named grid-overlay-explainer.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 \"./grid-overlay-explainer\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function GridOverlayExplainer(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(GridOverlayExplainer, {\n  columns: { type: ControlType.Number, title: \"Columns\", min: 4, max: 12, step: 1, defaultValue: 12 },\n  gutter: { type: ControlType.Number, title: \"Gutter\", min: 0, max: 48, step: 2, defaultValue: 16 },\n  margin: { type: ControlType.Number, title: \"Margin\", min: 0, max: 96, step: 4, defaultValue: 24 },\n  maxOpacity: { type: ControlType.Number, title: \"Overlay strength\", min: 0.1, max: 1, step: 0.05, defaultValue: 1 },\n  manual: { type: ControlType.Number, title: \"Fixed progress %\", min: 0, max: 100, step: 5, defaultValue: 0 },\n  bandColor: { type: ControlType.Color, title: \"Band colour\", defaultValue: \"#ff5a36\" },\n  blockColor: { type: ControlType.Color, title: \"Block colour\", defaultValue: \"#c6f26b\" },\n  textColor: { type: ControlType.Color, title: \"Block text colour\", defaultValue: \"#10261f\" },\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 \"Grid overlay explainer\" 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 \"Grid overlay explainer\" element from the Enrichr Library: Column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\nPage: https://enrichr.dev/elements/grid-overlay-explainer.html\nMachine-readable spec: https://enrichr.dev/elements/grid-overlay-explainer.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-grid-overlay-explainer\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-grid-overlay-explainer\"), { ...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": "The bands are decorative and hidden from assistive technology; the example layout is a labelled group. With reduced motion the overlay is fully visible and does not fade. Do not rely on colour alone to explain the grid in real documentation.",
  "performance": "One bounding-rect read per scroll frame and one custom property write. No animation library and no layout changes while it runs.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-grid\">\r\n  <div class=\"ef-grid__layout\"></div>\r\n  <div class=\"ef-grid__bands\" aria-hidden=\"true\"></div>\r\n  <span class=\"ef-grid__tag\" aria-hidden=\"true\"></span>\r\n</div>",
    "css": ".ef-grid { position: relative; padding: 0 var(--ef-margin, 24px); min-height: 14rem; --ef-cols: 12; --ef-gutter: 16px; }\r\n.ef-grid__layout, .ef-grid__bands { display: grid; grid-template-columns: repeat(var(--ef-cols), minmax(0, 1fr)); gap: var(--ef-gutter); }\r\n.ef-grid__layout { position: relative; z-index: 1; padding: 1.2rem 0; row-gap: var(--ef-gutter); }\r\n.ef-grid__block { border-radius: 0.5rem; min-height: 3.4rem; display: flex; align-items: flex-end; padding: 0.5rem 0.7rem; font-size: 0.8rem; font-weight: 600; color: var(--ef-ink, #10261f); background: var(--ef-block, #c6f26b); overflow: hidden; }\r\n.ef-grid__bands { position: absolute; z-index: 2; inset: 0 var(--ef-margin, 24px); pointer-events: none; opacity: var(--ef-o, 1); }\r\n.ef-grid__band { background: color-mix(in srgb, var(--ef-band-hex, #ff5a36) 32%, transparent); border-inline: 1px solid var(--ef-band-hex, #ff5a36); }\r\n.ef-grid__tag { position: absolute; z-index: 3; right: var(--ef-margin, 24px); top: 0.3rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 100rem; background: #fff; color: #000; opacity: var(--ef-o, 1); }",
    "js": "// Grid overlay explainer: column and gutter bands fade in over a live layout as it scrolls into view, to show how the grid is built.\r\n// The layout and the bands read the same CSS custom properties, so they can never disagree.\r\n// mount(root, { columns (4-12), gutter (px), margin (px), maxOpacity (0-1), manual (0 = follow scroll, 1-100 = fixed %), bandColor, blockColor, textColor })\r\nfunction mount(root, o) {\r\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\r\n  var box = root.querySelector(\".ef-grid\");\r\n  var layout = root.querySelector(\".ef-grid__layout\");\r\n  var bands = root.querySelector(\".ef-grid__bands\");\r\n  var tag = root.querySelector(\".ef-grid__tag\");\r\n  var opts = {}, raf = 0;\r\n\r\n  // block spans for a 12 column grid; scaled down for fewer columns\r\n  var SPANS = [[12, \"Header\"], [8, \"Main\"], [4, \"Aside\"], [4, \"A\"], [4, \"B\"], [4, \"C\"]];\r\n  function render() {\r\n    var cols = Math.max(2, Math.min(12, opts.columns));\r\n    box.style.setProperty(\"--ef-cols\", cols);\r\n    box.style.setProperty(\"--ef-gutter\", opts.gutter + \"px\");\r\n    box.style.setProperty(\"--ef-margin\", opts.margin + \"px\");\r\n    box.style.setProperty(\"--ef-band-hex\", opts.bandColor);\r\n    box.style.setProperty(\"--ef-block\", opts.blockColor);\r\n    box.style.setProperty(\"--ef-ink\", opts.textColor);\r\n    layout.textContent = \"\"; bands.textContent = \"\";\r\n    SPANS.forEach(function (s) {\r\n      var d = document.createElement(\"div\");\r\n      d.className = \"ef-grid__block\";\r\n      d.style.gridColumn = \"span \" + Math.max(1, Math.round((s[0] / 12) * cols));\r\n      d.textContent = s[1];\r\n      layout.appendChild(d);\r\n    });\r\n    for (var i = 0; i < cols; i++) { var b = document.createElement(\"div\"); b.className = \"ef-grid__band\"; bands.appendChild(b); }\r\n    tag.textContent = cols + \" columns · \" + opts.gutter + \"px gutter · \" + opts.margin + \"px margin\";\r\n    layout.setAttribute(\"role\", \"group\");\r\n    layout.setAttribute(\"aria-label\", \"Example layout on a \" + cols + \" column grid\");\r\n    paint();\r\n  }\r\n  function paint() {\r\n    raf = 0;\r\n    var p = 1;\r\n    if (!reduce) {\r\n      if (opts.manual > 0) p = opts.manual / 100;\r\n      else { var r = box.getBoundingClientRect(), vh = window.innerHeight || 800; p = Math.min(1, Math.max(0, (vh * 0.9 - r.top) / (vh * 0.5))); }\r\n    }\r\n    box.style.setProperty(\"--ef-o\", String((p * opts.maxOpacity).toFixed(3)));\r\n  }\r\n  function schedule() { if (!raf) raf = requestAnimationFrame(paint); }\r\n  function update(next) {\r\n    opts = Object.assign({ columns: 12, gutter: 16, margin: 24, maxOpacity: 1, manual: 0, bandColor: \"#ff5a36\", blockColor: \"#c6f26b\", textColor: \"#10261f\" }, opts, next || {});\r\n    render();\r\n  }\r\n  update(o);\r\n  if (!reduce) { window.addEventListener(\"scroll\", schedule, { passive: true }); window.addEventListener(\"resize\", schedule); }\r\n  return { update: update, destroy: function () { cancelAnimationFrame(raf); window.removeEventListener(\"scroll\", schedule); window.removeEventListener(\"resize\", schedule); } };\r\n}"
  }
}