/* ════════════════════════════════════════════════════════════════════════
   OpsGrep — Cheat Sheet Page Template
   Applied only on pages using page-cheatsheet.php template.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Layout: wide content + sticky sidebar ───────────────────────────────── */
.opsgrep-cheatsheet-page .ct-content-area,
.opsgrep-cheatsheet-page #main {
  max-width: 100% !important;
  padding: 0 !important;
}

.og-cs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-areas: 'sidebar content';
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
  min-height: calc(100vh - 64px);
}

/* ── Sticky sidebar ──────────────────────────────────────────────────────── */
.og-cs-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 64px;               /* height of the sticky header */
  height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--og-bg2);
  border-right: 1px solid var(--og-border);
  padding: 1.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--og-border2) transparent;
}

.og-cs-sidebar::-webkit-scrollbar { width: 4px; }
.og-cs-sidebar::-webkit-scrollbar-thumb { background: var(--og-border2); border-radius: 2px; }

.og-cs-sidebar__header {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--og-border);
  margin-bottom: .75rem;
}

.og-cs-sidebar__tech {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--og-faint);
  font-family: var(--og-font-mono);
  margin-bottom: .25rem;
}

.og-cs-sidebar__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--og-text);
  line-height: 1.3;
}

/* TOC nav list */
.og-cs-sidebar__nav {
  list-style: none;
  padding: 0 .5rem;
  margin: 0;
}

.og-cs-sidebar__nav li a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  font-size: .82rem;
  color: var(--og-muted);
  text-decoration: none;
  border-radius: var(--og-radius);
  transition: background .12s, color .12s;
  line-height: 1.35;
}

.og-cs-sidebar__nav li a:hover,
.og-cs-sidebar__nav li a.is-active {
  background: var(--og-bg3);
  color: var(--og-text);
  text-decoration: none;
}

.og-cs-sidebar__nav li a.is-active { color: var(--og-accent); }

.og-cs-sidebar__nav li a::before {
  content: '#';
  font-family: var(--og-font-mono);
  font-size: .75rem;
  color: var(--og-border2);
  flex-shrink: 0;
  transition: color .12s;
}

.og-cs-sidebar__nav li a:hover::before,
.og-cs-sidebar__nav li a.is-active::before { color: var(--og-accent); }

/* Danger & FAQ links */
.og-cs-sidebar__nav .nav-danger a { color: var(--og-danger); }
.og-cs-sidebar__nav .nav-danger a::before { color: var(--og-danger); opacity: .6; content: '⚠'; }
.og-cs-sidebar__nav .nav-faq a::before { content: '?'; }

/* ── Main content area ───────────────────────────────────────────────────── */
.og-cs-main {
  grid-area: content;
  padding: 2rem 2.5rem 4rem;
  max-width: 980px;
  min-width: 0;
}

/* Cheatsheet H1 */
.og-cs-main .entry-title,
.og-cs-main h1 {
  font-size: clamp(1.5rem, 3vw, 2.1rem) !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  color: var(--og-text) !important;
  margin-bottom: .5rem !important;
  padding-bottom: 0 !important;
  border-bottom: none !important;
}

.og-cs-main .entry-content h1 {
  font-size: clamp(1.5rem, 3vw, 2.1rem) !important;
  border-bottom: 1px solid var(--og-border) !important;
  padding-bottom: .75rem !important;
  margin-bottom: 1rem !important;
}

/* AEO intro paragraph */
.og-cs-main .entry-content > p:first-of-type {
  color: var(--og-muted);
  font-size: .95rem;
  line-height: 1.7;
  padding: .875rem 1rem;
  background: var(--og-bg2);
  border-left: 3px solid var(--og-accent);
  border-radius: 0 var(--og-radius) var(--og-radius) 0;
  margin-bottom: 1.75rem;
}

/* ── Inline search bar ───────────────────────────────────────────────────── */
.og-cs-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.75rem;
  position: relative;
}

.og-cs-search__input {
  width: 100%;
  padding: .6rem 1rem .6rem 2.5rem;
  background: var(--og-bg2);
  border: 1px solid var(--og-border);
  border-radius: var(--og-radius);
  color: var(--og-text);
  font-family: var(--og-font-mono);
  font-size: .875rem;
  transition: border-color .15s;
}

.og-cs-search__input:focus {
  border-color: var(--og-accent);
  outline: none;
}

.og-cs-search__input::placeholder { color: var(--og-faint); }

.og-cs-search__icon {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--og-faint);
  pointer-events: none;
  font-size: .875rem;
}

.og-cs-match-count {
  font-size: .75rem;
  color: var(--og-faint);
  white-space: nowrap;
  font-family: var(--og-font-mono);
}

/* ── Inline TOC (from generator) ────────────────────────────────────────── */
.entry-content nav.cs-toc,
.cs-toc {
  background: var(--og-bg2) !important;
  border: 1px solid var(--og-border) !important;
  border-radius: var(--og-radius-lg) !important;
  padding: 1rem 1.5rem !important;
  margin-bottom: 2rem !important;
  display: none !important; /* Hidden — sidebar TOC replaces it on desktop */
}

@media (max-width: 900px) {
  .entry-content nav.cs-toc,
  .cs-toc { display: block !important; }
}

.cs-toc h2 {
  font-size: .75rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: .08em !important;
  color: var(--og-faint) !important;
  margin: 0 0 .6rem !important;
  border: none !important;
  padding: 0 !important;
}

.cs-toc ol {
  margin: 0 !important;
  padding-left: 1.1rem !important;
  column-count: 2;
  column-gap: 1.5rem;
}

.cs-toc li { margin: .2rem 0 !important; }

.cs-toc a {
  color: var(--og-muted) !important;
  font-size: .82rem !important;
  text-decoration: none !important;
  transition: color .12s;
}

.cs-toc a:hover { color: var(--og-accent) !important; }

/* ── Group sections ──────────────────────────────────────────────────────── */
.entry-content section,
.og-cs-main section {
  margin-bottom: 3rem;
  scroll-margin-top: 80px;
}

.entry-content section h2,
.og-cs-main section h2 {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  color: var(--og-text) !important;
  margin: 0 0 1rem !important;
  padding-bottom: .6rem !important;
  border-bottom: 1px solid var(--og-border) !important;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.entry-content section h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--og-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Cheatsheet command table ────────────────────────────────────────────── */
.cheatsheet-table,
table.cheatsheet-table.comparison {
  width: 100% !important;
  border-collapse: collapse !important;
  border: 1px solid var(--og-border) !important;
  border-radius: var(--og-radius-lg) !important;
  overflow: hidden !important;
  margin-bottom: 0 !important;
  display: table !important;
  font-size: .875rem;
}

.cheatsheet-table thead tr {
  background: var(--og-bg3) !important;
}

.cheatsheet-table th {
  font-size: .72rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: .07em !important;
  color: var(--og-muted) !important;
  padding: .55rem .875rem !important;
  border: none !important;
  border-bottom: 1px solid var(--og-border) !important;
  white-space: nowrap;
  background: none !important;
}

/* Column widths */
.cheatsheet-table th:nth-child(1) { width: 18%; }
.cheatsheet-table th:nth-child(2) { width: 57%; }
.cheatsheet-table th:nth-child(3) { width: 25%; }

.cheatsheet-table td {
  padding: .5rem .875rem !important;
  border: none !important;
  border-bottom: 1px solid var(--og-border) !important;
  vertical-align: middle !important;
  color: var(--og-text-soft) !important;
  background: transparent !important;
}

.cheatsheet-table tbody tr:last-child td { border-bottom: none !important; }

.cheatsheet-table tbody tr {
  background: transparent;
  transition: background .1s;
}

.cheatsheet-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,.015);
}

.cheatsheet-table tbody tr:hover { background: var(--og-bg3) !important; }

/* Action column */
.cheatsheet-table td:first-child {
  font-size: .8rem;
  font-weight: 500;
  color: var(--og-muted) !important;
  white-space: nowrap;
}

/* Command column — code block inside table */
.cheatsheet-table td:nth-child(2) pre.copycoded {
  background: var(--og-bg3) !important;
  border: 1px solid var(--og-border) !important;
  border-radius: 4px !important;
  padding: .35rem .65rem !important;
  margin: 0 !important;
  font-size: .82rem !important;
  line-height: 1.4 !important;
  white-space: pre-wrap;
  word-break: break-all;
}

.cheatsheet-table td:nth-child(2) pre.copycoded code {
  color: #79C0FF !important;
}

/* Flags column */
.cheatsheet-table td:nth-child(3) code {
  font-family: var(--og-font-mono);
  font-size: .78rem;
  color: var(--og-muted) !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Dangerous row */
.cheatsheet-table .cs-danger-row {
  background: var(--og-danger-dim) !important;
}

.cheatsheet-table .cs-danger-row td { color: #FFA8A8 !important; }

.cheatsheet-table .cs-danger-row td:nth-child(2) pre.copycoded {
  background: rgba(248,81,73,.08) !important;
  border-color: rgba(248,81,73,.25) !important;
}

.cheatsheet-table .cs-danger-row td:nth-child(2) pre.copycoded code {
  color: #FF9580 !important;
}

/* ── Danger section ──────────────────────────────────────────────────────── */
section.cs-danger,
.entry-content .cs-danger {
  background: var(--og-danger-dim) !important;
  border: 1px solid rgba(248,81,73,.3) !important;
  border-left: 4px solid var(--og-danger) !important;
  border-radius: 0 var(--og-radius-lg) var(--og-radius-lg) 0 !important;
  padding: 1.25rem 1.5rem !important;
  margin: 2rem 0 !important;
}

section.cs-danger h2,
.cs-danger h2 {
  color: var(--og-danger) !important;
  margin-top: 0 !important;
  font-size: 1.1rem !important;
  border: none !important;
}

section.cs-danger h2::before { background: var(--og-danger) !important; }

section.cs-danger p { color: var(--og-muted) !important; }

/* ── Row hidden by search ────────────────────────────────────────────────── */
.cheatsheet-table tr.og-hidden { display: none; }
.og-section-hidden { opacity: .35; }

/* ── Highlighted search match ────────────────────────────────────────────── */
mark.og-match {
  background: rgba(16,185,129,.25);
  color: var(--og-accent);
  border-radius: 2px;
  padding: 0 .15em;
}

/* ── FAQ (cheatsheet) ────────────────────────────────────────────────────── */
#faq h2 {
  font-size: 1.2rem !important;
  border-bottom: 1px solid var(--og-border) !important;
  padding-bottom: .6rem !important;
}

.og-cs-main .wp-block-faq-item {
  background: var(--og-bg2) !important;
  border: 1px solid var(--og-border) !important;
}

/* ── Print overrides ─────────────────────────────────────────────────────── */
@media print {
  .og-cs-sidebar, .og-cs-search { display: none !important; }
  .og-cs-layout { grid-template-columns: 1fr; }
  .og-cs-main { padding: 0; }
  pre.copycoded { background: #f4f4f4 !important; color: #000 !important; border: 1px solid #ccc !important; }
  .copycoded-btn { display: none !important; }
  .cheatsheet-table th { background: #e2e8f0 !important; color: #000 !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .og-cs-layout {
    grid-template-columns: 1fr;
    grid-template-areas: 'content';
  }

  .og-cs-sidebar { display: none; } /* Inline TOC takes over */
  .og-cs-main { padding: 1.5rem 1.25rem 3rem; max-width: 100%; }
  .cs-toc ol { column-count: 1; }
}

@media (max-width: 600px) {
  .cheatsheet-table { font-size: .8rem; }
  .cheatsheet-table th:nth-child(3),
  .cheatsheet-table td:nth-child(3) { display: none; } /* Hide flags on mobile */
  .cheatsheet-table th:nth-child(1) { width: 25%; }
  .cheatsheet-table th:nth-child(2) { width: 75%; }
  .og-cs-main { padding: 1.25rem 1rem 2.5rem; }
}
