/* ==================================================================
   Cheat-sheet theme bridge.

   The static cheat sheets (/oscp, /security-plus) were written against a
   small set of legacy variables (--bg, --panel, --text ...). This file maps
   them onto the same design tokens the React app uses, so every palette
   preset in /shared/palettes.css restyles the cheat sheets identically to
   the rest of the site.  Load AFTER /shared/palettes.css.

   IMPORTANT: several legacy names (--muted, --accent, --primary, --success)
   collide with palette token names, and the palette blocks are selected with
   [data-palette="..."], which outranks a plain :root rule. The bridge is
   therefore written with a higher-specificity selector so the legacy meaning
   always wins, and it reads the palette through *non-colliding* source
   tokens (--foreground, --muted-foreground, --primary-ink ...).
   ================================================================== */

html:root,
html:root[data-palette] {
  --bg: var(--background);
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --text: var(--foreground);

  /* legacy --muted means "muted TEXT", not the muted surface */
  --muted: var(--muted-foreground);

  /* --border / --border-strong / --input / --ring already come from the
     palette file with the same names and meanings. */

  /* legacy --primary means "accent text/lines" -> use the readable ink tone */
  --primary: var(--primary-ink);
  --primary-dim: var(--primary-glow);
  --accent: var(--primary-ink);
  --success: var(--success-ink, oklch(0.82 0.1 168));
  --warning: var(--warning-ink, oklch(0.865 0.105 92));
  --danger: oklch(0.72 0.16 22);

  /* Terminal blocks stay dark in every palette (see below) */
  --code-bg: #0b0f14;
  --code-border: #2a3441;

  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Epilogue", -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Urbanist", var(--sans);
}

/* Command blocks are ALWAYS the classic dark terminal look — near-black
   block with cyan-tinted text — in every palette, including light ones like
   Paper & Ink. Terminals don't turn paper-white. */
.cmd-cell,
pre,
code {
  --cmd-bg: #0b0f14;
  --cmd-text: #d6f4ff;
}

.cmd-cell,
pre,
code,
pre code {
  color: var(--cmd-text);
}

/* ==================================================================
   Readability hardening (2026-09) — applies to every cheat sheet.

   1. Every command surface is a dark block with light text, in every
      palette. Never light-on-light.
   2. Commands stay on ONE line and scroll horizontally instead of
      wrapping into unreadable ribbons.
   3. The redundant per-command "Copy" chrome is removed.
   4. Wider content column so tables and code fit.
   ================================================================== */

/* --- 1 + 2: dark command surfaces, single-line commands ----------- */
.code-wrap,
.code-wrap pre,
pre,
.table-wrap td.cmd-cell {
  background: #0b0f14 !important;
  color: #d6f4ff !important;
  border-color: #1e2732;
}

.code-wrap pre,
pre {
  overflow-x: auto;
  white-space: pre !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

pre code,
.code-wrap code {
  background: transparent !important;
  color: #d6f4ff !important;
  white-space: pre !important;
}

/* Inline / table code becomes a dark chip so it can never disappear
   against a light page. */
.content code,
.table-wrap td code,
.table-wrap th code,
li code,
p code {
  background: #0b0f14;
  color: #d6f4ff;
  font-family: var(--mono);
  padding: 0.12em 0.4em;
  border: 1px solid #1e2732;
  border-radius: 3px;
}

/* Command cells in tables: full dark block, one line, own scrollbar. */
.table-wrap td.cmd-cell,
.table-wrap td.cmd-cell code {
  white-space: pre !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}
.table-wrap td.cmd-cell {
  max-width: 0;
  overflow-x: auto;
}
.table-wrap tr:nth-child(even) td.cmd-cell {
  background: #0b0f14 !important;
}

/* --- 3: no copy chrome ------------------------------------------- */
.copy-btn,
.cmd-copy,
.cell-copy,
button.copy-btn,
button.cmd-copy,
button.cell-copy,
[data-copy] {
  display: none !important;
}

/* --- 4: roomier boxes -------------------------------------------- */
.layout,
.topbar-inner {
  max-width: 1600px;
}
.table-wrap table {
  min-width: 100%;
}
.table-wrap th,
.table-wrap td {
  padding: 10px 14px;
}

/* Terminal blocks stay dark even when printing. */
@media print {
  .code-wrap,
  .code-wrap pre,
  pre,
  .table-wrap td.cmd-cell {
    background: #0b0f14 !important;
    color: #d6f4ff !important;
  }
}
