/* ══════════════════════════════════════════════════════════════════════════════
   CTFFactory Documentation — docs.css
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Base reset for docs shell ─────────────────────────────────────────────── */
body.docs-shell {
  --docs-sidebar-w: 260px;
  --docs-toc-w: 220px;
  --docs-gap: 0px;
  --docs-content-max: 760px;
  --docs-bg: #0b0f18;
  --docs-surface: #111827;
  --docs-surface2: #1a2236;
  --docs-border: rgba(255,255,255,.07);
  --docs-fg: #e2e8f0;
  --docs-muted: #8b99b5;
  --docs-accent: #0aff63;
  --docs-accent2: #8b5cf6;
  --docs-link: #60a5fa;
  --docs-code-bg: #0d1526;
  --docs-topbar-h: 54px;
  background: var(--docs-bg);
  color: var(--docs-fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  margin: 0; padding: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Top navigation bar ─────────────────────────────────────────────────────── */
.docs-topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--docs-topbar-h);
  background: rgba(11,15,24,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--docs-border);
  z-index: 100;
}
.docs-topbar-inner {
  display: flex; align-items: center; gap: 0;
  height: 100%; max-width: 1600px; margin: 0 auto;
  padding: 0 20px;
}

.docs-brand {
  display: flex; align-items: center; gap: 7px;
  text-decoration: none; flex-shrink: 0; margin-right: 28px;
}
.docs-brand-flag { font-size: 1.1rem; line-height: 1; }
.docs-brand-name { font-size: .98rem; font-weight: 800; color: var(--docs-fg); letter-spacing: -.01em; }
.docs-brand-name em { color: var(--docs-accent); font-style: normal; }
.docs-brand-tag {
  font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--docs-muted); border: 1px solid var(--docs-border);
  padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}

.docs-topnav {
  display: flex; align-items: center; gap: 2px; flex: 1; overflow-x: auto;
  scrollbar-width: none;
}
.docs-topnav::-webkit-scrollbar { display: none; }
.docs-topnav-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 7px;
  font-size: .84rem; font-weight: 500; color: var(--docs-muted);
  text-decoration: none; white-space: nowrap;
  transition: color .15s, background .15s;
}
.docs-topnav-link:hover { color: var(--docs-fg); background: rgba(255,255,255,.05); }
.docs-topnav-link.active { color: var(--docs-fg); background: rgba(255,255,255,.07); }

.docs-topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.docs-lang-btn {
  font-size: .8rem; font-weight: 600; color: var(--docs-muted);
  text-decoration: none; padding: 4px 10px;
  border: 1px solid var(--docs-border); border-radius: 6px;
  transition: color .15s, border-color .15s;
}
.docs-lang-btn:hover { color: var(--docs-fg); border-color: rgba(255,255,255,.15); }
.docs-app-btn {
  font-size: .82rem; font-weight: 600; color: var(--docs-accent);
  text-decoration: none; padding: 5px 13px;
  border: 1px solid rgba(10,255,99,.25); border-radius: 7px;
  background: rgba(10,255,99,.06);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.docs-app-btn:hover { background: rgba(10,255,99,.1); border-color: rgba(10,255,99,.4); }

/* ── Main layout ───────────────────────────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: var(--docs-sidebar-w) 1fr var(--docs-toc-w);
  grid-template-rows: 1fr;
  min-height: calc(100vh - var(--docs-topbar-h));
  margin-top: var(--docs-topbar-h);
  max-width: 1600px;
  margin-left: auto; margin-right: auto;
  width: 100%;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.docs-sidebar {
  position: sticky; top: var(--docs-topbar-h);
  height: calc(100vh - var(--docs-topbar-h));
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--docs-border);
  padding: 20px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* Search */
.docs-search-wrap { padding: 0 12px 16px; }
.docs-search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--docs-surface); border: 1px solid var(--docs-border);
  border-radius: 8px; padding: 7px 10px;
  cursor: text; transition: border-color .15s;
}
.docs-search-box:focus-within { border-color: rgba(10,255,99,.35); }
.docs-search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--docs-fg); font-size: .83rem;
}
.docs-search-input::placeholder { color: var(--docs-muted); }
.docs-search-kbd {
  font-size: .68rem; color: var(--docs-muted);
  border: 1px solid var(--docs-border); border-radius: 4px;
  padding: 1px 5px; font-family: inherit; flex-shrink: 0;
}
.docs-search-results {
  position: absolute; z-index: 200;
  background: var(--docs-surface); border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
  width: calc(var(--docs-sidebar-w) - 24px);
  margin-top: 4px; max-height: 320px; overflow-y: auto;
}
.docs-search-result {
  display: flex; flex-direction: column; padding: 10px 14px;
  text-decoration: none; border-bottom: 1px solid var(--docs-border);
  transition: background .12s;
}
.docs-search-result:last-child { border-bottom: none; }
.docs-search-result:hover { background: rgba(255,255,255,.05); }
.docs-search-result-section { font-size: .72rem; color: var(--docs-muted); margin-bottom: 2px; }
.docs-search-result-title { font-size: .85rem; color: var(--docs-fg); font-weight: 500; }

/* Nav sections */
.docs-nav { padding: 0 8px; }
.docs-nav-section { margin-bottom: 4px; }
.docs-nav-section-btn {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: 7px;
  font-size: .82rem; font-weight: 600; color: var(--docs-muted);
  text-align: left; transition: color .15s, background .15s;
}
.docs-nav-section-btn:hover { color: var(--docs-fg); background: rgba(255,255,255,.04); }
.docs-nav-section.open .docs-nav-section-btn { color: var(--docs-fg); }
.docs-nav-section-icon { font-size: 1rem; flex-shrink: 0; }
.docs-nav-chevron {
  margin-left: auto; flex-shrink: 0; color: var(--docs-muted);
  transition: transform .2s; transform: rotate(-90deg);
}
.docs-nav-section.open .docs-nav-chevron { transform: rotate(0deg); }

.docs-nav-pages {
  list-style: none; margin: 2px 0 6px; padding: 0 0 0 28px;
  display: none;
}
.docs-nav-section.open .docs-nav-pages { display: block; }
.docs-nav-link {
  display: block; padding: 5px 8px; border-radius: 6px;
  font-size: .83rem; color: var(--docs-muted); text-decoration: none;
  transition: color .12s, background .12s;
}
.docs-nav-link:hover { color: var(--docs-fg); background: rgba(255,255,255,.04); }
.docs-nav-link.active {
  color: var(--docs-accent); background: rgba(10,255,99,.08);
  font-weight: 600;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.docs-main {
  min-width: 0;
  padding: 40px 48px 60px;
  max-width: calc(var(--docs-content-max) + 96px);
}

.docs-breadcrumb {
  display: flex; align-items: center; gap: 7px;
  font-size: .78rem; color: var(--docs-muted); margin-bottom: 20px;
}
.docs-breadcrumb a { color: var(--docs-muted); text-decoration: none; }
.docs-breadcrumb a:hover { color: var(--docs-fg); }

/* ── Article typography ─────────────────────────────────────────────────────── */
.docs-article { max-width: var(--docs-content-max); }

.docs-article h1 {
  font-size: 2rem; font-weight: 800; color: var(--docs-fg);
  margin: 0 0 8px; line-height: 1.2; letter-spacing: -.02em;
}
.docs-article > p:first-of-type {
  font-size: 1.05rem; color: var(--docs-muted); margin: 0 0 32px; line-height: 1.6;
}
.docs-article h2 {
  font-size: 1.2rem; font-weight: 700; color: var(--docs-fg);
  margin: 40px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--docs-border);
}
.docs-article h3 {
  font-size: 1rem; font-weight: 700; color: var(--docs-fg);
  margin: 28px 0 10px;
}
.docs-article p { margin: 0 0 16px; color: var(--docs-fg); }
.docs-article a { color: var(--docs-link); text-decoration: none; }
.docs-article a:hover { text-decoration: underline; }
.docs-article ul, .docs-article ol { margin: 0 0 16px; padding-left: 22px; }
.docs-article li { margin-bottom: 5px; }
.docs-article li > p { margin: 0; }
.docs-article strong { color: var(--docs-fg); font-weight: 600; }
.docs-article em { color: var(--docs-muted); }

/* Inline code */
.docs-article code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: .83em;
  background: var(--docs-code-bg);
  border: 1px solid var(--docs-border);
  border-radius: 4px; padding: 1px 5px;
  color: var(--docs-accent);
}

/* Code blocks */
.docs-article pre {
  background: var(--docs-code-bg);
  border: 1px solid var(--docs-border);
  border-radius: 10px; padding: 16px 20px;
  overflow-x: auto; margin: 0 0 20px;
  position: relative;
}
.docs-article pre code {
  background: none; border: none; padding: 0;
  font-size: .85rem; color: #c9d7ff; display: block;
}

/* Copy button */
.docs-copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.06); border: 1px solid var(--docs-border);
  border-radius: 5px; padding: 3px 10px;
  font-size: .72rem; font-weight: 600; color: var(--docs-muted);
  cursor: pointer; transition: background .12s, color .12s;
}
.docs-copy-btn:hover { background: rgba(255,255,255,.12); color: var(--docs-fg); }

/* Tables */
.docs-article table {
  width: 100%; border-collapse: collapse; margin: 0 0 20px;
  font-size: .88rem;
}
.docs-article th {
  background: var(--docs-surface); text-align: left;
  padding: 8px 12px; font-weight: 600; color: var(--docs-muted);
  border-bottom: 1px solid var(--docs-border); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.docs-article td {
  padding: 9px 12px; border-bottom: 1px solid var(--docs-border);
  vertical-align: top;
}
.docs-article tr:last-child td { border-bottom: none; }

/* Callout blocks — markdown: > [!NOTE], > [!TIP], > [!WARNING] */
.docs-article blockquote {
  margin: 0 0 20px; padding: 14px 16px;
  border-left: 3px solid var(--docs-accent2);
  background: rgba(139,92,246,.07); border-radius: 0 8px 8px 0;
  color: var(--docs-muted);
}
.docs-article blockquote p { margin: 0; color: inherit; }
.docs-article blockquote strong { color: var(--docs-accent2); }

/* ── Right TOC ─────────────────────────────────────────────────────────────── */
.docs-toc {
  position: sticky; top: var(--docs-topbar-h);
  height: calc(100vh - var(--docs-topbar-h));
  overflow-y: auto; padding: 32px 16px 40px 20px;
  border-left: 1px solid var(--docs-border);
  font-size: .8rem;
}
.docs-toc-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--docs-muted); margin: 0 0 10px;
}
.docs-toc-list { list-style: none; margin: 0; padding: 0; }
.docs-toc-item { margin-bottom: 2px; }
.docs-toc-h3 { padding-left: 12px; }
.docs-toc-link {
  display: block; padding: 3px 6px; border-radius: 5px;
  color: var(--docs-muted); text-decoration: none;
  transition: color .12s, background .12s;
  border-left: 2px solid transparent;
}
.docs-toc-link:hover { color: var(--docs-fg); }
.docs-toc-link.active {
  color: var(--docs-accent); border-left-color: var(--docs-accent);
  background: rgba(10,255,99,.06);
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.docs-pagination {
  display: flex; justify-content: space-between; gap: 16px;
  margin: 48px 0 32px; max-width: var(--docs-content-max);
}
.docs-pagination-link {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: 10px;
  border: 1px solid var(--docs-border); text-decoration: none;
  transition: border-color .15s, background .15s; min-width: 0; max-width: 48%;
  background: var(--docs-surface);
}
.docs-pagination-link:hover { border-color: rgba(10,255,99,.3); background: rgba(10,255,99,.04); }
.docs-pagination-link.next { margin-left: auto; text-align: right; }
.docs-pagination-link > span:not(.docs-pagination-arrow) { display: flex; flex-direction: column; min-width: 0; }
.docs-pagination-arrow { font-size: 1.2rem; color: var(--docs-muted); flex-shrink: 0; }
.docs-pagination-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--docs-muted); font-weight: 600; }
.docs-pagination-title { font-size: .88rem; font-weight: 600; color: var(--docs-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Content footer ────────────────────────────────────────────────────────── */
.docs-content-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: .76rem; color: var(--docs-muted); opacity: .6;
  padding-top: 24px; border-top: 1px solid var(--docs-border);
  max-width: var(--docs-content-max);
}
.docs-content-footer a { color: inherit; text-decoration: none; }
.docs-content-footer a:hover { color: var(--docs-fg); }

/* ── Mobile toggle button ──────────────────────────────────────────────────── */
.docs-mobile-toggle {
  display: none;
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  background: var(--docs-accent); border: none; border-radius: 50%;
  width: 48px; height: 48px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(10,255,99,.25);
  align-items: center; justify-content: center; color: #000;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: var(--docs-sidebar-w) 1fr; }
  .docs-toc { display: none; }
}

@media (max-width: 800px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-main { padding: 24px 20px 48px; }
  .docs-sidebar {
    position: fixed; top: var(--docs-topbar-h); left: 0; bottom: 0;
    width: var(--docs-sidebar-w); z-index: 200;
    background: var(--docs-bg); transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: none;
    border-right: 1px solid var(--docs-border);
  }
  .docs-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.4);
  }
  .docs-mobile-toggle { display: flex; }
  .docs-topnav { display: none; }
  .docs-breadcrumb { display: none; }
}

@media (max-width: 480px) {
  .docs-article h1 { font-size: 1.5rem; }
  .docs-pagination { flex-direction: column; }
  .docs-pagination-link { max-width: 100%; }
}
