{
  "$schema": "../../schema.json",
  "version": "1.0.0",
  "license": "MIT",
  "id": "turn-in",
  "type": "shot",
  "title": "Turn in",
  "summary": "An object arrives edge-first and turns to face the camera with a spring's overshoot; the camera answers with a small counter-move, in 3 s.",
  "tags": [
    "shot",
    "camera",
    "object",
    "reveal",
    "3d",
    "card",
    "cover"
  ],
  "params": [
    {
      "name": "image",
      "type": "string",
      "default": "",
      "description": "the object's picture (path); empty draws a card in the brand's colors",
      "group": "main",
      "control": "text"
    },
    {
      "name": "title",
      "type": "string",
      "default": "Boards",
      "description": "on the drawn card",
      "group": "main",
      "control": "text"
    },
    {
      "name": "label",
      "type": "string",
      "default": "01",
      "description": "small, above the title",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "ratio",
      "type": "number",
      "default": 1,
      "min": 0.5,
      "max": 2,
      "step": 0.05,
      "description": "width / height: 1 a cover, 1.6 a card, 0.6 a phone",
      "group": "main"
    },
    {
      "name": "from",
      "type": "enum",
      "default": "left",
      "options": [
        "left",
        "right"
      ],
      "description": "the edge it arrives from",
      "group": "main",
      "control": "segmented"
    },
    {
      "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/turn-in/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>turn-in</title>\n<!--\n  Shot · turn in (3 s). An object (a card, a cover, a screenshot) arrives edge-first and turns to face the camera,\n  overshooting a touch and settling; the camera answers with a small counter-move, so the turn reads in depth.\n  Arrive 0–1.4 s · Settle 1.4–2.2 s · Hold 2.2–3 s.\n  Look, fonts and sound come from /brand. Edit CONFIG: the object's picture (or a drawn card with a title), its\n  proportions. Ask your agent to use it as the reveal of a product shot, a cover, a card.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  #obj { overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }\n  #obj img { position: absolute; inset: 0; 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=\"vig\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"world\"><div id=\"obj\"><div id=\"label\"></div><div id=\"title\"></div></div></div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease, spring } 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  image: '',                             // the object's picture (path); empty draws a card in the brand's colors\n  title: 'Boards',                       // on the drawn card\n  label: '01',                           // small, above the title\n  ratio: 1.0,                            // width / height of the object: 1 a cover, 1.6 a card, 0.6 a phone\n  from: 'left',                          // the edge it arrives from: 'left' or 'right'\n  format: [1920, 1080],\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 3, dir = CONFIG.from === 'right' ? -1 : 1;\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.4;\ndocument.querySelector('#vig').style.background = 'radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.6) 100%)';\nconst $ = (id) => document.getElementById(id);\n\nconst DIST = SHORT * 0.7, K = 1 + DIST / (SHORT * 1.7);\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });\nconst obj = $('obj'), oh = SHORT * 0.6 * K, ow = oh * CONFIG.ratio, R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;\nObject.assign(obj.style, { width: `${ow}px`, height: `${oh}px`, borderRadius: `${R}px`, padding: `${oh * 0.08}px`, background: B.surface(0.22), border: `1.5px solid ${B.color('figure')}70`, boxShadow: `0 ${SHORT * 0.05}px ${SHORT * 0.14}px rgba(0,0,0,0.7)` });\nif (CONFIG.image) { const img = document.createElement('img'); img.src = CONFIG.image; obj.prepend(img); $('label').remove(); $('title').remove(); }\nelse {\n  if (bgId) { const f = document.createElement('div'); Object.assign(f.style, { position: 'absolute', inset: 0, opacity: 0.25 }); obj.prepend(f); B.shader(s, f, bgId); }\n  const label = B.style($('label'), 'caption', { short: SHORT * K, color: 'muted' }), title = B.style($('title'), 'display', { short: SHORT * K * 0.8 });\n  label.textContent = CONFIG.label; title.textContent = CONFIG.title; label.style.position = title.style.position = 'relative';\n  title.style.marginTop = `${SHORT * 0.015}px`;\n}\nawait document.fonts.ready;\n\nconst T = { turn: [0.1, 1.8] };\ns.update((t) => {\n  // the turn: from 85° edge-on to face-on with a spring's overshoot\n  const q = ease.inOutCubic(progress(t, T.turn[0], T.turn[1] - 0.2));   // slow in and out: the edge reads, then the face settles\n  const slide = progress(t, ...T.turn, ease.outCubic);\n  cam.place(obj, { x: dir * SHORT * 0.5 * (1 - slide), y: 0, z: -SHORT * 0.1 * (1 - slide), yaw: dir * (85 - 85 * q), pitch: 4 * (1 - q) });\n  obj.style.opacity = String(progress(t, 0, 0.3));\n  // the camera answers: a small move the other way, then still\n  cam.at({ x: -dir * SHORT * 0.05 * (1 - slide), y: 0, z: DIST + SHORT * 0.08 * (1 - slide), yaw: -dir * 6 * (1 - slide), pitch: 0 });\n  cam.focus(DIST, SHORT * 1.2, 6);\n  if ($('title')) { wordRise($('title'), t, { start: T.turn[1] - 0.3, each: B.pace.stagger, duration: 0.7 }); blurIn($('label'), t, { start: T.turn[1] - 0.4, duration: 0.5 }); }\n});\nB.cue(s, 'transition', T.turn[0]); B.cue(s, 'land', T.turn[1] - 0.1);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/turn-in/brief.md",
      "content": "# Turn in\n\nShot: turn-in (3 s), from paper-motion.app. The look, fonts and sound come from `brand/`.\n\nA shot is one gesture. Put the object's picture in `CONFIG.image` (or keep the drawn card and its title), set `ratio` and `from`; check `npx paper-motion still` at 0.7 and 1.9 s; render.\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.6"
  },
  "usage": "npx paper-motion add turn-in --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 turn is a spring (`spring()` from paper-motion): stiffness and damping in the scene set the overshoot."
  ],
  "related": [
    "flip-3d",
    "release"
  ],
  "preview": {
    "video": "previews/turn-in.webm",
    "poster": "previews/turn-in.jpg",
    "at": 1.9,
    "values": {
      "title": "Boards",
      "label": "01"
    }
  },
  "mood": [
    "bold",
    "playful",
    "technical"
  ],
  "duration": 3,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "beats": [
    {
      "name": "Arrive",
      "from": 0,
      "to": 1.4,
      "what": "edge-first, turning to face the camera"
    },
    {
      "name": "Settle",
      "from": 1.4,
      "to": 2.2,
      "what": "overshoot and rest; the words land"
    },
    {
      "name": "Hold",
      "from": 2.2,
      "to": 3,
      "what": "still"
    }
  ],
  "when": [
    "revealing a cover, a card, a screenshot",
    "the first second of a product shot"
  ],
  "needs": [
    {
      "kind": "screen",
      "has": [
        "title"
      ],
      "fill": {
        "image": "$image",
        "title": "$title"
      }
    }
  ]
}