{
  "$schema": "../../schema.json",
  "id": "social-loop",
  "type": "recipe",
  "title": "Social loop",
  "summary": "A seamless 8 s loop for a feed: a living background, the brand and one line that comes and goes.",
  "tags": [
    "recipe",
    "loop",
    "social",
    "9:16",
    "4:5"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "params": [
    {
      "name": "line",
      "type": "string",
      "default": "One line in the brand’s voice.",
      "description": "the line that comes and goes",
      "group": "main",
      "control": "text"
    },
    {
      "name": "what",
      "type": "string",
      "default": "",
      "description": "name · what it is · where; empty builds it",
      "group": "main",
      "control": "text"
    },
    {
      "name": "background",
      "type": "string",
      "default": "",
      "description": "a background id from the registry; empty uses the brand's first",
      "group": "main",
      "control": "select"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1080x1350",
      "options": [
        "1080x1350",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size",
      "group": "main",
      "control": "segmented"
    },
    {
      "name": "text",
      "type": "enum",
      "default": "",
      "options": [
        "",
        "rise",
        "pop",
        "blur"
      ],
      "description": "how the line enters; empty follows motion.json",
      "group": "advanced",
      "control": "segmented"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/social-loop/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>social loop</title>\n<!--\n  Recipe · social loop (8 s, seamless). A piece that plays forever in a feed.\n  Field: a shader-set entry the whole loop · What: name and what it is, small and steady · Line 1–5 s: one line\n  enters, holds, leaves · Seam: the last 0.5 s returns to the first frame. Check frame 0 and the last with pamo still.\n  Look, fonts, pace and sound come from /brand (serve from the project root). Edit CONFIG first.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n</style>\n</head>\n<body>\n<main id=\"stage\">\n  <div id=\"bg\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"what\" class=\"abs\"></div>\n  <div id=\"line\" class=\"abs\"></div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease } from 'paper-motion';\nimport { wordRise, popIn, blurIn } from 'paper-motion/moves';\nimport { loadBrand } from 'paper-motion/brand';\n\nconst CONFIG = {\n  background: null,                  // a shader-set id with `loop` or `motion` (pamo add grain-slate), or null\n  backgroundOpacity: 0.85,                 // the shader behind the type; 1 for a field with no words over it\n  what: null,                        // \"Name · what it is · where\"; null builds it from the brand\n  line: 'One line in the brand’s voice.',\n  text: null,                        // rise | pop | blur; null follows motion.json\n  format: [1080, 1350],              // 1080×1350 (feed), 1080×1920 (stories), 1080×1080\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), M = Math.round(SHORT * 0.08), D = 8;\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 && (e.loop || e.motion))?.id ?? B.set.entries.find((e) => e.shader && !e.image)?.id;\nif (bgId) B.shader(s, '#bg', bgId, { loop: D });\ndocument.querySelector('#bg').style.opacity = CONFIG.backgroundOpacity;   // the material sits behind the type, never over it\n\nconst what = B.style(document.querySelector('#what'), 'caption', { short: SHORT, color: 'figure' });\nconst line = B.style(document.querySelector('#line'), 'title', { short: SHORT });\nObject.assign(what.style, { left: `${M}px`, top: `${M}px`, right: `${M}px` });\nObject.assign(line.style, { left: `${M}px`, right: `${M}px`, bottom: `${M}px` });\nwhat.textContent = CONFIG.what ?? [B.name, (B.identity['In one line'] ?? '').split(/[.\\n]/)[0]].filter(Boolean).join(' · ');\nline.textContent = CONFIG.line;\nconst TEXT = CONFIG.text ?? { typing: 'rise', blur: 'blur', track: 'rise' }[B.motion?.text] ?? 'rise';\n\ns.update((t) => {\n  if (TEXT === 'pop') popIn(line, t, { start: 1.0 });\n  else if (TEXT === 'blur') blurIn(line, t, { start: 1.0, duration: 0.9 });\n  else wordRise(line, t, { start: 1.0, each: B.pace.stagger, duration: 0.8 });\n  // leave before the seam: the loop closes on the same empty frame it opened with\n  const out = progress(t, 5.0, 5.6, ease.inCubic);\n  line.style.opacity = TEXT === 'blur' && t < 5 ? line.style.opacity : 1 - out;\n  line.style.translate = `0 ${-out * SHORT * 0.02}px`;\n});\nB.cue(s, 'text', 1.0); B.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/social-loop/brief.md",
      "content": "# Social loop\n\nRecipe: social loop (8 s), from paper-motion.app. The look, fonts, pace and sound come from `brand/`.\n\n## Before building\n- Agree the brief with the user: what the brand is in plain words, the one action at the end, the format.\n- Edit `CONFIG` at the top of scene.html: the copy, the background id, the format.\n- Swap the moves for the ones the user picked (`npx paper-motion add <id>`) and put real material where there is some.\n\n## Check and render\n- `npx paper-motion still pieces/social-loop/scene.html --count 8` and look at the contact sheet.\n- `npx paper-motion render pieces/social-loop/scene.html --motion-blur 5`\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "npx paper-motion add social-loop --name my-piece\n# edit CONFIG in pieces/my-piece/scene.html, then:\nnpx paper-motion render pieces/my-piece/scene.html --motion-blur 5",
  "notes": [
    "Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work: pamo add sage-night instrument) and, for the background, a shader-set entry (pamo add mesh-sage).",
    "Structure and timing only; the look always comes from the brand.",
    "Uses these moves from the engine: word-rise, pop-in, blur-in."
  ],
  "related": [
    "word-rise",
    "pop-in",
    "blur-in"
  ],
  "preview": {
    "video": "previews/social-loop.webm",
    "poster": "previews/social-loop.jpg",
    "at": 3.5,
    "values": {
      "line": "Your agent proposes. You choose. It renders.",
      "what": "paper-motion · brand videos by coding agents"
    }
  },
  "mood": [
    "calm",
    "minimal",
    "warm"
  ],
  "duration": 8,
  "formats": [
    "4:5",
    "9:16",
    "1:1"
  ],
  "when": [
    "a feed post that plays forever",
    "presence, not information"
  ],
  "beats": [
    {
      "name": "Field",
      "from": 0,
      "to": 8,
      "what": "a living background and the brand, steady"
    },
    {
      "name": "Line",
      "from": 1,
      "to": 5,
      "what": "one line enters, holds, leaves"
    },
    {
      "name": "Seam",
      "from": 7.5,
      "to": 8,
      "what": "back to the first frame"
    }
  ]
}