{
  "$schema": "../../schema.json",
  "version": "1.0.0",
  "license": "MIT",
  "id": "svg-logo",
  "type": "block",
  "title": "SVG logo",
  "summary": "The brand's own SVG logo draws on: outlines trace in the accent, shapes fill from their centre, a glint passes and the name lands beside it.",
  "tags": [
    "block",
    "brand",
    "logo",
    "svg",
    "sting",
    "end-card"
  ],
  "params": [
    {
      "name": "background",
      "type": "string",
      "default": "",
      "description": "a background id from the registry; empty uses the brand's first",
      "group": "advanced",
      "control": "select"
    },
    {
      "name": "name",
      "type": "string",
      "default": "",
      "description": "the name beside the mark; empty takes the brand's name, 'none' for the mark alone",
      "group": "main",
      "control": "text"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size; the layout recomposes for each",
      "group": "main",
      "control": "segmented"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/svg-logo/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>svg-logo</title>\n<!--\n  Brand · SVG logo draw (5.4 s). The brand's own logo, from its SVG: every shape's outline traces on in the accent, one\n  after another; the shapes fill in from their centre on a spring, the outlines let go, a glint crosses the mark and\n  the name lands beside it. The camera starts close and tilted on the mark and pulls back to the lockup. Paste any\n  SVG in `svg`; each path, rect, circle, ellipse, polygon or line animates as one part.\n  Vertical/square: the lockup stacks (name under the mark), the name sized to fit the width; the camera starts on\n  the mark and settles on the stacked lockup.\n  Trace 0.3–1.7 s · Fill 1.4–2.4 s · Glint 2.5 s · Name 2.7 s · Hold to 5.4 s.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  #lock { display: flex; align-items: center; }\n  #mark { position: relative; flex: none; }\n  #mark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }\n  #glint { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; }\n  #name { white-space: nowrap; }\n</style>\n</head>\n<body>\n<main id=\"stage\">\n  <div id=\"bg\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"vig\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"world\"><div id=\"lock\"><div id=\"mark\"></div><div id=\"name\"></div></div></div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease, spring } from 'paper-motion';\nimport { camera } from 'paper-motion/kit';\nimport { loadBrand } from 'paper-motion/brand';\n\nconst CONFIG = {\n  background: null,                      // a shader-set id, or null for the brand's first entry\n  // the logo; `currentColor` takes the brand's figure, `var(--accent)` its accent\n  svg: `<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n    <path d=\"M18 12 H64 L84 32 V88 H18 Z\" fill=\"currentColor\"/>\n    <path d=\"M64 12 V32 H84 Z\" fill=\"var(--accent)\"/>\n    <path d=\"M30 50 H64\" stroke=\"var(--ground)\" stroke-width=\"6\" stroke-linecap=\"round\" fill=\"none\"/>\n    <path d=\"M30 63 H72\" stroke=\"var(--ground)\" stroke-width=\"6\" stroke-linecap=\"round\" fill=\"none\"/>\n    <path d=\"M30 76 H52\" stroke=\"var(--ground)\" stroke-width=\"6\" stroke-linecap=\"round\" fill=\"none\"/>\n  </svg>`,\n  name: '',                              // the name beside the mark; empty takes the brand's name, 'none' for the mark alone\n  format: [1920, 1080],\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 5.4;\nconst s = scene({ width: W, height: H, fps: 30, duration: D, background: B.color('ground') });\nconst bgId = CONFIG.background ?? B.set.entries.find((e) => e.shader && !e.image)?.id;\nif (bgId) B.shader(s, '#bg', bgId);\nconst $ = (id) => document.getElementById(id);\n$('bg').style.opacity = 0.35;\n$('vig').style.background = 'radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 25%, rgba(0,0,0,0.7) 100%)';\nconst accent = B.color('accent', '#E9E4D8'), figure = B.color('figure'), ground = B.color('ground');\n\nconst DIST = SHORT * 0.62, K = 1 + DIST / (SHORT * 1.7);\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });\nconst stack = W <= H, mark = $('mark'), ms = SHORT * (H > W ? 0.55 : 0.36) * K;\nif (stack) $('lock').style.flexDirection = 'column';\nObject.assign(mark.style, { width: `${ms}px`, height: `${ms}px`, color: figure, '--accent': accent, '--ground': ground });\nmark.style.setProperty('--accent', accent); mark.style.setProperty('--ground', ground);\nmark.innerHTML = CONFIG.svg;\nconst glint = document.createElement('div'); glint.id = 'glint'; mark.append(glint);\nconst svg = mark.querySelector('svg');\nconst parts = [...svg.querySelectorAll('path, rect, circle, ellipse, polygon, polyline, line')];\n// attributes don't read CSS variables: move those colours into styles\nfor (const p of parts) for (const k of ['fill', 'stroke']) { const v = p.getAttribute(k); if (v && v.includes('var(')) { p.style[k] = v; p.removeAttribute(k); } }\n// each part gets an outline twin that traces on first\nconst outlines = parts.map((p) => {\n  const o = p.cloneNode(); o.removeAttribute('fill'); o.removeAttribute('stroke-width');\n  Object.assign(o.style, { fill: 'none', stroke: accent, strokeWidth: '0.9', strokeLinecap: 'round', strokeLinejoin: 'round' });\n  svg.append(o); return o;\n});\nconst name = B.style($('name'), 'display', { short: SHORT * K, color: 'figure' });\nname.textContent = CONFIG.name === 'none' ? '' : CONFIG.name || B.name;\nObject.assign(name.style, stack ? { fontSize: `${ms * 0.36}px`, marginTop: `${ms * 0.12}px` } : { fontSize: `${ms * 0.36}px`, marginLeft: `${ms * 0.16}px` });\ncam.place($('lock'), { x: 0, y: 0, z: 0 });\nawait document.fonts.ready;\nconst lens = outlines.map((o) => o.getTotalLength());\noutlines.forEach((o, i) => { o.style.strokeDasharray = `${lens[i]}`; });\n// the centre of each part, so it can grow out of itself\nconst boxes = parts.map((p) => { const b = p.getBBox(); return `${b.x + b.width / 2}px ${b.y + b.height / 2}px`; });\nif (stack) {   // the name fits the width at the camera's final distance, with a margin\n  const fin = (SHORT * 1.7) / (SHORT * 1.7 + DIST + SHORT * 0.04);\n  name.style.fontSize = `${Math.min(ms * 0.36, ms * 0.36 * (W * 0.84 / fin) / Math.max(1, name.offsetWidth))}px`;\n}\nconst lh = $('lock').offsetHeight, markY = -lh / 2 + ms / 2;\nconst lw = $('lock').offsetWidth, nameShift = (name.offsetWidth + ms * 0.16) / 2;\n\nconst T = { trace: [0.3, 1.7], fill: [1.4, 2.4], glint: [2.5, 3.3], name: 2.7 };\nconst n = parts.length;\ns.update((t) => {\n  parts.forEach((p, i) => {\n    const k = n > 1 ? i / (n - 1) : 0;\n    const a = T.trace[0] + (T.trace[1] - T.trace[0] - 0.7) * k, d = progress(t, a, a + 0.7, ease.inOutCubic);\n    outlines[i].style.strokeDashoffset = `${lens[i] * (1 - d)}`; outlines[i].style.opacity = d > 0 ? String(1 - progress(t, T.fill[0] + 0.3 + k * 0.4, T.fill[0] + 0.8 + k * 0.4)) : '0';\n    const fa = T.fill[0] + (T.fill[1] - T.fill[0] - 0.5) * k, f = t >= fa ? spring(t - fa, { stiffness: 210, damping: 14 }) : 0;\n    p.style.transformOrigin = boxes[i]; p.style.transformBox = 'view-box';\n    p.style.transform = `scale(${0.6 + 0.4 * f})`; p.style.opacity = String(Math.min(1, f * 1.6));\n  });\n  // a glint across the finished mark\n  const g = progress(t, ...T.glint, ease.inOutSine);\n  glint.style.background = `linear-gradient(115deg, transparent ${g * 140 - 30}%, rgba(255,255,255,0.55) ${g * 140 - 20}%, transparent ${g * 140 - 10}%)`;\n  glint.style.webkitMaskImage = glint.style.maskImage = `url(\"data:image/svg+xml;utf8,${encodeURIComponent(CONFIG.svg.replace(/var\\(--[a-z]+\\)|currentColor/g, '#fff'))}\")`;\n  glint.style.webkitMaskSize = glint.style.maskSize = '100% 100%';\n  glint.style.opacity = String(Math.sin(g * Math.PI));\n  // the name lands beside the mark; the lockup recentres as it does\n  const nm = t >= T.name ? spring(t - T.name, { stiffness: 170, damping: 17 }) : 0;\n  name.style.opacity = String(Math.min(1, nm * 1.5)); name.style.transform = stack ? `translateY(${(1 - nm) * -ms * 0.15}px)` : `translateX(${(1 - nm) * -ms * 0.15}px)`; name.style.filter = nm < 0.9 ? `blur(${(1 - nm) * 8}px)` : 'none';\n  // the camera: close and tilted on the mark, back to the lockup\n  const p = progress(t, 0, T.name + 0.6, ease.inOutCubic);\n  const markX = -lw / 2 + ms / 2, cx = markX * (1 - nm) + 0 * nm;\n  cam.at({ x: stack ? 0 : cx, y: stack ? markY * (1 - nm) : 0, z: DIST - SHORT * 0.85 * (1 - p) + SHORT * 0.1 * nm - SHORT * 0.06 * progress(t, T.name + 0.6, D, ease.inOutSine), yaw: -18 * (1 - p), pitch: 8 * (1 - p), roll: -3 * (1 - p) });\n});\nB.cue(s, 'text', T.trace[0]); B.cue(s, 'land', T.fill[0] + 0.3); B.cue(s, 'transition', T.name);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/svg-logo/brief.md",
      "content": "# SVG logo\n\nBlock: svg-logo (5.4 s), from paper-motion.app. The look, fonts and sound come from `brand/`.\n\nThe brand's own SVG logo draws on: outlines trace in the accent, shapes fill from their centre, a glint passes and the name lands beside it.\n\nA block is one ready-made moment. Edit `CONFIG` (its words, numbers and format: 16:9, 9:16 or 1:1, the layout recomposes for each); check `npx paper-motion still` at 1.7 and 2.4 s; render.\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.6"
  },
  "usage": "npx paper-motion add svg-logo --name my-svg-logo\n# edit CONFIG in pieces/my-svg-logo/scene.html, then:\nnpx paper-motion render pieces/my-svg-logo/scene.html --motion-blur 5",
  "notes": [
    "Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work) and, for the field, a shader-set entry.",
    "Recomposes for 16:9, 9:16 and 1:1: set `format` and the layout and camera follow."
  ],
  "related": [
    "logo-build",
    "end-card"
  ],
  "preview": {
    "video": "previews/svg-logo.webm",
    "poster": "previews/svg-logo.jpg",
    "at": 5,
    "values": {}
  },
  "mood": [
    "technical",
    "luxury"
  ],
  "duration": 5.4,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "beats": [
    {
      "name": "Trace",
      "from": 0.3,
      "to": 1.7,
      "what": "trace"
    },
    {
      "name": "Fill",
      "from": 1.4,
      "to": 2.4,
      "what": "fill"
    },
    {
      "name": "Glint",
      "from": 2.5,
      "to": 3.1,
      "what": "glint"
    },
    {
      "name": "Name",
      "from": 2.7,
      "to": 3.3000000000000003,
      "what": "name"
    },
    {
      "name": "Hold",
      "from": 3.3000000000000003,
      "to": 5.4,
      "what": "hold"
    }
  ],
  "when": [
    "a logo sting from your own SVG",
    "the close of any video"
  ],
  "needs": [
    {
      "kind": "logo",
      "fill": {
        "svg": "$svg",
        "name": "$name"
      }
    }
  ]
}