/* ─── Fantasque Sans Mono (self-hosted webfont) ──────────── */
@font-face {
  font-family: 'Fantasque Sans Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/FantasqueSansMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Fantasque Sans Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/FantasqueSansMono-Italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Fantasque Sans Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/FantasqueSansMono-Bold.woff2') format('woff2');
}
@font-face {
  font-family: 'Fantasque Sans Mono';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/FantasqueSansMono-BoldItalic.woff2') format('woff2');
}

/* ─── Docs layout ───────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 64px);
  max-width: 1300px;
  margin: 0 auto;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.docs-sidebar {
  border-right: 1px solid var(--border);
  padding: 32px 0 48px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--bg2);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section {
  padding: 0 20px 24px;
}

.sidebar-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 8px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.sidebar-link {
  display: block;
  padding: 7px 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: 2px;
  border-left: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  text-decoration: none;
  line-height: 1.3;
}
.sidebar-link:hover {
  color: var(--text);
  background: rgba(154,202,60,.06);
  border-left-color: var(--green-mid);
  text-decoration: none;
}
.sidebar-link.active {
  color: var(--green);
  background: rgba(154,202,60,.08);
  border-left-color: var(--green);
  font-weight: 700;
}

/* ─── Content area ──────────────────────────────────────── */
.docs-content {
  padding: 48px 56px 80px;
  min-width: 0;
}

.docs-body {
  max-width: 820px;
}

/* ─── Prose styles ──────────────────────────────────────── */
.docs-body h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.docs-body h1::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 56px; height: 2px;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
}

.docs-body h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--green);
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.docs-body h3 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  margin: 28px 0 10px;
}

.docs-body h4 {
  font-family: 'Rajdhani', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 20px 0 8px;
}

.docs-body p {
  font-family: 'Rajdhani', sans-serif;
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 16px;
}

.docs-body strong { color: var(--text); font-weight: 700; }
.docs-body em { color: var(--green-glow); font-style: italic; }

.docs-body a {
  color: var(--green-glow);
  border-bottom: 1px solid rgba(181,230,101,.25);
  transition: border-color .15s, color .15s;
}
.docs-body a:hover {
  color: var(--green);
  border-bottom-color: var(--green);
  text-decoration: none;
}

/* ─── Code ──────────────────────────────────────────────── */
.docs-body code {
  font-family: 'Fantasque Sans Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .9em;
  background: rgba(154,202,60,.07);
  border: 1px solid rgba(154,202,60,.18);
  color: var(--green-glow);
  padding: 2px 7px;
  border-radius: 2px;
}

.docs-body pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green-dark);
  border-radius: 2px;
  padding: 20px 24px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
}
.docs-body pre code {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
  font-size: .92rem;
  line-height: 1.65;
}

/* ─── Tables ────────────────────────────────────────────── */
.docs-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-family: 'Rajdhani', sans-serif;
  font-size: .9rem;
}
.docs-body th {
  background: var(--bg3);
  color: var(--green);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: .75rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.docs-body td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}
.docs-body tr:hover td { background: rgba(154,202,60,.03); }
.docs-body td code { font-size: .82em; }

/* ─── Blockquote ────────────────────────────────────────── */
.docs-body blockquote {
  border-left: 3px solid var(--green-dark);
  background: rgba(154,202,60,.04);
  padding: 14px 20px;
  margin: 20px 0;
  border-radius: 0 2px 2px 0;
}
.docs-body blockquote p {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

/* ─── Lists ─────────────────────────────────────────────── */
.docs-body ul, .docs-body ol {
  font-family: 'Rajdhani', sans-serif;
  font-size: .95rem;
  color: var(--muted);
  padding-left: 24px;
  margin-bottom: 16px;
  line-height: 1.75;
}
.docs-body li { margin-bottom: 4px; }
.docs-body li::marker { color: var(--green-dark); }

/* ─── Horizontal rule ───────────────────────────────────── */
.docs-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ─── Strikethrough ─────────────────────────────────────── */
.docs-body del { color: var(--dim); }

/* ─── Mermaid diagrams ──────────────────────────────────── */
.docs-body .mermaid {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  margin: 24px 0;
  overflow-x: auto;
  text-align: center;
  cursor: zoom-in;
}
.docs-body .mermaid svg {
  max-width: 100%;
  height: auto;
  image-rendering: crisp-edges;
}

/* Mermaid fullscreen viewer */
.mermaid-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(10, 12, 15, 0.92);
  display: none;
}

.mermaid-lightbox.open {
  display: block;
}

.mermaid-lightbox-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

.mermaid-lightbox-button {
  border: 1px solid var(--border-accent);
  background: var(--bg3);
  color: var(--text);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

.mermaid-lightbox-button:hover {
  border-color: var(--green);
  color: var(--green-glow);
}

.mermaid-lightbox-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .03em;
  text-align: center;
  z-index: 2;
}

.mermaid-lightbox-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

.mermaid-lightbox-viewport.dragging {
  cursor: grabbing;
}

.mermaid-lightbox-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  will-change: transform;
}

.mermaid-lightbox-stage svg {
  display: block;
  max-width: none;
  height: auto;
}

/* ─── Docs footer ───────────────────────────────────────── */
.docs-footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

/* ─── Nav active state ──────────────────────────────────── */
.nav-links .nav-active {
  color: var(--green) !important;
}

/* ─── Mobile hamburger ──────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 8px 10px;
  cursor: pointer;
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--muted);
  transition: background .2s;
}
.nav-hamburger:hover span { background: var(--green); }

.nav-mobile {
  display: none;
  flex-direction: column;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  gap: 4px;
}
.nav-mobile.open { display: flex; }
.nav-mobile a {
  font-family: 'Rajdhani', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 0;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  transition: color .15s;
}
.nav-mobile a:hover { color: var(--green); text-decoration: none; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }

  .docs-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    display: none; /* collapsed by default on mobile */
  }

  .docs-content { padding: 32px 24px 60px; }
  .nav-hamburger { display: flex; }
  .nav-links a:not(.nav-github) { display: none; }
}

@media (max-width: 480px) {
  .docs-content { padding: 24px 16px 48px; }
}

/* ─── Syntax highlighting (Rouge) — Blades theme ────────────
   Token colors tuned to the green/dark Blades palette.
   Rouge wraps fenced code in .highlight with token spans. */
.docs-body .highlight,
.docs-body .highlighter-rouge .highlight {
  background: transparent;
}

/* Optional language badge for fenced blocks */
.docs-body div.highlighter-rouge {
  position: relative;
}

/* Base text inside highlighted blocks */
.docs-body .highlight code,
.docs-body .highlight pre {
  color: var(--text);
}

/* Comments */
.docs-body .highlight .c,
.docs-body .highlight .ch,
.docs-body .highlight .cd,
.docs-body .highlight .cm,
.docs-body .highlight .cp,
.docs-body .highlight .cpf,
.docs-body .highlight .c1,
.docs-body .highlight .cs   { color: #5A5C60; font-style: italic; }

/* Keywords */
.docs-body .highlight .k,
.docs-body .highlight .kc,
.docs-body .highlight .kd,
.docs-body .highlight .kn,
.docs-body .highlight .kp,
.docs-body .highlight .kr   { color: #9ACA3C; font-weight: 600; }
.docs-body .highlight .kt   { color: #C8E68A; font-weight: 600; } /* type keyword */

/* Strings */
.docs-body .highlight .s,
.docs-body .highlight .sa,
.docs-body .highlight .sb,
.docs-body .highlight .sc,
.docs-body .highlight .dl,
.docs-body .highlight .sd,
.docs-body .highlight .s2,
.docs-body .highlight .se,
.docs-body .highlight .sh,
.docs-body .highlight .si,
.docs-body .highlight .sx,
.docs-body .highlight .sr,
.docs-body .highlight .s1,
.docs-body .highlight .ss   { color: #D7BA7D; }

/* Numbers */
.docs-body .highlight .m,
.docs-body .highlight .mb,
.docs-body .highlight .mf,
.docs-body .highlight .mh,
.docs-body .highlight .mi,
.docs-body .highlight .mo,
.docs-body .highlight .il   { color: #B5E665; }

/* Functions / methods */
.docs-body .highlight .nf,
.docs-body .highlight .fm   { color: #B5E665; }

/* Classes, namespaces, types */
.docs-body .highlight .nc,
.docs-body .highlight .nn,
.docs-body .highlight .no,
.docs-body .highlight .nl   { color: #C8E68A; }

/* Builtins / constants */
.docs-body .highlight .nb,
.docs-body .highlight .bp,
.docs-body .highlight .kva  { color: #9ACA3C; }

/* Variables */
.docs-body .highlight .n,
.docs-body .highlight .nv,
.docs-body .highlight .vc,
.docs-body .highlight .vg,
.docs-body .highlight .vi   { color: var(--text); }

/* Operators / punctuation */
.docs-body .highlight .o,
.docs-body .highlight .ow,
.docs-body .highlight .p    { color: #8B8D91; }

/* HTML/XML tags & attributes */
.docs-body .highlight .nt   { color: #9ACA3C; }
.docs-body .highlight .na   { color: #B5E665; }

/* Decorators / annotations */
.docs-body .highlight .nd   { color: #C8E68A; }

/* Generic diff / output */
.docs-body .highlight .gd   { color: #ff6b6b; background: rgba(255,107,107,.08); }
.docs-body .highlight .gi   { color: #9ACA3C; background: rgba(154,202,60,.08); }
.docs-body .highlight .gh,
.docs-body .highlight .gu   { color: var(--green-glow); font-weight: 600; }
.docs-body .highlight .gp   { color: #5A5C60; }
.docs-body .highlight .ge   { font-style: italic; }
.docs-body .highlight .gs   { font-weight: 600; }

/* Errors */
.docs-body .highlight .err  { color: #ff6b6b; background: rgba(255,107,107,.08); }

