{
  "id": "triangle-tile-drift",
  "kind": "element",
  "title": "Triangle tile drift",
  "summary": "A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.",
  "url": "https://enrichr.dev/elements/triangle-tile-drift.html",
  "section": "svg-bg",
  "techniques": [],
  "stack": [
    "Vanilla JS",
    "SVG"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "playful",
    "calm"
  ],
  "intents": [
    "animated triangle pattern background",
    "geometric tile background loop",
    "sliding svg pattern background",
    "colour shifting pattern background",
    "seamless moving tile pattern"
  ],
  "status": "tested",
  "params": [
    {
      "key": "tile",
      "label": "Tile size (px)",
      "type": "range",
      "min": 30,
      "max": 240,
      "step": 2,
      "value": 100
    },
    {
      "key": "slide",
      "label": "Slide time per tile (s)",
      "type": "range",
      "min": 1,
      "max": 30,
      "step": 0.5,
      "value": 9
    },
    {
      "key": "cycle",
      "label": "Colour shift",
      "type": "select",
      "options": [
        [
          "drift",
          "Gentle drift (stays near your colours)"
        ],
        [
          "full",
          "Full hue cycle (original)"
        ],
        [
          "off",
          "Off"
        ]
      ],
      "value": "drift"
    },
    {
      "key": "cycleTime",
      "label": "Colour shift time (s)",
      "type": "range",
      "min": 2,
      "max": 40,
      "step": 0.5,
      "value": 14
    },
    {
      "key": "pulse",
      "label": "Glow pulse time (s)",
      "type": "range",
      "min": 1,
      "max": 20,
      "step": 0.5,
      "value": 6
    },
    {
      "key": "glow",
      "label": "Glow strength",
      "type": "range",
      "min": 0,
      "max": 0.6,
      "step": 0.01,
      "value": 0.25
    },
    {
      "key": "c1",
      "label": "Top left square",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "c2",
      "label": "Top right square",
      "type": "color",
      "value": "#1a7a4c"
    },
    {
      "key": "c3",
      "label": "Bottom left square",
      "type": "color",
      "value": "#4b1a9a"
    },
    {
      "key": "c4",
      "label": "Bottom right square",
      "type": "color",
      "value": "#fbf8f1"
    },
    {
      "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 \"Triangle tile drift\" element to this project.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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/triangle-tile-drift.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 \"Triangle tile drift\" 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 \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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 \"Triangle tile drift\" element to this codebase.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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-triangle-tile-drift.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Triangle tile drift 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 \"Triangle tile drift\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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- triangle-tile-drift.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 \"./triangle-tile-drift\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function TriangleTileDrift(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 \"Triangle tile drift\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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- triangle-tile-drift.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/TriangleTileDrift.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./triangle-tile-drift\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function TriangleTileDrift(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 \"Triangle tile drift\" element.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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), triangle-tile-drift.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 \"Triangle tile drift\" element. No packages, no server code.\n\nThis is the \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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 triangle-tile-drift.js and then main.js), style.css (the CSS below), triangle-tile-drift.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 \"Triangle tile drift\" 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 \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.json\n\nWhat it does: One SVG pattern tile is split into four squares, and each square is cut on a diagonal into a light and a darker triangle (the darker one is the square's colour mixed 22% toward ink). Three loops run at once, with the original's timings. The pattern slides one whole tile toward the lower right every 9 seconds in a straight line, so the loop has no seam. The colours shift on a 14 second linear cycle, with saturation rising to 1.15 at the half-way point and back: the shift uses the same maths as the CSS hue-rotate() and saturate() filters, applied to the eight fill colours. Full hue cycle turns all the way round the colour wheel as the original does; Gentle drift swings 40 degrees each way so the colours stay close to the ones you pick. A soft radial light in the middle pulses between 35% and 75% opacity every 6 seconds on an ease-in-out curve.\nAccessibility: The SVG is decorative and has a text label. With prefers-reduced-motion it shows one still frame in the colours you picked and never animates. The changes are slow and nothing flashes. Nothing needs the keyboard.\n\nTunable settings:\n- Tile size (px): range 30 to 240, step 2, default 100\n- Slide time per tile (s): range 1 to 30, step 0.5, default 9\n- Colour shift: select (Gentle drift (stays near your colours) / Full hue cycle (original) / Off), default drift\n- Colour shift time (s): range 2 to 40, step 0.5, default 14\n- Glow pulse time (s): range 1 to 20, step 0.5, default 6\n- Glow strength: range 0 to 0.6, step 0.01, default 0.25\n- Top left square: color, default #e6ff55\n- Top right square: color, default #1a7a4c\n- Bottom left square: color, default #4b1a9a\n- Bottom right square: color, default #fbf8f1\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/triangle-tile-drift.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 \"Triangle tile drift\" 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 \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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 TriangleTileDrift.\n2. Paste the JavaScript below into a separate code file named triangle-tile-drift.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 \"./triangle-tile-drift\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function TriangleTileDrift(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(TriangleTileDrift, {\n  tile: { type: ControlType.Number, title: \"Tile size\", min: 30, max: 240, step: 2, defaultValue: 100 },\n  slide: { type: ControlType.Number, title: \"Slide time per tile\", min: 1, max: 30, step: 0.5, defaultValue: 9 },\n  cycle: { type: ControlType.Enum, title: \"Colour shift\", options: [\"drift\",\"full\",\"off\"], optionTitles: [\"Gentle drift (stays near your colours)\",\"Full hue cycle (original)\",\"Off\"], defaultValue: \"drift\" },\n  cycleTime: { type: ControlType.Number, title: \"Colour shift time\", min: 2, max: 40, step: 0.5, defaultValue: 14 },\n  pulse: { type: ControlType.Number, title: \"Glow pulse time\", min: 1, max: 20, step: 0.5, defaultValue: 6 },\n  glow: { type: ControlType.Number, title: \"Glow strength\", min: 0, max: 0.6, step: 0.01, defaultValue: 0.25 },\n  c1: { type: ControlType.Color, title: \"Top left square\", defaultValue: \"#e6ff55\" },\n  c2: { type: ControlType.Color, title: \"Top right square\", defaultValue: \"#1a7a4c\" },\n  c3: { type: ControlType.Color, title: \"Bottom left square\", defaultValue: \"#4b1a9a\" },\n  c4: { type: ControlType.Color, title: \"Bottom right square\", defaultValue: \"#fbf8f1\" },\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 \"Triangle tile drift\" 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 \"Triangle tile drift\" element from the Enrichr Library: A pattern of two-tone triangle tiles that slides slowly on the diagonal while its colours drift and a soft light pulses in the middle.\nPage: https://enrichr.dev/elements/triangle-tile-drift.html\nMachine-readable spec: https://enrichr.dev/elements/triangle-tile-drift.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-triangle-tile-drift\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-triangle-tile-drift\"), { ...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 SVG is decorative and has a text label. With prefers-reduced-motion it shows one still frame in the colours you picked and never animates. The changes are slow and nothing flashes. Nothing needs the keyboard.",
  "performance": "There is no filter: the colour shift is worked out for eight colours in script and written to the triangles, and the slide is one transform on the pattern. The browser redraws from one small tile. The loop pauses off screen or in a hidden tab.",
  "dependencies": [],
  "codepen": "https://codepen.io/Enrichr-Dev/pen/YPZdjBL",
  "source": {
    "markup": "<div class=\"ef-ttd\">\n  <svg class=\"ef-ttd__svg\" viewBox=\"0 0 800 600\" preserveAspectRatio=\"xMidYMid slice\" role=\"img\" aria-label=\"A pattern of two-tone triangle tiles in lime, green, violet and cream that slides slowly toward the lower right while a soft light pulses in the middle\">\n    <defs>\n      <linearGradient class=\"ef-ttd__bggrad\" id=\"ef-ttd-bg\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n        <stop class=\"ef-ttd__bg1\" offset=\"0%\" stop-color=\"#0c1e18\"/>\n        <stop class=\"ef-ttd__bg2\" offset=\"100%\" stop-color=\"#050d0a\"/>\n      </linearGradient>\n      <pattern class=\"ef-ttd__pat\" id=\"ef-ttd-grid\" width=\"100\" height=\"100\" patternUnits=\"userSpaceOnUse\">\n        <polygon class=\"ef-ttd__t\" points=\"0,0 50,0 50,50\" fill=\"#b4c94a\"/>\n        <polygon class=\"ef-ttd__t\" points=\"0,0 50,50 0,50\" fill=\"#e6ff55\"/>\n        <polygon class=\"ef-ttd__t\" points=\"50,0 100,0 50,50\" fill=\"#1a7a4c\"/>\n        <polygon class=\"ef-ttd__t\" points=\"100,0 100,50 50,50\" fill=\"#175f3e\"/>\n        <polygon class=\"ef-ttd__t\" points=\"0,50 50,50 0,100\" fill=\"#3b1979\"/>\n        <polygon class=\"ef-ttd__t\" points=\"50,50 50,100 0,100\" fill=\"#4b1a9a\"/>\n        <polygon class=\"ef-ttd__t\" points=\"50,50 100,50 100,100\" fill=\"#c7c8c0\"/>\n        <polygon class=\"ef-ttd__t\" points=\"50,50 100,100 50,100\" fill=\"#fbf8f1\"/>\n      </pattern>\n      <radialGradient class=\"ef-ttd__glowgrad\" id=\"ef-ttd-glow\" cx=\"50%\" cy=\"50%\" r=\"75%\">\n        <stop class=\"ef-ttd__g1\" offset=\"0%\" stop-color=\"#fbf8f1\" stop-opacity=\"0.25\"/>\n        <stop class=\"ef-ttd__g2\" offset=\"100%\" stop-color=\"#fbf8f1\" stop-opacity=\"0\"/>\n      </radialGradient>\n    </defs>\n    <rect class=\"ef-ttd__base\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" fill=\"url(#ef-ttd-bg)\"/>\n    <rect class=\"ef-ttd__tiles\" x=\"-100\" y=\"-100\" width=\"1000\" height=\"800\" fill=\"url(#ef-ttd-grid)\"/>\n    <rect class=\"ef-ttd__glow\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" fill=\"url(#ef-ttd-glow)\" opacity=\"0.55\"/>\n  </svg>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-ttd { position: relative; width: 100%; min-height: 22rem; overflow: hidden; border-radius: 1rem; background: #0c1e18; }\n.ef-ttd .ef-ttd__svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Triangle tile drift: an SVG pattern tile split into four squares, each cut on a diagonal into a light and a dark triangle.\n// Three loops run at once, as in the original SVG: the pattern slides one whole tile toward the lower right every 9 s in a\n// straight line (so the loop has no seam); the tile colours shift hue on a 14 s linear cycle with saturation rising to 1.15\n// at the half-way point; and a soft radial light in the middle pulses between 35% and 75% opacity every 6 s on an\n// ease-in-out curve. The hue shift uses the same matrices as the CSS hue-rotate() and saturate() filters, applied to the\n// eight fill colours, so there is no filter to repaint. \"Gentle drift\" swings the hue 40 degrees each way so the colours stay\n// close to the ones you pick; \"Full hue cycle\" is the original 360 degree turn.\n// Reduced motion shows one still frame with the colours as picked. Pauses off screen and in hidden tabs.\n// mount(root, { tile (px), slide (s per tile), cycle (\"drift\" | \"full\" | \"off\"), cycleTime (s), pulse (s), glow (strength),\n//               c1, c2, c3, c4 (top left, top right, bottom left, bottom right squares), background })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var box = root.querySelector(\".ef-ttd\");\n  var svg = root.querySelector(\".ef-ttd__svg\");\n  var pat = root.querySelector(\".ef-ttd__pat\");\n  var tris = [].slice.call(root.querySelectorAll(\".ef-ttd__t\"));\n  var tiles = root.querySelector(\".ef-ttd__tiles\");\n  var glow = root.querySelector(\".ef-ttd__glow\");\n  var g1 = root.querySelector(\".ef-ttd__g1\");\n  var bg1 = root.querySelector(\".ef-ttd__bg1\"), bg2 = root.querySelector(\".ef-ttd__bg2\");\n  var INK = [12, 30, 24];\n  // which square each triangle belongs to, and whether it is the darker facet (same light/dark split as the original)\n  var SQUARE = [0, 0, 1, 1, 2, 2, 3, 3], DARK = [1, 0, 0, 1, 1, 0, 1, 0];\n  var opts = {}, base = [], raf = 0, visible = true, io = null, ro = null, destroyed = false, last = 0, clock = 0, W = 1, H = 1;\n\n  // unique ids so several copies can sit on one page\n  var uid = Math.random().toString(36).slice(2, 9);\n  [[\"ef-ttd__bggrad\", \"ef-ttd__base\"], [\"ef-ttd__pat\", \"ef-ttd__tiles\"], [\"ef-ttd__glowgrad\", \"ef-ttd__glow\"]].forEach(function (pair, i) {\n    var def = root.querySelector(\".\" + pair[0]), id = \"ef-ttd-\" + i + \"-\" + uid;\n    def.setAttribute(\"id\", id);\n    root.querySelector(\".\" + pair[1]).setAttribute(\"fill\", \"url(#\" + id + \")\");\n  });\n\n  function num(v, d) { v = Number(v); return isFinite(v) ? v : d; }\n  function hex(h, d) { var m = /^#?([0-9a-f]{6})$/i.exec(h || \"\"); var v = parseInt(m ? m[1] : d, 16); return [v >> 16, (v >> 8) & 255, v & 255]; }\n  function clamp(v) { return v < 0 ? 0 : v > 255 ? 255 : v; }\n  function rgb(c) { return \"rgb(\" + Math.round(c[0]) + \",\" + Math.round(c[1]) + \",\" + Math.round(c[2]) + \")\"; }\n  // CSS ease-in-out, cubic-bezier(0.42, 0, 0.58, 1)\n  function bez(a, b, t) { var u = 1 - t; return 3 * u * u * t * a + 3 * u * t * t * b + t * t * t; }\n  function easeInOut(x) {\n    var lo = 0, hi = 1, t = x;\n    for (var i = 0; i < 20; i++) { var v = bez(0.42, 0.58, t); if (Math.abs(v - x) < 1e-5) break; if (v < x) lo = t; else hi = t; t = (lo + hi) / 2; }\n    return bez(0, 1, t);\n  }\n  // hue-rotate(deg) then saturate(s), the Filter Effects matrices, clamped after each step like a filter chain\n  function filter(c, deg, s) {\n    var a = deg * Math.PI / 180, cs = Math.cos(a), sn = Math.sin(a), r = c[0], g = c[1], b = c[2];\n    var r1 = clamp(r * (0.213 + cs * 0.787 - sn * 0.213) + g * (0.715 - cs * 0.715 - sn * 0.715) + b * (0.072 - cs * 0.072 + sn * 0.928));\n    var g1 = clamp(r * (0.213 - cs * 0.213 + sn * 0.143) + g * (0.715 + cs * 0.285 + sn * 0.140) + b * (0.072 - cs * 0.072 - sn * 0.283));\n    var b1 = clamp(r * (0.213 - cs * 0.213 - sn * 0.787) + g * (0.715 - cs * 0.715 + sn * 0.715) + b * (0.072 + cs * 0.928 + sn * 0.072));\n    return [\n      clamp(r1 * (0.213 + 0.787 * s) + g1 * (0.715 - 0.715 * s) + b1 * (0.072 - 0.072 * s)),\n      clamp(r1 * (0.213 - 0.213 * s) + g1 * (0.715 + 0.285 * s) + b1 * (0.072 - 0.072 * s)),\n      clamp(r1 * (0.213 - 0.213 * s) + g1 * (0.715 - 0.715 * s) + b1 * (0.072 + 0.928 * s))\n    ];\n  }\n\n  function frame(t) {\n    // slide: one tile toward the lower right per \"slide\" seconds, linear\n    var p = (t / opts.slide) % 1, d = p * opts.tile;\n    pat.setAttribute(\"patternTransform\", \"translate(\" + d.toFixed(2) + \" \" + d.toFixed(2) + \") scale(\" + (opts.tile / 100).toFixed(4) + \")\");\n    // colour: 0 -> 50% -> 100% keyframes, linear; saturation 1 -> 1.15 -> 1\n    var c = (t / opts.cycleTime) % 1, sat = c < 0.5 ? 1 + 0.15 * c / 0.5 : 1.15 - 0.15 * (c - 0.5) / 0.5, hue = 0;\n    if (opts.cycle === \"full\") hue = 360 * c;\n    else if (opts.cycle === \"drift\") hue = 40 * (c < 0.25 ? c * 4 : c < 0.75 ? 2 - c * 4 : c * 4 - 4);\n    else sat = 1;\n    for (var i = 0; i < tris.length; i++) tris[i].setAttribute(\"fill\", rgb(hue || sat !== 1 ? filter(base[i], hue, sat) : base[i]));\n    // glow: 0.35 -> 0.75 -> 0.35 with ease-in-out on each half\n    var g = (t / opts.pulse) % 1, op = g < 0.5 ? 0.35 + 0.4 * easeInOut(g / 0.5) : 0.75 - 0.4 * easeInOut((g - 0.5) / 0.5);\n    glow.setAttribute(\"opacity\", op.toFixed(3));\n  }\n  function still() {\n    var keep = opts.cycle; opts.cycle = \"off\";\n    frame(opts.pulse * 0.25); opts.cycle = keep;\n  }\n\n  function loop(now) {\n    raf = requestAnimationFrame(loop);\n    var dt = Math.min(0.05, (now - last) / 1000 || 0); last = now;\n    if (!visible || document.hidden) return;\n    clock += dt;\n    frame(clock);\n  }\n  function resize() {\n    W = Math.max(1, box.clientWidth); H = Math.max(1, box.clientHeight);\n    svg.setAttribute(\"viewBox\", \"0 0 \" + W + \" \" + H);\n    svg.setAttribute(\"preserveAspectRatio\", \"none\");\n    tiles.setAttribute(\"x\", -opts.tile); tiles.setAttribute(\"y\", -opts.tile);\n    tiles.setAttribute(\"width\", W + opts.tile * 2); tiles.setAttribute(\"height\", H + opts.tile * 2);\n    if (reduce) still(); else frame(clock);\n  }\n\n  function update(partial) {\n    opts = Object.assign({ tile: 100, slide: 9, cycle: \"drift\", cycleTime: 14, pulse: 6, glow: 0.25,\n      c1: \"#e6ff55\", c2: \"#1a7a4c\", c3: \"#4b1a9a\", c4: \"#fbf8f1\", background: \"#0c1e18\" }, opts, partial || {});\n    opts.tile = Math.max(10, num(opts.tile, 100)); opts.slide = Math.max(0.2, num(opts.slide, 9));\n    opts.cycleTime = Math.max(0.5, num(opts.cycleTime, 14)); opts.pulse = Math.max(0.2, num(opts.pulse, 6));\n    opts.glow = Math.max(0, num(opts.glow, 0.25));\n    if ([\"drift\", \"full\", \"off\"].indexOf(opts.cycle) < 0) opts.cycle = \"drift\";\n    var sq = [hex(opts.c1, \"e6ff55\"), hex(opts.c2, \"1a7a4c\"), hex(opts.c3, \"4b1a9a\"), hex(opts.c4, \"fbf8f1\")];\n    base = SQUARE.map(function (s, i) {\n      var c = sq[s];\n      return DARK[i] ? [c[0] * 0.78 + INK[0] * 0.22, c[1] * 0.78 + INK[1] * 0.22, c[2] * 0.78 + INK[2] * 0.22] : c;\n    });\n    var bg = hex(opts.background, \"0c1e18\");\n    bg1.setAttribute(\"stop-color\", opts.background);\n    bg2.setAttribute(\"stop-color\", rgb([bg[0] * 0.45, bg[1] * 0.45, bg[2] * 0.45]));\n    box.style.background = opts.background;\n    g1.setAttribute(\"stop-opacity\", opts.glow);\n    if (destroyed) return;\n    resize();\n  }\n\n  update(o);\n  if (!reduce) {\n    if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(box); }\n    last = performance.now(); raf = requestAnimationFrame(loop);\n  }\n  if (\"ResizeObserver\" in window) { ro = new ResizeObserver(function () { if (!destroyed) resize(); }); ro.observe(box); }\n  return {\n    update: update,\n    destroy: function () {\n      destroyed = true; cancelAnimationFrame(raf);\n      if (io) io.disconnect();\n      if (ro) ro.disconnect();\n    }\n  };\n}"
  }
}