/*
 * Terminal theme, matching badlands.dev: flat black, JetBrains Mono, phosphor
 * green, faint scanlines.
 *
 * Deliberate choices, recorded because they are the ones a reviewer would
 * question:
 *
 * 1. Mono everywhere, including headings and figures. The house data-viz rule
 *    prefers a system sans and warns off display faces, but the parent site's
 *    whole identity is a terminal, and a sans header on a black terminal page
 *    reads as the foreign element. Brand wins here; it is a considered override,
 *    not an oversight.
 *
 * 2. Dark only, no light mode. The site this lives in is dark by design, so a
 *    light variant would be a theme nobody sees and nobody validates.
 *
 * 3. Mastery meters use a single-hue GREEN ramp - bright fill on a dark green
 *    track - because a meter encodes magnitude. Track #205c20 measures 2.46:1
 *    against the #0a0a0a surface, clearing the 2:1 floor for an ordinal ramp,
 *    with monotone lightness and one hue. Validated, not eyeballed.
 *
 * 4. State - mastered, due, locked, correct, wrong - is carried by a GLYPH AND A
 *    WORD first; color only reinforces. That is not optional here. Against the
 *    brand green, amber measured 5.3 CVD delta-E under deuteranopia, well inside
 *    the confusable band, so the attention state uses magenta #ff5fff instead
 *    (deutan 18.6, tritan 13.0, normal-vision 23.6 - all clear). Even so,
 *    green-vs-red for correct-vs-wrong can never be safe on hue alone, which is
 *    why every verdict also says "Correct" or "Not quite" in words.
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  color-scheme: dark;

  --surface-1: #0a0a0a;
  --page: #0a0a0a;
  --text-primary: #33ff33;
  --text-secondary: #777777;
  --text-muted: #555555;
  --hairline: #1a1a1a;
  --border-ring: #222222;

  /* Single-hue green ramp, for magnitude. */
  --meter-fill: #33ff33;
  --meter-track: #205c20;
  --accent: #33ff33;

  /* Reserved for state. Never used for anything else. */
  --status-good: #33ff33;
  --status-attention: #ff5fff;
  --status-critical: #ff5555;

  --code-bg: #0f0f0f;

  --radius: 2px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--mono);
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Scanlines, as on the site index. Decorative and non-interactive. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(51, 255, 51, 0.01) 2px,
    rgba(51, 255, 51, 0.01) 4px
  );
  pointer-events: none;
  z-index: 100;
}

a {
  color: var(--accent);
}

/* ---------------------------------------------------------------- header --- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.5rem 1.5rem 1.1rem;
  border-bottom: 1px solid var(--hairline);
}

.topbar .prompt {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.3rem;
}

.topbar h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.topbar h1::before {
  content: './';
  color: var(--text-muted);
}

.topbar h1 .cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Respect a reduced-motion preference: a blinking cursor is decoration. */
@media (prefers-reduced-motion: reduce) {
  .topbar h1 .cursor {
    animation: none;
  }
}

.topbar .tagline {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-top: 0.35rem;
  line-height: 1.6;
}

.stats {
  display: flex;
  gap: 1.75rem;
  margin-left: auto;
  align-items: flex-end;
}

/* Stat tile: label above, value bold, proportional figures. */
.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.stat .label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat .value {
  font-size: 1.25rem;
  font-weight: 700;
}

.ghost-button {
  font: inherit;
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    border-color 0.2s,
    color 0.2s;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------------ layout - */

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  max-width: 1200px;
  margin: 1.25rem auto 3rem;
  padding: 0 1.5rem;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.panel > h2 {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--hairline);
}

.panel > h2::before {
  content: '// ';
}

/* ------------------------------------------------------------- skill list -- */

.skill-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skill {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  display: block;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.skill:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(51, 255, 51, 0.03);
}

.skill:disabled {
  cursor: not-allowed;
  color: var(--text-muted);
}

.skill-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.skill-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.skill-score {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.skill-blurb {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.5rem;
  line-height: 1.45;
}

/* Meter: bright fill on a darker step of the same green ramp. */
.meter {
  height: 4px;
  background: var(--meter-track);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--meter-fill);
  transition: width 0.35s ease;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border-ring);
  border-radius: var(--radius);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge.good {
  color: var(--status-good);
  border-color: var(--status-good);
}

.badge.due,
.badge.review {
  color: var(--status-attention);
  border-color: var(--status-attention);
}

.badge.locked {
  color: var(--text-muted);
  border-color: var(--hairline);
}

/* ----------------------------------------------------------------- problem -- */

.problem-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.problem-skill {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.progress-dots {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.prompt {
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

pre,
.editor {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  tab-size: 4;
}

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  white-space: pre;
}

pre.context {
  color: var(--text-muted);
  background: transparent;
  border-left: 1px solid var(--hairline);
  padding: 0.1rem 0 0.1rem 0.75rem;
  white-space: pre;
  overflow-x: auto;
}

.editor {
  width: 100%;
  background: var(--code-bg);
  color: var(--text-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  resize: vertical;
  caret-color: var(--accent);
}

.editor:focus-visible,
.skill:focus-visible,
button:focus-visible,
.choice:focus-within {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.field-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.35rem;
}

.code-stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

/* Choice options. */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.choice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.83rem;
  line-height: 1.5;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.choice:hover {
  border-color: var(--accent);
  background: rgba(51, 255, 51, 0.03);
}

.choice input {
  margin-top: 0.3rem;
  accent-color: var(--accent);
}

.choice.is-correct {
  border-color: var(--status-good);
}

.choice.is-chosen-wrong {
  border-color: var(--status-critical);
}

.choice .marker {
  font-weight: 700;
  min-width: 1.1em;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.primary-button {
  font: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  /* Ink on a bright green fill must be the page black, not white. */
  color: #0a0a0a;
  cursor: pointer;
}

.primary-button:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
}

.primary-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.keyhint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- verdict -- */

.verdict {
  margin-top: 1.1rem;
  border-top: 1px solid var(--hairline);
  padding-top: 0.9rem;
}

.verdict-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.verdict.correct .verdict-head {
  color: var(--status-good);
}

.verdict.wrong .verdict-head {
  color: var(--status-critical);
}

.verdict.broken .verdict-head {
  color: var(--status-attention);
}

.delta {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.diff {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0.6rem 0;
}

.diff h4 {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.explanation {
  font-size: 0.83rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-top: 0.6rem;
}

.hint {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--code-bg);
  border-left: 1px solid var(--accent);
  padding: 0.55rem 0.7rem;
  margin-top: 0.6rem;
}

/* ------------------------------------------------------------------ status -- */

.status {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.6rem 1.5rem 0;
  min-height: 1.9rem;
}

.status::before {
  content: 'guest@badlands:~$ ';
}

.status.error {
  color: var(--status-critical);
}

.empty {
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

.session-summary {
  list-style: none;
  margin: 0.5rem 0;
}

.session-summary li {
  font-size: 0.83rem;
  margin-bottom: 0.25rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
