/* Mab Arena Web UI stylesheet — doc 27 §18 (Sprint-5 WBS).
 *
 * Two layout modes share this one file:
 *  - Sprint-0's original bare landing page (`/`, no bodyClass) keeps its
 *    original narrow-column look (rules below the "Sprint-0 legacy" marker).
 *  - Arena pages (`bodyClass="arena-shell"`, set via src/renderer.tsx) use
 *    the wider, centered card layout defined first below.
 *
 * Deliberately plain CSS, no preprocessor/framework — consistent with this
 * repo's "minimum resource usage" constraint (doc 32): zero extra build
 * tooling, one small static file, cacheable by the browser like any other
 * static asset. */

:root {
  --color-bg: #0f1115;
  --color-surface: #1a1d24;
  --color-surface-alt: #232733;
  --color-border: #2e333f;
  --color-text: #e7e9ee;
  --color-text-muted: #9aa1b1;
  --color-primary: #6d5efc;
  --color-primary-hover: #5a4cf0;
  --color-danger: #f0546b;
  --color-easy: #3ecf8e;
  --color-medium: #f2b84b;
  --color-hard: #f0546b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  margin: 0;
  line-height: 1.6;
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

/* ---------------------------------------------------------------------
 * Arena shell layout (bodyClass="arena-shell")
 * ------------------------------------------------------------------- */

body.arena-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.arena-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.arena-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
}

.arena-nav-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.arena-nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.arena-nav-links a,
.arena-nav-links button {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.arena-nav-links a:hover,
.arena-nav-links button:hover {
  color: var(--color-text);
}

.arena-main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.arena-main.arena-main-narrow {
  max-width: 480px;
}

.arena-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

h1, h2, h3 {
  line-height: 1.25;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header p {
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* --- Forms --- */

.arena-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
}

.form-field {
  margin-bottom: 1.25rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.form-field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 1rem;
}

.form-field input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-field textarea {
  width: 100%;
  min-height: 220px;
  padding: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

/* --- Buttons --- */

.button {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.button-primary {
  background: var(--color-primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--color-primary-hover);
}

.button-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.button-secondary:hover {
  border-color: var(--color-primary);
}

.button-block {
  display: block;
  width: 100%;
  text-align: center;
}

/* --- Alerts --- */

.alert-error {
  background: rgba(240, 84, 107, 0.12);
  border: 1px solid var(--color-danger);
  color: #ffb0bd;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.muted {
  color: var(--color-text-muted);
}

/* --- Challenge cards / dashboard --- */

.dashboard-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

#challenge-list {
  display: grid;
  gap: 1rem;
}

.challenge-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.challenge-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.challenge-card h3 {
  margin: 0.25rem 0 1rem;
}

.challenge-vertical {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: capitalize;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

.badge-easy {
  background: rgba(62, 207, 142, 0.15);
  color: var(--color-easy);
}

.badge-medium {
  background: rgba(242, 184, 75, 0.15);
  color: var(--color-medium);
}

.badge-hard {
  background: rgba(240, 84, 107, 0.15);
  color: var(--color-hard);
}

/* --- Challenge detail / submission --- */

.challenge-prompt {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1rem 0 2rem;
  white-space: pre-wrap;
}

/* --- Session report / timeline --- */

.kv-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.kv-list dt {
  color: var(--color-text-muted);
}

.kv-list dd {
  margin: 0;
}

.timeline-event {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
}

.timeline-event-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.timeline-payload {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ---------------------------------------------------------------------
 * Sprint-0 legacy layout (bare `/` landing page, no bodyClass)
 * ------------------------------------------------------------------- */

body:not(.arena-shell) {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  color: #1a1a1a;
  background: #fff;
}

body:not(.arena-shell) code {
  background: #f0f0f0;
  color: inherit;
}
