GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / galaxies-wafers / iterations/07-code-card

Code Card and 3 more files

A JavaScript module in the iterations folder of Galaxies Wafers that draws families and the Renewable Energy Planning Database (REPD) register. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.

522 lines of JavaScript and CSS and HTML from galaxies-wafers, in 4 files. Topic: Kuiper, cosmos and drawing engines. Section 1184 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Code Card render · galaxies-wafers / iterations/07-code-card/code-card.mjs lines 1–268
  2. Iterations — 07 Code Card Page render · galaxies-wafers / iterations/07-code-card/index.html lines 1–45
  3. Questions render · galaxies-wafers / iterations/07-code-card/questions.mjs lines 1–125
  4. Iterations — 07 Code Card Style Sheet render · galaxies-wafers / iterations/07-code-card/style.css lines 1–84

Code Card

A JavaScript module in the iterations folder of Galaxies Wafers that draws families and the Renewable Energy Planning Database (REPD) register. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.

rendergalaxies-wafers / iterations/07-code-card/code-card.mjs · lines 1–268 of 268 · Entry point · pattern openCard (shared by 6 files)

What it does
It draws families and the REPD register. Defines 13 functions or classes, including atlasRadius, $, bin, index, onAtlasAxis. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain terms in the code: the REPD register.
Inputs & outputs
In: JSON file families.json. Out: canvas drawing.
Downstream impact
Used directly by 1 file: Iterations — 07 Code Card Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
What it achieves
It closes card (`closeCard`) and opens card (`openCard`). Iteration 07: brightness by association, and the code card. It responds to wafer, click and pointerdown events.
Why it matters
Loaded by the 07 Code Card page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
Application
galaxies-wafers · iterations/07-code-card · JavaScript module
Uses
Galaxies Wafers — Lib (import)
Used by
loaded by Iterations — 07 Code Card Page (script src)
Produces
atlasRadius, $, bin, index, onAtlasAxis, shine, draw, redraw, pick, closeCard, positionCard, span
Defines here
atlasRadius, $, bin, index, onAtlasAxis, shine, draw, redraw, pick, closeCard, positionCard, span, openCard
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/07-code-card/code-card.mjs:1-268 · blob 439b2d6fb91250aeed1d1118f30ffba9570b207d · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: unknown
/* code-card.mjs — iteration 07: brightness by association, and the code card.
 *
 * Two things lifted from Grid Atlas (repd_grid_atlasv8 / v9):
 *
 * 1. SIZE BY WEIGHT. The Atlas sizes a REPD project by capacity with
 *      ['interpolate', ['linear'], capacity, 0,8, 10,12, 50,16, 100,20, 200,26, 350,32, 500,38]
 *    so Cleve Hill and Botley West read as the big bright sites they are. Here the
 *    weight is a line's association count: how many function families carry it.
 *    The count is put onto the Atlas's own capacity axis by the layer's own
 *    maximum (read from the data, never typed), so the fewest families take the
 *    Atlas's smallest stop and the layer's most-carried line takes its largest.
 *
 * 2. THE POPUP. The Atlas's maplibregl popup (ventusv8.css: black ground, cyan,
 *    #444 edge, monospace, a bold 13px title, grey detail, amber figure, the
 *    bordered popup-btn) opens at the point tapped. The same card opens here at
 *    the tapped line. Everything in it is textContent.
 */

import { place, ownersOf, indexOfKey, fmt } from '../../lib.mjs';

const DATA = 'https://globalgrid2050.com/testcode/202609142202/data/';
const LAYER = 'copying';
const COLOUR = '#ffd54a';
const WAFER = '../../';

/* The Atlas's REPD radius stops, verbatim: [capacity, radius px] pairs. */
const ATLAS_STOPS = [[0, 8], [10, 12], [50, 16], [100, 20], [200, 26], [350, 32], [500, 38]];
const ATLAS_TOP = ATLAS_STOPS[ATLAS_STOPS.length - 1][0];
const ATLAS_MIN_R = ATLAS_STOPS[0][1], ATLAS_MAX_R = ATLAS_STOPS[ATLAS_STOPS.length - 1][1];

function atlasRadius(v) {
  if (v <= ATLAS_STOPS[0][0]) return ATLAS_MIN_R;
  for (let i = 1; i < ATLAS_STOPS.length; i++) {
    const [x1, y1] = ATLAS_STOPS[i];
    if (v <= x1) { const [x0, y0] = ATLAS_STOPS[i - 1]; return y0 + (y1 - y0) * (v - x0) / (x1 - x0); }
  }
  return ATLAS_MAX_R;
}

const $ = id => document.getElementById(id);

/* ── styles: the Atlas popup, lifted ─────────────────────────────────────── */

const css = document.createElement('style');
css.textContent = `
#brightness{position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:1}
.codecard{position:fixed;z-index:7;transform:translate(-50%,calc(-100% - 12px));
  background:#000;color:#00ffff;border:1px solid #444;border-radius:4px;
  font-family:monospace;font-size:12px;line-height:1.45;padding:8px 10px;
  min-width:220px;max-width:280px;box-shadow:0 1px 6px #0009}
.codecard::after{content:'';position:absolute;left:50%;bottom:-7px;margin-left:-6px;
  border:6px solid transparent;border-bottom:0;border-top-color:#444}
.codecard[data-below]{transform:translate(-50%,12px)}
.codecard[data-below]::after{bottom:auto;top:-7px;border-top:0;border-bottom:6px solid #444}
.codecard .cc-x{position:absolute;top:0;right:2px;background:none;border:0;color:#888;
  font:inherit;font-size:14px;cursor:pointer;padding:2px 5px}
.codecard .cc-title{display:block;color:#ffd54a;font-size:13px;font-weight:bold;margin-right:14px}
.codecard .cc-grey{color:#888}
.codecard .cc-amber{color:#ffae00}
.codecard .cc-small{color:#555;font-size:10px}
.codecard .cc-fam{display:block;color:#aaa;font-size:11px;overflow-wrap:anywhere}
.codecard .cc-sym{color:#00ffff;font-weight:bold}
.popup-search-btns{display:flex;gap:6px;margin-top:8px}
.popup-btn{flex:1;padding:5px 0;font-family:monospace;font-size:11px;font-weight:bold;border:1px solid #444;
  border-radius:3px;cursor:pointer;text-align:center;text-decoration:none;display:block;transition:border-color .15s,color .15s}
.popup-btn-images{background:#0a0a0a;color:#00ffff;border-color:#00ffff}
.popup-btn-images:hover{background:#00ffff;color:#000}
`;
document.head.appendChild(css);

const canvas = document.createElement('canvas');
canvas.id = 'brightness';
document.body.appendChild(canvas);
const ctx = canvas.getContext('2d');

/* ── data ────────────────────────────────────────────────────────────────── */

const S = {
  particles: null,   /* [{key, families, chars, x, y}] ascending by families, brightest drawn last */
  maxFam: 0,
  families: null, owner: null, ownerKeys: null, ownerXY: null,
  keys: null, lens: null
};

async function bin(name, Kind) {
  const r = await fetch(DATA + name, { cache: 'default' });
  if (!r.ok) throw new Error(DATA + name + ' returned HTTP ' + r.status);
  return new Kind(await r.arrayBuffer());
}

/* The family index and lengths, for the card. Same files, same cache as app.mjs. */
const index = (async () => {
  const [families, famLines, keys, lens] = await Promise.all([
    fetch(DATA + 'families.json', { cache: 'default' }).then(r => r.json()),
    bin('lines.bin', Uint32Array), bin('all-lines.bin', Uint32Array), bin('all-lines.len.bin', Uint16Array)
  ]);
  S.families = families; S.keys = keys; S.lens = lens;
  S.owner = ownersOf(families, famLines);
  S.ownerKeys = Uint32Array.from(S.owner.keys());
  S.ownerXY = new Float32Array(S.ownerKeys.length * 2);
  S.ownerKeys.forEach((k, i) => { const [x, y] = place(k); S.ownerXY[i * 2] = x; S.ownerXY[i * 2 + 1] = y; });
})().catch(e => { console.warn('code card: family index unavailable:', e); });

window.addEventListener('wafer:layer', e => {
  const { id, on, doc } = e.detail;
  if (id !== LAYER) return;
  if (!on || !doc) { S.particles = null; S.maxFam = 0; redraw(); return; }
  let max = 0;
  const ps = doc.features.filter(f => f.geometry?.type === 'Point').map(f => {
    const fam = f.properties?.families ?? 0;
    if (fam > max) max = fam;
    const [x, y] = place(f.geometry.key);
    return { key: f.geometry.key, families: fam, chars: f.properties?.chars, x, y };
  });
  ps.sort((a, b) => a.families - b.families);
  S.particles = ps; S.maxFam = max;
  redraw();
});

/* A line's association count on the Atlas's capacity axis, then its radius and shine. */
const onAtlasAxis = fam => (S.maxFam ? Math.min(fam, S.maxFam) / S.maxFam : 0) * ATLAS_TOP;
const shine = r => (r - ATLAS_MIN_R) / (ATLAS_MAX_R - ATLAS_MIN_R);

/* ── drawing ─────────────────────────────────────────────────────────────── */

const LEVELS = 8;   /* shine is quantised to this many steps for drawing */
let marked = -1, lastView = null;

function draw(v) {
  lastView = v;
  if (!v || !v.w || !v.h) return;
  const dpr = v.dpr || 1, W = Math.round(v.w * dpr), H = Math.round(v.h * dpr);
  if (canvas.width !== W || canvas.height !== H) { canvas.width = W; canvas.height = H; }
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  ctx.clearRect(0, 0, v.w, v.h);
  if (S.particles) {
    /* Atlas radii are for a map of a few thousand sites; the wafer holds tens of
       thousands, so the whole scale follows the camera and reaches the Atlas's
       own pixel sizes once the beam is focused in. */
    const k = Math.min(1, Math.sqrt(v.zoom) / 4);
    /* One path per shine level, so tens of thousands of particles cost a handful
       of fills rather than one fill each. */
    const halos = Array.from({ length: LEVELS }, () => new Path2D());
    const cores = Array.from({ length: LEVELS }, () => new Path2D());
    for (const p of S.particles) {
      const sx = (p.x - v.x) * v.zoom + v.w / 2, sy = v.h / 2 - (p.y - v.y) * v.zoom;
      const R = atlasRadius(onAtlasAxis(p.families)), r = Math.max(0.6, R * k);
      if (sx < -r || sy < -r || sx > v.w + r || sy > v.h + r) continue;
      const b = Math.round(shine(R) * (LEVELS - 1)), rc = Math.max(0.5, r * 0.4);
      halos[b].moveTo(sx + r, sy); halos[b].arc(sx, sy, r, 0, 6.2832);
      cores[b].moveTo(sx + rc, sy); cores[b].arc(sx, sy, rc, 0, 6.2832);
    }
    ctx.globalCompositeOperation = 'lighter';
    ctx.fillStyle = COLOUR;
    for (let b = 0; b < LEVELS; b++) {
      const s = b / (LEVELS - 1);
      ctx.globalAlpha = 0.12 + 0.28 * s; ctx.fill(halos[b]);   /* the halo */
      ctx.globalAlpha = 0.35 + 0.65 * s; ctx.fill(cores[b]);   /* the core */
    }
    ctx.globalCompositeOperation = 'source-over';
    ctx.globalAlpha = 1;
  }
  if (marked > 0) {
    const [x, y] = place(marked);
    const sx = (x - v.x) * v.zoom + v.w / 2, sy = v.h / 2 - (y - v.y) * v.zoom;
    ctx.strokeStyle = COLOUR; ctx.lineWidth = 1.5;
    ctx.beginPath(); ctx.arc(sx, sy, 9, 0, 6.2832); ctx.stroke();
  }
  if (card && marked > 0) positionCard();
}
const redraw = () => draw(window.__wafer?.view ?? null);
window.__wafer?.onDraw.add(draw);

/* ── tap: the nearest carried line ───────────────────────────────────────── */

const REACH = 16;   /* px */

function pick(cx, cy) {
  const v = window.__wafer?.view;
  if (!v || !v.zoom || !S.ownerKeys) return -1;
  let best = -1, bestD = REACH * REACH, bestF = 0;
  const n = S.ownerKeys.length;
  for (let i = 0; i < n; i++) {
    const dx = (S.ownerXY[i * 2] - v.x) * v.zoom + v.w / 2 - cx;
    const dy = v.h / 2 - (S.ownerXY[i * 2 + 1] - v.y) * v.zoom - cy;
    const d = dx * dx + dy * dy;
    if (d > bestD) continue;
    const f = S.owner.get(S.ownerKeys[i]).length;
    if (d < bestD || f > bestF) { best = S.ownerKeys[i]; bestD = d; bestF = f; }
  }
  return best;
}

let card = null;

function closeCard() { if (card) card.remove(); card = null; marked = -1; redraw(); }

function positionCard() {
  const v = window.__wafer?.view; if (!v || !card) return;
  const [x, y] = place(marked);
  const sx = (x - v.x) * v.zoom + v.w / 2, sy = v.h / 2 - (y - v.y) * v.zoom;
  const half = card.offsetWidth / 2 + 8;
  card.style.left = Math.max(half, Math.min(v.w - half, sx)) + 'px';
  card.style.top = sy + 'px';
  if (sy - card.offsetHeight - 20 < 0) card.setAttribute('data-below', ''); else card.removeAttribute('data-below');
}

function span(cls, text) { const s = document.createElement('span'); s.className = cls; s.textContent = text; return s; }

function openCard(key) {
  if (card) card.remove();
  marked = key;
  const fams = S.owner.get(key) || [];
  const i = indexOfKey(S.keys, key);
  const chars = i >= 0 ? S.lens[i] : null;

  card = document.createElement('div');
  card.className = 'codecard';
  card.setAttribute('role', 'dialog');
  card.dataset.key = String(key);
  card.dataset.families = String(fams.length);

  const x = document.createElement('button');
  x.className = 'cc-x'; x.type = 'button'; x.textContent = '×'; x.setAttribute('aria-label', 'close');
  x.addEventListener('click', closeCard);
  card.appendChild(x);

  const title = span('cc-title', 'Line ' + fmt(key));
  card.appendChild(title);
  card.appendChild(span('cc-grey', 'numbered line of code'));
  card.appendChild(document.createElement('br'));
  card.appendChild(span('cc-amber', fmt(fams.length) + (fams.length === 1 ? ' association' : ' associations')));
  card.appendChild(span('cc-small', ' ● ' + (chars === null ? 'length unknown' : fmt(chars) + ' characters')));
  card.appendChild(document.createElement('br'));
  for (const f of fams.slice(0, 3)) {
    const fa = S.families[f];
    const row = document.createElement('span'); row.className = 'cc-fam';
    row.append(span('cc-sym', fa.block ?? '—'), document.createTextNode(' ' + fa.name));
    card.appendChild(row);
  }
  if (fams.length > 3) card.appendChild(span('cc-small', 'and ' + fmt(fams.length - 3) + ' more'));

  const btns = document.createElement('div'); btns.className = 'popup-search-btns';
  const a = document.createElement('a');
  a.className = 'popup-btn popup-btn-images';
  a.href = WAFER + '?line=' + encodeURIComponent(String(key));
  a.textContent = 'OPEN IN THE LINE WAFER';
  btns.appendChild(a);
  card.appendChild(btns);

  document.body.appendChild(card);
  positionCard();
  redraw();
}

let down = null;
document.addEventListener('pointerdown', e => { down = e.isPrimary ? [e.clientX, e.clientY] : null; });
document.addEventListener('pointerup', e => {
  if (!down || e.target?.id !== 'stage') return;
  const moved = Math.abs(e.clientX - down[0]) + Math.abs(e.clientY - down[1]);
  down = null;
  if (moved >= 7) return;
  const key = pick(e.clientX, e.clientY);
  if (key > 0) openCard(key); else closeCard();
});
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeCard(); });

window.__codecard = Object.freeze({ ready: () => index, get particles() { return S.particles?.length ?? 0; } });

Iterations — 07 Code Card Page

A web page in Galaxies Wafers. Published at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.

rendergalaxies-wafers / iterations/07-code-card/index.html · lines 1–45 of 45 · Entry point

What it does
It draws its content. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
README: "The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/202609151339."
Inputs & outputs
In: form fields (user input). Out: web page.
Downstream impact
It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
What it achieves
The Line Wafer — every numbered line of the estate, on one surface.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
galaxies-wafers · iterations/07-code-card · page
Uses
Iterations — 07 Code Card Style Sheet (stylesheet), Questions (stylesheet), Galaxies Wafers — Proof Page (link), Iterations — 01 Route Alpha (script src), Layers Panel (script src), Code Card (script src), Questions (script src)
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/07-code-card/index.html:1-45 · blob 127ac6e79d9bd8be6f0acfa48cb294528851cae9 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=5">
<meta name="color-scheme" content="dark">
<title>The Line Wafer — every numbered line of the estate, on one surface</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="questions.css">
</head>
<body>

<canvas id="stage" aria-label="Every permanently numbered line of code in the estate, placed by its own number."></canvas>

<header id="bar">
  <span id="wordmark">THE LINE WAFER</span>
  <span id="count" class="dim">loading the numbered database…</span>
  <details id="questions"><summary>Questions</summary><dl id="qlist"></dl><p id="machine" class="dim"></p></details>
</header>

<form id="beam" autocomplete="off">
  <input id="a" inputmode="numeric" pattern="[0-9]*" placeholder="line number" aria-label="line number to fly to">
  <input id="b" inputmode="numeric" pattern="[0-9]*" placeholder="connect to…" aria-label="second line number to connect to">
  <button id="go" type="submit">FLY</button>
</form>

<section id="panel" hidden>
  <button id="close" type="button" aria-label="close">✕</button>
  <div id="panelbody"></div>
</section>

<footer id="foot">
  <span id="prov" class="dim">provenance loading</span>
  <span id="hint" class="dim">drag to steer · pinch or scroll to focus the beam · tap a line</span>
  <a id="proofs" href="../../proof/">check every claim on this page</a>
</footer>

<noscript><p class="dim" style="padding:1rem">This surface is drawn from the numbered database at run time, so it needs JavaScript. Nothing here is typed into the page.</p></noscript>

<script type="module" src="app.mjs"></script>
<script type="module" src="layers-panel.mjs"></script>
<script type="module" src="code-card.mjs"></script>
<script type="module" src="questions.mjs"></script>
</body>
</html>

Questions

A JavaScript module in the iterations folder of Galaxies Wafers that works with layer tags (`layerTags`) and single-line diagram (SLD) sentence (`sldSentence`) (units: MW). Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.

rendergalaxies-wafers / iterations/07-code-card/questions.mjs · lines 1–125 of 125 · Entry point · pattern sldSentence (shared by 8 files)

What it does
It draws its content. Defines 11 functions or classes, including $, fmt, answer, fill, readJSON. Side effects: changes the web page (DOM); makes network requests.
Downstream impact
Used directly by 1 file: Iterations — 07 Code Card Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
What it achieves
It reads JSON (`readJSON`) and is built from the fmt step (`fmt`) and the answer step (`answer`). Iteration 07, the Code Card: the owner's three questions and the machine detail line. It reads `../../layers/manifest.json`. It responds to resize and toggle events.
Why it matters
Loaded by the 07 Code Card page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
Application
galaxies-wafers · iterations/07-code-card · JavaScript module
Uses
none found
Used by
loaded by Iterations — 07 Code Card Page (script src)
Produces
$, fmt, answer, fill, readJSON, layerTags, sldSentence, text, mount, fit, paint
Defines here
$, fmt, answer, fill, readJSON, layerTags, sldSentence, text, mount, fit, paint
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/07-code-card/questions.mjs:1-125 · blob 91e9e7c395b5dd0be43e125ce31dfb70cee964c6 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: duplicate_candidate
/* questions.mjs — iteration 07, the Code Card: the owner's three questions and
 * the machine detail line. Particle and card state are read at run time from
 * window.__codecard (code-card.mjs line 268) and the open card's own data
 * attributes; layer counts from layers/manifest.json; functions cited to line.
 */

const $ = id => document.getElementById(id);
const fmt = n => Number(n).toLocaleString('en-GB');
const DATA_PIN = 'https://globalgrid2050.com/testcode/202609142202/data/';
const SEARCH = 'repository search at ee082ea';   /* the commit the "who else" searches were run on */

/* One question and its answer. Parts are strings or [text, href] links; text only, never HTML. */
function answer(dl, q, parts) {
  const dt = document.createElement('dt'); dt.textContent = q;
  const dd = document.createElement('dd');
  const fill = ps => {
    dd.replaceChildren();
    for (const p of [].concat(ps)) {
      if (Array.isArray(p)) { const a = document.createElement('a'); a.textContent = p[0]; a.href = p[1]; dd.append(a); }
      else dd.append(String(p));
    }
  };
  fill(parts);
  dl.append(dt, dd);
  return fill;
}

/* One fetch, 15 s timeout, only when the reader opens the panel. */
async function readJSON(url) {
  const c = new AbortController();
  const t = setTimeout(() => c.abort(), 15000);
  try {
    const r = await fetch(url, { cache: 'default', signal: c.signal });
    if (!r.ok) throw new Error(url + ' returned HTTP ' + r.status);
    return await r.json();
  } finally { clearTimeout(t); }
}

/* The layer rows' tags as the layers panel shows them now, counted from its own DOM. */
function layerTags() {
  const c = new Map();
  for (const t of document.querySelectorAll('#layersList .ltag')) {
    const s = (t.textContent.match(/[A-Z]+/) || ['?'])[0];
    c.set(s, (c.get(s) || 0) + 1);
  }
  return c.size ? [...c].map(([s, n]) => `${fmt(n)} ${s}`).join(', ') : 'layer rows not built yet';
}

/* Layers whose id names an SLD, read from a manifest at run time (name-match inference). */
function sldSentence(m, file) {
  const hits = m.layers.filter(l => /sld/i.test(l.id));
  if (!hits.length) return `None of the ${fmt(m.layers.length)} layers in ${file} carries "sld" in its id.`;
  return `Of ${fmt(m.layers.length)} layers in ${file}, ${hits.length} carry "sld" in their id (name-match inference): ` +
    hits.map(l => `${l.id} (${fmt(l.features)} features, draws ${l.draws})`).join(', ') + '.';
}

const text = id => ($(id)?.textContent || '').trim();

/* Collapsed by default. Nothing is read or fetched until the reader opens it; the
   machine line repaints every 500 ms only while it is open. */
function mount(build, machine) {
  const box = $('questions'), dl = $('qlist'), out = $('machine');
  if (!box || !dl || !out) return;
  let built = false, timer = 0;
  /* Opened, the panel stops above whatever is drawn at the bottom (line panel, clock, strip, beam form), never over it. */
  const fit = () => {
    const top = box.getBoundingClientRect().top;
    let floor = innerHeight;
    for (const id of ['panel', 'clock', 'ptable', 'beam']) {
      const el = $(id);
      const r = el && !el.hidden ? el.getBoundingClientRect() : null;
      if (r && r.height > 0 && r.top > top) floor = Math.min(floor, r.top);
    }
    box.style.maxHeight = Math.max(96, Math.min(innerHeight * 0.45, floor - top - 8)) + 'px';
  };
  const paint = () => {
    fit();
    try { out.textContent = 'Machine detail · ' + machine(); }
    catch (e) { out.textContent = 'Machine detail · not established: ' + e.message; }
  };
  /* A bottom element that grows while the panel is open refits it at once, not at the next repaint. */
  if ('ResizeObserver' in window) {
    const ro = new ResizeObserver(() => { if (box.open) fit(); });
    for (const id of ['panel', 'clock', 'ptable', 'beam']) if ($(id)) ro.observe($(id));
  }
  addEventListener('resize', () => { if (box.open) fit(); });
  box.addEventListener('toggle', () => {
    clearInterval(timer);
    if (!box.open) return;
    if (!built) { built = true; build(dl); }
    paint();
    timer = setInterval(paint, 500);
  });
}

const COMMIT = 'dd20a5c';   /* the commit that made this page; the Questions panel is added later */

mount(dl => {
  const q1 = answer(dl, '1 · How does this help draw a system or a single-line diagram?', 'reading layers/manifest.json…');
  answer(dl, '2 · What is this code used for?',
    'Showing how many function families carry a line, and what they are. code-card.mjs: an index (line 92) loads families.json, lines.bin, all-lines.bin and all-lines.len.bin from the pinned data (DATA line 21); ' +
    'when the copying layer is ticked the layers panel announces it with a wafer:layer event (layers-panel.mjs toggle() line 177) and draw() line 129 paints each carried line as a particle, one Path2D per shine level; ' +
    'pick() line 178 finds the nearest carried line within 16 px and openCard() line 210 opens the popup: line, association count, characters, first three families with their block symbols. It imports place, ownersOf, indexOfKey and fmt from lib.mjs (line 19). ' +
    `Who else: nothing imports code-card.mjs but this page (${SEARCH}); its popup look was copied, not imported, into the root app.mjs (comment at line 696) and iteration 31 card.mjs (line 16); lib.mjs is imported by 42 files (${SEARCH}).`);
  answer(dl, '3 · Where does it lead next?', [
    'A card\'s button opens the line in the Line Wafer at the repository root (code-card.mjs line 246). ',
    ['Iteration 31, Code Card Everywhere', '../31-code-card-everywhere/'],
    ' carries this card\'s look into a card for every tap (31-code-card-everywhere/card.mjs line 16).']);
  readJSON('../../layers/manifest.json').then(m => {
    const copying = m.layers.find(l => l.id === 'copying');
    q1('It draws no electrical element; it maps code. It borrows Grid Atlas\'s REPD capacity radius stops (ATLAS_STOPS, code-card.mjs line 27), which the Atlas uses for project capacity in MW; ' +
      'here the axis carries an association count scaled by the layer\'s own maximum (onAtlasAxis() line 121), so a particle\'s size has no MW meaning. ' +
      (copying ? `The copying layer lists ${fmt(copying.features)} features (layers/manifest.json, read now). ` : 'layers/manifest.json lists no copying layer now, so no particles can be drawn. ') +
      sldSentence(m, 'layers/manifest.json'));
  }).catch(e => q1(`Not established: layers/manifest.json could not be read (${e.message}). The page draws no electrical element.`));
}, () => {
  const card = document.querySelector('.codecard');
  const C = window.__codecard;
  return 'inputs: ?layers= (the particles need copying, LAYER code-card.mjs line 22; layers-panel.mjs line 251), ?line= and ?to= (permanent line keys, readURL() app.mjs line 496), a tap on the wafer (CSS px, reach 16 px, line 176); ' +
    `data: all-lines.meta.json, all-lines.bin, all-lines.len.bin, all-lines.family.bin, families.json and lines.bin from ${DATA_PIN} (app.mjs line 48, code-card.mjs line 21), ${text('prov') || 'provenance not loaded yet'} · ` +
    `outputs: ${text('count') || 'count not loaded yet'}; particles drawn from the copying layer now ${C ? fmt(C.particles) : 'not known'}; ` +
    `card now ${card ? `line ${fmt(card.dataset.key)}, ${fmt(card.dataset.families)} associations` : 'closed'}; radius R·k px with R 8–38 on the Atlas stops, k = min(1, √zoom ÷ 4), at least 0.6 px (lines 140 and 147); layer rows now ${layerTags()} · ` +
    'refusals: if the family index cannot load, the reason goes to the console and a tap opens no card (line 102); a tap farther than 16 px from any carried line closes the card; a layer reads FAIL or EMPTY with its reason; unknown ?layers= ids are dropped without a warning (layers-panel.mjs line 253); refuse() app.mjs line 514 · ' +
    `source: page commit ${COMMIT}; lib.mjs and layers/ from this repository`;
});

Iterations — 07 Code Card Style Sheet

A style sheet in Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.

Set aside from the main view: 92% of its lines are the same as iterations/21-dark-pixels/style.css (galaxies-wafers), which stays. (near-copy-of, proposed by families.py). 91% of lines shared with Iterations — 21 Dark Pixels Style Sheet; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9189 to galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/21-dark-pixels/style.css:1-92 9d04de4ea47b8ded947b87f2f91c830acd076cb3
  • sha256 3a872ac9a035e61f38bdf561c9890a3f086b481df40e611e022ae354f78a91ef
  • target sha256 106d7fa0b58ca4c66fe9ee61e756a5e48562afaaf3a1bde7ccd8d121c5637063
  • group of 3 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

rendergalaxies-wafers / iterations/07-code-card/style.css · lines 1–84 of 84 · Entry point

What it does
Side effects: changes the web page (DOM).
Downstream impact
Used directly by 2 files: Iterations — 07 Code Card Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/); Wafer (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/10-ground-bridge/wafer.html). Reached from 1 other entry point, including Iterations — 10 Ground Bridge Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/10-ground-bridge/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/.
What it achieves
The Line Wafer. Designed at 430 px first; the desktop is the same layout with more room.
Why it matters
Loaded by the 07 Code Card page at https://ventusltd.github.io/galaxies-wafers/iterations/07-code-card/ and 1 other page.
Application
galaxies-wafers · iterations/07-code-card · style sheet
Uses
none found
Used by
loaded by Iterations — 07 Code Card Page (stylesheet), loaded by Wafer (stylesheet)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/07-code-card/style.css:1-84 · blob 0178ae1a3b0818abe372608dc5a62126c19c0f63 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
/* The Line Wafer. Designed at 430 px first; the desktop is the same layout with
   more room. One canvas, three chrome strips, nothing that scrolls the page. */

:root{
  --ink:#d8dee9; --dim:#8b93a7; --ground:#0b0d12; --edge:#1b2030;
  --lit:#ffd54a; --beam:#5ec8f2;
  --top:env(safe-area-inset-top,0px); --bot:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--ground); color:var(--ink);
  font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  overflow:hidden; overscroll-behavior:none; -webkit-text-size-adjust:100%;
}
#stage{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none}

#bar{
  position:fixed; left:0; right:0; top:0; z-index:2;
  display:flex; gap:.75rem; align-items:baseline; flex-wrap:wrap;
  padding:calc(var(--top) + .5rem) .75rem .5rem;
  background:linear-gradient(#0b0d12ee,#0b0d1200); pointer-events:none;
}
#wordmark{letter-spacing:.14em; font-size:11px}
.dim{color:var(--dim)}

#beam{
  position:fixed; z-index:3; left:.5rem; right:.5rem;
  bottom:calc(var(--bot) + 3.4rem);
  display:flex; gap:.4rem;
}
#beam input{
  flex:1 1 0; min-width:0; padding:.6rem .55rem;
  background:#11151f; color:var(--ink); border:1px solid var(--edge); border-radius:6px;
  font:inherit; font-size:16px; /* 16px stops iOS zooming the page on focus */
}
#beam input:focus{outline:none; border-color:var(--beam)}
#beam button{
  flex:0 0 auto; padding:.6rem .9rem; border-radius:6px; cursor:pointer;
  background:#11151f; color:var(--beam); border:1px solid var(--beam);
  font:inherit; font-size:13px; letter-spacing:.1em;
}
#beam button:active{background:#16202c}

#panel{
  position:fixed; z-index:4; left:.5rem; right:.5rem;
  bottom:calc(var(--bot) + 6.6rem);
  max-height:52vh; overflow:auto; -webkit-overflow-scrolling:touch;
  background:#0e121bf2; border:1px solid var(--edge); border-radius:8px;
  padding:.75rem .8rem 1rem;
}
#panel[hidden]{display:none!important}
#close{
  position:absolute; top:.35rem; right:.4rem; width:2rem; height:2rem;
  background:none; border:0; color:var(--dim); font:inherit; font-size:15px; cursor:pointer;
}
#panel h2{margin:0 .5rem .5rem 0; font-size:15px; font-weight:600; letter-spacing:.02em}
#panel h2 .n{color:var(--lit)}
#panel dl{display:grid; grid-template-columns:auto 1fr; gap:.15rem .6rem; margin:.5rem 0}
#panel dt{color:var(--dim)}
#panel dd{margin:0; overflow-wrap:anywhere}
#panel p{margin:.5rem 0 0}
#panel ul{margin:.35rem 0 0; padding-left:1.1rem}
#panel li{margin:.15rem 0}
.fam{color:var(--beam)}
.refuse{color:var(--lit)}

#foot{
  position:fixed; z-index:2; left:0; right:0; bottom:0;
  display:flex; gap:.15rem; flex-direction:column;
  padding:.35rem .75rem calc(var(--bot) + .35rem);
  background:linear-gradient(#0b0d1200,#0b0d12ee); pointer-events:none;
  font-size:10.5px;
}
#hint{text-align:left}
#foot a{color:var(--beam); pointer-events:auto; text-decoration:underline}

@media (min-width:760px){
  #beam{left:auto; right:1rem; width:26rem; bottom:calc(var(--bot) + 2.9rem)}
  #foot{flex-direction:row; gap:.6rem; justify-content:space-between}
  #hint{text-align:right}
  #panel{left:1rem; right:auto; width:26rem; bottom:calc(var(--bot) + 2.5rem); max-height:66vh}
  #foot{font-size:11px}
}