/* nes-state-diff.css: styles for R-Z5.5.Y-STATE-DIFF-2026-05-16.
 *
 * Scopes the .va-cog-nes-statediff-* token namespace used by the wk-6
 * NES debugger's "Diff slots…" panel (lives inside the save row,
 * collapsible). Separate file (NOT portal.css, NOT nes-debugger.css,
 * NOT nes-save-state.css) per the scoped-CSS-file pattern; render.py
 * copy_theme() auto-discovers it under courses/_pipeline/theme/.
 *
 * Mobile-first per Z5.1 L1: 5 filter chips + 2 select-pickers stay
 * within a 320px viewport without horizontal scroll; diff tables wrap
 * cleanly because the byte rows are kept at 3 columns max.
 *
 * Tap-target floors:
 *   - filter chips (All / CPU regs / Work RAM / Palette / OAM) carry
 *     the same 44x44 floor selects + control buttons use elsewhere.
 *   - select-pickers inherit the system 44x44 form-control floor.
 *
 * License: (c) 2026 Virtus Cyber Academy.
 */

/* ============================================================
 * Top-level diff panel (sits inside .va-cog-nes-save-row).
 * Hidden by default; the Diff button toggles the [hidden] attr.
 * ============================================================ */
.va-cog-nes-statediff-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.7rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg-card, #111);
  border: 1px solid var(--border, #333);
  border-radius: 5px;
}

.va-cog-nes-statediff-panel[hidden] { display: none; }

/* ============================================================
 * Header: slot pickers + scope filter chips.
 * ============================================================ */
.va-cog-nes-statediff-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.va-cog-nes-statediff-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.va-cog-nes-statediff-picker-label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold, #fbbf24);
}

.va-cog-nes-statediff-picker {
  min-height: 44px;
  padding: 0.3rem 0.5rem;
  background: var(--bg-card-sunken, #0c0c0c);
  color: var(--fg, #e2e8f0);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}

.va-cog-nes-statediff-picker:focus-visible {
  outline: 2px solid var(--green, #4ade80);
  outline-offset: 1px;
}

.va-cog-nes-statediff-picker-sep {
  font-size: 1.2rem;
  color: var(--fg-muted, #94a3b8);
  padding: 0 0.2rem;
}

.va-cog-nes-statediff-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.va-cog-nes-statediff-chip {
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem 0.7rem;
  background: var(--bg-card-sunken, #0c0c0c);
  color: var(--fg, #e2e8f0);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.va-cog-nes-statediff-chip:hover {
  border-color: var(--green, #4ade80);
}

.va-cog-nes-statediff-chip[data-selected="true"] {
  border-color: var(--green, #4ade80);
  background: rgba(74, 222, 128, 0.12);
  color: var(--green, #4ade80);
}

/* ============================================================
 * Banner (cross-ROM refusal, empty-slot guidance, no-diff message).
 * data-banner-kind switches the accent color (error = amber, info = green).
 * ============================================================ */
.va-cog-nes-statediff-banner {
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--bg-card-sunken, #0c0c0c);
  border: 1px solid var(--border, #333);
  color: var(--fg, #e2e8f0);
}

.va-cog-nes-statediff-banner[hidden] { display: none; }

.va-cog-nes-statediff-banner[data-banner-kind="error"] {
  border-color: var(--amber, #f59e0b);
  color: var(--amber, #f59e0b);
}

.va-cog-nes-statediff-banner[data-banner-kind="info"] {
  border-color: var(--green, #4ade80);
  color: var(--green, #4ade80);
}

/* ============================================================
 * Body: summary line + per-section blocks.
 * ============================================================ */
.va-cog-nes-statediff-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.va-cog-nes-statediff-summary {
  font-size: 0.85rem;
  color: var(--fg-muted, #94a3b8);
  font-family: var(--mono, ui-monospace, monospace);
}

.va-cog-nes-statediff-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-card-sunken, #0c0c0c);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
}

.va-cog-nes-statediff-section-head {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold, #fbbf24);
}

.va-cog-nes-statediff-none {
  font-size: 0.8rem;
  color: var(--fg-muted, #94a3b8);
  font-style: italic;
}

/* ============================================================
 * Diff tables (CPU / bytes / OAM share base styling).
 * ============================================================ */
.va-cog-nes-statediff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.va-cog-nes-statediff-table th,
.va-cog-nes-statediff-table td {
  padding: 0.3rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.va-cog-nes-statediff-table thead th {
  font-weight: 700;
  color: var(--fg-muted, #94a3b8);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.va-cog-nes-statediff-table tbody th {
  font-weight: 700;
  color: var(--fg, #e2e8f0);
  white-space: nowrap;
}

.va-cog-nes-statediff-table code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.85rem;
}

/* CPU table: dim rows where the register is unchanged so the eye
 * tracks the row that actually moved. */
.va-cog-nes-statediff-cpu tbody tr[data-diff-differ="false"] {
  color: var(--fg-muted, #94a3b8);
}

.va-cog-nes-statediff-cpu tbody tr[data-diff-differ="true"] td {
  color: var(--green, #4ade80);
}

/* Flag-bit pills inside the Flags row. */
.va-cog-nes-statediff-flags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.va-cog-nes-statediff-flag-bit {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--fg-muted, #94a3b8);
}

.va-cog-nes-statediff-flag-bit[data-flag-differ="true"] {
  color: var(--green, #4ade80);
  background: rgba(74, 222, 128, 0.12);
  font-weight: 700;
}

/* Byte tables (work RAM + palette): make the slot-B value (the
 * "after" side) pop so the eye sees what changed. */
.va-cog-nes-statediff-bytes tbody td:last-child code {
  color: var(--green, #4ade80);
  font-weight: 700;
}

.va-cog-nes-statediff-bytes tbody td:first-of-type code {
  color: var(--fg-muted, #94a3b8);
}

/* Work-RAM table can grow tall; cap its height so the panel does
 * not push the rest of the page out of view. */
.va-cog-nes-statediff-section[data-diff-section="workRam"] .va-cog-nes-statediff-table {
  display: block;
  max-height: 280px;
  overflow-y: auto;
}

.va-cog-nes-statediff-section[data-diff-section="workRam"] .va-cog-nes-statediff-table thead,
.va-cog-nes-statediff-section[data-diff-section="workRam"] .va-cog-nes-statediff-table tbody {
  display: table;
  width: 100%;
  table-layout: fixed;
}

/* OAM table: same growth cap + the per-slot 4-byte tuple stays on
 * one line via the inherited <code> rules. */
.va-cog-nes-statediff-section[data-diff-section="oam"] .va-cog-nes-statediff-table {
  display: block;
  max-height: 280px;
  overflow-y: auto;
}

.va-cog-nes-statediff-section[data-diff-section="oam"] .va-cog-nes-statediff-table thead,
.va-cog-nes-statediff-section[data-diff-section="oam"] .va-cog-nes-statediff-table tbody {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.va-cog-nes-statediff-oam tbody td code {
  color: var(--green, #4ade80);
}

.va-cog-nes-statediff-oam tbody td:first-of-type code {
  color: var(--fg-muted, #94a3b8);
}

/* ============================================================
 * Mobile breakpoint: stack the picker row into a single column,
 * narrow the chip text, and keep the diff tables from forcing
 * horizontal scroll. The byte rows are intrinsically narrow
 * (3 short columns) so they fit a 320px viewport.
 * ============================================================ */
@media (max-width: 480px) {
  .va-cog-nes-statediff-picker-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .va-cog-nes-statediff-picker-sep { display: none; }
  .va-cog-nes-statediff-chip { padding: 0.4rem 0.55rem; font-size: 0.78rem; }
  .va-cog-nes-statediff-table { font-size: 0.78rem; }
  .va-cog-nes-statediff-table th,
  .va-cog-nes-statediff-table td { padding: 0.25rem 0.35rem; }
  .va-cog-nes-statediff-section[data-diff-section="workRam"] .va-cog-nes-statediff-table,
  .va-cog-nes-statediff-section[data-diff-section="oam"]     .va-cog-nes-statediff-table {
    max-height: 220px;
  }
}
