{
  "$schema": "../../schema.json",
  "version": "1.0.0",
  "license": "MIT",
  "id": "focus-pull",
  "type": "shot",
  "title": "Focus pull",
  "summary": "A close-up: a detail sharp and large, a title soft behind it; the focus pulls to the title as the camera eases back, in 4 s.",
  "tags": [
    "shot",
    "close-up",
    "focus",
    "depth",
    "camera",
    "title"
  ],
  "params": [
    {
      "name": "detailText",
      "type": "string",
      "default": "0.2s",
      "description": "the detail in focus first: a word or a number",
      "group": "main",
      "control": "text"
    },
    {
      "name": "detailImage",
      "type": "string",
      "default": "",
      "description": "or a picture for the detail (path)",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "title",
      "type": "string",
      "default": "Every frame, on time.",
      "description": "what comes into focus behind it",
      "group": "main",
      "control": "text"
    },
    {
      "name": "line",
      "type": "string",
      "default": "",
      "description": "a small line under the title",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "background",
      "type": "string",
      "default": "",
      "description": "a background id from the registry; empty uses the brand's first",
      "group": "advanced",
      "control": "select"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size",
      "group": "main",
      "control": "segmented"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/focus-pull/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>focus-pull</title>\n<!--\n  Shot · focus pull (4 s). A close-up: a detail is sharp and large, a title stands behind it, soft; the focus pulls\n  from the detail to the title as the camera eases back a step. One gesture, one thing said.\n  Detail 0–1.6 s · Pull 1.6–2.6 s · Title 2.6–4 s.\n  Look, fonts and sound come from /brand. Edit CONFIG: the detail (a word, a number, or a picture), the title.\n  Ask your agent to put your own material in `detail.image`, change the words, or chain this shot into a piece.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  .place { display: flex; flex-direction: column; align-items: center; text-align: center; box-sizing: border-box; }\n  #detail { overflow: hidden; display: flex; align-items: center; justify-content: center; }\n  #detail img { width: 100%; height: 100%; object-fit: cover; }\n</style>\n</head>\n<body>\n<main id=\"stage\">\n  <div id=\"bg\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"world\">\n    <div id=\"p-title\" class=\"place\"><div id=\"title\"></div><div id=\"line\"></div></div>\n    <div id=\"detail\"></div>\n  </div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease } from 'paper-motion';\nimport { wordRise, blurIn } from 'paper-motion/moves';\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  detail: { text: '0.2s', image: '' },   // the thing in focus first: a word or number, or a picture (path)\n  title: 'Every frame, on time.',        // what comes into focus behind it\n  line: '',                              // a small line under the title; empty for none\n  format: [1920, 1080],\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 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);\ndocument.querySelector('#bg').style.opacity = 0.35;\nconst $ = (id) => document.getElementById(id);\n\nconst DIST = SHORT * 0.5, K = 1 + DIST / (SHORT * 1.6);\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.6 });\n// the detail: close, a little to the left; the title a step behind, to the right\nconst detail = $('detail'), ds = SHORT * 0.36 * K;\nObject.assign(detail.style, { width: `${ds}px`, height: `${ds}px`, borderRadius: `${(B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K}px`, background: B.surface(), border: `1.5px solid ${B.color('muted')}55`, boxShadow: `0 ${SHORT * 0.03}px ${SHORT * 0.1}px rgba(0,0,0,0.5)` });\nif (CONFIG.detail.image) { const img = document.createElement('img'); img.src = CONFIG.detail.image; detail.append(img); }\nelse { const t = document.createElement('div'); B.style(t, 'display', { short: SHORT * K * 0.9 }); t.textContent = CONFIG.detail.text; t.style.fontFamily = B.font('mono'); t.style.letterSpacing = '-0.02em'; t.style.whiteSpace = 'nowrap'; detail.append(t);\n  const fit = (ds * 0.84) / t.scrollWidth; if (fit < 1) t.style.fontSize = `${parseFloat(t.style.fontSize) * fit}px`; }   // a longer number shrinks to fit the card\ncam.place(detail, { x: -SHORT * 0.34 * K, y: SHORT * 0.02, z: SHORT * 0.12, yaw: 8 });\nconst title = B.style($('title'), 'display', { short: SHORT * K }), line = B.style($('line'), 'body', { short: SHORT * K, color: 'muted' });\ntitle.textContent = CONFIG.title; line.textContent = CONFIG.line; line.style.marginTop = `${SHORT * 0.02}px`;\n$('p-title').style.width = `${W * 0.42 * K}px`; $('p-title').style.alignItems = 'flex-start'; $('p-title').style.textAlign = 'left';\ntitle.style.maxWidth = '10ch';\ncam.place($('p-title'), { x: SHORT * 0.36 * K, y: -SHORT * 0.01, z: -SHORT * 0.3, yaw: -6 });\nawait document.fonts.ready;\n\n// the focus plane moves from the detail to the title while the camera eases back a step and turns to face it\nconst T = { pull: [1.6, 2.6] };\ns.update((t) => {\n  const p = progress(t, ...T.pull, ease.inOutCubic);\n  cam.at({ x: -SHORT * 0.08 * K * (1 - p) + SHORT * 0.06 * K * p, y: 0, z: DIST + SHORT * 0.12 * (1 - p) + SHORT * 0.1 * p, yaw: 6 * (1 - p) - 3 * p, pitch: 1 - 2 * p });\n  const focalZ = (SHORT * 0.12) * (1 - p) + (-SHORT * 0.3) * p;              // where the sharp plane is, in world z\n  cam.focus(cam.pos.z - focalZ, SHORT * 0.22, 14, { fade: Infinity });\n  cam.place(detail, { x: -SHORT * 0.34 * K, y: SHORT * 0.02, z: SHORT * 0.12, yaw: 8, scale: 1 + 0.02 * progress(t, 0, D) });   // a breath on the detail\n  wordRise(title, t, { start: 0.2, each: B.pace.stagger, duration: 0.8 });   // the title is there from the start, soft, and sharpens\n  blurIn(line, t, { start: T.pull[1], duration: 0.6 });\n});\nB.cue(s, 'land', 0.2); B.cue(s, 'transition', T.pull[0]); B.cue(s, 'text', T.pull[1]);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/focus-pull/brief.md",
      "content": "# Focus pull\n\nShot: focus-pull (4 s), from paper-motion.app. The look, fonts and sound come from `brand/`.\n\nA shot is one gesture. Edit `CONFIG` (the detail, the title, the line), check `npx paper-motion still` at 0.8 and 3.2 s, render. Chain it before a recipe or another shot when the piece needs it.\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.6"
  },
  "usage": "npx paper-motion add focus-pull --name my-shot\n# edit CONFIG in pieces/my-shot/scene.html, then:\nnpx paper-motion render pieces/my-shot/scene.html --motion-blur 6",
  "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.",
    "The depth of field is real: `cam.focus()` from paper-motion/kit blurs by distance from the focal plane."
  ],
  "related": [
    "push-in",
    "launch"
  ],
  "preview": {
    "video": "previews/focus-pull.webm",
    "poster": "previews/focus-pull.jpg",
    "at": 3.2,
    "values": {
      "detailText": "0.2s",
      "title": "Every frame, on time.",
      "line": "paper-motion renders what your agent directs."
    }
  },
  "mood": [
    "calm",
    "editorial",
    "technical"
  ],
  "duration": 4,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "beats": [
    {
      "name": "Detail",
      "from": 0,
      "to": 1.6,
      "what": "the detail sharp, the title soft"
    },
    {
      "name": "Pull",
      "from": 1.6,
      "to": 2.6,
      "what": "focus travels to the title; the camera eases back"
    },
    {
      "name": "Title",
      "from": 2.6,
      "to": 4,
      "what": "the title sharp, the detail soft"
    }
  ],
  "when": [
    "one number or one word deserves a close-up",
    "opening a piece on a detail before the name"
  ],
  "needs": [
    {
      "kind": "figure",
      "fill": {
        "detail": {
          "text": "$display",
          "image": ""
        },
        "title": "$label"
      }
    }
  ]
}