/* SQL cheat sheets (/sql-cheat-sheets): the hub, a side-by-side dialect table and one
   sheet per engine. Screen: full-width, a sticky contents rail beside multi-column
   snippet blocks. Print: the chrome drops out and the blocks flow into two columns
   (three in landscape) as a reference card. */

/* ---------- Full-width frame ---------- */
.cheat-page .wrap { max-width: none; padding: 0 clamp(16px, 2vw, 32px); }
.cheat-page .page-head .lede { max-width: 60ch; text-wrap: pretty; }
.cheat-page .tools-intro { max-width: 60ch; text-wrap: pretty; }
.cheat-print-source { display: none; }

/* SQL reads literally: no ">=" or "<>" drawn as a ligature, and long lines wrap
   inside their box instead of scrolling, so nothing needs a horizontal scrollbar. */
.cheat-sql {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: .82rem;
  line-height: 1.55;
  font-variant-ligatures: none;
  margin: 0;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

/* ---------- Engine switcher (sheet pages) ---------- */
.cheat-engines { margin: 26px 0 0; }
.cheat-engines ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.cheat-engines a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--heading);
  font-weight: 600;
  font-size: .94rem;
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.cheat-engines a:hover { border-color: var(--blue-bright); text-decoration: none; }
.cheat-engines a[aria-current="page"] { background: var(--heading); border-color: var(--heading); color: var(--cream); }

/* ---------- Sheet layout: contents rail + snippet columns ---------- */
.cheat-page .cheat-sheet { padding-top: clamp(32px, 4vw, 48px); }
.cheat-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }

.cheat-toc-title {
  font-family: "JetBrains Mono", monospace;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.cheat-toc ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.cheat-toc a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: .9rem;
  text-decoration: none;
}
.cheat-toc a:hover { border-color: var(--blue-bright); text-decoration: none; }
.cheat-toc a[aria-current="true"] { color: var(--heading); border-color: var(--heading); font-weight: 600; }

.cheat-sections { column-width: 25rem; column-gap: clamp(24px, 2.4vw, 40px); }
.cheat-block { break-inside: avoid; margin: 0 0 34px; padding: 0; scroll-margin-top: 90px; }
.cheat-page .cheat-block h2 {
  font-size: 1.3rem;
  margin: 0 0 4px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--heading);
}
.cheat-rows { margin: 0; }
.cheat-row { padding: 10px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.cheat-row:last-child { border-bottom: none; }
.cheat-row dt { font-size: .93rem; font-weight: 600; color: var(--heading); margin: 0 0 6px; }
.cheat-row dd { margin: 0; display: flex; gap: 8px; align-items: flex-start; }
.cheat-row dd .cheat-sql { flex: 1 1 auto; min-width: 0; }

/* Copy buttons are added by cheat-sheets.js, so a script-less page shows none. */
.cheat-copy {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: 600 .8rem/1 "Inter", system-ui, sans-serif;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.cheat-copy:hover { color: var(--heading); border-color: var(--blue-bright); }
.cheat-copy[data-state="done"] { color: var(--green); border-color: var(--green); }
.cheat-copy[data-state="failed"] { color: var(--pink-ink); border-color: var(--pink-ink); }
@media (pointer: coarse) { .cheat-copy { min-height: 44px; } }

.cheat-quirks { margin-top: 14px; padding: clamp(32px, 4vw, 48px) 0 0; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.cheat-page .cheat-quirk-list {
  max-width: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
  gap: 0 clamp(24px, 2.4vw, 40px);
}
.cheat-page .cheat-quirk-list li { max-width: 60ch; border-bottom: 1px solid var(--line); text-wrap: pretty; }
.cheat-page .cheat-quirk-list li:last-child { border-bottom: 1px solid var(--line); }

@media (min-width: 1100px) {
  .cheat-layout { grid-template-columns: 13.5rem minmax(0, 1fr); gap: clamp(32px, 3vw, 56px); align-items: start; }
  .cheat-toc { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; }
  .cheat-toc ol { display: block; border-left: 1px solid var(--line); }
  .cheat-toc a {
    display: flex;
    min-height: 34px;
    padding: 4px 0 4px 14px;
    margin-left: -1px;
    border: none;
    border-left: 1px solid transparent;
    border-radius: 0;
    color: var(--muted);
  }
  .cheat-toc a:hover { color: var(--heading); }
  .cheat-toc a[aria-current="true"] { color: var(--heading); border-left-color: var(--heading); }
}

/* ---------- Other sheets ---------- */
.cheat-links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 28px; }
.cheat-links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* ---------- Hub ---------- */
.cheat-page .cheat-hub { padding-top: clamp(32px, 4vw, 48px); }
.cheat-page .cheat-hub-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 18px; }
.cheat-card { padding: 24px; }
.cheat-card-sig { font-size: .78rem; background: var(--cream); }
.cheat-card p { text-wrap: pretty; }
.cheat-card-meta { font-size: .86rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.cheat-compare-scroll { overflow-x: auto; border-radius: 12px; }
.cheat-compare-scroll:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.cheat-compare { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cheat-compare th, .cheat-compare td { text-align: left; vertical-align: top; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.cheat-compare thead th {
  font-family: "JetBrains Mono", monospace;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1.5px solid var(--heading);
  padding-top: 0;
}
.cheat-compare thead th:first-child { width: 11rem; color: var(--muted); }
.cheat-compare tbody th { font-weight: 600; color: var(--heading); font-size: .95rem; }
.cheat-compare .cheat-sql { font-size: .78rem; padding: 8px 10px; }
.cheat-compare-note { display: block; font-size: .8rem; color: var(--muted); margin: 0 0 6px; }
.cheat-compare-none { font-size: .86rem; color: var(--muted); }

/* Below desktop the five-column table becomes one block per task, each cell
   labelled with its engine, so a phone never scrolls sideways. */
@media (max-width: 1099px) {
  .cheat-compare, .cheat-compare tbody, .cheat-compare tr, .cheat-compare th, .cheat-compare td { display: block; width: 100%; }
  .cheat-compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cheat-compare tr { padding: 0 0 18px; margin: 0 0 18px; border-bottom: 1.5px solid var(--heading); }
  .cheat-compare tbody th { font-family: "Fredoka", "Inter", system-ui, sans-serif; font-size: 1.15rem; padding: 0 0 8px; border: none; }
  .cheat-compare td { padding: 8px 0; border-bottom: none; }
  .cheat-compare td::before {
    content: attr(data-engine);
    display: block;
    font-family: "JetBrains Mono", monospace;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 0 0 4px;
  }
}
@media (min-width: 700px) and (max-width: 1099px) {
  .cheat-compare tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .cheat-compare tbody th { grid-column: 1 / -1; }
}

/* ---------- FAQ ---------- */
.cheat-page .tools-faq { max-width: none; grid-template-columns: repeat(auto-fill, minmax(min(100%, 25rem), 1fr)); }
.cheat-page .tools-faq .card p { max-width: 60ch; text-wrap: pretty; }
.cheat-faq { scroll-margin-top: 70px; }

.cheat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .cheat-engines a, .cheat-copy { transition: none; }
}

/* ---------- Print: a reference card ---------- */
@page { margin: 12mm 11mm; }

@media print {
  /* Light ink on any theme: :not(#_) outranks the dark-mode token selectors. */
  :root:not(#_) {
    --cream: #fff;
    --card: #fff;
    --ink: #111;
    --muted: #444;
    --heading: #000;
    --line: #c8c8c8;
    --link: #000;
  }
  body { background: #fff; }
  header.nav, footer, .tools-cta, .tools-crumbs, .cheat-other, .cheat-engines, .cheat-toc,
  .cheat-copy, .cheat-faq, .tools-xref-sec, .cheat-sr, .page-head .eyebrow { display: none !important; }

  .cheat-page .wrap { padding: 0; }
  .page-head { padding: 0 0 4pt; }
  .page-head h1 { font-size: 17pt; margin: 0 0 3pt; }
  .page-head .lede { font-size: 8.5pt; line-height: 1.4; max-width: none; }
  .cheat-print-source { display: block; font-family: "JetBrains Mono", monospace; font-size: 7.5pt; margin: 2pt 0 0; }

  .tools-sec { padding: 6pt 0 0; border-top: none; }
  .cheat-page .cheat-sheet, .cheat-page .cheat-hub { padding-top: 4pt; }
  .cheat-layout { display: block; }
  .cheat-sections { columns: 2; column-gap: 7mm; column-rule: .5pt solid #c8c8c8; }
  .cheat-block { margin: 0 0 7pt; break-inside: auto; }
  .cheat-page .cheat-block h2 { font-size: 10.5pt; margin: 0; padding-bottom: 2pt; border-bottom-width: 1pt; break-after: avoid; }
  .cheat-row { padding: 2.5pt 0; border-bottom: .5pt solid #c8c8c8; break-inside: avoid; }
  .cheat-row dt { font-size: 7.5pt; margin: 0 0 1pt; }
  .cheat-sql {
    font-size: 7pt;
    line-height: 1.35;
    padding: 1.5pt 3pt;
    border: none;
    background: #f3f3f3;
    border-radius: 2pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .cheat-quirks { margin-top: 4pt; padding-top: 4pt; border-top: 1pt solid #000; break-before: avoid; }
  .tools-sec h2, .cheat-quirks h2 { font-size: 11pt; margin: 0 0 3pt; break-after: avoid; }
  .cheat-page .cheat-quirk-list { display: block; columns: 2; column-gap: 7mm; }
  .cheat-page .cheat-quirk-list li { font-size: 7.5pt; line-height: 1.4; padding: 2.5pt 0; break-inside: avoid; border-bottom: .5pt solid #c8c8c8; }

  .cheat-page .cheat-hub-grid { grid-template-columns: repeat(3, 1fr); gap: 6pt; }
  .tools-hub-card { box-shadow: none; padding: 6pt; break-inside: avoid; }
  .tools-hub-card .tools-more { display: none; }
  .cheat-compare-scroll { overflow: visible; }
  .cheat-compare { table-layout: auto; }
  .cheat-compare th, .cheat-compare td { padding: 3pt; font-size: 7.5pt; }
  .cheat-compare tr { break-inside: avoid; }
  .cheat-compare .cheat-sql { font-size: 6.5pt; }
  a { text-decoration: none; }
}

@media print and (orientation: landscape) {
  .cheat-sections, .cheat-page .cheat-quirk-list { columns: 3; }
}
