/* The cheat sheet dialog. Shares .overlay for the backdrop; everything below is
   the panel, which is its own scroll container so the action bar can stick. */

.cheatsheet { align-items: start; overflow: hidden; }

.cheatsheet-panel {
  position: relative;
  width: min(1180px, 100%);
  max-height: calc(100dvh - var(--u) * 4);
  overflow-y: auto;
  padding: 0 calc(var(--u) * 4) calc(var(--u) * 4);
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
}

.cheatsheet-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: var(--u);
  align-items: center;
  padding: calc(var(--u) * 2) 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.cheatsheet-bar .kicker { margin-right: auto; }
/* The download is an anchor so it works without JavaScript and can be
   right-clicked like any other link — it just wears the button. */
.cheatsheet-bar a.btn { display: inline-block; text-decoration: none; }
.cheatsheet-bar .overlay-close { position: static; flex: none; }

.cheatsheet-title {
  margin-top: calc(var(--u) * 3);
  font-size: var(--fs-headline);
  font-weight: 900;
  line-height: .96;
  letter-spacing: -1px;
}

.cheatsheet-body {
  margin-top: calc(var(--u) * 3);
  column-count: 2;
  column-gap: calc(var(--u) * 3);
}

/* ── byline ───────────────────────────────────────────────────────────────── */
.cs-byline {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  column-span: all;
  margin-bottom: calc(var(--u) * 2);
  padding: calc(var(--u) * 1.5);
  border: 1px solid var(--border);
  background: var(--bg-panel);
}

/* The one round thing in a project of square corners: it reads as a person,
   which is the point, and nothing else on the page is circular to confuse it. */
.cs-portrait {
  flex: none;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
}

.cs-byline-text { min-width: 0; }
.cs-byline-channel { color: var(--accent-1); }
.cs-byline-line { margin-top: 2px; font-size: var(--fs-small); color: var(--text-secondary); }
.cs-byline-link {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--fs-small);
  color: var(--accent-2);
}
/* Printed, where a link is not clickable and the address is the only way back. */
.cs-byline-url {
  display: none;
  font-family: var(--mono);
  font-size: var(--fs-kicker);
  color: var(--text-muted);
}

.cs-link {
  margin-bottom: calc(var(--u) * 2);
  column-span: all;
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cs-link code { color: var(--accent-2); font-family: inherit; text-transform: none; }

/* Paper only — styles/print.css reveals it. */
.cs-footer {
  display: none;
  column-span: all;
  padding-top: 3mm;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--fs-kicker);
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ── section ──────────────────────────────────────────────────────────────── */
.cs-section {
  break-inside: avoid-column;
  margin-bottom: calc(var(--u) * 3);
  padding: calc(var(--u) * 2);
  border: 1px solid var(--border);
  background: var(--bg-panel);
}

/* The command list is long enough that keeping it in one column would strand
   half a page of whitespace beside it. */
#cs-commands { column-span: all; }
#cs-commands .cs-rows { column-count: 2; column-gap: calc(var(--u) * 3); }

.cs-head { display: flex; align-items: baseline; gap: var(--u); flex-wrap: wrap; }
.cs-kicker { flex: 1 1 auto; }

.cs-anchor {
  flex: none;
  padding: 0 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  font-family: var(--mono);
  cursor: pointer;
}
.cs-anchor:hover { color: var(--accent-1); border-color: var(--accent-1); }

.cs-title {
  flex: 1 0 100%;
  margin-top: 4px;
  font-size: calc(var(--fs-body) * 1.35);
  font-weight: 900;
  letter-spacing: -.5px;
}

.cs-blurb {
  margin-top: var(--u);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

/* ── rows ─────────────────────────────────────────────────────────────────── */
.cs-rows { margin-top: calc(var(--u) * 2); }

.cs-rows-head {
  display: grid;
  grid-template-columns: minmax(0, 16ch) 1fr;
  gap: var(--u);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.cs-row {
  display: grid;
  grid-template-columns: minmax(0, 16ch) 1fr;
  gap: var(--u);
  break-inside: avoid;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.cs-row:last-child { border-bottom: 0; }

.cs-term {
  font-family: var(--mono);
  font-size: var(--fs-small);
  overflow-wrap: anywhere;
}
.cs-term code { font-family: inherit; color: inherit; }

.cs-detail { margin: 0; }
.cs-gloss { font-size: var(--fs-small); color: var(--text-secondary); }
.cs-meta,
.cs-note { margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.cs-note { font-family: var(--sans); font-size: var(--fs-small); }

.cs-detail code,
.cs-notes code,
.cs-callout code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-family: var(--mono);
  font-size: .9em;
  color: var(--accent-1);
}

/* ── group ────────────────────────────────────────────────────────────────── */
.cs-group { break-inside: avoid; margin-top: calc(var(--u) * 2); }
.cs-group-label {
  padding: 4px 8px;
  border-left: 3px solid currentColor;
  background: var(--bg-surface);
}
.cs-group .cs-rows { margin-top: var(--u); }

/* ── notes ────────────────────────────────────────────────────────────────── */
.cs-notes { margin-top: calc(var(--u) * 2); display: grid; gap: 8px; }
.cs-notes li {
  position: relative;
  padding-left: 16px;
  break-inside: avoid;
  font-size: var(--fs-small);
  color: var(--text-secondary);
}
.cs-notes li::before {
  content: '';
  position: absolute;
  left: 0; top: .6em;
  width: 7px; height: 1px;
  background: var(--accent-2);
}

/* ── callout ──────────────────────────────────────────────────────────────── */
.cs-callout {
  break-inside: avoid;
  margin-top: calc(var(--u) * 2);
  padding: calc(var(--u) * 1.5);
  border: 1px solid var(--accent-warn);
  background: var(--wash-warn);
}
.cs-callout-title {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: 1.5px;
  color: var(--accent-warn);
}
.cs-callout-body { margin-top: 6px; font-size: var(--fs-small); }

/* ── breakpoints ──────────────────────────────────────────────────────────── */
@media (max-width: 1199px) {
  .cheatsheet-body,
  #cs-commands .cs-rows { column-count: 1; }
}

@media (max-width: 859px) {
  .cheatsheet-panel { padding: 0 calc(var(--u) * 2) calc(var(--u) * 2); }
  .cheatsheet-bar { flex-wrap: wrap; }
  .cheatsheet-bar .kicker { flex: 1 0 100%; }
  .cs-rows-head { display: none; }
  .cs-row { grid-template-columns: 1fr; gap: 2px; }
}
