/* bitforge — styling. Black on white, monospace, terminal-tool feel. */

:root {
  --ink: #111111;
  --bg: #ffffff;
  --panel: #fafafa;
  --line: #cccccc;
  --line-strong: #888888;
  --muted: #555555;
  --sel: #111111;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

body { display: flex; flex-direction: column; }

/* ---------- toolbar ---------- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
/* Menu bar (File / Edit dropdowns, desktop-app style) */
#menubar { display: flex; align-items: center; gap: 2px; flex: 1; }
.menu { position: relative; }
.menu-btn { border: none; background: none; border-radius: 3px; padding: 4px 10px; font: inherit; color: var(--ink); cursor: pointer; }
.menu-btn:hover, .menu.open > .menu-btn { background: #e6e6e6; }
.menu-items {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 100;
  min-width: 250px; padding: 4px 0; background: #fff;
  border: 1px solid var(--line-strong); box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.12);
}
.menu.open .menu-items { display: block; }
.menu-items button {
  display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 18px;
  border: none; background: none; text-align: left; padding: 5px 14px; font: inherit; color: var(--ink); cursor: pointer;
}
.menu-items button:hover { background: #f0f0f0; }
.menu-items .mi-key { color: var(--muted); font-size: 11px; white-space: nowrap; }
.menu-items hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-items .mi-info { padding: 5px 14px 6px; color: var(--muted); font-size: 12px; line-height: 1.5; white-space: pre-line; }

/* About modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop[hidden] { display: none; } /* the display:flex above would otherwise override the UA hidden rule */
.modal { background: #fff; border: 1px solid var(--line-strong); box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2); min-width: 440px; max-width: 90vw; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.modal-head button { padding: 0 8px; border: none; background: none; font-size: 16px; line-height: 1; cursor: pointer; }
.modal-body { padding: 12px 16px 14px; font-size: 13px; line-height: 1.55; }
.modal-body .muted { color: var(--muted); }
.modal-body label { display: block; margin-top: 10px; font-weight: 700; }
.modal-body input[type="text"] {
  width: 100%; margin-top: 4px; font: inherit;
  padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink);
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.rz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 10px; }
.rz-grid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 0; }
.rz-grid input[type="number"] {
  width: 72px; font: inherit; text-align: right;
  padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink);
}

button {
  font: inherit;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover { background: #f0f0f0; }
button:active { background: #e4e4e4; }
/* Destructive (but undoable) actions get a subtle reddish outline. */
button.btn-danger { border-color: #cc3333; color: #a03030; }
button.btn-danger:hover { background: #fff5f5; }

/* ---------- layout ---------- */
#layout { flex: 1; display: flex; min-height: 0; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 288px;
  flex: 0 0 288px;
  border-right: 1px solid var(--line-strong);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.sel-header {
  font-size: 20px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 36px;
}
.jumprow { display: flex; gap: 6px; }
.jumprow input {
  flex: 1;
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
#selector { border: 1px solid var(--line); background: #fff; image-rendering: pixelated; }
.sel-hint { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* ---------- content / tabs ---------- */
#content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); padding: 0 8px; }
.tab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
}
.tab:hover { background: #f4f4f4; }
.tab.active { border-bottom-color: var(--ink); font-weight: 700; }

.panel { display: none; flex: 1; flex-direction: column; padding: 10px; min-height: 0; }
.panel.active { display: flex; }
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.glyph-status { display: inline-flex; gap: 2px; align-items: center; }
.glyph-status button { padding: 1px 8px; font-size: 11px; border-radius: 2px; }
.glyph-status button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: bold; }
.panel-head label { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.panel-head input[type="number"] { width: 60px; font: inherit; padding: 2px 4px; border: 1px solid var(--line-strong); border-radius: 3px; }
.spacer { flex: 1; }

/* ---------- canvas surfaces ---------- */
/* Everything renders as black ink on white — no checkerboard. */
.canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  background: #ffffff;
}
.canvas-wrap canvas { margin: 12px; image-rendering: pixelated; flex: 0 0 auto; }

/* Solid white editing surface; preview surfaces stay transparent over the board. */
#editor { background: #fff; border: 1px solid var(--line); }
#atlas { background: #fff; border: 1px solid var(--line); }
#pv-text-canvas { border: 1px solid var(--line); }

/* ---------- preview ---------- */
/* Preview is a simple vertical stack: markup input, then the rendered sample. */
.textcol { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#pv-text {
  font: inherit;
  resize: vertical;
  min-height: 64px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 6px;
}

/* ---------- guidelines controls ---------- */
.guides {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
}
.guides .glock { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }
.guides .gadd { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.guides .gadd button { padding: 1px 6px; font-size: 11px; }
.guides .glist { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.gchip {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid #999; border-left: 3px solid #999; border-radius: 3px;
  padding: 1px 4px; background: #fff; font-size: 11px;
}
.gchip b { font-weight: 700; }
.gchip i { font-style: normal; color: var(--muted); }
.gdel {
  border: none; background: transparent; padding: 0 2px; cursor: pointer;
  font-size: 13px; line-height: 1; color: #a00;
}
.gdel:hover { color: #f00; }
.gnone { color: var(--muted); font-style: italic; }

/* ---------- glyph status menu + QA ---------- */
.status-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  border: 1px solid #111;
  background: #fff;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}
.status-menu button {
  border: none;
  background: #fff;
  padding: 3px 12px 3px 8px;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.status-menu button:hover { background: #eee; }

.qa-badge { color: #a00; font-size: 12px; }
.qa-hint { color: var(--muted); font-size: 12px; }
.markup-note { color: var(--muted); font-size: 12px; }
.markup-note code { background: #f2f2f2; padding: 0 3px; }
.qa-empty { color: var(--muted); padding: 10px; font-size: 13px; }
.qa-table-wrap { overflow: auto; max-height: calc(100vh - 190px); }
#qa-table { border-collapse: collapse; width: 100%; font-size: 12px; }
#qa-table th, #qa-table td { border-bottom: 1px solid var(--line); padding: 2px 8px; text-align: left; white-space: nowrap; }
#qa-table th { background: var(--panel); position: sticky; top: 0; }
.qa-code { border: none; background: transparent; font: inherit; color: #111; text-decoration: underline; cursor: pointer; padding: 0; }
.qa-code:hover { color: #a00; }
/* QA summary strip + status icons (DECISIONS #59) */
.qa-summary { padding: 8px 12px 0; }
.qa-sum-row { margin: 2px 0; color: var(--muted); font-size: 12px; }
.qa-sum-row b { color: var(--ink); font-weight: normal; }
.qa-ic { display: inline-block; width: 15px; margin-right: 4px; }
.qa-svg { vertical-align: -2px; }
#qa-table tr.qa-sil td { color: var(--muted); }
button.qa-silbtn { font-size: 11px; padding: 1px 8px; }

/* ---------- shortcut reference card ---------- */
.keys-card {
  position: fixed;
  top: 44px;
  right: 12px;
  z-index: 50;
  min-width: 260px;
  max-width: 420px;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid #111;
  background: #fff;
  padding: 8px 12px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
}
.keys-card[hidden] { display: none; }
.keys-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.keys-head button { border: none; background: transparent; font-size: 15px; cursor: pointer; color: #555; }
.keys-head button:hover { color: #f00; }
#keys-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
#keys-list li { padding: 2px 0; border-bottom: 1px dotted var(--line); }
#keys-list li:last-child { border-bottom: none; }
#keys-list b { display: inline-block; min-width: 110px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.toast.error { background: #b00020; }
