/* workbench.css — VirtusLang Workbench (R-WASM-3 Step 3 production UI).
 *
 * Palette B (per academy site brand):
 *   Background:    #0a0a0a (near-black)
 *   Foreground:    #d0d0d0 (warm grey)
 *   Accent green:  #4ade80 (active / success)
 *   Accent gold:   #fbbf24 (highlight / status)
 *   Accent red:    #ef4444 (error)
 *   Pane border:   #2a2a2a (subtle separator)
 *
 * Layout: 6-pane grid (1 input + 4 outputs + 1 log); flex-collapses
 * to tabs on narrow screens (mobile fallback per memo §4.4).
 */

:root {
  --bg:        #0a0a0a;
  --fg:        #d0d0d0;
  --green:     #4ade80;
  --gold:      #fbbf24;
  --red:       #ef4444;
  --pane-bd:   #2a2a2a;
  --pane-bg:   #131313;
  --code-bg:   #1a1a1a;
  --mono:      'Geist Mono', 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 1rem;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--pane-bd);
  padding-bottom: 0.5rem;
}

h1 { color: var(--gold); font-size: 1.3rem; margin: 0; }
h2 { color: var(--green); font-size: 1.0rem; margin: 0; }

#status {
  color: var(--gold);
  font-size: 0.9rem;
  font-family: var(--mono);
}
#status.ok   { color: var(--green); }
#status.fail { color: var(--red); }

.tabbar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid var(--pane-bd);
}
.tab {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--pane-bd);
  border-bottom: none;
  padding: 0.4rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  bottom: -1px;
}
.tab:hover { border-color: var(--green); color: var(--green); }
.tab.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--pane-bg);
  font-weight: 600;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar select,
.toolbar input[type=file],
.toolbar button {
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--green);
  padding: 0.4rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
}

.toolbar button.primary {
  background: var(--green);
  color: var(--bg);
  font-weight: 600;
}

.toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

.pane {
  background: var(--pane-bg);
  border: 1px solid var(--pane-bd);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  min-height: 16em;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.pane-header h2 { font-size: 0.85rem; }

.pane-header .actions {
  display: flex;
  gap: 0.3rem;
}

.pane-header button {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--pane-bd);
  padding: 0.15rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
}
.pane-header button:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green);
}
.pane-header button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pane textarea,
.pane pre {
  flex: 1;
  width: 100%;
  background: var(--code-bg);
  color: var(--fg);
  border: 0;
  padding: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.4;
  resize: vertical;
  overflow: auto;
  white-space: pre;
  min-height: 12em;
  max-height: 32em;
  margin: 0;
}

.pane textarea {
  outline: none;
}

#log-pane pre {
  white-space: pre-wrap;
  color: #a0a0a0;
}

.stage-status {
  font-size: 0.75rem;
  font-family: var(--mono);
}
.stage-status.ok   { color: var(--green); }
.stage-status.fail { color: var(--red); }

/* Mobile fallback: collapse to single column + tab-switch panes. */
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .pane { min-height: 14em; }
  .pane textarea, .pane pre { min-height: 10em; max-height: 18em; }
}

footer {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: #707070;
  border-top: 1px solid var(--pane-bd);
  padding-top: 0.5rem;
}

footer a { color: var(--green); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* === netlistsvg gate-level netlist pane (R-SILICON-VIZ-TIER-A) ============ */
#fpga-netlistsvg-pane { min-height: 16em; }
.netlistsvg-view {
  background: #f8f8f8;                  /* netlistsvg ships dark-stroke-on-light */
  border: 1px solid var(--pane-bd);
  border-radius: 4px;
  padding: 0.5rem;
  overflow: auto;                       /* native pan via scroll */
  min-height: 12em;
  max-height: 32em;
  resize: vertical;
}
.netlistsvg-view svg { display: block; }
.netlistsvg-placeholder, .netlistsvg-error {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #404040;
  margin: 0.5rem;
}
.netlistsvg-error { color: var(--red); background: #1a1a1a; padding: 0.5rem; border-radius: 4px; }
.netlistsvg-pedagogy {
  font-size: 0.8rem;
  color: #a0a0a0;
  margin: 0.6rem 0 0.2rem 0;
  line-height: 1.4;
}
.netlistsvg-pedagogy a { color: var(--gold); text-decoration: none; }
.netlistsvg-pedagogy a:hover { text-decoration: underline; }
#fpga-netlistsvg-budget { color: var(--green); font-family: var(--mono); }
#fpga-netlistsvg-summary { margin-right: 0.5rem; }
#fpga-netlistsvg-pane .actions button { font-family: var(--mono); }

@media (max-width: 720px) {
  .netlistsvg-view { max-height: 22em; }
}

/* === operate pane (R-DIGITALJS-OPERATE-PANE-2026-05) ===================== */
#fpga-operate-pane { min-height: 18em; }
#fpga-operate-pane .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
#fpga-operate-attribution {
  flex: 1 1 14rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.operate-host {
  background: #f8f8f8;
  border: 1px solid var(--pane-bd);
  border-radius: 4px;
  padding: 0.5rem;
  overflow: auto;
  min-height: 16em;
  max-height: 36em;
  resize: vertical;
  position: relative;
}
#fpga-operate-paper {
  min-height: 14em;
  min-width: 100%;
  /* DigitalJS sets explicit width on the joint paper; allow horizontal
   * pan via the host's overflow:auto. */
}
.operate-placeholder, .operate-error {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #404040;
  margin: 0.5rem;
}
.operate-error {
  color: var(--red);
  background: #1a1a1a;
  padding: 0.5rem;
  border-radius: 4px;
}
.operate-pedagogy {
  font-size: 0.8rem;
  color: #a0a0a0;
  margin: 0.6rem 0 0.2rem 0;
  line-height: 1.45;
}
.operate-pedagogy a { color: var(--gold); text-decoration: none; }
.operate-pedagogy a:hover { text-decoration: underline; }
.operate-btn {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--pane-bg);
  color: var(--text);
  border: 1px solid var(--pane-bd);
  border-radius: 3px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  min-height: 36px;
}
.operate-btn:hover:not([disabled]),
.operate-btn:focus-visible:not([disabled]) {
  border-color: var(--gold);
  color: var(--gold);
  outline: none;
}
.operate-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.operate-tick {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--gold);
  margin-left: 0.4rem;
  white-space: nowrap;
}
.operate-tick #fpga-operate-tick { color: var(--green); }

/* Mobile-first responsive: tablet stacks controls, mobile collapses
 * the attribution but keeps Step + Reset always visible. */
@media (max-width: 900px) {
  #fpga-operate-pane .actions {
    flex-direction: column;
    align-items: flex-start;
  }
  #fpga-operate-attribution {
    flex: 1 1 auto;
    white-space: normal;
    text-overflow: clip;
  }
  .operate-host { max-height: 28em; }
}
@media (max-width: 480px) {
  /* Step + Reset stay first / visible; Start / Pause may scroll into
   * view via the actions container.  Action buttons take more vertical
   * space to keep tap targets >= 44px. */
  .operate-btn { min-height: 44px; padding: 0.45rem 0.7rem; }
  .operate-host { max-height: 24em; }
}

/* === step-through visualizer (Tab 4) ===================================== */
.step-grid { grid-template-columns: repeat(2, 1fr); }

.step-data-input {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--pane-bd);
  padding: 0.3rem;
}

.toolbar button.step-ctrl {
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--green);
  padding: 0.4rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
}
.toolbar button.step-ctrl:hover { border-color: var(--gold); color: var(--gold); }

.step-legend {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: #a0a0a0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.legend-swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border: 1px solid var(--pane-bd);
  margin-right: 0.15rem;
  vertical-align: middle;
}
.legend-swatch.read  { background: var(--gold);  }
.legend-swatch.write { background: var(--green); }

/* Register file grid */
.step-regfile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.3rem;
  background: var(--code-bg);
  flex: 1;
  overflow: auto;
  min-height: 12em;
  max-height: 32em;
}
.step-reg {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border: 1px solid #1f1f1f;
  background: #131313;
  border-radius: 2px;
  transition: background-color 480ms ease, border-color 480ms ease, color 480ms ease;
}
.step-reg-name { color: #a0a0a0; }
.step-reg-val  { color: var(--fg); }
.step-reg.flash-read {
  background: rgba(251,191,36,0.22);
  border-color: var(--gold);
  color: var(--gold);
}
.step-reg.flash-read .step-reg-name,
.step-reg.flash-read .step-reg-val { color: var(--gold); }
.step-reg.flash-write {
  background: rgba(74,222,128,0.22);
  border-color: var(--green);
}
.step-reg.flash-write .step-reg-name,
.step-reg.flash-write .step-reg-val { color: var(--green); }
.step-reg.flash-read.flash-write {
  /* Read-then-written: writeback wins visually, but border stays gold so the
   * student sees the dependency. */
  background: rgba(74,222,128,0.22);
  border-color: var(--gold);
}

/* Disassembly pane */
.step-disasm {
  flex: 1;
  background: var(--code-bg);
  padding: 0.4rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow: auto;
  min-height: 12em;
  max-height: 32em;
}
.step-disasm-line {
  padding: 0.1rem 0.4rem;
  border-left: 3px solid transparent;
  transition: background-color 480ms ease, border-color 480ms ease;
  color: #b0b0b0;
}
.step-disasm-line.active {
  background: rgba(251,191,36,0.18);
  border-left-color: var(--gold);
  color: var(--gold);
}
.step-disasm-line.just-executed {
  background: rgba(74,222,128,0.10);
  border-left-color: var(--green);
  color: var(--fg);
}
.step-disasm-addr { color: #707070; }
.step-disasm-hex  { color: #6b9fcf; }
.step-disasm-asm  { color: inherit; }

.step-pc-readout {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--gold);
}

.step-pedagogy {
  font-size: 0.85rem;
  color: #a0a0a0;
  margin: 0.8rem 0 0.2rem 0;
  line-height: 1.5;
}
.step-pedagogy a    { color: var(--gold); text-decoration: none; }
.step-pedagogy a:hover { text-decoration: underline; }
.step-pedagogy code { color: var(--green); font-family: var(--mono); font-size: 0.85em; }

/* Mobile-friendly fallback: stack panels; smaller fonts.  Academy doctrine is
 * desktop-first for this surface (per the brief and the visual-learner memo),
 * but the page should not break at 360px wide. */
@media (max-width: 720px) {
  .step-grid { grid-template-columns: 1fr; }
  .step-regfile-grid, .step-disasm { max-height: 18em; }
}
