/* ============================================================================
   shotgate.coldqubit.org/docs · surface styles
   ----------------------------------------------------------------------------
   The docs reader, adapted from the design system's docs UI kit. Tokens and
   canonical components come from ../styles/styles.css. Dark default; the
   theme toggle flips [data-theme="light"] on <html> for the reading surface.
   ============================================================================ */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); }

/* ---- top bar ---- */
.docbar { position: sticky; top: 0; z-index: 40; height: 60px; display: flex; align-items: center; gap: 20px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.docbar .brand { display: flex; align-items: center; gap: 11px; }
.docbar .brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.03em; color: var(--text); white-space: nowrap; }
.docbar .docs-tag { font: var(--text-code-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.iconbtn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: all var(--dur); background: transparent; }
.iconbtn:hover { color: var(--text); border-color: var(--border-interactive); }
.iconbtn svg { width: 18px; height: 18px; }
.nav-toggle { display: none; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 260px minmax(0,1fr) 220px; max-width: 1340px; margin: 0 auto; }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 28px 20px 40px; border-right: 1px solid var(--line); }
.nav-group { margin-bottom: 26px; }
.nav-group h5 { font: var(--text-kicker); letter-spacing: var(--kicker-tracking); text-transform: uppercase; color: var(--text-faint); margin: 0 0 12px; padding-left: 12px; }
.nav-item { display: block; padding: 7px 12px; border-radius: var(--radius-sm); font: var(--text-body-sm); color: var(--text-secondary); cursor: pointer; transition: all var(--dur); margin-bottom: 2px; }
.nav-item:hover { color: var(--text); background: var(--bg-elevated); }
.nav-item.active { color: var(--violet-300); background: var(--violet-800); font-weight: 600; }
[data-theme="light"] .nav-item.active { color: var(--violet-700); background: color-mix(in srgb, var(--violet-200) 50%, transparent); }
.nav-item.ext { display: flex; align-items: center; gap: 7px; }
.nav-item.ext svg { width: 13px; height: 13px; opacity: 0.7; flex-shrink: 0; }

/* ---- article ---- */
.article { padding: 40px 56px 100px; min-width: 0; }
.crumb { font: var(--text-code-sm); color: var(--text-faint); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb .src { margin-left: auto; color: var(--text-muted); }
.crumb .src:hover { color: var(--text); }
.article h1 { font: var(--text-h1); font-size: clamp(2rem,1.6rem+1.4vw,2.6rem); letter-spacing: -0.025em; margin: 0; }
.article h2 { font: var(--text-h3); margin: 44px 0 0; letter-spacing: -0.01em; scroll-margin-top: 80px; padding-top: 8px; }
.article h3 { font: var(--text-h4); margin: 32px 0 0; scroll-margin-top: 80px; }
.article h4 { font: var(--text-body); font-weight: 600; color: var(--text); margin: 26px 0 0; scroll-margin-top: 80px; }
.article p { font: var(--text-body); color: var(--text-secondary); margin: 16px 0 0; max-width: 72ch; text-wrap: pretty; }
.article p code, .article li code, .article td code, .article h2 code, .article h3 code { font: var(--text-code-sm); background: var(--bg-sunken); color: var(--accent); padding: 1px 6px; border-radius: 4px; }
.article ul, .article ol { margin: 16px 0 0; padding-left: 22px; max-width: 72ch; }
.article li { font: var(--text-body); color: var(--text-secondary); margin-bottom: 8px; }
.article strong { color: var(--text); font-weight: 600; }
.article a:not(.nav-item) { color: var(--accent); border-bottom: 1px solid var(--border-interactive); }
.article a:not(.nav-item):hover { border-bottom-color: var(--accent); }
.article img { max-width: 100%; border-radius: var(--radius-md); border: 1px solid var(--line); margin-top: 22px; }
.article hr { border: none; border-top: 1px solid var(--line); margin: 36px 0 0; }
.article blockquote { margin: 22px 0 0; padding: 2px 18px; border-left: 2px solid var(--violet-500); background: var(--bg-elevated); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.article blockquote p { font: var(--text-body-sm); }

/* ---- code block ---- */
.article .code { background: var(--bg-code); border: 1px solid var(--ink-600); border-radius: var(--radius-md); overflow: hidden; margin-top: 22px; }
.article .code .code-head { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--ink-700); background: rgba(255,255,255,0.02); }
.article .code .code-head .lang { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--violet-300); text-transform: uppercase; letter-spacing: .08em; }
.article .code .code-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-500); }
.article .code pre { margin: 0; padding: 16px 18px; font: var(--text-code); white-space: pre; overflow-x: auto; color: var(--fg-2); }
.article .code pre code { background: none; padding: 0; color: inherit; font: inherit; }
[data-theme="light"] .article .code { border-color: var(--line-strong); }

/* mermaid diagrams */
.article .mermaid-wrap { margin-top: 22px; padding: 20px; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius-md); overflow-x: auto; }
.article .mermaid-wrap svg { max-width: 100%; height: auto; }

/* ---- tables (markdown) ---- */
.article table { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md); border-collapse: separate; border-spacing: 0; overflow: hidden; margin-top: 22px; font-size: 14px; }
.article th { text-align: left; font: var(--text-code-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 11px 16px; background: var(--bg-sunken); border-bottom: 1px solid var(--line); }
.article td { padding: 12px 16px; border-bottom: 1px solid var(--line-faint); color: var(--text-secondary); vertical-align: top; }
.article tr:last-child td { border-bottom: none; }

/* ---- loading / error ---- */
.loading { font: var(--text-code); color: var(--text-muted); padding: 40px 0; }
.load-err { margin-top: 40px; }

/* ---- prev/next ---- */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager a { flex: 1; max-width: 48%; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px 18px; transition: all var(--dur); border-bottom: none !important; }
.pager a:hover { border-color: var(--border-interactive); background: var(--bg-elevated); }
.pager .dir { font: var(--text-code-sm); color: var(--text-faint); }
.pager .ttl { font: var(--text-body-sm); font-weight: 600; color: var(--text); margin-top: 4px; }
.pager .next { text-align: right; margin-left: auto; }

/* ---- TOC ---- */
.toc { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); padding: 40px 24px; overflow-y: auto; }
.toc h6 { font: var(--text-kicker); letter-spacing: var(--kicker-tracking); text-transform: uppercase; color: var(--text-faint); margin: 0 0 14px; }
.toc a { display: block; font: var(--text-small); color: var(--text-muted); padding: 5px 0 5px 12px; border-left: 1px solid var(--line); transition: all var(--dur); }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--violet-300); border-left-color: var(--violet-400); }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px 1fr; }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: flex; }
  .docbar .docs-tag { display: none; }
  /* sidebar becomes a slide-over panel under the docbar */
  .sidebar { position: fixed; top: 60px; left: 0; bottom: 0; width: min(300px, 84vw); z-index: 30; background: var(--bg); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform var(--dur-slow, 320ms) var(--ease-out); height: auto; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
  .article { padding: 28px 22px 80px; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager .next { margin-left: 0; }
}
