{
  "format": "css.observer/playground@1",
  "id": "4b1efa17-9be5-56d1-91aa-1dc12253aa02",
  "url": "https://css.observer/u/mighil/s/ogk36iwlyw",
  "title": "Path trace",
  "description": "One stroke draws the path, then stops.",
  "category": "effects",
  "tags": [
    "stroke",
    "micro-interaction"
  ],
  "visibility": "public",
  "status": "published",
  "revision": 1,
  "author": "mighil",
  "forked_from": null,
  "created_at": "2026-12-02T12:07:29.000Z",
  "updated_at": "2026-12-02T14:20:44.069Z",
  "published_at": "2026-12-02T12:07:29.000Z",
  "source": {
    "html": "<svg class=\"trace-svg\" id=\"trace-svg\" viewBox=\"0 0 220 56\" aria-hidden=\"true\">\n        <path d=\"M8 40 C40 8, 70 48, 110 22 S180 8, 212 34\"/>\n      </svg>\n",
    "css": "/* Auto light / dark — follows prefers-color-scheme */\n:root{\n  color-scheme: light dark;\n  --text-color: hsl(0, 0%, 18%);\n  --heading-color: hsl(0, 0%, 18%);\n  --background-color: hsl(0, 0%, 99%);\n  --bg-color: hsl(0, 0%, 99%);\n  --link-color: hsl(0, 0%, 18%);\n  --visited-color: hsl(0, 0%, 18%);\n  --blockquote-color: hsl(0, 0%, 18%);\n  --code-bg-color: hsl(0, 0%, 95%);\n  --code-color: hsl(0, 0%, 18%);\n  --sub-color: hsl(0, 0%, 29%);\n}\n@media (prefers-color-scheme: dark){\n:root{\n  --text-color: hsla(0, 0%, 93%, 1);\n  --heading-color: hsla(0, 0%, 93%, 1);\n  --background-color: hsla(0, 0%, 0%, 1);\n  --bg-color: hsla(0, 0%, 0%, 1);\n  --link-color: hsla(0, 0%, 93%, 1);\n  --visited-color: hsla(0, 0%, 93%, 0.85);\n  --blockquote-color: hsla(0, 0%, 93%, 1);\n  --code-bg-color: hsla(0, 0%, 8%, 1);\n  --code-color: limegreen;\n  --sub-color: hsla(0, 0%, 93%, 0.78);\n}\n}\n\n/* Preview layout */\nbody {\n  margin: 0;\n  min-height: 100vh;\n  display: grid;\n  place-items: center;\n  padding: 24px;\n  box-sizing: border-box;\n  background: var(--background-color);\n  color: var(--text-color);\n  font: 15px/1.5 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n}\n\n.trace-svg{width:min(100%,300px);height:72px;overflow:visible;color:inherit}\n\n.trace-svg path{\n  fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;\n  opacity:.85;\n}\n",
    "js": "const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nfunction pulseTap(el) {\n  if (!el || reduce) return;\n  el.classList.remove('is-tap');\n  void el.offsetWidth;\n  el.classList.add('is-tap');\n  clearTimeout(el._tapTimer);\n  el._tapTimer = setTimeout(() => el.classList.remove('is-tap'), 260);\n}\n// Path trace\n  const traceSvg = document.getElementById('trace-svg');\n  function runTrace() {\n    if (!traceSvg) return;\n    const path = traceSvg.querySelector('path');\n    if (!path) return;\n    const len = path.getTotalLength();\n    path.style.transition = 'none';\n    path.style.strokeDasharray = String(len);\n    path.style.strokeDashoffset = String(len);\n    void path.getBoundingClientRect();\n    if (reduce) {\n      path.style.strokeDashoffset = '0';\n      return;\n    }\n    requestAnimationFrame(() => {\n      path.style.transition = 'stroke-dashoffset 1.4s cubic-bezier(.22, 1, .36, 1)';\n      path.style.strokeDashoffset = '0';\n    });\n  }\n  runTrace();\n\ndocument.querySelectorAll('[data-act]').forEach((btn) => {\n    btn.addEventListener('click', (e) => {\n      e.stopPropagation();\n      const act = btn.getAttribute('data-act');\n      if (act === 'trace') runTrace();\n    });\n  });"
  }
}