GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / cosmic / tools/explore/theme

Play and 2 more files (part 1)

A JavaScript file in the theme folder of Cosmic that checks badges (`checkBadges`), builds hud (`buildHud`) and refreshes hud (`refreshHud`).

699 lines of JavaScript and CSS from cosmic, in 3 files. Topic: Kuiper, cosmos and drawing engines. Section 1157 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. Play render · cosmic / tools/explore/theme/play.css lines 1–173
  2. Play interaction · cosmic / tools/explore/theme/play.js lines 1–463
  3. Seethrough render · cosmic / tools/explore/theme/seethrough.css lines 1–63

Play

A style sheet in the theme folder of Cosmic.

rendercosmic / tools/explore/theme/play.css · lines 1–173 of 173 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
README: "`inject.py` copies `play.css` and `play.js` to `/theme/`."
What it achieves
Explore Code play layer (`theme/play.css`). Progressive enhancement, added after build by `theme/inject.py`.
Why it matters
No other file in the estate was found to import it.
Application
cosmic · tools/explore/theme · style sheet
Uses
none found
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
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/theme/play.css:1-173 · blob 01f4992b5e1679a36c782943813029754373a0ec · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/* Explore Code play layer (theme/play.css). Progressive enhancement, added after build by theme/inject.py.
   Part 1 works with JS off: phone fixes from the player reviews (the RECOMMENDATIONS.md of players 1-8).
   Part 2 styles the cockpit HUD that play.js draws. Its look follows the Energy Transition Simulator overlay
   (mod/menu-style.js and mod/menu-bar.js): black page, hairline edges, one dropdown panel at a time,
   the pressed title underlined, a dim readout in tabular numbers, a short note that fades.
   The visualiser app (visual/index.html, <main id="stage">) is left alone: every rule is scoped away from it. */

:root{
  --pl-bg:#000;--pl-panel:#0b0e14;--pl-panel-2:#111620;--pl-line:#2f343d;--pl-ink:#fff;--pl-muted:#a6adbb;
  --pl-link:#66ccff;--pl-accent:#00ffff;--pl-go:#00ff88;--pl-sun:#ffd24a;--pl-alert:#ff6666;
  /* the simulator's own tokens (menu-style.js) and grid colours (overlay.html GRID, substations) */
  --pl-sim-panel:rgba(10,10,10,.86);--pl-sim-edge:#1c2c3a;--pl-sim-line:#9cdbff;--pl-sim-text:#cfe9ff;--pl-sim-dim:#6f8ea6;
  --pl-sim-warn:#ffb27a;--pl-sim-sub:#ffd400;--pl-kv400:#0054ff;--pl-kv275:#ff0000;--pl-kv132:#00b050;
  --pl-tap:44px;--pl-r:6px;--pl-t:160ms cubic-bezier(.2,.7,.2,1)
}

/* ---------- Part 1: phone fixes (JS off too) ---------- */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
:where(body:not(:has(> main#stage))){overflow-x:hidden}
:where(body:not(:has(> main#stage))) :is(main,header,footer,li,td,th,dd,dt,p,h1,h2,h3,a,code){overflow-wrap:anywhere;min-width:0}
:where(body:not(:has(> main#stage))) :is(header,nav,main,footer){box-sizing:border-box;max-width:min(1100px,100%)}
:where(body:not(:has(> main#stage))) img,:where(body:not(:has(> main#stage))) svg{max-width:100%;height:auto}
/* tables scroll inside themselves, never the page */
:where(body:not(:has(> main#stage))) table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
:where(body:not(:has(> main#stage))) pre{max-width:100%;overflow-x:auto;white-space:pre}
/* 16px form text so iOS does not zoom; inputs never wider than the screen */
:where(body:not(:has(> main#stage))) :is(input,select,textarea){font-size:16px;max-width:100%;box-sizing:border-box}
:where(body:not(:has(> main#stage))) :is(input,select,button){min-height:var(--pl-tap)}
:where(body:not(:has(> main#stage))) button{cursor:pointer;border-radius:var(--pl-r);padding-inline:14px}
:where(body:not(:has(> main#stage))) form#f{display:flex;gap:8px;flex-wrap:wrap}
:where(body:not(:has(> main#stage))) #q{flex:1 1 220px;width:100%;max-width:560px;border-radius:var(--pl-r);padding:10px 12px}
/* focus rings */
:where(body:not(:has(> main#stage))) :is(a,button,input,select,textarea,summary):focus-visible{outline:2px solid var(--pl-accent);outline-offset:3px;border-radius:2px}
/* 44px tap targets for the controls a thumb aims at (inline links inside sentences are exempt, WCAG 2.5.8) */
:where(body:not(:has(> main#stage))) > nav{gap:6px 8px;align-items:center}
:where(body:not(:has(> main#stage))) > nav a{display:inline-flex;align-items:center;min-height:var(--pl-tap);padding:0 12px;border:1px solid var(--pl-line);
  border-radius:999px;text-decoration:none;transition:border-color var(--pl-t),background var(--pl-t)}
:where(body:not(:has(> main#stage))) > nav a:hover{border-color:var(--pl-accent);background:var(--pl-panel)}
:where(body:not(:has(> main#stage))) summary{min-height:var(--pl-tap);display:flex;align-items:center;gap:6px}
:where(body:not(:has(> main#stage))) summary::-webkit-details-marker{color:var(--pl-accent)}
:where(body:not(:has(> main#stage))) summary::marker{color:var(--pl-accent)}
:where(body:not(:has(> main#stage))) main :is(ul,ol) > li > a:first-child{display:inline-block;box-sizing:border-box;min-height:var(--pl-tap);padding:10px 0}
:where(body:not(:has(> main#stage))) main :is(ul,ol) > li{margin:2px 0}
:where(body:not(:has(> main#stage))) .crumbs a{display:inline-block;box-sizing:border-box;min-height:var(--pl-tap);padding:10px 0}
a{text-underline-offset:3px}
a:hover{color:var(--pl-accent)}
@media (max-width:600px){
  /* one column "What it does" box: labels above answers (player 1, item 1) */
  :where(body:not(:has(> main#stage))) dl.v{grid-template-columns:1fr;gap:0}
  :where(body:not(:has(> main#stage))) dl.v dt{margin-top:10px}
  :where(body:not(:has(> main#stage))) dl.v dd{margin:2px 0 0}
  :where(body:not(:has(> main#stage))) :is(header,nav,main,footer){padding-left:14px;padding-right:14px}
  :where(body:not(:has(> main#stage))) section.file{margin-left:-10px;padding-left:8px}
  :where(body:not(:has(> main#stage))) h1{font-size:20px;line-height:1.25}
  :where(body:not(:has(> main#stage))) ul.links{columns:1}
}

/* ---------- Part 2: cockpit HUD (drawn by play.js) ---------- */
.pl-hud{position:sticky;top:0;z-index:30;display:flex;align-items:stretch;gap:0;min-height:var(--pl-tap);
  background:var(--pl-sim-panel);border-bottom:1px solid var(--pl-sim-edge);color:var(--pl-sim-text);
  font:13px/1.3 system-ui,-apple-system,"Segoe UI",sans-serif;font-variant-numeric:tabular-nums;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);overflow-x:auto;overflow-y:hidden;scrollbar-width:none;
  animation:pl-drop .32s cubic-bezier(.2,.7,.2,1) both}
.pl-hud::-webkit-scrollbar{display:none}
@keyframes pl-drop{from{transform:translateY(-100%);opacity:0}to{transform:none;opacity:1}}
.pl-hud > *{flex:none}
.pl-hud .pl-brand{display:inline-flex;align-items:center;gap:6px;padding:0 12px;color:var(--pl-accent);text-decoration:none;
  letter-spacing:.12em;font-size:11px;font-weight:600;border-right:1px solid var(--pl-sim-edge)}
.pl-hud .pl-brand i{width:8px;height:8px;border-radius:50%;background:var(--pl-go);box-shadow:0 0 8px var(--pl-go);animation:pl-pulse 2.4s ease-in-out infinite}
@keyframes pl-pulse{50%{opacity:.35}}
.pl-modes{display:flex;align-items:stretch}
.pl-modes:empty{display:none}
.pl-hud :is(.pl-title,.pl-mode,.pl-btn){appearance:none;background:transparent;border:0;border-bottom:2px solid transparent;border-radius:0;
  color:var(--pl-sim-dim);font:inherit;min-height:var(--pl-tap);padding:0 12px;display:inline-flex;align-items:center;gap:6px;
  cursor:pointer;text-decoration:none;white-space:nowrap;transition:color var(--pl-t),border-color var(--pl-t),background var(--pl-t)}
.pl-hud :is(.pl-title,.pl-mode,.pl-btn):hover{color:#fff;background:rgba(156,219,255,.05)}
.pl-hud :is(.pl-title[aria-expanded="true"],.pl-mode[aria-pressed="true"],.pl-mode.on){color:#fff;border-bottom-color:var(--pl-sim-line)}
.pl-hud :is(.pl-title,.pl-mode,.pl-btn):focus-visible{outline:2px solid var(--pl-accent);outline-offset:-3px}
.pl-hud .pl-sep{width:1px;background:var(--pl-sim-edge);margin:8px 2px}
.pl-hud .pl-count{min-width:1.6em;padding:1px 6px;border-radius:999px;border:1px solid var(--pl-sim-edge);color:var(--pl-accent);font-size:11px;text-align:center}
.pl-hud .pl-count.done{border-color:var(--pl-go);color:var(--pl-go)}
.pl-hud kbd{font:11px ui-monospace,Menlo,Consolas,monospace;border:1px solid var(--pl-sim-edge);border-radius:3px;padding:0 4px;color:var(--pl-sim-dim)}
.pl-hud .pl-fly{color:var(--pl-sim-sub)}
.pl-hud .pl-fly:hover{color:#fff;border-bottom-color:var(--pl-sim-sub)}
.pl-hud .pl-where{margin-left:auto;display:inline-flex;align-items:center;padding:0 12px;color:var(--pl-sim-dim);font-size:12px;white-space:nowrap}
.pl-hud .pl-where b{color:var(--pl-sim-text);font-weight:500}
.pl-ico{display:inline-block;width:1em;text-align:center}

/* dropdown panels: one open at a time, like the simulator's .gm-panel */
.pl-panel{position:fixed;z-index:41;top:calc(var(--pl-tap) + 4px);left:8px;width:min(380px,calc(100vw - 16px));max-height:calc(100vh - 90px);
  overflow:auto;box-sizing:border-box;background:var(--pl-sim-panel);border:1px solid var(--pl-sim-edge);border-radius:var(--pl-r);
  padding:10px 12px;color:var(--pl-sim-text);font:13px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif;
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);box-shadow:0 12px 40px rgba(0,0,0,.6);
  animation:pl-open .24s cubic-bezier(.2,.7,.2,1) both}
.pl-panel[hidden]{display:none}
@keyframes pl-open{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
.pl-panel h2{font-size:11px;font-weight:600;letter-spacing:.06em;color:var(--pl-sim-dim);text-transform:uppercase;margin:4px 0 6px;border:0;padding:0}
.pl-panel p{margin:4px 0 8px}
.pl-panel .pl-big{font-size:17px;color:#fff;margin:2px 0}
.pl-panel .pl-note{color:var(--pl-sim-dim);font-size:12px}
.pl-panel a{color:var(--pl-link)}
.pl-panel .pl-gm-sep{border-top:1px solid var(--pl-sim-edge);margin:8px 0}
.pl-panel button,.pl-panel .pl-act{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:var(--pl-tap);padding:0 14px;
  border:1px solid var(--pl-sim-edge);border-radius:4px;background:rgba(156,219,255,.04);color:var(--pl-sim-text);font:inherit;cursor:pointer;
  text-decoration:none;transition:border-color var(--pl-t),color var(--pl-t),background var(--pl-t)}
.pl-panel button:hover,.pl-panel .pl-act:hover{border-color:var(--pl-sim-line);color:#fff}
.pl-panel button[aria-pressed="true"]{border-color:var(--pl-sim-line);color:#fff}
.pl-panel .pl-row{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.pl-panel ul{list-style:none;margin:6px 0;padding:0}
.pl-panel li{margin:0;padding:0}
.pl-panel li > a,.pl-panel li > span{display:flex;align-items:center;gap:8px;min-height:var(--pl-tap);padding:0 6px;border-radius:4px;text-decoration:none}
.pl-panel li > a:hover{background:rgba(156,219,255,.06)}
.pl-panel .pl-ok{color:var(--pl-go)}
.pl-panel .pl-todo{color:var(--pl-sim-dim)}
.pl-meter{height:6px;border-radius:3px;background:var(--pl-sim-edge);overflow:hidden;margin:6px 0}
.pl-meter > i{display:block;height:100%;background:linear-gradient(90deg,var(--pl-accent),var(--pl-go));transition:width .6s cubic-bezier(.2,.7,.2,1)}
.pl-badges{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px;margin:8px 0}
.pl-badge{border:1px solid var(--pl-sim-edge);border-radius:var(--pl-r);padding:8px;text-align:center;color:var(--pl-sim-dim);font-size:11px;line-height:1.3}
.pl-badge b{display:block;font-size:22px;line-height:1.2;color:var(--pl-sim-edge);filter:grayscale(1)}
.pl-badge.got{border-color:var(--pl-sim-line);color:var(--pl-sim-text);background:rgba(156,219,255,.05)}
.pl-badge.got b{color:var(--pl-sun);filter:none;text-shadow:0 0 10px rgba(255,210,74,.5)}

/* the note: like the simulator's #sim-note, bottom-left, fades */
.pl-toast{position:fixed;left:12px;bottom:calc(16px + env(safe-area-inset-bottom,0px));z-index:42;max-width:min(520px,calc(100vw - 24px));
  box-sizing:border-box;padding:10px 14px;border:1px solid var(--pl-sim-line);border-radius:var(--pl-r);background:var(--pl-sim-panel);
  color:var(--pl-sim-text);font:13px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  box-shadow:0 0 24px rgba(0,255,255,.15);opacity:0;transform:translateY(12px);transition:opacity .24s,transform .24s cubic-bezier(.2,.7,.2,1);pointer-events:none}
.pl-toast.show{opacity:1;transform:none}
.pl-toast b{color:var(--pl-sun)}

/* big tappable cards and buttons (added by play.js) */
ul.pl-cards{list-style:none;padding:0;margin:12px 0;display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px}
ul.pl-cards > li{position:relative;margin:0;background:var(--pl-panel);border:1px solid var(--pl-line);border-radius:var(--pl-r);padding:14px 14px 18px;
  color:var(--pl-muted);font-size:14px;overflow:hidden;transition:border-color var(--pl-t),transform var(--pl-t),background var(--pl-t)}
ul.pl-cards > li:hover,ul.pl-cards > li:focus-within{border-color:var(--pl-accent);background:var(--pl-panel-2);transform:translateY(-2px)}
ul.pl-cards > li > a:first-child{display:flex;min-height:var(--pl-tap);align-items:center;font-size:17px;text-decoration:none}
ul.pl-cards > li > a:first-child::after{content:"";position:absolute;inset:0}  /* the whole card is the tap target */
ul.pl-cards > li .lic{position:relative;z-index:1}
.pl-strip{position:absolute;left:0;right:0;bottom:0;height:6px;display:flex}
.pl-strip > i{display:block;height:100%}
.pl-visited{position:absolute;top:10px;right:10px;font-size:11px;color:var(--pl-go)}
.pl-live{display:flex;align-items:center;justify-content:center;gap:10px;min-height:56px;margin:14px 0;padding:0 20px;border:1px solid var(--pl-go);
  border-radius:var(--pl-r);background:linear-gradient(90deg,rgba(0,255,136,.12),rgba(0,255,255,.06));color:#fff;font:600 16px/1.2 system-ui,-apple-system,"Segoe UI",sans-serif;
  text-decoration:none;box-shadow:0 0 0 rgba(0,255,136,0);transition:box-shadow var(--pl-t),transform var(--pl-t),border-color var(--pl-t)}
.pl-live:hover{color:#fff;border-color:var(--pl-accent);box-shadow:0 0 24px rgba(0,255,136,.25);transform:translateY(-1px)}
.pl-live small{font-weight:400;color:var(--pl-muted);font-size:12px;overflow-wrap:anywhere}
.pl-chips{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0}
.pl-chip{display:inline-flex;align-items:center;gap:6px;min-height:var(--pl-tap);padding:0 12px;border:1px solid var(--pl-line);border-radius:999px;
  color:var(--pl-link);background:var(--pl-panel);font:13px system-ui,-apple-system,"Segoe UI",sans-serif;text-decoration:none}
.pl-chip:hover{border-color:var(--pl-accent)}
.pl-chip.live{border-color:rgba(0,255,136,.6);color:var(--pl-go)}
.pl-chip.fly{border-color:rgba(255,212,0,.6);color:var(--pl-sim-sub)}
.pl-chip.hunt{border-color:var(--pl-accent);color:var(--pl-accent)}
section.file.pl-target{box-shadow:inset 4px 0 0 var(--pl-accent)}
section.file.pl-flash{animation:pl-flash 1.2s ease-out 1}
@keyframes pl-flash{0%{background:rgba(0,255,255,.18)}100%{background:transparent}}

/* "About this build" fold (play.js wraps the build notes) */
details.pl-about{margin:8px 0;border:1px solid var(--pl-line);border-radius:var(--pl-r);padding:0 12px;background:var(--pl-panel)}
details.pl-about > summary{color:var(--pl-muted);font-size:13px;cursor:pointer;min-height:var(--pl-tap);display:flex;align-items:center}
details.pl-about[open]{padding-bottom:6px}

@media (max-width:600px){
  .pl-hud .pl-label{display:none}            /* icons + counters only; full names stay as aria-label */
  .pl-hud .pl-where{display:none}
  .pl-hud :is(.pl-title,.pl-mode,.pl-btn){padding:0 11px;min-width:var(--pl-tap);justify-content:center}
  .pl-panel{left:8px;right:8px;width:auto}
}
@media print{.pl-hud,.pl-panel,.pl-toast,.pl-live,.pl-chips{display:none!important}}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
  ul.pl-cards > li:hover,ul.pl-cards > li:focus-within,.pl-live:hover{transform:none}
}

Play

A JavaScript file in the theme folder of Cosmic that checks badges (`checkBadges`), builds hud (`buildHud`) and refreshes hud (`refreshHud`).

interactioncosmic / tools/explore/theme/play.js · lines 1–463 of 463 · pattern sectionPage (shared by 2 files)

What it does
It draws its content. Defines 38 functions or classes, including get, set, today, dayBefore, fnv. Side effects: changes the web page (DOM); makes network requests; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
README: "`inject.py` copies `play.css` and `play.js` to `/theme/`."
Inputs & outputs
In: JSON file play-index.json; browser storage (getItem). Out: browser storage (setItem).
Downstream impact
Used directly by 1 file: Test Theme (cosmic).
What it achieves
It checks badges (`checkBadges`), builds hud (`buildHud`) and refreshes hud (`refreshHud`). Explore Code play layer (`theme/play.js`). Vanilla, no dependencies, no external hosts. It responds to click, keydown and DOMContentLoaded events.
Why it matters
Checked by Test Theme.
Application
cosmic · tools/explore/theme · script
Uses
none found
Used by
run by Test Theme (script call)
Produces
get, set, today, dayBefore, fnv, el, pad4, index, prep, fileHref, save, streak
Defines here
get, set, today, dayBefore, fnv, el, pad4, index, prep, fileHref, save, streak, count, award, checkBadges, chime, toast, nextToast, esc, title, buildHud, refreshHud, toggle, typing, loading, failed, randomJump, cotd, roleChip, newHunt
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/theme/play.js:1-463 · blob baf37b207c9ce98c64427cb0b1547380e0d82467 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network, storage · domain stage: unknown · users: none · canonical: unknown
/* Explore Code play layer (theme/play.js). Vanilla, no dependencies, no external hosts.
   Added after build by theme/inject.py as one deferred script. With JS off the pages read exactly as built.
   Draws the shared cockpit HUD (look from the Energy Transition Simulator overlay: mod/menu-style.js and
   mod/menu-bar.js), a code of the day, a random-file jump (r), a pattern hunt, badges and a streak.
   Every fact shown comes from the page itself or theme/play-index.json, a digest of build_graph.json.
   Progress lives in localStorage under "ec-play:*" (wrapped in try/catch). Sound is off by default.
   Contract with theme/ide.js (HOTBAR-36): the HUD holds <div class="pl-modes" data-pl-slot="modes">; when the HUD
   is ready, <html data-pl-hud="ready"> is set and document fires "pl:hud-ready" with detail {slot, hud}. */
(function () {
  'use strict';
  if (window.ExplorePlay) return;
  var doc = document, html = doc.documentElement;
  var me = doc.currentScript || doc.querySelector('script[data-ec-theme="play"]');
  var root = ((me && me.src) || '').replace(/theme\/play\.js(\?.*)?$/, '');
  var here = location.href.split('#')[0].split('?')[0];
  var rel = root && here.indexOf(root) === 0 ? here.slice(root.length) : '';
  if (rel === '') rel = 'index.html';
  var isApp = !!doc.querySelector('main#stage, canvas#cv, [data-pl-nohud]');

  /* ---------- storage, never throws ---------- */
  var P = 'ec-play:';
  function get(k, d) { try { var v = localStorage.getItem(P + k); return v == null ? d : JSON.parse(v); } catch (e) { return d; } }
  function set(k, v) { try { localStorage.setItem(P + k, JSON.stringify(v)); } catch (e) { /* private mode or full */ } }

  function today() { return new Date().toISOString().slice(0, 10); }           // UTC date
  function dayBefore(d) { var t = new Date(d + 'T00:00:00Z'); t.setUTCDate(t.getUTCDate() - 1); return t.toISOString().slice(0, 10); }
  function fnv(s) { var h = 2166136261; for (var i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; }
  function el(tag, attrs, kids) {
    var n = doc.createElement(tag);
    if (attrs) for (var k in attrs) {
      if (k === 'text') n.textContent = attrs[k];
      else if (k === 'cls') n.className = attrs[k];
      else if (k.slice(0, 2) === 'on') n.addEventListener(k.slice(2), attrs[k]);
      else n.setAttribute(k, attrs[k]);
    }
    (kids || []).forEach(function (c) { if (c != null) n.appendChild(typeof c === 'string' ? doc.createTextNode(c) : c); });
    return n;
  }
  function pad4(n) { return ('000' + n).slice(-4); }
  var T = '︎'; // text presentation for the symbol glyphs

  /* ---------- the build digest ---------- */
  var idxPromise = null;
  function index() {
    if (!idxPromise) {
      idxPromise = (root && window.fetch ? fetch(root + 'theme/play-index.json', { credentials: 'same-origin' })
        .then(function (r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
        .then(prep) : Promise.reject(new Error('no index')));
      idxPromise.catch(function () { /* handled by callers */ });
    }
    return idxPromise;
  }
  function prep(d) {
    d.secUrl = {}; d.secTitle = {}; d.secTopic = {};
    d.sections.forEach(function (s) { d.secUrl[s[0]] = s[1]; d.secTitle[s[0]] = s[3]; d.secTopic[s[0]] = s[2]; });
    d.byId = {}; d.bySec = {};
    d.files.forEach(function (f) { d.byId[f[0]] = f; (d.bySec[f[1]] = d.bySec[f[1]] || []).push(f); });
    d.byPat = {};
    d.files.forEach(function (f) { if (f[3] >= 0) (d.byPat[f[3]] = d.byPat[f[3]] || []).push(f); });
    return d;
  }
  // file row: [id, section, block, pattern, crs, published, role, lang, title, repo]
  function fileHref(d, f) { return root + (d.secUrl[f[1]] || ('s/' + pad4(f[1]) + '.html')) + '#f' + f[2]; }

  /* ---------- progress ---------- */
  var st = {
    visited: get('visited', {}), days: get('days', []), badges: get('badges', {}), randoms: get('randoms', 0),
    hunt: get('hunt', null), cotd: get('cotd', ''), sound: get('sound', false), langs: get('langs', {})
  };
  function save() {
    set('visited', st.visited); set('days', st.days.slice(-120)); set('badges', st.badges); set('randoms', st.randoms);
    set('hunt', st.hunt); set('cotd', st.cotd); set('sound', st.sound); set('langs', st.langs);
  }
  function streak() {
    var have = {}; st.days.forEach(function (d) { have[d] = 1; });
    var d = today(), n = 0;
    while (have[d]) { n++; d = dayBefore(d); }
    return n;
  }
  function count(prefix) { var n = 0; for (var k in st.visited) if (k.indexOf(prefix) === 0) n++; return n; }

  var BADGES = [
    ['first', '◉', 'First contact', 'Open your first page'],
    ['ten', '◈', 'Surveyor', 'Visit 10 different pages'],
    ['fifty', '✦', 'Field engineer', 'Visit 50 different pages'],
    ['topics', '⌖', 'Cartographer', 'Visit all 9 topic pages'],
    ['journeys', '⇆', 'Route planner', 'Walk all 4 journeys'],
    ['daily', '☀' + T, 'Code of the day', 'Open the code of the day'],
    ['dice', '⚄' + T, 'Dice roller', 'Take 5 random jumps'],
    ['hunt', '⌘', 'Pattern hunter', 'Finish a pattern hunt'],
    ['live', '⚡' + T, 'Live wire', 'Open a live tool'],
    ['fly', '✈' + T, 'Pilot', 'Use Fly there'],
    ['polyglot', '≣', 'Polyglot', 'Read files in 5 languages'],
    ['streak3', '③', '3-day streak', 'Explore on 3 days in a row'],
    ['streak7', '⑦', '7-day streak', 'Explore on 7 days in a row']
  ];
  function award(id, quiet) {
    if (st.badges[id]) return false;
    st.badges[id] = today(); save();
    var b = BADGES.filter(function (x) { return x[0] === id; })[0];
    if (b && !quiet) { toast('Badge earned: <b>' + b[1] + ' ' + b[2] + '</b>'); chime(); }
    refreshHud();
    return true;
  }
  function checkBadges() {
    var n = Object.keys(st.visited).length;
    if (n >= 1) award('first');
    if (n >= 10) award('ten');
    if (n >= 50) award('fifty');
    if (count('topics/') >= 9) award('topics');
    if (count('journeys/') >= 4) award('journeys');
    if (st.randoms >= 5) award('dice');
    if (Object.keys(st.langs).length >= 5) award('polyglot');
    var s = streak();
    if (s >= 3) award('streak3');
    if (s >= 7) award('streak7');
  }

  /* ---------- sound (off unless switched on) ---------- */
  var actx = null;
  function chime(up) {
    if (!st.sound) return;
    try {
      actx = actx || new (window.AudioContext || window.webkitAudioContext)();
      var t = actx.currentTime;
      [0, 0.09].forEach(function (dt, i) {
        var o = actx.createOscillator(), g = actx.createGain();
        o.type = 'triangle'; o.frequency.value = (up === false ? [440, 330] : [660, 990])[i];
        g.gain.setValueAtTime(0.0001, t + dt); g.gain.exponentialRampToValueAtTime(0.08, t + dt + 0.02);
        g.gain.exponentialRampToValueAtTime(0.0001, t + dt + 0.18);
        o.connect(g); g.connect(actx.destination); o.start(t + dt); o.stop(t + dt + 0.2);
      });
    } catch (e) { /* no audio */ }
  }

  /* ---------- the note (simulator #sim-note) ---------- */
  var toastEl = null, toastQ = [], toastBusy = false;
  function toast(htmlText) { toastQ.push(htmlText); if (!toastBusy) nextToast(); }
  function nextToast() {
    var m = toastQ.shift();
    if (!m) { toastBusy = false; return; }
    toastBusy = true;
    if (!toastEl) { toastEl = el('div', { cls: 'pl-toast', role: 'status', 'aria-live': 'polite' }); doc.body.appendChild(toastEl); }
    toastEl.innerHTML = m;
    requestAnimationFrame(function () { toastEl.classList.add('show'); });
    setTimeout(function () { toastEl.classList.remove('show'); setTimeout(nextToast, 300); }, 3200);
  }
  function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }

  /* ---------- record this visit ---------- */
  st.visited[rel] = 1;
  if (st.days.indexOf(today()) < 0) st.days.push(today());
  save();

  var api = window.ExplorePlay = { root: root, rel: rel, index: index, hud: null, slot: null, toast: toast, award: award };
  if (isApp) { checkBadges(); return; }   // the visualiser has its own bar and keys; only progress is recorded

  /* ---------- HUD ---------- */
  var hud, slot, panels = {}, titles = {}, cnt = {}, whereEl, flyEl;
  function title(id, icon, label, aria, withCount) {
    var b = el('button', { cls: 'pl-title', type: 'button', 'aria-expanded': 'false', 'aria-controls': 'pl-p-' + id, 'aria-label': aria },
      [el('span', { cls: 'pl-ico', 'aria-hidden': 'true', text: icon }), el('span', { cls: 'pl-label', text: label })]);
    if (withCount) { cnt[id] = el('span', { cls: 'pl-count', 'aria-hidden': 'true', text: '–' }); b.appendChild(cnt[id]); }
    b.addEventListener('click', function (e) { e.stopPropagation(); toggle(id); });
    titles[id] = b;
    var p = el('div', { cls: 'pl-panel', id: 'pl-p-' + id, role: 'dialog', 'aria-label': aria, hidden: '' });
    p.addEventListener('click', function (e) { e.stopPropagation(); });
    panels[id] = p;
    return b;
  }
  function buildHud() {
    hud = el('div', { id: 'pl-hud', cls: 'pl-hud', role: 'region', 'aria-label': 'Explore cockpit' });
    hud.appendChild(el('a', { cls: 'pl-brand', href: root + 'index.html', 'aria-label': 'Explore Code home' }, [el('i', { 'aria-hidden': 'true' }), 'EXPLORE']));
    slot = el('div', { cls: 'pl-modes', 'data-pl-slot': 'modes', role: 'group', 'aria-label': 'Mode' });
    hud.appendChild(slot);
    hud.appendChild(title('today', '☀' + T, 'Today', 'Code of the day'));
    hud.appendChild(title('hunt', '⌘', 'Hunt', 'Pattern hunt', true));
    hud.appendChild(title('badges', '★', 'Badges', 'Badges and streak', true));
    hud.appendChild(el('button', { cls: 'pl-btn', type: 'button', id: 'pl-random', 'aria-label': 'Random file (key r)', title: 'Random file (r)', onclick: randomJump },
      [el('span', { cls: 'pl-ico', 'aria-hidden': 'true', text: '⚄' + T }), el('span', { cls: 'pl-label', text: 'Random' }), el('kbd', { cls: 'pl-label', text: 'r' })]));
    whereEl = el('span', { cls: 'pl-where', 'aria-live': 'off' });
    hud.appendChild(whereEl);
    doc.body.insertBefore(hud, doc.body.firstChild);
    for (var k in panels) doc.body.appendChild(panels[k]);
    api.hud = hud; api.slot = slot;
    html.setAttribute('data-pl-hud', 'ready');
    try { doc.dispatchEvent(new CustomEvent('pl:hud-ready', { detail: { slot: slot, hud: hud } })); } catch (e) { /* old browser */ }
    refreshHud();
  }
  function refreshHud() {
    if (!hud) return;
    var n = Object.keys(st.visited).length, s = streak(), b = Object.keys(st.badges).length;
    whereEl.innerHTML = '<b>' + n + '</b>&nbsp;pages · streak&nbsp;<b>' + s + '</b>d';
    cnt.badges.textContent = b + '/' + BADGES.length;
    if (st.hunt) {
      cnt.hunt.textContent = st.hunt.found.length + '/' + st.hunt.n;
      cnt.hunt.classList.toggle('done', st.hunt.found.length >= st.hunt.n);
      titles.hunt.setAttribute('aria-label', 'Pattern hunt, ' + st.hunt.found.length + ' of ' + st.hunt.n + ' found');
    }
    titles.badges.setAttribute('aria-label', 'Badges and streak, ' + b + ' of ' + BADGES.length + ' badges');
  }
  var open = null;
  function toggle(id, force) {
    var willOpen = force != null ? force : open !== id;
    if (open && panels[open]) { panels[open].hidden = true; titles[open].setAttribute('aria-expanded', 'false'); }
    open = null;
    if (!willOpen) return;
    open = id;
    var p = panels[id];
    RENDER[id](p);
    p.hidden = false;
    titles[id].setAttribute('aria-expanded', 'true');
    if (innerWidth > 600) {
      var r = titles[id].getBoundingClientRect(), w = p.offsetWidth;
      p.style.left = Math.max(8, Math.min(r.left, innerWidth - w - 8)) + 'px';
      p.style.top = (hud.getBoundingClientRect().bottom + 4) + 'px';
    } else { p.style.left = ''; p.style.top = (hud.getBoundingClientRect().bottom + 4) + 'px'; }
  }
  doc.addEventListener('click', function () { if (open) toggle(open, false); });
  doc.addEventListener('keydown', function (e) {
    if (e.key === 'Escape' && open) { var t = titles[open]; toggle(open, false); t.focus(); return; }
    if (hud && hud.contains(doc.activeElement) && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) {
      var items = [].slice.call(hud.querySelectorAll('a,button')), i = items.indexOf(doc.activeElement);
      if (i >= 0) { e.preventDefault(); items[(i + (e.key === 'ArrowRight' ? 1 : items.length - 1)) % items.length].focus(); }
      return;
    }
    if (e.key === 'r' && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && !typing(e.target)) { e.preventDefault(); randomJump(); }
  });
  function typing(t) { return t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)); }
  function loading(p) { p.textContent = ''; p.appendChild(el('p', { cls: 'pl-note', text: 'Loading the build digest…' })); }
  function failed(p) { p.textContent = ''; p.appendChild(el('p', { cls: 'pl-note', text: 'The build digest (theme/play-index.json) could not be loaded here, so this panel is empty. The pages themselves are complete.' })); }

  /* ---------- random jump ---------- */
  function randomJump() {
    index().then(function (d) {
      var f = d.files[Math.floor(Math.random() * d.files.length)];
      st.randoms++; save(); checkBadges();
      location.href = fileHref(d, f);
    }, function () { toast('The random jump needs the build digest, which did not load.'); });
  }

  /* ---------- code of the day ---------- */
  function cotd(d) { return d.files[fnv('explore-code-of-the-day:' + today()) % d.files.length]; }
  function roleChip(d, f) {
    var r = d.roles[f[6]];
    if (!r) return null;
    var c = el('span', { cls: 'badge r-' + r[0], text: r[0] });
    return c;
  }
  var RENDER = {
    today: function (p) {
      loading(p);
      index().then(function (d) {
        var f = cotd(d), t = d.topics[d.secTopic[f[1]]];
        p.textContent = '';
        p.appendChild(el('h2', { text: 'Code of the day · ' + today() + ' UTC' }));
        p.appendChild(el('p', { cls: 'pl-big', text: f[8] || ('File ' + f[0]) }));
        p.appendChild(el('p', null, [roleChip(d, f), ' ' + (f[9] || '') + ' · ' + (d.langs[f[7]] || '') + ' · section ' + f[1] + (t ? ' · ' + t[1] : '')]));
        p.appendChild(el('div', { cls: 'pl-row' }, [
          el('a', { cls: 'pl-act', href: fileHref(d, f), onclick: function () { st.cotd = today(); save(); award('daily', true); } }, ['▶' + T + ' Open the code of the day']),
          el('button', { type: 'button', onclick: function () { toggle('today', false); randomJump(); } }, ['⚄' + T + ' Random file'])
        ]));
        p.appendChild(el('p', { cls: 'pl-note', text: 'The same file for everyone today; it changes at midnight UTC. Press r on any page for a random file.' }));
      }, function () { failed(p); });
    },
    hunt: function (p) {
      loading(p);
      index().then(function (d) {
        ensureHunt(d);
        var h = st.hunt, files = d.byPat[h.pi] || [], found = {};
        h.found.forEach(function (id) { found[id] = 1; });
        p.textContent = '';
        p.appendChild(el('h2', { text: 'Pattern hunt' }));
        p.appendChild(el('p', { cls: 'pl-big' }, ['Find all ' + h.n + ' files sharing the pattern ', el('code', { text: d.patterns[h.pi] })]));
        var m = el('div', { cls: 'pl-meter' }, [el('i', { style: 'width:' + Math.round(100 * h.found.length / h.n) + '%' })]);
        p.appendChild(m);
        p.appendChild(el('p', { cls: 'pl-note', text: h.found.length + ' of ' + h.n + ' found. A file counts as found when you scroll to it on its section page.' }));
        var ul = el('ul');
        files.forEach(function (f) {
          if (found[f[0]]) ul.appendChild(el('li', null, [el('a', { href: fileHref(d, f) }, [el('span', { cls: 'pl-ok', text: '✓' }), f[8] + ' (' + f[9] + ')'])]));
        });
        var left = files.filter(function (f) { return !found[f[0]]; });
        if (left.length) {
          var repos = {};
          left.forEach(function (f) { repos[f[9]] = (repos[f[9]] || 0) + 1; });
          ul.appendChild(el('li', null, [el('span', { cls: 'pl-todo', text: '○ ' + left.length + ' still hidden, in: ' + Object.keys(repos).map(function (r) { return r + ' (' + repos[r] + ')'; }).join(', ') })]));
        } else {
          ul.appendChild(el('li', null, [el('span', { cls: 'pl-ok', text: '★ Hunt complete' })]));
        }
        p.appendChild(ul);
        var hint = el('div', { cls: 'pl-row' });
        var hb = el('button', { type: 'button', 'aria-expanded': 'false', onclick: function () {
          hb.setAttribute('aria-expanded', 'true');
          var s = left[0] || files[0];
          hb.replaceWith(el('a', { cls: 'pl-act', href: root + (d.secUrl[s[1]] || '') }, ['Clue: section ' + s[1] + ' →']));
        } }, ['Show a clue']);
        hint.appendChild(hb);
        hint.appendChild(el('button', { type: 'button', onclick: function () { newHunt(d, true); RENDER.hunt(p); } }, ['↻ New hunt']));
        p.appendChild(hint);
      }, function () { failed(p); });
    },
    badges: function (p) {
      p.textContent = '';
      p.appendChild(el('h2', { text: 'Badges' }));
      var g = el('div', { cls: 'pl-badges' });
      BADGES.forEach(function (b) {
        var got = !!st.badges[b[0]];
        g.appendChild(el('div', { cls: 'pl-badge' + (got ? ' got' : ''), title: b[3] + (got ? ' (earned ' + st.badges[b[0]] + ')' : '') },
          [el('b', { 'aria-hidden': 'true', text: b[1] }), b[2], el('br'), el('span', { cls: 'pl-note', text: got ? 'earned' : b[3] })]));
      });
      p.appendChild(g);
      p.appendChild(el('div', { cls: 'pl-gm-sep' }));
      p.appendChild(el('p', { cls: 'pl-note', text: Object.keys(st.visited).length + ' pages visited · topics ' + count('topics/') + '/9 · journeys ' + count('journeys/') + '/4 · streak ' + streak() + ' day(s) · ' + st.randoms + ' random jumps' }));
      var snd = el('button', { type: 'button', 'aria-pressed': String(!!st.sound), onclick: function () {
        st.sound = !st.sound; save(); snd.setAttribute('aria-pressed', String(st.sound)); snd.lastChild.textContent = st.sound ? ' Sound on' : ' Sound off'; chime();
      } }, [el('span', { 'aria-hidden': 'true', text: '♪' }), st.sound ? ' Sound on' : ' Sound off']);
      var reset = el('button', { type: 'button', onclick: function () {
        if (!window.confirm('Clear your Explore Code progress on this device?')) return;
        try { Object.keys(localStorage).forEach(function (k) { if (k.indexOf(P) === 0) localStorage.removeItem(k); }); } catch (e) { /* ignore */ }
        st = { visited: {}, days: [], badges: {}, randoms: 0, hunt: null, cotd: '', sound: false, langs: {} }; save(); refreshHud(); RENDER.badges(p);
      } }, ['Reset progress']);
      p.appendChild(el('div', { cls: 'pl-row' }, [snd, reset]));
      p.appendChild(el('p', { cls: 'pl-note', text: 'Progress stays in this browser only (localStorage). Nothing is sent anywhere.' }));
    }
  };

  /* ---------- pattern hunt ---------- */
  function newHunt(d, random) {
    if (!d.hunts.length) return;
    var k = random ? Math.floor(Math.random() * d.hunts.length) : fnv('explore-hunt:' + today()) % d.hunts.length;
    var pi = d.hunts[k];
    st.hunt = { pi: pi, name: d.patterns[pi], n: (d.byPat[pi] || []).length, found: [], since: today() };
    save(); refreshHud();
  }
  function ensureHunt(d) {
    var h = st.hunt;
    if (!h || d.patterns[h.pi] !== h.name || (d.byPat[h.pi] || []).length !== h.n) newHunt(d, false);
  }

  /* ---------- page enhancements (DOM moves and additions only; built text stays) ---------- */
  function aboutFold() {
    var header = doc.querySelector('body > header');
    if (!header) return;
    var ks = [].slice.call(header.querySelectorAll(':scope > p.k'));
    var first = ks.filter(function (p) { return /^Cut \d{4}-/.test(p.textContent.trim()); })[0];
    if (!first) return;
    var det = el('details', { cls: 'pl-about' }, [el('summary', { text: 'About this build' })]);
    first.parentNode.insertBefore(det, first);
    var n = first;
    while (n && n.matches && n.matches('p.k')) { var nx = n.nextElementSibling; det.appendChild(n); n = nx; }
  }
  function cards(d) {
    if (!/^(index\.html)?$/.test(rel)) return;
    [].slice.call(doc.querySelectorAll('main > h2')).forEach(function (h) {
      var t = h.textContent.trim(), ul = h.nextElementSibling;
      while (ul && ul.tagName !== 'UL' && ul.tagName !== 'H2') ul = ul.nextElementSibling;
      if (!ul || ul.tagName !== 'UL') return;
      if (t !== 'Start with a topic' && t !== 'Core production engines') return;
      ul.classList.add('pl-cards');
      [].slice.call(ul.children).forEach(function (li) {
        var a = li.querySelector('a'); if (!a) return;
        var href = a.getAttribute('href') || '';
        if (st.visited[href]) li.appendChild(el('span', { cls: 'pl-visited', text: '✓ visited' }));
        var m = /^topics\/([^.]+)\.html$/.exec(href);
        if (!m || !d) return;
        var tp = d.topics.filter(function (x) { return x[0] === m[1]; })[0];
        if (!tp) return;
        var tot = tp[3].reduce(function (a2, b) { return a2 + b; }, 0);
        if (!tot) return;
        var strip = el('span', { cls: 'pl-strip', 'aria-hidden': 'true' });
        tp[3].forEach(function (c, i) {
          if (!c) return;
          var r = d.roles[i];
          strip.appendChild(el('i', { style: 'width:' + (100 * c / tot).toFixed(2) + '%;background:' + r[2], title: r[1] + ': ' + c + ' files' }));
        });
        li.appendChild(strip);
      });
    });
  }
  function hostPath(u) { try { var x = new URL(u); return x.host + (x.pathname.length > 1 ? x.pathname : ''); } catch (e) { return u; } }
  function sectionPage(d, num) {
    var files = d.bySec[num] || [];
    var main = doc.querySelector('main');
    if (!main) return;
    if (d.byId && files.length) {
      var f0 = cotd(d);
      if (f0[1] === num) { st.cotd = today(); save(); award('daily'); }
    }
    files.forEach(function (f) { if (d.langs[f[7]]) st.langs[d.langs[f[7]]] = 1; });
    save();
    // big live button: the first published page among this section's files
    var live = files.filter(function (f) { return f[5] >= 0; })[0];
    if (live) {
      var u = d.urls[live[5]];
      main.insertBefore(el('a', { cls: 'pl-live', href: u, target: '_blank', rel: 'noopener', onclick: function () { award('live'); } },
        [el('span', { 'aria-hidden': 'true', text: '▶' + T }), 'Open the live tool', el('small', { text: hostPath(u) })]), main.firstChild);
    }
    var crs = files.filter(function (f) { return f[4]; })[0];
    if (crs) {
      flyEl = el('a', { cls: 'pl-btn pl-fly', 'data-pl-fly': '', 'data-file': String(crs[0]), href: root + 'pilot/?file=' + crs[0],
        title: 'A file here names a coordinate system (build data contracts)', 'aria-label': 'Fly there', onclick: function () { award('fly'); } },
        [el('span', { cls: 'pl-ico', 'aria-hidden': 'true', text: '✈' + T }), el('span', { cls: 'pl-label', text: 'Fly there' })]);
      hud.insertBefore(flyEl, whereEl);
    }
    var h = st.hunt, targets = [];
    files.forEach(function (f) {
      var sec = doc.getElementById('f' + f[2]);
      if (!sec) return;
      var chips = [];
      if (f[5] >= 0) chips.push(el('a', { cls: 'pl-chip live', href: d.urls[f[5]], target: '_blank', rel: 'noopener', onclick: function () { award('live'); } }, ['▶' + T + ' Open live']));
      if (f[4]) chips.push(el('a', { cls: 'pl-chip fly', href: root + 'pilot/?file=' + f[0], 'data-pl-fly': '', 'data-file': String(f[0]), onclick: function () { award('fly'); } }, ['✈' + T + ' Fly there']));
      if (h && f[3] === h.pi) {
        var got = h.found.indexOf(f[0]) >= 0;
        var c = el('span', { cls: 'pl-chip hunt', text: (got ? '✓ Collected: ' : '⌘ Hunt target: ') + d.patterns[f[3]] });
        chips.push(c);
        sec.classList.add('pl-target');
        if (!got) targets.push([sec, f, c]);
      }
      if (chips.length) {
        var h2 = sec.querySelector('h2');
        var box = el('div', { cls: 'pl-chips' }, chips);
        if (h2 && h2.nextSibling) sec.insertBefore(box, h2.nextSibling); else sec.appendChild(box);
      }
    });
    if (targets.length) watchTargets(d, targets);
  }
  function collect(d, sec, f, chip) {
    var h = st.hunt;
    if (!h || h.found.indexOf(f[0]) >= 0) return;
    h.found.push(f[0]); save();
    chip.textContent = '✓ Collected: ' + d.patterns[f[3]];
    sec.classList.remove('pl-flash'); void sec.offsetWidth; sec.classList.add('pl-flash');
    refreshHud();
    if (h.found.length >= h.n) { toast('Hunt complete: all <b>' + h.n + '</b> files with <b>' + esc(h.name) + '</b>'); award('hunt'); }
    else { toast('Found <b>' + h.found.length + ' of ' + h.n + '</b> · pattern <b>' + esc(h.name) + '</b>'); chime(); }
  }
  function watchTargets(d, targets) {
    if (!('IntersectionObserver' in window)) { targets.forEach(function (t) { collect(d, t[0], t[1], t[2]); }); return; }
    var io = new IntersectionObserver(function (es) {
      es.forEach(function (e) {
        if (!e.isIntersecting) return;
        io.unobserve(e.target);
        var t = targets.filter(function (x) { return x[0] === e.target; })[0];
        if (t) collect(d, t[0], t[1], t[2]);
      });
    }, { threshold: 0, rootMargin: '-25% 0px -25% 0px' });
    targets.forEach(function (t) { io.observe(t[0]); });
  }

  /* ---------- start ---------- */
  function start() {
    buildHud();
    aboutFold();
    checkBadges();
    var m = /^s\/(\d+)\.html$/.exec(rel);
    index().then(function (d) {
      ensureHunt(d); refreshHud();
      cards(d);
      if (m) sectionPage(d, parseInt(m[1], 10));
    }, function () { cards(null); });
  }
  if (doc.readyState === 'loading') doc.addEventListener('DOMContentLoaded', start); else start();
})();

Seethrough

A style sheet in the theme folder of Cosmic.

rendercosmic / tools/explore/theme/seethrough.css · lines 1–63 of 63 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
What it achieves
The See Through mode for Explore Code (PERISCOPE-64).
Why it matters
No other file in the estate was found to import it.
Application
cosmic · tools/explore/theme · style sheet
Uses
none found
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
cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/theme/seethrough.css:1-63 · blob e6ee78ee67ceb3065e3b406b4b14829e294acd78 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/* seethrough.css: the See Through mode for Explore Code (PERISCOPE-64).
   Look lifted from See Through's own plain.css (kuiper-belt/see-through/202611020012): white words on black,
   1px white borders, square corners, system-ui, underline for the chosen button, the joystick ring.
   Everything is namespaced .st- and every node carries data-st, so the page's own text is untouched. */
.st-btn, .st-fab, .st-x, .st-tab, .st-pick {
  font: 400 16px/1.2 system-ui, sans-serif; font-variant-numeric: tabular-nums;
  color: #fff; background: #000; border: 1px solid #fff; border-radius: 0;
  padding: 8px 12px; min-height: 44px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; letter-spacing: normal; text-shadow: none;
}
.st-btn:hover, .st-fab:hover, .st-x:hover, .st-tab:hover, .st-pick:hover,
.st-btn[aria-pressed="true"], .st-fab[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 6px; }
.st-btn:focus-visible, .st-fab:focus-visible, .st-x:focus-visible,
.st-tab:focus-visible, .st-pick:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.st-ring { width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 50%; box-sizing: border-box; flex: none;
  background: radial-gradient(circle, currentColor 0 2px, transparent 3px); }

/* in the HUD or IDE mode group the button takes that group's own look, with See Through's ring in front */
.st-mode:not(.st-fab) { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.st-mode:not(.st-fab) .st-ring { width: 11px; height: 11px; border-width: 1.5px; }

/* the row under a file's heading when the IDE layer is not there */
.st-row { margin: 6px 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.st-row .st-more { font: 400 13px/1.3 system-ui, sans-serif; color: inherit; opacity: .8; }

/* the floating mode button: See Through's joystick ring, bottom right, under the HUD's panels */
.st-fab { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 35; background: rgba(0,0,0,.85); box-shadow: 0 0 0 1px #000; }

/* overlay */
html.st-open, html.st-open body { overflow: hidden !important; }
.st-overlay { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column;
  font: 400 14px/1.3 system-ui, sans-serif; }
.st-hud { display: flex; align-items: center; gap: 8px; padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  border-bottom: 1px solid #fff; background: #000; flex: none; min-height: 48px; box-sizing: border-box; }
.st-hud .st-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-hud .st-name { font-size: 18px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-hud .st-where { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-hud .st-where code { font: inherit; }
.st-frame { flex: 1 1 auto; position: relative; background: #000; }
.st-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.st-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: min(90vw, 520px);
  border: 1px solid #fff; background: #000; padding: 14px 16px; text-align: center; font-size: 16px; }
.st-note[hidden] { display: none; }
.st-note p { margin: 0 0 10px; }

/* chooser: one button per substation, with the line it comes from */
.st-list { flex: 1 1 auto; overflow: auto; padding: 12px max(12px, env(safe-area-inset-left)); }
.st-list h3 { font: 400 13px/1.3 system-ui, sans-serif; text-transform: uppercase; margin: 14px 0 6px; opacity: .85; overflow-wrap: anywhere; }
.st-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.st-pick { width: 100%; text-align: left; flex-direction: column; align-items: flex-start; }
.st-pick b { font-weight: 400; font-size: 18px; text-transform: uppercase; }
.st-pick code { font: 400 12px/1.35 ui-monospace, Menlo, Consolas, monospace; opacity: .85; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .st-hud { flex-wrap: wrap; }
  .st-hud .st-title { flex-basis: 100%; order: -1; }
  .st-hud .st-name { font-size: 16px; }
  .st-hud .st-where { white-space: normal; overflow-wrap: anywhere; }
  .st-btn, .st-fab, .st-x, .st-tab { font-size: 15px; padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) { .st-overlay * { transition: none !important; } }
@media print { .st-fab, .st-row, .st-overlay, [data-st] { display: none !important; } }