/* ---------------------------------------------------------------------------
   cheatsheets — shared stylesheet
   One column, hairline rules, monospaced key chips. No JS, no dependencies.
   Tweak the custom properties below and every sheet follows.
   --------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;

  --bg: #fbfbfc;
  --text: #17171b;
  --muted: #71717f;
  --line: rgba(20, 20, 30, 0.09);
  --hover: rgba(20, 20, 30, 0.03);
  --accent: #6c4ff6;

  --kbd-bg: #fff;
  --kbd-line: rgba(20, 20, 30, 0.15);
  --kbd-shadow: 0 1px 0 rgba(20, 20, 30, 0.05);

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --text: #ededf2;
    --muted: #9797a4;
    --line: rgba(255, 255, 255, 0.1);
    --hover: rgba(255, 255, 255, 0.035);
    --accent: #a996ff;

    --kbd-bg: #1c1c21;
    --kbd-line: rgba(255, 255, 255, 0.14);
    --kbd-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: clamp(2.5rem, 7vw, 5rem) 1.5rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* --- masthead ------------------------------------------------------------ */

.masthead {
  margin-bottom: clamp(2.5rem, 6vw, 3.5rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.5rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* --- sections ------------------------------------------------------------ */

section + section {
  margin-top: clamp(2.25rem, 5vw, 3rem);
}

section > h2 {
  margin: 0 0 0.625rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* --- shortcut tables ----------------------------------------------------- */
/* One <tr> per shortcut. The hairline above the first row doubles as the
   underline for the section label, so sections stay visually anchored. */

.shortcuts {
  width: 100%;
  border-collapse: collapse;
}

.shortcuts caption,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.shortcuts td {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
  vertical-align: baseline;
}

.shortcuts tr:hover td {
  background: var(--hover);
}

.shortcuts .action {
  padding-right: 1.5rem;
}

.shortcuts .note {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

.shortcuts .keys {
  width: 1%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-align: right;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 0.2em 0.45em;
  border: 1px solid var(--kbd-line);
  border-radius: 6px;
  background: var(--kbd-bg);
  box-shadow: var(--kbd-shadow);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
}

/* Chips packed tight — "any one of these keys", e.g. the arrow cluster. */
.keygroup {
  display: inline-flex;
  gap: 0.25rem;
}

/* --- index -------------------------------------------------------------- */

.sheets {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sheets li {
  border-top: 1px solid var(--line);
}

.sheets a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 0;
  text-decoration: none;
}

.sheets a:hover {
  color: inherit;
}

.sheets .name {
  font-weight: 550;
}

.sheets a:hover .name {
  color: var(--accent);
}

.sheets .desc {
  color: var(--muted);
  font-size: 0.875rem;
}

.sheets .arrow {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* --- footer -------------------------------------------------------------- */

footer {
  margin-top: clamp(3rem, 8vw, 4.5rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
}

footer p {
  margin: 0 0 0.4rem;
}

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 34rem) {
  .shortcuts tr {
    display: grid;
    gap: 0.4rem;
    padding: 0.8rem 0;
    border-top: 1px solid var(--line);
  }

  .shortcuts td {
    padding: 0;
    border-top: 0;
  }

  .shortcuts .keys {
    width: auto;
    text-align: left;
    white-space: normal;
  }
}

/* --- print --------------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff;
    --text: #000;
    --muted: #444;
    --line: rgba(0, 0, 0, 0.25);
    --hover: transparent;
    --kbd-bg: #fff;
    --kbd-line: rgba(0, 0, 0, 0.4);
    --kbd-shadow: none;
  }

  body {
    max-width: none;
    padding: 0;
  }

  section {
    break-inside: avoid;
  }
}
