/* =========================================================================
   Bhairava Docs — layout & prose (loaded after style.css)
   ========================================================================= */

.docs-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 216px;
  gap: 44px;
  max-width: 1360px;
  margin-inline: auto;
  padding: calc(var(--nav-h) + 36px) 28px 96px;
}

/* ---------------- Left sidebar ---------------- */
.docs-sidebar { position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; max-height: calc(100vh - var(--nav-h) - 40px); overflow-y: auto; padding-right: 6px; }
.docs-sidebar::-webkit-scrollbar { width: 6px; } .docs-sidebar::-webkit-scrollbar-thumb { background: hsl(var(--border-strong)); border-radius: 3px; }

.docs-search { position: relative; margin-bottom: 22px; }
.docs-search input {
  width: 100%; padding: 10px 12px 10px 36px; border-radius: 10px; font-size: 0.9rem; font-family: inherit;
  background: hsl(var(--surface) / 0.7); border: 1px solid hsl(var(--border)); color: hsl(var(--foreground));
  transition: border-color .15s, box-shadow .15s;
}
.docs-search input:focus { outline: none; border-color: hsl(var(--primary) / 0.6); box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15); }
.docs-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: hsl(var(--muted-foreground)); pointer-events: none; }
.docs-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 0.68rem; color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); border-radius: 5px; padding: 1px 5px; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; display: none;
  background: hsl(var(--surface)); border: 1px solid hsl(var(--border-strong)); border-radius: 12px;
  box-shadow: var(--shadow-md); overflow: hidden; max-height: 320px; overflow-y: auto;
}
.search-results.show { display: block; }
.search-results a { display: block; padding: 9px 13px; font-size: 0.86rem; border-bottom: 1px solid hsl(var(--border)); }
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a.sel { background: hsl(var(--primary) / 0.12); }
.search-results a small { display: block; color: hsl(var(--muted-foreground)); font-size: 0.72rem; margin-top: 1px; }
.search-results .empty { padding: 13px; color: hsl(var(--muted-foreground)); font-size: 0.85rem; }

.docs-group { margin-bottom: 20px; }
.docs-group > h6 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: hsl(var(--muted-foreground)); margin-bottom: 8px; font-weight: 700; }
.docs-group ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.docs-group ul a {
  display: block; padding: 7px 12px; border-radius: 8px; font-size: 0.9rem; color: hsl(var(--muted-foreground));
  border-left: 2px solid transparent; transition: color .12s, background .12s, border-color .12s;
}
.docs-group ul a:hover { color: hsl(var(--foreground)); background: hsl(var(--muted) / 0.6); }
.docs-group ul a.active { color: hsl(var(--primary)); background: hsl(var(--primary) / 0.1); border-left-color: hsl(var(--primary)); font-weight: 600; }

/* ---------------- Content ---------------- */
.doc-content { min-width: 0; }
.doc-breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: hsl(var(--muted-foreground)); margin-bottom: 20px; }
.doc-breadcrumb a:hover { color: hsl(var(--primary)); }
.doc-breadcrumb svg { width: 13px; height: 13px; opacity: 0.6; }

.doc-content h1 { font-size: clamp(1.9rem, 3.6vw, 2.5rem); margin-bottom: 14px; letter-spacing: -0.03em; }
.doc-content .lead { font-size: 1.15rem; color: hsl(var(--muted-foreground)); margin-bottom: 36px; line-height: 1.55; }
.doc-content h2 { font-size: 1.55rem; margin-top: 52px; margin-bottom: 16px; padding-top: 20px; border-top: 1px solid hsl(var(--border)); scroll-margin-top: calc(var(--nav-h) + 24px); letter-spacing: -0.02em; }
.doc-content h3 { font-size: 1.18rem; margin-top: 34px; margin-bottom: 12px; scroll-margin-top: calc(var(--nav-h) + 24px); }
.doc-content h4 { font-size: 1rem; margin-top: 24px; margin-bottom: 8px; }
.doc-content p { color: hsl(var(--foreground) / 0.86); margin-bottom: 16px; }
.doc-content ul, .doc-content ol { color: hsl(var(--foreground) / 0.86); margin: 0 0 18px; padding-left: 22px; display: flex; flex-direction: column; gap: 7px; }
.doc-content li { padding-left: 4px; }
.doc-content a:not(.btn) { color: hsl(var(--primary)); text-decoration: underline; text-decoration-color: hsl(var(--primary) / 0.35); text-underline-offset: 3px; }
.doc-content a:not(.btn):hover { text-decoration-color: hsl(var(--primary)); }
.doc-content strong { color: hsl(var(--foreground)); font-weight: 650; }
.doc-content code { font-family: var(--font-mono); font-size: 0.85em; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); padding: 1.5px 6px; border-radius: 5px; }
.doc-content pre { background: hsl(222 47% 4%); border: 1px solid hsl(var(--border-strong)); border-radius: 12px; padding: 18px 20px; overflow-x: auto; margin: 0 0 22px; position: relative; }
[data-theme="light"] .doc-content pre { background: hsl(222 30% 12%); }
.doc-content pre code { background: none; border: none; padding: 0; color: hsl(210 40% 96%); font-size: 0.84rem; line-height: 1.7; }
.doc-content pre .cm { color: hsl(215 20% 55%); } /* comment */
.doc-content pre .tok { color: hsl(var(--c-teal)); }  /* keyword/flag */
.doc-content pre .str { color: hsl(var(--c-orange)); } /* string */

.copy-btn { position: absolute; top: 10px; right: 10px; font-size: 0.72rem; padding: 4px 9px; border-radius: 6px; background: hsl(217 33% 20%); color: hsl(210 40% 90%); border: 1px solid hsl(var(--border-strong)); opacity: 0; transition: opacity .15s; }
.doc-content pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: hsl(217 33% 26%); }

/* tables */
.doc-content table { width: 100%; border-collapse: collapse; margin: 0 0 24px; font-size: 0.9rem; }
.doc-content th, .doc-content td { text-align: left; padding: 10px 14px; border-bottom: 1px solid hsl(var(--border)); vertical-align: top; }
.doc-content th { color: hsl(var(--muted-foreground)); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; background: hsl(var(--muted) / 0.4); }
.doc-content tr:hover td { background: hsl(var(--muted) / 0.3); }
.doc-content td code { white-space: nowrap; }

/* callouts */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; margin: 0 0 22px; border: 1px solid; font-size: 0.92rem; }
.callout .ic { flex: none; font-size: 1.05rem; line-height: 1.4; }
.callout p:last-child { margin-bottom: 0; }
.callout.info { background: hsl(var(--primary) / 0.08); border-color: hsl(var(--primary) / 0.25); }
.callout.warn { background: hsl(var(--warning) / 0.1); border-color: hsl(var(--warning) / 0.3); }
.callout.tip  { background: hsl(var(--success) / 0.1); border-color: hsl(var(--success) / 0.28); }

/* method pills for API */
.method { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: 0.03em; }
.method.get { background: hsl(var(--c-teal) / 0.16); color: hsl(var(--c-teal)); }
.method.post { background: hsl(var(--primary) / 0.16); color: hsl(var(--primary)); }
.method.put, .method.patch { background: hsl(var(--c-orange) / 0.16); color: hsl(var(--c-orange)); }
.method.del { background: hsl(var(--danger) / 0.16); color: hsl(var(--danger)); }
.doc-content td .method { display: inline-block; }

/* feature/section anchor cards */
.doc-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 0 0 24px; }
.doc-card { padding: 18px; border-radius: 12px; background: hsl(var(--surface) / 0.5); border: 1px solid hsl(var(--border)); transition: border-color .15s, transform .15s; }
.doc-card:hover { border-color: hsl(var(--primary) / 0.4); transform: translateY(-2px); }
.doc-card h4 { margin: 0 0 5px; font-size: 0.98rem; }
.doc-card p { margin: 0; font-size: 0.85rem; color: hsl(var(--muted-foreground)); }

/* prev / next */
.doc-nav-btns { display: flex; justify-content: space-between; gap: 16px; margin-top: 60px; padding-top: 28px; border-top: 1px solid hsl(var(--border)); }
.doc-nav-btns a { flex: 1; max-width: 48%; padding: 16px 18px; border-radius: 12px; border: 1px solid hsl(var(--border)); transition: border-color .15s, background .15s; }
.doc-nav-btns a:hover { border-color: hsl(var(--primary) / 0.4); background: hsl(var(--muted) / 0.4); }
.doc-nav-btns .dir { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.doc-nav-btns .ttl { font-weight: 600; margin-top: 3px; color: hsl(var(--foreground)); }
.doc-nav-btns .next { text-align: right; margin-left: auto; }

/* ---------------- Right TOC ---------------- */
.docs-toc { position: sticky; top: calc(var(--nav-h) + 28px); align-self: start; max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto; }
.docs-toc h6 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: hsl(var(--muted-foreground)); margin-bottom: 12px; font-weight: 700; }
.docs-toc ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid hsl(var(--border)); }
.docs-toc a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; font-size: 0.83rem; color: hsl(var(--muted-foreground)); border-left: 2px solid transparent; transition: color .12s, border-color .12s; }
.docs-toc a.lvl-3 { padding-left: 26px; font-size: 0.8rem; }
.docs-toc a:hover { color: hsl(var(--foreground)); }
.docs-toc a.active { color: hsl(var(--primary)); border-left-color: hsl(var(--primary)); font-weight: 600; }

/* mobile sidebar toggle */
.docs-menu-btn { display: none; position: fixed; bottom: 22px; right: 22px; z-index: 45; width: 52px; height: 52px; border-radius: 50%; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-glow); align-items: center; justify-content: center; }
.docs-menu-btn svg { width: 24px; height: 24px; }
.docs-backdrop { display: none; position: fixed; inset: 0; z-index: 44; background: hsl(222 47% 3% / 0.6); }

@media (max-width: 1080px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 780px) {
  .docs-layout { grid-template-columns: 1fr; padding-top: calc(var(--nav-h) + 20px); }
  .docs-sidebar {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0; width: 280px; z-index: 46; max-height: none;
    background: hsl(var(--background)); border-right: 1px solid hsl(var(--border)); padding: 22px 18px;
    transform: translateX(-105%); transition: transform .25s ease;
  }
  .docs-sidebar.open { transform: none; }
  .docs-menu-btn { display: flex; }
  .docs-backdrop.show { display: block; }
}
