/* WASM Explorer — page layout + styles for DOM built by wasm_decoder.js (tokens only). */
.wx-loading { display: grid; gap: var(--s-3); }
.wx-progress { display: grid; gap: 6px; }

/* Module header */
.wx-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
}
.wx-head__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-width: 0; flex: 1 1 260px; }
.wx-head__title .panel__title { min-width: 0; max-width: 100%; }
.wx-file { display: block; max-width: 100%; font-family: var(--mono); font-size: 0.92rem; }
.wx-head__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.wx-status { max-width: 100%; min-width: 0; }
.wx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.wx-dot.ok { background: var(--success); }
.wx-dot.bad { background: var(--danger); }

/* Summary key/values */
.wx-kvs {
  margin: 0; padding: var(--s-4);
  display: grid; gap: var(--s-2);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  grid-auto-flow: dense;
}
.wx-kv--wide { grid-column: 1 / -1; }
@media (min-width: 720px) { .wx-kv--wide { grid-column: span 3; } }
.wx-kv { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.wx-kv dt { font-size: 0.75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; }
.wx-kv dd { margin: 2px 0 0; font-family: var(--mono); font-size: 0.88rem; color: var(--text); word-break: break-word; }

/* Tabs bar */
.wx-tabs-wrap { padding: 0 var(--s-4); border-bottom: 1px solid var(--border); }
.wx-tabs-wrap .tabs { border-bottom: 0; }

/* List + viewer split */
.wx-split { display: grid; gap: var(--s-3); padding: var(--s-4); }
@media (min-width: 960px) {
  .wx-split { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: stretch; }
}
.wx-side { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.wx-list {
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  overflow: auto; max-height: 260px; min-height: 120px;
}
@media (min-width: 960px) { .wx-list { max-height: none; height: calc(70vh - 50px); } }

.wx-list .row {
  display: flex; width: 100%; gap: 10px; align-items: center; justify-content: space-between;
  min-height: 40px; padding: 6px 10px; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer;
  box-shadow: inset 3px 0 0 transparent; transition: background 0.12s var(--ease);
}
.wx-list .row:first-child { border-top: 0; }
.wx-list .row:hover { background: var(--surface-2); }
.wx-list .row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.wx-list .row.active .name { color: var(--text); font-weight: 650; }
.wx-list .row--empty { justify-content: center; cursor: default; color: var(--text-3); font-size: 0.88rem; }
.wx-list .row--empty:hover { background: transparent; }
.wx-list .left { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.wx-list .tag {
  flex: 0 0 auto; font-family: var(--mono); font-size: 0.7rem; padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-text);
}
.wx-list .name { font-family: var(--mono); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wx-list .meta { flex: 0 0 auto; font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); }

/* Code viewer */
.wx-codebox {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  height: 60vh; min-height: 320px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--code-bg); color: var(--text);
  padding: var(--s-3); font-family: var(--mono); font-size: 0.82rem;
}
@media (min-width: 960px) { .wx-codebox { height: 70vh; } }
.wx-js-toggle { position: absolute; top: 8px; right: 8px; z-index: 2; }
#viewerContainer { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.viewer-pane { display: none; height: 100%; overflow: auto; white-space: pre; line-height: 1.55; tab-size: 2; }
.viewer-pane.active { display: block; }
.wx-empty { padding: var(--s-4); color: var(--text-3); white-space: normal; }

/* Interactive hexdump (virtualised rows) */
.hex-container { user-select: none; font-size: 0.75rem; line-height: normal; }
.hex-row { display: flex; gap: 16px; padding: 0 4px; height: 24px; align-items: center; width: max-content; min-width: 100%; border-bottom: 1px solid var(--border); }
.hex-row:hover { background: var(--surface-2); }
.hex-offset { color: var(--text-3); width: 70px; flex-shrink: 0; }
.hex-bytes { display: flex; gap: 6px; width: 380px; flex-shrink: 0; }
.hex-ascii { display: flex; gap: 1px; }
.byte, .ascii { cursor: pointer; padding: 1px; border-radius: 2px; transition: background 0.12s var(--ease); }
.byte:hover, .ascii:hover, .byte.highlighted, .ascii.highlighted { background: var(--accent-soft); }
.byte.selected, .ascii.selected { background: var(--accent); color: var(--on-accent); }

/* Call graph */
.graph-pane.active { display: flex; flex-direction: column; white-space: normal; }
.graph-controls, .graph-legend {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 10px; margin-bottom: 8px; border-radius: var(--r-sm); background: var(--surface-2);
  font-family: var(--font); font-size: 0.8rem; color: var(--text-3);
}
.graph-info { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
/* categorical node colours (match the SVG fills) */
.legend-dot--imp { background: #ffcf5c; }
.legend-dot--def { background: #7c5cff; }
.legend-dot--exp { background: #38d39f; }
.graph-svg-container { flex: 1; overflow: auto; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); padding: 10px; }
.graph-svg-container svg { display: block; max-width: none; height: auto; transition: transform 0.2s var(--ease); }
.graph-grid { stroke: var(--border); opacity: 0.5; }
.graph-node { cursor: pointer; }
.graph-label { fill: var(--text-2); }
.graph-label.is-hover { fill: var(--text); font-weight: 700; }
.graph-edge { transition: stroke 0.15s ease, stroke-width 0.15s ease; }

/* Opcode stats */
.stats-summary, .stats-categories {
  padding: 12px; border-radius: var(--r-sm); background: var(--surface-2);
  line-height: 1.6; white-space: normal; margin-bottom: 12px;
}
.stats-categories { margin: 12px 0 0; }
.stats-chart { padding: 10px 0; overflow-x: auto; }
.stats-label { fill: var(--text-2); }
.stats-count { fill: var(--text-3); }
