{
  "id": 128,
  "slug": "spatial-canvas-moodboard",
  "name": "Pannable & Zoomable Spatial Canvas",
  "kind": "ui",
  "family": "Spatial & Canvas",
  "sourceSite": {
    "name": "Kinopio",
    "url": "https://kinopio.club/",
    "verifiedStatus": 200
  },
  "tagline": "Infinite dot-grid thinking canvas with pointer panning, cursor-anchored zoom, draggable cards, and live SVG connectors.",
  "whyUnique": "Replaces rigid vertical lists with spatial memory: cards move freely in 2D space with elastic dashed SVG wires, cursor-centered wheel zoom, and a one-tap Fit View reset for mobile screens.",
  "theme": "light",
  "mobileStrength": "high",
  "tags": [
    "spatial-canvas",
    "moodboard",
    "pan-zoom",
    "infinite-canvas",
    "whiteboard",
    "direct-manipulation"
  ],
  "bestFor": [
    "Creative moodboards and brand sprints",
    "Spatial brainstorming and mind-mapping",
    "Architecture diagramming and research boards",
    "Visual storyboarding workspaces"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#F3F5F0",
      "name": "Lichen Cream"
    },
    {
      "role": "surface",
      "hex": "#FFFFFF",
      "name": "Card White"
    },
    {
      "role": "ink",
      "hex": "#1C2420",
      "name": "Pine Charcoal"
    },
    {
      "role": "accent",
      "hex": "#2A9D6F",
      "name": "Botanical Green"
    },
    {
      "role": "muted",
      "hex": "#5F6D65",
      "name": "Sage Slate"
    }
  ],
  "typography": {
    "display": "Inter",
    "body": "Inter",
    "mono": "JetBrains Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700&family=JetBrains+Mono:wght@600&display=swap",
    "scaleNotes": "14px bold card titles, 12.5px compact descriptions, 10px mono category pills, 12px mono zoom percentage readout."
  },
  "layoutNotes": "Full-viewport touch-action:none stage with CSS-transformed world layer, SVG bezier wire overlay, and floating top/bottom pill HUDs that never block canvas hits.",
  "interactionNotes": "Pointer capture handles smooth background panning and individual card dragging across mouse and touch; wheel zoom anchors to cursor coordinates while +/−/Fit View provide explicit controls.",
  "mobileNotes": "Auto-runs Fit View on initial load and viewport resize so all spatial cards frame cleanly at 390px, with >=40px floating pill zoom controls and touch-friendly card dragging.",
  "agentGuardrails": {
    "do": [
      "Set touch-action: none on the spatial viewport and use Pointer Events for unified mouse and touch drag.",
      "Always include an explicit Fit View button so users can never get lost off-canvas.",
      "Keep floating HUD bars pointer-events:none on their wrappers so canvas drag remains unobstructed."
    ],
    "dont": [
      "Never rely exclusively on scroll-wheel or trackpad pinch without +/- zoom buttons.",
      "Avoid re-rendering the entire DOM on pan frames; update a single CSS transform matrix."
    ]
  },
  "demoFile": "demos/spatial-canvas-moodboard.html",
  "thumbDesktop": "thumbs/spatial-canvas-moodboard-desktop.webp",
  "thumbMobile": "thumbs/spatial-canvas-moodboard-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/spatial-canvas-moodboard",
    "markdown": "https://templates.michaelpitts.net/t/spatial-canvas-moodboard.md",
    "api": "https://templates.michaelpitts.net/api/templates/spatial-canvas-moodboard",
    "demo": "https://templates.michaelpitts.net/demos/spatial-canvas-moodboard.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/spatial-canvas-moodboard-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/spatial-canvas-moodboard-mobile.webp"
  },
  "agentPrompt": "Design & build using template #128 \"Pannable & Zoomable Spatial Canvas\" (ui / Spatial & Canvas, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/spatial-canvas-moodboard.md\nLive demo: https://templates.michaelpitts.net/demos/spatial-canvas-moodboard.html\nReal-world inspiration: Kinopio (https://kinopio.club/)\n\nCore aesthetic: Replaces rigid vertical lists with spatial memory: cards move freely in 2D space with elastic dashed SVG wires, cursor-centered wheel zoom, and a one-tap Fit View reset for mobile screens.\nPalette: canvas: #F3F5F0 (Lichen Cream), surface: #FFFFFF (Card White), ink: #1C2420 (Pine Charcoal), accent: #2A9D6F (Botanical Green), muted: #5F6D65 (Sage Slate)\nTypography: Display=\"Inter\", Body=\"Inter\", Mono=\"JetBrains Mono\"\nLayout: Full-viewport touch-action:none stage with CSS-transformed world layer, SVG bezier wire overlay, and floating top/bottom pill HUDs that never block canvas hits.\nInteractions: Pointer capture handles smooth background panning and individual card dragging across mouse and touch; wheel zoom anchors to cursor coordinates while +/−/Fit View provide explicit controls.\nMobile: Auto-runs Fit View on initial load and viewport resize so all spatial cards frame cleanly at 390px, with >=40px floating pill zoom controls and touch-friendly card dragging.\n\nGuardrails:\n- DO: Set touch-action: none on the spatial viewport and use Pointer Events for unified mouse and touch drag.\n- DO: Always include an explicit Fit View button so users can never get lost off-canvas.\n- DO: Keep floating HUD bars pointer-events:none on their wrappers so canvas drag remains unobstructed.\n- DON'T: Never rely exclusively on scroll-wheel or trackpad pinch without +/- zoom buttons.\n- DON'T: Avoid re-rendering the entire DOM on pan frames; update a single CSS transform matrix.",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Pannable & Zoomable Spatial Canvas — Kinopio-Inspired Pattern</title>\n<style>\n  :root {\n    --canvas: #f3f5f0;\n    --dot: #cbd4c4;\n    --surface: #ffffff;\n    --ink: #1c2420;\n    --muted: #5f6d65;\n    --accent: #2a9d6f;\n    --accent-2: #e07a5f;\n    --accent-3: #4f6df5;\n    --border: rgba(28,36,32,0.12);\n    --font: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", sans-serif;\n    --mono: ui-monospace, \"SF Mono\", Menlo, monospace;\n  }\n  * { box-sizing: border-box; margin: 0; padding: 0; }\n  html, body {\n    height: 100%;\n    overflow: hidden;\n    background: var(--canvas);\n    color: var(--ink);\n    font-family: var(--font);\n    user-select: none;\n    touch-action: none;\n  }\n  .viewport {\n    position: fixed;\n    inset: 0;\n    cursor: grab;\n    background-image: radial-gradient(var(--dot) 1.4px, transparent 1.4px);\n    background-size: 24px 24px;\n  }\n  .viewport.panning { cursor: grabbing; }\n  .world {\n    position: absolute;\n    left: 0; top: 0;\n    width: 2400px; height: 1600px;\n    transform-origin: 0 0;\n  }\n  svg.wires {\n    position: absolute;\n    inset: 0;\n    width: 100%; height: 100%;\n    pointer-events: none;\n    overflow: visible;\n  }\n  .card {\n    position: absolute;\n    width: 230px;\n    background: var(--surface);\n    border: 1.5px solid var(--border);\n    border-radius: 14px;\n    padding: 13px 14px;\n    box-shadow: 0 10px 26px rgba(28,36,32,0.08);\n    cursor: move;\n    transition: box-shadow .15s, border-color .15s;\n  }\n  .card:hover, .card.dragging {\n    box-shadow: 0 18px 36px rgba(28,36,32,0.16);\n    border-color: var(--accent);\n    z-index: 20;\n  }\n  .card-tag {\n    display: inline-block;\n    font: 700 10px var(--mono);\n    text-transform: uppercase;\n    letter-spacing: 0.06em;\n    padding: 3px 8px;\n    border-radius: 999px;\n    margin-bottom: 8px;\n  }\n  .card-title { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 6px; }\n  .card-body { font-size: 12.5px; color: var(--muted); line-height: 1.48; }\n  .swatches { display: flex; gap: 6px; margin-top: 10px; }\n  .swatch { height: 26px; flex: 1; border-radius: 7px; border: 1px solid rgba(0,0,0,0.08); }\n  .mini-art {\n    margin-top: 10px;\n    height: 74px;\n    border-radius: 9px;\n    overflow: hidden;\n    border: 1px solid var(--border);\n  }\n  .hud-top {\n    position: fixed;\n    top: 14px; left: 14px; right: 14px;\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 10px;\n    pointer-events: none;\n    z-index: 40;\n  }\n  .pill-bar {\n    pointer-events: auto;\n    display: flex;\n    align-items: center;\n    gap: 6px;\n    background: rgba(255,255,255,0.92);\n    border: 1px solid var(--border);\n    border-radius: 999px;\n    padding: 5px 8px;\n    box-shadow: 0 8px 24px rgba(28,36,32,0.08);\n    backdrop-filter: blur(12px);\n  }\n  .board-name { font-size: 13px; font-weight: 700; padding: 0 8px; white-space: nowrap; }\n  .btn {\n    min-height: 40px; min-width: 40px;\n    padding: 0 12px;\n    border-radius: 999px;\n    border: 1px solid transparent;\n    background: transparent;\n    color: var(--ink);\n    font: 600 13px var(--font);\n    cursor: pointer;\n    display: inline-flex; align-items: center; justify-content: center; gap: 6px;\n  }\n  .btn:hover { background: rgba(28,36,32,0.06); }\n  .btn.primary { background: var(--ink); color: #fff; }\n  .btn.primary:hover { background: var(--accent); }\n  .hud-bottom {\n    position: fixed;\n    bottom: 16px; left: 50%;\n    transform: translateX(-50%);\n    z-index: 40;\n    max-width: calc(100vw - 24px);\n  }\n  .zoom-readout { font: 600 12px var(--mono); min-width: 44px; text-align: center; color: var(--muted); }\n  .hint-chip {\n    position: fixed;\n    bottom: 72px; left: 50%; transform: translateX(-50%);\n    background: rgba(28,36,32,0.85); color: #fff;\n    padding: 6px 12px; border-radius: 999px; font-size: 12px;\n    pointer-events: none; z-index: 35; white-space: nowrap;\n  }\n  @media (max-width: 640px) {\n    .board-name { font-size: 12px; padding: 0 4px; }\n    .hide-sm { display: none; }\n  }\n</style>\n</head>\n<body>\n<div class=\"hud-top\">\n  <div class=\"pill-bar\">\n    <span class=\"board-name\">🌿 Autumn Packaging Moodboard</span>\n    <span class=\"hide-sm\" style=\"font:600 11px var(--mono);color:var(--muted);padding-right:6px;\" id=\"cardCount\">6 cards</span>\n  </div>\n  <div class=\"pill-bar\">\n    <button class=\"btn primary\" id=\"addCardBtn\" type=\"button\">+ Add Card</button>\n  </div>\n</div>\n\n<div class=\"viewport\" id=\"viewport\" aria-label=\"Spatial moodboard canvas\">\n  <div class=\"world\" id=\"world\">\n    <svg class=\"wires\" id=\"wires\"></svg>\n  </div>\n</div>\n\n<div class=\"hint-chip\" id=\"hintChip\">Drag background to pan · Drag cards to arrange · Scroll or tap ± to zoom</div>\n\n<div class=\"hud-bottom\">\n  <div class=\"pill-bar\">\n    <button class=\"btn\" id=\"zoomOutBtn\" type=\"button\" aria-label=\"Zoom out\">−</button>\n    <span class=\"zoom-readout\" id=\"zoomReadout\">100%</span>\n    <button class=\"btn\" id=\"zoomInBtn\" type=\"button\" aria-label=\"Zoom in\">+</button>\n    <button class=\"btn\" id=\"fitBtn\" type=\"button\">Fit View</button>\n  </div>\n</div>\n\n<script>\nconst CARDS = [\n  { id: 'c1', x: 110, y: 120, tag: 'Direction', bg: '#e6f4ee', fg: '#1e7451', title: 'Tactile Paper & Botanical Ink', body: 'Uncoated 320gsm cotton stock paired with debossed serif marks and sage foil accents.', art: 'botanical' },\n  { id: 'c2', x: 420, y: 90, tag: 'Palette', bg: '#fdeee9', fg: '#b94e34', title: 'Earth & Mineral Swatches', body: 'Warm clay, lichen sage, deep pine ink, and bleached linen highlights.', swatches: ['#2a9d6f', '#e07a5f', '#264653', '#e9c46a', '#f4f1de'] },\n  { id: 'c3', x: 420, y: 310, tag: 'Typography', bg: '#edf0ff', fg: '#3952c7', title: 'Display + Mono Pairing', body: 'Editorial high-contrast headlines anchored by tabular monospace batch numbers.', art: 'type' },\n  { id: 'c4', x: 730, y: 160, tag: 'Form Factor', bg: '#fef6e0', fg: '#9a6700', title: 'Refillable Tin Geometry', body: 'Chamfered 18mm corner radius with magnetic lid detent and blind-embossed crest.', art: 'tin' },\n  { id: 'c5', x: 140, y: 370, tag: 'Research', bg: '#f1eef9', fg: '#6b46c1', title: 'Unboxing Ritual Notes', body: 'First touch is dry paper grain; inner lid reveals brew ratio diagram in 1-color ink.' },\n  { id: 'c6', x: 720, y: 390, tag: 'Decision', bg: '#e6f4ee', fg: '#1e7451', title: 'Sign-off Target: Oct 18', body: 'Send dielines + Pantone drawdowns to Kyoto press once foil contrast passes review.' }\n];\n\nconst EDGES = [\n  ['c1', 'c2'], ['c1', 'c3'], ['c1', 'c5'], ['c2', 'c4'], ['c3', 'c4'], ['c4', 'c6'], ['c3', 'c6']\n];\n\nconst viewport = document.getElementById('viewport');\nconst world = document.getElementById('world');\nconst wires = document.getElementById('wires');\nconst zoomReadout = document.getElementById('zoomReadout');\nconst cardCount = document.getElementById('cardCount');\n\nlet state = { x: 40, y: 40, scale: 1 };\n\nfunction artSVG(kind) {\n  if (kind === 'botanical') {\n    return `<div class=\"mini-art\"><svg viewBox=\"0 0 220 74\" width=\"100%\" height=\"100%\"><rect width=\"220\" height=\"74\" fill=\"#eef4ee\"/><path d=\"M18 68 C58 14, 118 58, 202 12\" stroke=\"#2a9d6f\" stroke-width=\"3\" fill=\"none\"/><circle cx=\"74\" cy=\"36\" r=\"14\" fill=\"#e07a5f\" opacity=\"0.8\"/><circle cx=\"148\" cy=\"32\" r=\"20\" fill=\"#264653\" opacity=\"0.22\"/></svg></div>`;\n  }\n  if (kind === 'type') {\n    return `<div class=\"mini-art\"><svg viewBox=\"0 0 220 74\" width=\"100%\" height=\"100%\"><rect width=\"220\" height=\"74\" fill=\"#1c2420\"/><text x=\"14\" y=\"42\" fill=\"#f3f5f0\" font-family=\"Georgia,serif\" font-size=\"28\" font-weight=\"700\">Aa Bb</text><text x=\"116\" y=\"42\" fill=\"#7ee0b4\" font-family=\"monospace\" font-size=\"13\">BATCH 042</text><text x=\"14\" y=\"61\" fill=\"#9ca8a1\" font-family=\"monospace\" font-size=\"10\">320GSM · DEBOSS · SAGE FOIL</text></svg></div>`;\n  }\n  if (kind === 'tin') {\n    return `<div class=\"mini-art\"><svg viewBox=\"0 0 220 74\" width=\"100%\" height=\"100%\"><rect width=\"220\" height=\"74\" fill=\"#faf6ec\"/><rect x=\"44\" y=\"12\" width=\"132\" height=\"50\" rx=\"14\" fill=\"#ffffff\" stroke=\"#264653\" stroke-width=\"2\"/><line x1=\"44\" y1=\"28\" x2=\"176\" y2=\"28\" stroke=\"#e07a5f\" stroke-width=\"2\" stroke-dasharray=\"4 3\"/><circle cx=\"110\" cy=\"45\" r=\"8\" fill=\"#2a9d6f\"/></svg></div>`;\n  }\n  return '';\n}\n\nfunction applyTransform() {\n  world.style.transform = `translate(${state.x}px, ${state.y}px) scale(${state.scale})`;\n  viewport.style.backgroundPosition = `${state.x}px ${state.y}px`;\n  viewport.style.backgroundSize = `${24 * state.scale}px ${24 * state.scale}px`;\n  zoomReadout.textContent = `${Math.round(state.scale * 100)}%`;\n}\n\nfunction renderWires() {\n  let html = '';\n  for (const [aId, bId] of EDGES) {\n    const a = CARDS.find(c => c.id === aId);\n    const b = CARDS.find(c => c.id === bId);\n    if (!a || !b) continue;\n    const x1 = a.x + 115, y1 = a.y + 65;\n    const x2 = b.x + 115, y2 = b.y + 65;\n    const mx = (x1 + x2) / 2;\n    html += `<path d=\"M ${x1} ${y1} C ${mx} ${y1}, ${mx} ${y2}, ${x2} ${y2}\" stroke=\"#8da095\" stroke-width=\"2\" stroke-dasharray=\"5 5\" fill=\"none\" opacity=\"0.65\"/>`;\n  }\n  wires.innerHTML = html;\n}\n\nfunction renderCards() {\n  world.querySelectorAll('.card').forEach(el => el.remove());\n  for (const c of CARDS) {\n    const el = document.createElement('article');\n    el.className = 'card';\n    el.dataset.id = c.id;\n    el.style.left = c.x + 'px';\n    el.style.top = c.y + 'px';\n    el.innerHTML = `\n      <span class=\"card-tag\" style=\"background:${c.bg};color:${c.fg};\">${c.tag}</span>\n      <h3 class=\"card-title\">${c.title}</h3>\n      <p class=\"card-body\">${c.body}</p>\n      ${c.swatches ? `<div class=\"swatches\">${c.swatches.map(s => `<div class=\"swatch\" style=\"background:${s}\" title=\"${s}\"></div>`).join('')}</div>` : ''}\n      ${c.art ? artSVG(c.art) : ''}\n    `;\n    attachCardDrag(el, c);\n    world.appendChild(el);\n  }\n  cardCount.textContent = `${CARDS.length} cards`;\n  renderWires();\n}\n\nfunction attachCardDrag(el, card) {\n  let startX, startY, origX, origY, dragging = false;\n  el.addEventListener('pointerdown', e => {\n    e.stopPropagation();\n    dragging = true;\n    el.classList.add('dragging');\n    el.setPointerCapture(e.pointerId);\n    startX = e.clientX; startY = e.clientY;\n    origX = card.x; origY = card.y;\n    document.getElementById('hintChip').style.opacity = '0';\n  });\n  el.addEventListener('pointermove', e => {\n    if (!dragging) return;\n    card.x = Math.round(origX + (e.clientX - startX) / state.scale);\n    card.y = Math.round(origY + (e.clientY - startY) / state.scale);\n    el.style.left = card.x + 'px';\n    el.style.top = card.y + 'px';\n    renderWires();\n  });\n  const end = () => { dragging = false; el.classList.remove('dragging'); };\n  el.addEventListener('pointerup', end);\n  el.addEventListener('pointercancel', end);\n}\n\nlet panning = false, panStartX = 0, panStartY = 0, origPanX = 0, origPanY = 0;\nviewport.addEventListener('pointerdown', e => {\n  if (e.target.closest('.card')) return;\n  panning = true;\n  viewport.classList.add('panning');\n  viewport.setPointerCapture(e.pointerId);\n  panStartX = e.clientX; panStartY = e.clientY;\n  origPanX = state.x; origPanY = state.y;\n  document.getElementById('hintChip').style.opacity = '0';\n});\nviewport.addEventListener('pointermove', e => {\n  if (!panning) return;\n  state.x = origPanX + (e.clientX - panStartX);\n  state.y = origPanY + (e.clientY - panStartY);\n  applyTransform();\n});\nconst stopPan = () => { panning = false; viewport.classList.remove('panning'); };\nviewport.addEventListener('pointerup', stopPan);\nviewport.addEventListener('pointercancel', stopPan);\n\nfunction zoomAt(factor, cx = window.innerWidth / 2, cy = window.innerHeight / 2) {\n  const next = Math.min(2.2, Math.max(0.45, state.scale * factor));\n  const ratio = next / state.scale;\n  state.x = cx - (cx - state.x) * ratio;\n  state.y = cy - (cy - state.y) * ratio;\n  state.scale = next;\n  applyTransform();\n}\n\nviewport.addEventListener('wheel', e => {\n  e.preventDefault();\n  zoomAt(e.deltaY < 0 ? 1.09 : 0.92, e.clientX, e.clientY);\n}, { passive: false });\n\ndocument.getElementById('zoomInBtn').addEventListener('click', () => zoomAt(1.2));\ndocument.getElementById('zoomOutBtn').addEventListener('click', () => zoomAt(0.83));\n\nfunction fitView() {\n  const xs = CARDS.map(c => c.x), ys = CARDS.map(c => c.y);\n  const minX = Math.min(...xs) - 40, maxX = Math.max(...xs) + 270;\n  const minY = Math.min(...ys) - 70, maxY = Math.max(...ys) + 210;\n  const scaleX = (window.innerWidth - 32) / (maxX - minX);\n  const scaleY = (window.innerHeight - 110) / (maxY - minY);\n  state.scale = Math.min(1.1, Math.max(0.42, Math.min(scaleX, scaleY)));\n  state.x = (window.innerWidth - (maxX - minX) * state.scale) / 2 - minX * state.scale;\n  state.y = (window.innerHeight - (maxY - minY) * state.scale) / 2 - minY * state.scale;\n  applyTransform();\n}\ndocument.getElementById('fitBtn').addEventListener('click', fitView);\n\nconst NEW_IDEAS = [\n  ['Texture', '#e6f4ee', '#1e7451', 'Linen Emboss Sample', 'Test 45-degree weave emboss on outer sleeve for warm grip.'],\n  ['Copy', '#fdeee9', '#b94e34', 'Origin Story Insert', 'Include farm elevation, harvest week, and roaster signature card.'],\n  ['Motion', '#edf0ff', '#3952c7', 'Micro-Interaction Spec', 'QR code on inner flap launches an interactive brew timer.']\n];\nlet ideaIdx = 0;\ndocument.getElementById('addCardBtn').addEventListener('click', () => {\n  const [tag, bg, fg, title, body] = NEW_IDEAS[ideaIdx++ % NEW_IDEAS.length];\n  const id = 'c' + (CARDS.length + 1);\n  const cx = Math.round((window.innerWidth / 2 - state.x) / state.scale - 115 + (Math.random() * 60 - 30));\n  const cy = Math.round((window.innerHeight / 2 - state.y) / state.scale - 60 + (Math.random() * 60 - 30));\n  CARDS.push({ id, x: cx, y: cy, tag, bg, fg, title, body });\n  EDGES.push([CARDS[CARDS.length - 2].id, id]);\n  renderCards();\n});\n\nrenderCards();\nfitView();\nwindow.addEventListener('resize', fitView);\n</script>\n</body>\n</html>\n"
}
