/* Cheatsheet-specific styles */
.cheatsheet-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  /* Slightly larger breathing room below the hero divider */
  margin-top: 24px;
}
.cheatsheet-nav {
  position: sticky;
  top: var(--nav-sticky-top); /* Adjust based on header height */
  /* Make long TOCs scroll within the viewport instead of the whole page */
  max-height: calc(100vh - 100px);
  /* Only vertical scrolling; prevent stray horizontal bars */
  overflow-y: auto;
  overflow-x: hidden;
  /* slight gutter next to a thin scrollbar */
  padding-right: 4px;
  scroll-behavior: smooth; /* smooth auto-centering when active changes */
}
/* Sane, minimal scrollbars (Firefox) */
.cheatsheet-nav,
pre {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Sane, minimal scrollbars (WebKit/Blink) */
.cheatsheet-nav::-webkit-scrollbar,
pre::-webkit-scrollbar {
  width: 8px;
}
.cheatsheet-nav::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track {
  background: transparent;
}
.cheatsheet-nav::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 8px;
  border: 2px solid transparent; /* create padding visually */
  background-clip: padding-box;
}
.cheatsheet-nav:hover::-webkit-scrollbar-thumb,
pre:hover::-webkit-scrollbar-thumb {
  background-color: var(--text-dim);
}
.cheatsheet-nav h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.cheatsheet-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cheatsheet-nav a {
  display: block;
  padding: 6px 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
  border-radius: 4px;
  font-weight: 500;
}
.cheatsheet-nav a:hover {
  background: var(--bg-alt);
  color: var(--text);
  text-decoration: none;
}
.cheatsheet-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-600);
  font-weight: 600;
}
.cheatsheet-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.cheatsheet-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 32px 0 12px;
}
.cheatsheet-content section:first-of-type h2 {
  margin-top: 8px;
}
.cheatsheet-content section + section {
  margin-top: 48px;
}
pre {
  background: var(--bg-alt);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.45;
  /* Subtle scrollbars in code blocks */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--border) transparent;
}
pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
/* WebKit/Blink horizontal scrollbar styling for code blocks */
pre::-webkit-scrollbar {
  height: 8px; /* horizontal bar height */
}
pre::-webkit-scrollbar-track {
  background: transparent;
}
pre::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
pre:hover::-webkit-scrollbar-thumb {
  background-color: var(--text-dim);
}
pre::-webkit-scrollbar-corner {
  background: transparent;
}
/* Better mobile readability: wrap code lines instead of forcing horizontal scroll */
@media (max-width: 900px) {
  /* Allow wrapping inside blocks while preserving indentation */
  pre,
  pre code {
    white-space: pre-wrap; /* wrap long lines but keep line breaks/indent */
    word-break: break-word; /* break long tokens */
    overflow-wrap: anywhere; /* as a last resort, break anywhere */
  }
  /* Inline code snippets can also overflow in narrow columns */
  code {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}
/* Global .button now in style.css; marketing overrides are scoped */

@media (max-width: 900px) {
  .cheatsheet-grid {
    grid-template-columns: 1fr;
    /* Tighten slightly on smaller screens */
    margin-top: 20px;
  }
  .cheatsheet-nav {
    display: none; /* Hide side nav on mobile */
  }
}

/* Page-specific nav indentation */
.cheatsheet-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cheatsheet-nav ul li {
  margin: 0 0 2px;
}
.cheatsheet-nav > ul > li > a {
  display: block;
  padding-left: 8px;
}
.cheatsheet-nav .subtopics {
  list-style: none;
  margin: 6px 0 12px 18px;
  padding-left: 0;
}
.cheatsheet-nav .subtopics li a {
  display: block;
  padding-left: 0;
}

/* Ensure headings are not obscured by sticky nav when navigated via hash */
/* Nav tweaks specific to cheatsheet/learning layout */
.cheatsheet-nav a:focus-visible {
  outline: 2px solid var(--accent-600);
  outline-offset: 2px;
}
.cheatsheet-nav ul ul {
  margin-left: 10px;
}
