<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Digest</title>
<link rel="stylesheet" href="digest-canvas-sdk/glow.css">
<style>
  /*
   * Full view: the thin client's kiosk Firefox workspace (Phase 11 step 5).
   * Multi-column grid so the globe and several windows sit side by side; globe
   * windows take a double-width cell because a 260px globe is unreadable across
   * a room.
   */
  html, body {
    margin: 0;
    padding: 0;
    background: var(--digest-bg);
  }

  #canvas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
    grid-auto-rows: minmax(12rem, auto);
    gap: 1.1rem;
    padding: 1.4rem;
    min-height: 100vh;
    font-size: 1.05rem;
  }

  #canvas .digest-window-globe {
    grid-column: span 2;
    grid-row: span 2;
  }

  @media (max-width: 60rem) {
    #canvas .digest-window-globe {
      grid-column: span 1;
    }
  }

  #canvas .digest-canvas-raw {
    grid-column: 1 / -1;
    margin: 0;
  }
</style>
</head>
<body>
<div id="canvas" class="digest-canvas"></div>

<script src="digest-canvas-sdk/window-chrome.js"></script>
<script src="digest-canvas-sdk/globe.js"></script>
<script src="digest-canvas-sdk/render.js"></script>
<script>
  // digest-web serves the shared output volume under /output/; run.py rewrites
  // output/latest.json at the end of every run, so this URL is always current
  // and no coordination with the scheduler is needed. Change it if you mount
  // the output volume at the server root instead.
  var DIGEST_URL = 'output/latest.json';
  var REFRESH_MS = 5 * 60 * 1000;

  var canvas = document.getElementById('canvas');

  // ?person=<name|nickname|id>, set by thinclient_agent/digest_canvas.py from a
  // request Home Assistant had ALREADY resolved — this page never works out who is
  // standing in front of it. With it, only that person's own digest sections are
  // drawn (they pick them in identity's admin panel); without it, the personal
  // section is left out rather than shown to whoever happens to walk past, which is
  // the plan's Phase 11.8 rule: never guess whose personal section this is.
  var person = new URLSearchParams(location.search).get('person') || '';

  function load() {
    DigestRender.load(canvas, DIGEST_URL, {
      detailLevel: 'full',
      person: person,
      requirePersonForPersonal: true
    });
  }

  load();
  setInterval(load, REFRESH_MS);
</script>
</body>
</html>
