/* emu6502 web interface: a lab-instrument chassis around an amber CRT. */

@font-face { font-family: "VT323"; font-weight: 400; font-display: swap; src: url("fonts/VT323-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap; src: url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexSansCondensed-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 500; font-display: swap; src: url("fonts/IBMPlexSansCondensed-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 600; font-display: swap; src: url("fonts/IBMPlexSansCondensed-SemiBold.woff2") format("woff2"); }

:root {
  --chassis: #22384a;
  --panel: #2a4458;
  --groove: #3c5a71;
  --legend: #dde4e9;
  --muted: #94a8b7;
  --data: #f1f4f6;
  --key: #e3e6e1;
  --key-shadow: #9aa39d;
  --key-text: #1d2a33;
  --screen: #170f05;
  --bezel: #0f161c;
  --phosphor: #ffb33a;
  --phosphor-dim: #a8701f;
  --lit: #ffb33a;
  --led-on: #ff4a3d;
  --led-off: #4b2c2c;
  --focus: #8fd3ff;

  --sans: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --crt: "VT323", "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--chassis);
  color: var(--legend);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Top bar ---------- */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--groove);
}

.brand {
  margin: 0 8px 0 0;
  font-family: var(--crt);
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  color: var(--phosphor);
  letter-spacing: 0.02em;
}

.controls, .files { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.key {
  background: var(--key);
  color: var(--key-text);
  border: 0;
  border-radius: 3px;
  padding: 6px 12px 5px;
  box-shadow: 0 2px 0 var(--key-shadow);
  font-weight: 500;
  cursor: pointer;
}
.key:active { transform: translateY(2px); box-shadow: 0 0 0 var(--key-shadow); }
.key:disabled { opacity: 0.45; cursor: default; }
.key-primary { min-width: 72px; background: var(--phosphor); box-shadow: 0 2px 0 #9b6516; }
.key-primary.is-running { background: var(--key); box-shadow: 0 2px 0 var(--key-shadow); }

.field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.field input, .field select {
  background: var(--panel);
  border: 1px solid var(--groove);
  border-radius: 3px;
  padding: 4px 6px;
  color: var(--data);
  font-family: var(--mono);
  font-size: 14px;
}
.field input { width: 6.5ch; text-transform: uppercase; }

/* A copy of the VIA port LEDs, centred in the free space of the bar. */
.bar-ports {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 10px;
  background: var(--bezel);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #000;
}
.bar-port { display: flex; align-items: center; gap: 8px; }
.bar-port-name, .bar-port-val { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.bar-port-val { min-width: 2ch; color: var(--data); }
.bar-ports .leds { gap: 5px; }
.bar-ports .led { width: 12px; height: 12px; }
/* Bits 7-4 and 3-0 in two groups of four, so a value is easy to read. */
.bar-ports .led:nth-child(5) { margin-left: 5px; }

.status {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.status.is-stopped { color: var(--phosphor); }
.status.is-error { color: var(--led-on); }

/* ---------- Layout ---------- */

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas:
    "screen side"
    "memory side";
  grid-template-rows: auto 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
.screen-area { grid-area: screen; }
.memory { grid-area: memory; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 1100px) {
  .desk {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "screen" "side" "memory";
  }
  .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
}
@media (max-width: 600px) {
  .bar, .desk { padding-left: 16px; padding-right: 16px; }
  .status { margin-left: 0; width: 100%; }
  .bar-ports { margin: 0; }
}

/* ---------- The screen ---------- */

.bezel {
  position: relative;
  background: var(--bezel);
  border-radius: 14px;
  padding: 18px;
  box-shadow: inset 0 0 0 1px #000, 0 1px 0 var(--groove);
}

.screen {
  position: relative;
  height: calc(24 * 1.05em + 28px);
  overflow: auto;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.18) 2px 3px),
    radial-gradient(ellipse at center, #22160a 0%, var(--screen) 75%);
  border-radius: 10px;
  padding: 14px 18px;
  color: var(--phosphor);
  font-family: var(--crt);
  font-size: clamp(13px, 1.55vw, 22px);
  line-height: 1.05;
  text-shadow: 0 0 6px rgba(255, 179, 58, 0.45);
  cursor: text;
  scrollbar-color: var(--phosphor-dim) transparent;
}
.bezel:focus-within .screen { box-shadow: 0 0 0 2px var(--phosphor-dim); }

/* The keyboard really goes to this invisible text box: phones only open
 * their on-screen keyboard for a focused text field. 16px stops iOS from
 * zooming in when it gets focus. */
.term-input {
  position: absolute;
  left: 18px;
  top: 18px;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  overflow: hidden;
  font-size: 16px;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  pointer-events: none;
}

.term-history, .term-grid {
  margin: 0;
  font: inherit;
  white-space: pre;
  overflow: visible;
}
.term-history { color: #d9952f; }

.cursor { background: var(--phosphor); color: var(--screen); text-shadow: none; }
.bezel:not(:focus-within) .cursor { background: transparent; color: inherit; outline: 1px solid var(--phosphor-dim); }

.term-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 12%;
  font-size: 1.15em;
  line-height: 1.3;
}
.term-empty[hidden] { display: none; }
.term-empty:not([hidden]) ~ .term-grid, .screen:has(.term-empty:not([hidden])) .term-grid { visibility: hidden; }
.term-empty p { margin: 0 0 0.6em; }
.term-empty code { color: #ffd38a; }
.linkish {
  background: none; border: 0; padding: 0;
  color: #ffd38a; text-decoration: underline; cursor: pointer;
  font: inherit;
}

.screen-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
  margin-top: 10px;
}
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.theme-field { margin-left: auto; }
.taskbar { display: none; }   /* see theme-classic.css */

/* Keys a phone keyboard does not have. Only on touch screens. */
.softkeys { display: none; gap: 6px; flex-wrap: wrap; }
@media (pointer: coarse) {
  .softkeys { display: flex; }
  #term-hint { display: none; }
}

body.is-dragging .bezel { box-shadow: 0 0 0 3px var(--phosphor); }

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border-radius: 6px;
  padding: 12px 14px 14px;
  box-shadow: inset 0 0 0 1px var(--groove);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 10px;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--legend);
}
.meta { color: var(--muted); font-family: var(--mono); font-size: 13px; margin-left: auto; }

.chip {
  background: transparent;
  border: 1px solid var(--groove);
  border-radius: 3px;
  padding: 2px 8px;
  color: var(--legend);
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }

/* CPU */

.regs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.reg { display: flex; flex-direction: column; gap: 2px; }
.reg-wide { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 10px; }
.reg-name { color: var(--muted); font-size: 13px; }
.reg-val { font-family: var(--mono); font-size: 18px; color: var(--data); }
.reg-wide .reg-val { font-size: 26px; }
.changed { color: var(--lit); }

.flags { display: flex; gap: 4px; margin-top: 12px; }
.flag {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  padding: 3px 0;
  border-radius: 3px;
  border: 1px solid var(--groove);
  color: var(--muted);
}
.flag.is-set { background: var(--phosphor); border-color: var(--phosphor); color: var(--screen); font-weight: 600; }
.flag.is-unused { border-style: dashed; opacity: 0.5; }
.flag.is-unused.is-set { background: transparent; border-color: var(--groove); color: var(--muted); font-weight: 400; }
.flag-label { display: block; font-family: var(--sans); font-size: 10.5px; font-weight: 400; opacity: 0.8; }

/* Disassembly */

.dis, .stack { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 13.5px; }
.dis li {
  display: grid;
  grid-template-columns: 14px 44px 76px 1fr;
  gap: 6px;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.dis li:hover { background: rgba(255,255,255,0.05); }
.dis .is-pc { background: rgba(255, 179, 58, 0.16); color: var(--phosphor); }
.dis .bp-dot { color: transparent; }
.dis .has-bp .bp-dot { color: var(--led-on); }
.dis .addr { color: var(--muted); }
.dis .is-pc .addr { color: var(--phosphor); }
.dis .bytes { color: #7f95a6; }
.bp-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.bp-list .chip { font-family: var(--mono); }

/* Stack */

.stack li { display: grid; grid-template-columns: 50px 28px 1fr; gap: 8px; padding: 1px 4px; }
.stack .addr { color: var(--muted); }
.stack .note { color: var(--muted); font-family: var(--sans); font-size: 13px; }
.stack .is-top { color: var(--phosphor); }
.stack .empty { color: var(--muted); font-family: var(--sans); }

/* Memory */

.hex {
  font-family: var(--mono);
  font-size: 13.5px;
  overflow-x: auto;
}
.hex-row { display: flex; gap: 14px; white-space: nowrap; }
.hex-addr { color: var(--muted); }
.hex-bytes { display: flex; gap: 0.6ch; }
.hex-bytes .gap { width: 0.6ch; }
.hex-byte { cursor: pointer; border-radius: 2px; padding: 0 1px; }
.hex-byte:hover { background: rgba(255,255,255,0.08); }
.hex-byte.changed { background: rgba(255, 179, 58, 0.22); color: var(--lit); }
.hex-byte.is-sp { outline: 1px solid var(--phosphor-dim); }
.hex-ascii { color: #b9c6cf; }

/* I/O */

.io { display: flex; flex-direction: column; gap: 10px; }
.port { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.port-name { color: var(--muted); font-size: 14px; }
.leds { display: flex; gap: 7px; }
.led {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--led-off);
  box-shadow: inset 0 -2px 2px rgba(0,0,0,0.35);
}
.led.is-on { background: var(--led-on); box-shadow: 0 0 8px rgba(255, 74, 61, 0.7); }
.led.is-input { background: transparent; border: 1.5px solid var(--groove); box-shadow: none; }
.led.is-input.is-on { border-color: var(--muted); }

.kv {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 2px 10px;
  margin: 0;
  font-size: 13.5px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); color: var(--data); }

@media (prefers-reduced-motion: reduce) {
  .key:active { transform: none; }
}
