/* generator-ui.css — styles for the layered character generator.
 *
 * Loaded standalone by generator-test.html and (Phase 3) by index.html
 * when the wizard mounts the generator. All selectors are scoped under
 * .cg-host so they cannot leak into the rest of the page.
 *
 * Colour palette mirrors docs/CONTEXT.md design system:
 *   bg:       #0a0a0f
 *   panel:    #0f0f1a
 *   border:   #1a1a2e
 *   accent:   #00ffff (cyan)
 *   success:  #00ff41
 *   text:     #c0c0c0
 *   muted:    #555 / #666
 */

.cg-host {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  color: #c0c0c0;
  background: #0a0a0f;
  font-family: 'Courier New', monospace;
  min-height: 100%;
  box-sizing: border-box;
}
.cg-host *, .cg-host *::before, .cg-host *::after { box-sizing: border-box; }

/* ── Sidebar ───────────────────────────────────────────────── */
.cg-sidebar {
  background: #0f0f1a;
  border-right: 1px solid #1a1a2e;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.cg-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid #1a1a2e;
}
.cg-tab {
  background: transparent;
  color: #666;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 10px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.cg-tab:hover {
  color: #c0c0c0;
  background: rgba(0, 255, 255, 0.04);
}
.cg-tab.active {
  color: #00ffff;
  border-bottom-color: #00ffff;
  background: rgba(0, 255, 255, 0.06);
}
.cg-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}
.cg-loading {
  color: #666;
  font-size: 10px;
  text-align: center;
  padding: 24px;
  letter-spacing: 1px;
}
.cg-section-title {
  color: #00ff41;
  font-size: 9px;
  letter-spacing: 2px;
  margin: 6px 2px 8px;
  text-transform: uppercase;
}
.cg-section-title + .cg-grid { margin-bottom: 14px; }

.cg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}
.cg-grid-colors {
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
}

.cg-thumb {
  /* Each thumb is a small character composite (32×64 native) rendered
   * via background-image at integer scale so pixels stay crisp. */
  aspect-ratio: 1 / 2;
  background: #050507;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid #1a1a2e;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: border-color 0.1s, transform 0.05s;
}
.cg-thumb:hover { border-color: #444; }
.cg-thumb.loaded { background-color: #0a0a0f; }
.cg-thumb.errored { background: #2a0808 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 32'><text x='8' y='20' fill='%23ff4040' font-size='10' text-anchor='middle' font-family='monospace'>?</text></svg>") center/contain no-repeat; }
.cg-thumb.selected {
  border-color: #00ffff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}
.cg-thumb-color {
  aspect-ratio: 1 / 2;
}
.cg-thumb-bald {
  background: #0a0a0f;
  color: #666;
  font-size: 18px;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main area ─────────────────────────────────────────────── */
.cg-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  gap: 18px;
  min-height: 100%;
}
.cg-preview-wrap {
  background: #050507;
  border: 1px solid #1a1a2e;
  padding: 24px 32px;
  min-width: 320px;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Preview sprite: native 32×64 scaled 6× → 192×384 box. For walk
 * (multi-frame), we set --cg-strip-w so the background-size matches the
 * full strip and we step through frames with a CSS animation. */
.cg-preview {
  --cg-frames: 1;
  --cg-strip-w: 32px;
  width: 192px;
  height: 384px;
  background-repeat: no-repeat;
  background-size: calc(var(--cg-strip-w) * 6) 384px;
  background-position: 0 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.cg-preview[data-action="walk"] {
  animation: cg-walk-cycle 0.7s steps(var(--cg-frames)) infinite;
}
@keyframes cg-walk-cycle {
  from { background-position-x: 0; }
  to   { background-position-x: calc(var(--cg-strip-w) * -6); }
}

.cg-action-row, .cg-cmd-row {
  display: flex;
  gap: 8px;
}
.cg-action, .cg-cmd {
  background: #0f0f1a;
  color: #c0c0c0;
  border: 1px solid #1a1a2e;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.cg-action:hover, .cg-cmd:hover {
  border-color: #444;
  color: #fff;
}
.cg-action.active {
  border-color: #00ffff;
  color: #00ffff;
  background: rgba(0, 255, 255, 0.06);
}
.cg-cmd { min-width: 100px; }
.cg-cmd[data-cmd="random"]:hover { border-color: #00ff41; color: #00ff41; }
.cg-cmd[data-cmd="save"]:hover   { border-color: #00ffff; color: #00ffff; }

.cg-json {
  width: 100%;
  max-width: 520px;
  margin-top: 12px;
  border: 1px solid #1a1a2e;
  background: #050507;
}
.cg-json > summary {
  padding: 8px 12px;
  color: #555;
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
}
.cg-json > summary:hover { color: #c0c0c0; }
.cg-json-body {
  margin: 0;
  padding: 12px;
  background: #0a0a0f;
  color: #c0c0c0;
  font-size: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  border-top: 1px solid #1a1a2e;
  max-height: 200px;
  overflow: auto;
}

/* ── Compact mode (when host < 720px wide) ─────────────────── */
@media (max-width: 720px) {
  .cg-host {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .cg-sidebar { border-right: none; border-bottom: 1px solid #1a1a2e; max-height: 300px; }
  .cg-main { padding: 18px 12px; }
}

/* ── Appearance mode toggle (wizard step 2b) ─────────────────
 * Lives OUTSIDE .cg-host scope because the buttons are siblings of
 * the host element, not children. Reuses the project palette. */
.appearance-mode-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.mode-btn {
  flex: 1;
  background: #0f0f1a;
  color: #c0c0c0;
  border: 1px solid #1a1a2e;
  padding: 8px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.mode-btn:hover {
  border-color: #444;
  color: #fff;
}
.mode-btn.active {
  border-color: #00ffff;
  color: #00ffff;
  background: rgba(0, 255, 255, 0.06);
}
