/* ============ Docs layout — loaded only on /docs/ article pages ============
   Reuses site.css custom properties (--surface, --border, --accent-*, --font-mono,
   --header-h, --max-w) and the existing .mk-code block styling. */

.docs-wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--site-pad-x); }
.docs-layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 196px;
  gap: 40px; align-items: start;
  padding: 28px 0 96px;
}

/* ---- Left sidebar ---- */
.docs-sidebar {
  position: sticky; top: calc(var(--header-h) + 18px); align-self: start;
  max-height: calc(100vh - var(--header-h) - 36px); overflow-y: auto;
  padding-right: 6px;
}
.docs-sidebar .ds-section { margin-bottom: 20px; }
.docs-sidebar .ds-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--text-muted); margin: 0 0 6px; padding: 0 10px;
}
.docs-sidebar a, .docs-sidebar .ds-soon {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: 6px; line-height: 1.35;
  font-size: 13.5px; color: var(--text-secondary); text-decoration: none;
}
.docs-sidebar a:hover { background: var(--bg-subtle); color: var(--text); }
.docs-sidebar a.is-active { background: var(--accent-soft); color: var(--accent-fg); font-weight: 600; }
.docs-sidebar .ds-soon { color: var(--text-muted); opacity: 0.55; cursor: default; }
.docs-sidebar .ds-soon span {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-muted); color: var(--text-muted); padding: 1px 5px; border-radius: 999px;
}

/* ---- Content ---- */
.docs-content { min-width: 0; }
.docs-content .docs-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600; color: var(--accent-fg); margin-bottom: 10px;
}
.docs-content h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 10px; line-height: 1.15; }
.docs-content .docs-lead { font-size: 16px; line-height: 1.6; color: var(--text-secondary); margin: 0 0 30px; }
.docs-content h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin: 42px 0 14px; scroll-margin-top: calc(var(--header-h) + 18px); }
.docs-content h3 { font-size: 15.5px; font-weight: 600; margin: 26px 0 8px; scroll-margin-top: calc(var(--header-h) + 18px); }
.docs-content p, .docs-content li { font-size: 14.5px; line-height: 1.72; color: var(--text-secondary); }
.docs-content strong { color: var(--text); font-weight: 600; }
.docs-content a { color: var(--accent-fg); text-decoration: underline; text-underline-offset: 2px; }
.docs-content ul, .docs-content ol { padding-left: 22px; margin: 0 0 18px; }
.docs-content li { margin-bottom: 6px; }
.docs-content :not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-muted); padding: 2px 6px; border-radius: 4px; color: var(--text);
}
.docs-content .mk-code { margin: 0 0 20px; position: relative; }
.docs-content hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }

/* Numbered step heads */
.docs-step { display: flex; align-items: center; gap: 10px; margin: 40px 0 14px; scroll-margin-top: calc(var(--header-h) + 18px); }
.docs-step .ds-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
}
.docs-step h2 { margin: 0; }

/* Callouts */
.docs-note, .docs-warn {
  border-radius: 8px; padding: 13px 16px; margin: 0 0 20px;
  font-size: 13.5px; line-height: 1.6; display: flex; gap: 10px; color: var(--text);
}
.docs-note { background: var(--blue-soft); }
.docs-warn { background: var(--amber-soft); }
.docs-note strong, .docs-warn strong { color: var(--text); }

/* Param / response tables */
.docs-content table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 13.5px; }
.docs-content th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.docs-content td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: top; }
.docs-content td code { white-space: nowrap; }

/* Prev/next footer */
.docs-pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.docs-pager a { flex: 1; text-decoration: none; color: inherit; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.docs-pager a:hover { border-color: var(--border-strong); }
.docs-pager .dp-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.docs-pager .dp-title { font-size: 14px; font-weight: 600; color: var(--text); }
.docs-pager .dp-next { text-align: right; }

/* ---- Right "on this page" TOC ---- */
.docs-toc { position: sticky; top: calc(var(--header-h) + 18px); align-self: start; font-size: 12.5px; }
.docs-toc .dt-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }
.docs-toc a { display: block; padding: 4px 0 4px 10px; border-left: 2px solid var(--border); color: var(--text-muted); text-decoration: none; line-height: 1.4; }
.docs-toc a.lvl-3 { padding-left: 22px; }
.docs-toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.docs-toc a.is-active { color: var(--accent-fg); border-left-color: var(--accent); }

/* Copy button injected onto code blocks */
.docs-copy {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 5px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary);
  opacity: 0; transition: opacity 120ms ease;
}
.docs-content .mk-code:hover .docs-copy { opacity: 1; }
.docs-copy:hover { color: var(--text); border-color: var(--border-strong); }

/* ---- Search command palette (⌘K) ---- */
.docs-search-modal { position: fixed; inset: 0; z-index: 1000; display: none; }
.docs-search-modal.is-open { display: block; }
.dsm-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.dsm-box {
  position: relative; max-width: 560px; margin: 12vh auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-xl); overflow: hidden;
}
.dsm-input {
  width: 100%; height: 52px; padding: 0 18px; box-sizing: border-box;
  border: 0; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--text); font-size: 15px; font-family: var(--font-sans); outline: none;
}
.dsm-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.dsr-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text);
}
.dsr-item.is-sel { background: var(--accent-soft); }
.dsr-title { font-size: 14px; font-weight: 500; }
.dsr-item.is-sel .dsr-title { color: var(--accent-fg); }
.dsr-sec { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.dsr-empty { padding: 22px 16px; color: var(--text-muted); font-size: 13px; line-height: 1.6; text-align: center; }
.dsr-empty a { color: var(--accent-fg); text-decoration: underline; text-underline-offset: 2px; }
.dsm-hint { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }

/* Sidebar collapses to a tap-to-open menu (+ a search button) below the 3-col layout. */
.docs-nav-bar { display: none; }

@media (max-width: 1080px) {
  .docs-layout { grid-template-columns: 1fr; gap: 0; }
  .docs-toc { display: none; }
  .docs-sidebar {
    position: static; max-height: none; overflow: visible;
    margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
  }
  .docs-nav-bar { display: flex; gap: 8px; }
  .docs-nav-toggle {
    flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface); color: var(--text); font-family: var(--font-sans);
    font-weight: 500; font-size: 14px; cursor: pointer;
  }
  .docs-nav-toggle svg { flex-shrink: 0; transition: transform 180ms ease; }
  .docs-sidebar.is-open .docs-nav-toggle svg { transform: rotate(180deg); }
  .docs-nav-search {
    flex-shrink: 0; width: 44px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface); color: var(--text-secondary); cursor: pointer;
  }
  .docs-nav-search:hover { color: var(--text); }
  .docs-nav-groups { display: none; padding-top: 16px; }
  .docs-sidebar.is-open .docs-nav-groups { display: block; }
}

@media (max-width: 480px) {
  .docs-pager { flex-direction: column; }
  .docs-pager .dp-next { text-align: left; }
}
