/* ==========================================================================
   docs.css: reference-library pages (ADRs + Onboarding).
   Layers on top of styles.css; reuses the same design tokens, so it is
   theme-aware (light/dark) and needs no colors of its own.
   ========================================================================== */

/* ----- Two-column doc layout ----- */
.doc-container { padding-top: 1.5rem; padding-bottom: 3.5rem; }

.doc-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.doc-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.doc-breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.doc-breadcrumb .current { color: var(--text); font-weight: 600; }
.doc-breadcrumb span[aria-hidden] { color: var(--border); }

.doc-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

/* ----- Sidebar (collection nav) ----- */
.doc-sidebar { position: sticky; top: 80px; }
.doc-sidebar-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.doc-sidebar-details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.doc-sidebar-details > summary::-webkit-details-marker { display: none; }
.doc-sidebar-details > summary::after {
  content: "▾";
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}
.doc-sidebar-details:not([open]) > summary { border-bottom: none; }
.doc-sidebar-details:not([open]) > summary::after { transform: rotate(-90deg); }

.doc-nav {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding: 0.5rem;
}
.doc-nav ol { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.doc-nav li { margin: 0; }
.doc-nav a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
}
.doc-nav a:hover { background: var(--surface-alt); color: var(--text); }
.doc-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ----- Rendered markdown content ----- */
.doc-content { min-width: 0; max-width: 80ch; }
.doc-kicker { margin-bottom: 0.4rem; }

.doc-content h1 { margin: 0 0 1rem; }
.doc-content h2 {
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.doc-content h3 { margin: 1.9rem 0 0.6rem; font-size: 1.18rem; }
.doc-content h4 { margin: 1.5rem 0 0.5rem; font-size: 1.02rem; }
.doc-content h5, .doc-content h6 { margin: 1.2rem 0 0.4rem; font-size: 0.95rem; color: var(--text-muted); }
.doc-content > :first-child { margin-top: 0; }

.doc-content p { margin: 0 0 1.05rem; }
.doc-content ul, .doc-content ol { margin: 0 0 1.1rem; padding-left: 1.5rem; }
.doc-content li { margin-bottom: 0.4rem; }
.doc-content li > ul, .doc-content li > ol { margin-top: 0.4rem; margin-bottom: 0.4rem; }
.doc-content strong { color: var(--text); }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* Anchored headings: subtle scroll offset so the sticky header does not cover them */
.doc-content :is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: 84px; }

/* Inline code */
.doc-content code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.36em;
  overflow-wrap: anywhere;
}
/* Code blocks */
.doc-content pre.doc-pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.25rem;
  line-height: 1.55;
}
.doc-content pre.doc-pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.86rem;
  color: var(--text);
  white-space: pre;
  overflow-wrap: normal;
}

/* Blockquotes / callouts */
.doc-content blockquote {
  margin: 0 0 1.25rem;
  padding: 0.6rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
}
.doc-content blockquote p:last-child { margin-bottom: 0; }
.doc-content blockquote blockquote { border-left-color: var(--border); background: transparent; }

/* Links inside prose keep the underlined base-style; dead cross-refs read as plain text */
.doc-deadlink { color: inherit; }

/* Tables (wrapped in .table-wrap for horizontal scroll) */
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.doc-content table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.doc-content thead th {
  background: var(--surface-alt);
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}
.doc-content th, .doc-content td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.doc-content tbody tr:last-child td { border-bottom: none; }
.doc-content td code { white-space: nowrap; }

/* Mermaid diagrams */
.doc-content pre.mermaid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0 0 1.4rem;
  overflow-x: auto;
  text-align: center;
  /* Before mermaid.run() replaces it, the source stays readable but muted */
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.doc-content pre.mermaid[data-processed="true"] { color: inherit; font-family: inherit; }
.doc-content pre.mermaid svg { max-width: 100%; height: auto; }

/* Footer nav on each doc */
.doc-foot { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* CTA text on hub cards */
.doc-cta { font-weight: 600; color: var(--accent); }

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; gap: 1.25rem; }
  .doc-sidebar { position: static; top: auto; }
  .doc-nav { max-height: 55vh; }
  /* Collapse the collection nav by default on small screens to keep content first */
  .doc-content { max-width: none; }
}
