/* leet.css — CivNode Leet: catalog, category, problem.
 *
 * Editor-forward; monospace heavy; calm background; two colours for tests
 * (one green, one red). The reveal sheet is a centred panel with a thin
 * accent border and a single 200ms fade-in — not a flashy modal. ✓ ✗ ✦
 * are typographic glyphs, never emoji.
 *
 * The JS in web/static/js/screens/training/leet/ uses BEM-style class
 * names rooted at .leet-catalog, .leet-category, .leet-problem. This file
 * follows the same names exactly; styles that don't have a matching DOM
 * hook were skipped per the design brief.
 *
 * Design tokens come from base.css (--bg-*, --text-*, --accent, etc.).
 * The few Leet-specific tokens below ride on top of those so the screens
 * inherit any future theme without a rewrite.
 */

/* ==========================================================================
   Shared — design tokens + screen shell
   ========================================================================== */

.leet-screen {
  /* Per-tier accents. Quiet on purpose — no neon, no traffic-light glare.
     Easy = soft moss, Medium = warm bronze, Hard = muted red. */
  --leet-easy:        var(--success);
  --leet-easy-bg:     color-mix(in srgb, var(--success) 14%, transparent);
  --leet-medium:      var(--resonance);
  --leet-medium-bg:   color-mix(in srgb, var(--resonance) 14%, transparent);
  --leet-hard:        var(--error);
  --leet-hard-bg:     color-mix(in srgb, var(--error) 14%, transparent);

  /* Test result colours — two and only two. */
  --leet-pass:        var(--success);
  --leet-fail:        var(--error);

  /* Editor surface — paper-like even on dark themes via the existing
     elevated surface. The code font is JetBrains Mono (--font-mono). */
  --leet-editor-bg:   var(--bg-secondary);
  --leet-editor-fg:   var(--text-primary);
  --leet-editor-border: var(--border);

  padding: 1.5rem 1.5rem 3rem;
  max-width: 1280px;
  margin: 0 auto;
}

.leet-screen__title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 1.5rem;
}

/* Loading / error / empty — used by all three screens.
   The same shapes recur with different prefixes; one ruleset handles them. */
.leet-catalog__loading,
.leet-category__loading,
.leet-problem__loading {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 2rem 0;
}

.leet-catalog__empty,
.leet-category__empty,
.leet-category__not-found,
.leet-problem__not-found {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-secondary);
  padding: 2rem 0;
  max-width: 65ch;
  line-height: 1.6;
}

.leet-catalog__empty-msg,
.leet-category__empty-msg,
.leet-category__not-found-msg,
.leet-problem__not-found-msg {
  margin-bottom: 1rem;
}

.leet-catalog__error,
.leet-category__error,
.leet-problem__error {
  font-family: var(--font-sans);
  padding: 1.5rem;
  border: 1px solid color-mix(in srgb, var(--error) 30%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--error) 6%, var(--bg-surface));
  max-width: 65ch;
}

.leet-catalog__error-msg,
.leet-category__error-msg,
.leet-problem__error-msg {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.leet-catalog__error-detail,
.leet-category__error-detail,
.leet-problem__error-detail {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.leet-category__back-link,
.leet-problem__back-link {
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  transition: border-color var(--transition), color var(--transition);
}
.leet-category__back-link:hover,
.leet-problem__back-link:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* ==========================================================================
   Catalog (/study/leet)
   ========================================================================== */

.leet-catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.leet-category-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem 1.2rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.leet-category-card:hover {
  background: var(--bg-elevated);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-sm);
}

.leet-category-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.leet-category-card__title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.leet-category-card__blurb {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  /* Two-line clamp keeps cards visually even without trimming the blurb
     on the API side — readers can still hover the card to see all of it
     by tapping in, but the grid stays rhythmic. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Counts: small flat tier squares + a textual summary above. */
.leet-counts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.leet-counts__summary {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0;
}

.leet-counts__row {
  display: flex;
  gap: 0.4rem;
}

.leet-counts__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  line-height: 1;
  border: 1px solid transparent;
}

.leet-counts__count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.leet-counts__label {
  font-family: var(--font-sans);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.leet-counts__cell--easy {
  background: var(--leet-easy-bg);
  border-color: color-mix(in srgb, var(--leet-easy) 35%, transparent);
}
.leet-counts__cell--easy .leet-counts__count { color: var(--leet-easy); }

.leet-counts__cell--medium {
  background: var(--leet-medium-bg);
  border-color: color-mix(in srgb, var(--leet-medium) 35%, transparent);
}
.leet-counts__cell--medium .leet-counts__count { color: var(--leet-medium); }

.leet-counts__cell--hard {
  background: var(--leet-hard-bg);
  border-color: color-mix(in srgb, var(--leet-hard) 35%, transparent);
}
.leet-counts__cell--hard .leet-counts__count { color: var(--leet-hard); }

.leet-counts__cell--zero {
  background: transparent;
  border-color: var(--border-subtle);
  opacity: 0.55;
}
.leet-counts__cell--zero .leet-counts__count,
.leet-counts__cell--zero .leet-counts__label {
  color: var(--text-muted);
}

/* ==========================================================================
   Category (/study/leet/:category)
   ========================================================================== */

.leet-category__breadcrumb,
.leet-problem__breadcrumb {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.leet-category__breadcrumb-link,
.leet-problem__breadcrumb-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.leet-category__breadcrumb-link:hover,
.leet-problem__breadcrumb-link:hover {
  color: var(--accent);
}

.leet-category__breadcrumb-current,
.leet-problem__breadcrumb-current {
  color: var(--text-primary);
}

.leet-category__body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.leet-category__title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.leet-category__blurb {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 65ch;
  margin: -0.5rem 0 0;
}

.leet-difficulty {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.leet-difficulty__heading {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.leet-difficulty--easy   .leet-difficulty__heading { color: var(--leet-easy); }
.leet-difficulty--medium .leet-difficulty__heading { color: var(--leet-medium); }
.leet-difficulty--hard   .leet-difficulty__heading { color: var(--leet-hard); }

/* Render the difficulty heading with a tiny tier swatch on the left. */
.leet-difficulty__heading::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 1px;
  background: currentColor;
}

.leet-difficulty__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.6rem;
}

.leet-problem-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition:
    background var(--transition),
    border-color var(--transition);
}

.leet-problem-card:hover {
  background: var(--bg-elevated);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.leet-problem-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.leet-problem-card--solved {
  border-color: color-mix(in srgb, var(--leet-easy) 40%, var(--border));
  background: color-mix(in srgb, var(--leet-easy) 5%, var(--bg-surface));
}

.leet-problem-card__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.leet-problem-card__title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.leet-problem-card__solved-mark {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--leet-pass);
  flex-shrink: 0;
}

.leet-problem-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.leet-problem-card__tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

.leet-problem-card__tag-sep {
  display: none; /* comma separators redundant once tags pill-render */
}

/* ==========================================================================
   Problem (/study/leet/:category/:slug)
   ========================================================================== */

.leet-problem__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.leet-problem__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

.leet-problem__title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
  flex: 1 1 auto;
  min-width: 0;
}

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

/* Difficulty chip — small flat pill with the tier accent. */
.leet-problem__difficulty {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1.4;
}

.leet-problem__difficulty--easy {
  color: var(--leet-easy);
  background: var(--leet-easy-bg);
  border-color: color-mix(in srgb, var(--leet-easy) 35%, transparent);
}
.leet-problem__difficulty--medium {
  color: var(--leet-medium);
  background: var(--leet-medium-bg);
  border-color: color-mix(in srgb, var(--leet-medium) 35%, transparent);
}
.leet-problem__difficulty--hard {
  color: var(--leet-hard);
  background: var(--leet-hard-bg);
  border-color: color-mix(in srgb, var(--leet-hard) 35%, transparent);
}

/* Hard problems get a typographic flourish (✦) in front of the label —
   a single character, not an emoji. Rendered as ::before so the JS text
   "Hard" stays untouched for screen-reader announcement. */
.leet-problem__difficulty--hard::before {
  content: '\2726\00a0'; /* ✦ + non-breaking space */
  font-family: var(--font-serif);
  font-weight: 600;
}

.leet-problem__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.leet-problem__tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}

.leet-problem__tag-sep {
  display: none; /* JS emits ", " separators; the pill style replaces them */
}

/* Solved / Tentative badge — quiet, informational, never celebratory. */
.leet-problem__solved-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
  animation: leet-badge-in 100ms ease both;
}

.leet-problem__solved-badge[data-status="solved"] {
  color: var(--leet-pass);
  background: color-mix(in srgb, var(--leet-pass) 12%, transparent);
  border-color: color-mix(in srgb, var(--leet-pass) 35%, transparent);
}

.leet-problem__solved-badge[data-status="tentative"] {
  color: var(--leet-medium);
  background: color-mix(in srgb, var(--leet-medium) 12%, transparent);
  border-color: color-mix(in srgb, var(--leet-medium) 35%, transparent);
}

@keyframes leet-badge-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Two-pane layout ────────────────────────────────────────────────────── */

.leet-problem__panes {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr);
  gap: 1.25rem;
  align-items: start;
}

.leet-problem__pane {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.leet-problem__pane-heading {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0;
}

/* Teach pane — quiet sidebar; reading-comfortable type. */
.leet-problem__teach {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding-right: 0.4rem;
}

.leet-problem__teach-body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.leet-problem__teach-body p {
  margin: 0 0 1em;
}
.leet-problem__teach-body p:last-child { margin-bottom: 0; }

.leet-problem__teach-body h1,
.leet-problem__teach-body h2,
.leet-problem__teach-body h3 {
  font-family: var(--font-serif);
  margin: 1.2em 0 0.4em;
  line-height: 1.25;
  color: var(--text-primary);
}
.leet-problem__teach-body h1 { font-size: 1.15rem; }
.leet-problem__teach-body h2 { font-size: 1.05rem; }
.leet-problem__teach-body h3 { font-size: 0.95rem; }

.leet-problem__teach-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-secondary);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.leet-problem__teach-body pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.8em 1em;
  margin: 1em 0;
  overflow-x: auto;
  line-height: 1.55;
}

.leet-problem__teach-body ul,
.leet-problem__teach-body ol {
  margin: 0.5em 0 1em 1.2em;
}
.leet-problem__teach-body ul { list-style: disc; }
.leet-problem__teach-body ol { list-style: decimal; }

/* Try pane — the editor IS the page on this side. */
.leet-problem__try {
  gap: 0.75rem;
}

/* ── Editor (tabs + textarea) ───────────────────────────────────────────── */

.leet-editor {
  display: flex;
  flex-direction: column;
  background: var(--leet-editor-bg);
  border: 1px solid var(--leet-editor-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leet-editor-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--leet-editor-border);
  padding: 0 0.4rem;
  overflow-x: auto;
}

.leet-editor-tab {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition);
}

.leet-editor-tab:hover {
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text-primary) 4%, transparent);
}

.leet-editor-tab--active {
  color: var(--text-primary);
  background: var(--leet-editor-bg);
  border-bottom-color: var(--accent);
}

/* Read-only tab (the contract file). Dim text; a small typographic lock
   slug in the corner. Not an icon image — keeps the file load minimal. */
.leet-editor-tab[data-readonly="1"] {
  color: var(--text-muted);
  font-style: italic;
}
.leet-editor-tab[data-readonly="1"]::after {
  content: '\00a0\00b7\00a0ro'; /* ` · ro` */
  font-style: normal;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.leet-editor__file {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.45;
  color: var(--leet-editor-fg);
  background: var(--leet-editor-bg);
  border: none;
  outline: none;
  resize: vertical;
  width: 100%;
  min-height: 320px;
  padding: 1rem 1.1rem;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow: auto;
}

.leet-editor__file:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent-subtle);
}

.leet-editor__file[readonly] {
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: default;
}

/* ── Run / Reset controls ───────────────────────────────────────────────── */

.leet-problem__try-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.leet-problem__run[data-running="1"] {
  opacity: 0.6;
  cursor: progress;
}

/* ── Test results ───────────────────────────────────────────────────────── */

.leet-problem__results {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-height: 2.4rem;
}

.leet-problem__results:empty {
  display: none;
}

.leet-problem__results-status,
.leet-problem__results-summary {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}

.leet-problem__results-summary {
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 0.5rem;
}

.leet-problem__results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.leet-problem__result-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  align-items: baseline;
  column-gap: 0.5rem;
  row-gap: 0.15rem;
  padding: 0.2rem 0;
}

.leet-problem__result-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  /* The literal text "pass"/"fail" from JS is replaced visually by ✓/✗
     so the row stays a single column of glyphs. The original word is
     still in the DOM for any screen reader / test harness. */
  font-size: 0;
  line-height: 1;
}
.leet-problem__result-row--pass .leet-problem__result-mark::before {
  content: '\2713'; /* ✓ */
  font-size: 0.95rem;
  color: var(--leet-pass);
}
.leet-problem__result-row--fail .leet-problem__result-mark::before {
  content: '\2717'; /* ✗ */
  font-size: 0.95rem;
  color: var(--leet-fail);
}

.leet-problem__result-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.leet-problem__result-row--fail .leet-problem__result-name {
  color: var(--leet-fail);
}

.leet-problem__result-detail {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.leet-problem__result-got,
.leet-problem__result-want {
  font-family: var(--font-mono);
}
.leet-problem__result-got::before  { content: ''; }
.leet-problem__result-want::before { content: ''; }

.leet-problem__results-empty,
.leet-problem__results-error {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--leet-fail);
  margin: 0.25rem 0 0;
}

.leet-problem__results-raw,
.leet-problem__results-stderr {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0 0;
  overflow-x: auto;
  white-space: pre;
}

.leet-problem__results-stderr {
  color: color-mix(in srgb, var(--leet-fail) 70%, var(--text-secondary));
}

/* ── Helper row (hints + reveal) ────────────────────────────────────────── */

.leet-problem__helper {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.leet-problem__helper-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Hint button — secondary CivNode button, BUT the "next" one carries a
   subtle accent border so the learner knows which step unlocks next. */
.leet-problem__hint {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.leet-problem__hint[data-next="1"]:not([disabled]) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.leet-problem__hint[data-unlocked="1"] {
  color: var(--text-secondary);
}

/* tertiary == ghost-ish reveal button; gold underline on hover only. */
.leet-problem__reveal {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.35em 0.85em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.leet-problem__reveal:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}
.leet-problem__reveal[data-revealed="1"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

/* Reveal confirm — inline row that appears next to the reveal button. */
.leet-problem__reveal-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: var(--radius);
}

.leet-problem__reveal-confirm-msg {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-primary);
  margin: 0;
  flex: 1 1 240px;
  line-height: 1.5;
}

/* Hint cards — thin-bordered rectangles stacking below the helper row. */
.leet-problem__hint-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leet-problem__hint-card {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 2px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  white-space: pre-wrap;
}

.leet-problem__hint-card--error {
  border-left-color: var(--leet-fail);
  color: var(--text-secondary);
}

.leet-problem__hint-card--auth {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left-color: var(--leet-medium);
}

.leet-problem__hint-card-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.leet-problem__hint-card-link:hover {
  color: var(--accent-hover);
}

/* ── Reveal sheet ───────────────────────────────────────────────────────── */
/* Fixed, centred, thin accent border. Single 200ms fade. No backdrop dim. */

.leet-problem__reveal-sheet-host {
  /* The host is just an anchor — actual positioning lives on the sheet. */
}

.leet-problem__reveal-sheet {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 90vw);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 1.5rem 1.75rem 1.75rem;
  z-index: 1000;
  animation: leet-sheet-in 200ms ease both;
}

@keyframes leet-sheet-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

.leet-problem__reveal-sheet-heading {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-right: 3rem; /* room for the close button */
}

.leet-problem__reveal-sheet-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.leet-problem__reveal-sheet-close:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.leet-problem__reveal-sheet-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-primary);
}

.leet-problem__reveal-sheet-commentary {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
}
.leet-problem__reveal-sheet-commentary p {
  margin: 0 0 0.8em;
}
.leet-problem__reveal-sheet-commentary p:last-child { margin-bottom: 0; }
.leet-problem__reveal-sheet-commentary code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-secondary);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}
.leet-problem__reveal-sheet-commentary pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.8em 1em;
  margin: 1em 0;
  overflow-x: auto;
  line-height: 1.55;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  /* Problem screen: stack Teach above Try at a smaller type size. The
     Teach panel loses its sticky behaviour so it scrolls with the page. */
  .leet-problem__panes {
    grid-template-columns: 1fr;
  }
  .leet-problem__teach {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
  }
  .leet-problem__teach-body {
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .leet-difficulty__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .leet-screen {
    padding: 1rem 1rem 2.5rem;
  }
  .leet-catalog__grid {
    grid-template-columns: 1fr;
  }
  .leet-problem__title {
    font-size: 1.4rem;
  }
  .leet-problem__reveal-sheet {
    width: 94vw;
    padding: 1.1rem 1.1rem 1.25rem;
  }
}
