/* neocognitron - page layout. Colour and type come ONLY from tokens.css. */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--c-bg); color: var(--c-ink); font-family: var(--font-body); font-size: var(--fs-1); line-height: var(--lh-body); }
a { color: var(--c-seed); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: var(--lh-tight); margin: 0; }
h1 { font-size: var(--fs-5); }
h2 { font-size: var(--fs-3); margin-bottom: var(--s-2); }
h3 { font-size: var(--fs-2); color: var(--c-ink-dim); margin-bottom: var(--s-1); }
p { margin: 0 0 var(--s-2); max-width: 70ch; color: var(--c-ink-dim); }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--fs-0); }
header { padding: var(--s-6) var(--s-4) var(--s-3); border-bottom: 1px solid var(--c-bg-3); }
header .kicker { color: var(--c-ink-mute); letter-spacing: 0.08em; text-transform: uppercase; font-size: var(--fs-0); margin-bottom: var(--s-1); }
main { padding: 0 var(--s-4) var(--s-12); }
section.panel { padding: var(--s-5) 0; border-bottom: 1px solid var(--c-bg-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: var(--s-2); }
.card { background: var(--c-bg-2); border: 1px solid var(--c-bg-3); border-radius: 6px; padding: var(--s-2); }
button, select, input[type=number] { font: inherit; font-size: var(--fs-0); color: var(--c-ink); background: var(--c-bg-3); border: 1px solid var(--c-ink-mute); border-radius: 4px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--c-seed); }
button.primary { background: var(--c-seed); color: var(--c-bg); border-color: var(--c-seed); }
button:disabled { opacity: 0.45; cursor: default; }
button.on { border-color: var(--c-life); color: var(--c-life); }
input[type=number] { width: 4.5em; }
.controls { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center; }
.digitbar button { min-width: 2.2em; }
.status { color: var(--c-ink-mute); font-size: var(--fs-0); min-height: 1.4em; }
.status b { color: var(--c-seed); font-weight: 500; }
/* retina */
#retina { image-rendering: pixelated; border: 1px solid var(--c-ink-mute); background: var(--c-bg); cursor: crosshair; touch-action: none; }
.retina-wrap { position: relative; display: inline-block; }
#retina-overlay { position: absolute; left: 0; top: 0; pointer-events: none; image-rendering: pixelated; }
/* progress */
.progress { height: 6px; background: var(--c-bg-3); border-radius: 3px; overflow: hidden; width: 100%; }
.progress > i { display: block; height: 100%; width: 0; background: var(--c-life); transition: width var(--dur-fast) var(--ease-out); }
/* inspector */
.stage { margin-bottom: var(--s-3); }
.stage h3 { display: flex; gap: var(--s-2); align-items: baseline; }
.stage h3 small { color: var(--c-ink-mute); font-size: var(--fs-0); }
.planes { display: flex; flex-wrap: wrap; gap: 4px; }
.planes canvas { image-rendering: pixelated; border: 1px solid var(--c-bg-3); cursor: pointer; background: var(--c-bg); }
.planes canvas.sel { border-color: var(--c-seed); box-shadow: 0 0 0 1px var(--c-seed); }
.planes canvas.dead { opacity: 0.35; }
.legend { color: var(--c-ink-mute); font-size: var(--fs-0); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
#kernel-view canvas { image-rendering: pixelated; border: 1px solid var(--c-bg-3); }
#kernels canvas { image-rendering: pixelated; border: 1px solid var(--c-bg-3); }
/* measurement table */
table { border-collapse: collapse; font-size: var(--fs-0); }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--c-bg-3); text-align: right; }
th { color: var(--c-ink-mute); font-weight: 500; }
td:first-child, th:first-child { text-align: left; }
/* cortex */
#cortex-scatter, #cortex-decay, #cortex-pool, #cortex-graph { image-rendering: auto; background: var(--c-bg); border: 1px solid var(--c-bg-3); border-radius: 4px; }
.retinas canvas { image-rendering: pixelated; border: 1px solid var(--c-bg-3); cursor: pointer; }
.retinas canvas.sel { border-color: var(--c-seed); }
.chip { display: inline-block; padding: 1px 6px; border-radius: 3px; background: var(--c-bg-3); color: var(--c-ink-dim); font-size: var(--fs-0); margin: 0 4px 4px 0; }
.chip.on { background: var(--c-life); color: var(--c-bg); }
@media (max-width: 720px) {
  header, main { padding-left: var(--s-2); padding-right: var(--s-2); }
  h1 { font-size: var(--fs-4); }
  .row { gap: var(--s-2); }
}
/* canvases never widen the page: they scale down with their column on narrow viewports */
#sec-cortex canvas:not(.view3d), #retina, #retina-overlay, .retina-wrap { max-width: 100%; height: auto; }
.retina-wrap { display: block; width: 280px; max-width: 100%; }
#retina-overlay { width: 100%; height: 100%; }
/* the table keeps its natural width but stops claiming the whole row: its own status line (the
   digit -> plane map) is one long string and without a basis it measured ~900 px, which pushed the
   chart beside it onto a line of its own. */
#measure-table { flex: 0 1 420px; min-width: 0; max-width: 100%; overflow-x: auto; }
#measure-table .status, #output, .mono { overflow-wrap: anywhere; }

/* the shift table as a picture, in the column that used to sit empty beside it. min-width:0 is what
   lets a flex item shrink below its content width - without it the canvas would push the row wide. */
.chart-col { flex: 1 1 300px; min-width: 0; max-width: 560px; }
#invariance-chart { display: block; width: 100%; max-width: 100%; height: auto;
  background: var(--c-bg); border: 1px solid var(--c-bg-3); border-radius: 6px; }

/* WebGL views */
.view3d { display: block; width: 100%; height: min(66vh, 560px); background: var(--c-bg); border: 1px solid var(--c-bg-3);
  border-radius: 6px; touch-action: none; cursor: grab; margin: var(--s-1) 0; }
.view3d:active { cursor: grabbing; }
.view3d.short { height: min(40vh, 320px); }
.view3d.missing { display: grid; place-items: center; color: var(--c-ink-mute); }
@media (max-width: 640px) { .view3d { height: 52vh; } .view3d.short { height: 30vh; } }

/* ===== shared one-cortex site nav (this page is a tab of the cortexclaw site) ===== */
.site-nav {
  position: sticky; top: 0; z-index: 9999;
  display: flex; align-items: center; flex-wrap: wrap; gap: 0;
  min-height: 36px;
  background: var(--c-bg-2);
  border-bottom: 1px solid var(--c-bg-3);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
}
.site-nav-brand { padding: 0 16px; color: var(--c-ink-mute); white-space: nowrap; border-right: 1px solid var(--c-bg-3); align-self: stretch; display: flex; align-items: center; }
.site-nav a { color: var(--c-ink-dim); text-decoration: none; padding: 10px 14px; border-right: 1px solid var(--c-bg-3); transition: color .15s, background .15s; }
.site-nav a:hover { color: var(--c-seed); background: rgba(240,196,107,0.06); }
.site-nav a.active { color: var(--c-seed); background: rgba(240,196,107,0.10); }

/* ===== live data strip ===== */
.livebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: 10px var(--s-4); background: var(--c-bg-2); border-bottom: 1px solid var(--c-bg-3); font-size: var(--fs-0); color: var(--c-ink-mute); }
.livebar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-life); box-shadow: 0 0 8px var(--c-life); flex: none; }
.livebar.stale .dot { background: var(--c-seed); box-shadow: 0 0 8px var(--c-seed); animation: livepulse 1.4s ease-in-out infinite; }
.livebar.err .dot { background: var(--c-blood); box-shadow: 0 0 8px var(--c-blood); }
@keyframes livepulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.livebar b { color: var(--c-ink); font-weight: 500; }
.livebar .grow { flex: 1 1 auto; }
.livebar button { font-size: var(--fs-0); padding: 4px 10px; }
#live-new { display: none; }
.livebar.stale #live-new { display: inline-block; }

/* community sizes - the 34 communities as ranked proportional bars (was a stack of 34 text chips
   inside the right card, which read as a list and left the left column of section 4 empty) */
.commbars { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 3px var(--s-3); margin-top: var(--s-1); }
.commbar { display: grid; grid-template-columns: 1.8em 1fr 3.4em; align-items: center; gap: 6px; font-size: var(--fs-0); color: var(--c-ink-mute); }
.commbar .track { position: relative; height: 16px; background: var(--c-bg-3); border-radius: 2px; overflow: hidden; }
.commbar .fill { position: absolute; left: 0; top: 0; bottom: 0; opacity: 0.5; }
.commbar .lab { position: absolute; left: 6px; right: 4px; top: 0; line-height: 16px; color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.commbar .n { text-align: right; font-variant-numeric: tabular-nums; }
