// Codex panel — click any chakra -> its codex (recipes/theses/formulas) opens in
// the side panel. Click a kernel dot -> that kernel's docs + recent live activity.
// Top-right "All Codices" -> unified search across all 5 chakras' codices.
// Doctrine v11 LOCKED. ZERO BANDAID — links are real; live activity shows honest state.
import { CHAKRAS, UNIVERSAL_KERNELS } from './config.js';
import { kernelEntry, lastHeartbeats } from './heartbeats.js';
let panel, body, closeBtn;
export function initCodex(){
panel = document.getElementById('panel');
body = document.getElementById('panelBody');
closeBtn = document.getElementById('panelClose');
closeBtn.onclick = closePanel;
document.getElementById('allCodices').onclick = openAllCodices;
addEventListener('keydown', e => { if (e.key==='Escape') closePanel(); });
}
function openPanel(){ panel.classList.add('open'); }
function closePanel(){ panel.classList.remove('open'); }
function chakraById(id){ return CHAKRAS.find(c => c.id===id); }
// ---------- chakra codex ----------
export function openChakraCodex(id){
const c = chakraById(id); if (!c) return;
const col = '#'+c.color.toString(16).padStart(6,'0');
const kernels = UNIVERSAL_KERNELS.map(k => `${k.name}`).join('')
+ c.vertical.map(k => `${k.name}`).join('');
body.innerHTML = `
Each kernel is a perpetual OODA loop (observe→decide→act→sign) rooted in a hash-linked, DSSE-signed codex. The Ouroboros loop threads SIGN→GATE→CHAIN→MEMORY→REPLAY through every chakra. Doctrine v11 LOCKED (749/14/163).