/* Cheatsheet stylesheet for docs/index.html.
   Dependency-free, single file. Tuned for the three-column comparison tables
   (Task / coreutils-sed-awk-dd / slice) generated from docs/cheatsheet.toml.
   Light and dark themes are driven entirely by prefers-color-scheme. */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --fg: #1c2024;
  --muted: #5c636b;
  --border: #e2e5e9;
  --rule: #eceef1;
  --accent: #2563c9;

  /* Inline code and table cells holding commands. */
  --code-bg: #f4f5f7;
  --code-fg: #1c2024;
  --code-border: #e2e5e9;

  /* The slice column is the payoff; tint it so it reads as the answer. */
  --slice-bg: #eef4ff;
  --slice-fg: #163b7a;

  --thead-bg: #f7f8fa;
  --row-alt: #fafbfc;
  --note-fg: #5c636b;

  --mono: ui-monospace, "SF Mono", "SFMono-Regular", "Cascadia Code", "Fira Code",
    Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --fg: #e6e8ea;
    --muted: #9aa1a9;
    --border: #2a2f35;
    --rule: #23272c;
    --accent: #6ea8ff;

    --code-bg: #1e2329;
    --code-fg: #e6e8ea;
    --code-border: #2a2f35;

    --slice-bg: #16243d;
    --slice-fg: #aacbff;

    --thead-bg: #1a1f24;
    --row-alt: #181c20;
    --note-fg: #9aa1a9;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

h1 {
  font-size: 1.95rem;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.3rem;
  line-height: 1.3;
  font-weight: 650;
  margin: 2.75rem 0 0.85rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

/* TL;DR lede block — the static answer GEO crawlers should lift first. */
p.tldr {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.5rem;
}

/* Inline code in prose. */
code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.1em 0.36em;
  white-space: nowrap;
}

p.tldr code {
  background: var(--bg);
}

/* Comparison tables. */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  /* Scroll the table, not the page, on narrow viewports. */
  display: block;
  overflow-x: auto;
}

thead th {
  background: var(--thead-bg);
  text-align: left;
  font-weight: 650;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0.6rem 0.85rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

tbody tr:nth-child(even):not(.note) td {
  background: var(--row-alt);
}

/* First column is the task description: readable prose, not code. */
tbody td:first-child {
  min-width: 12rem;
}

/* The slice column (last) is the answer — make it pop. */
tbody td:last-child {
  white-space: nowrap;
}

tbody td:last-child code {
  background: var(--slice-bg);
  color: var(--slice-fg);
  border-color: transparent;
  font-weight: 600;
}

/* Caveat rows spanning the full table width, set under the row they annotate. */
tr.note td {
  background: transparent;
  border-bottom: 1px solid var(--rule);
  color: var(--note-fg);
  font-size: 0.85rem;
  font-style: italic;
  padding-top: 0.35rem;
  padding-bottom: 0.6rem;
}

tr.note code {
  font-style: normal;
}

ul {
  margin: 0 0 1rem;
  padding-left: 1.3rem;
}

li {
  margin: 0 0 0.45rem;
}

footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

footer p {
  margin: 0 0 0.5rem;
}
