/* =========================================================
 * Binderus Docs — shared styles + chrome
 * Single source of truth for nav, sidebar, footer, content, theme.
 * Loaded as a stylesheet by every docs page. No per-page <style> blocks.
 * ========================================================= */

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
:root {
  --bg:#0b0b12; --bg-card:#111119; --bg-elevated:#1a1a25; --surface:#21212f;
  --primary:#7c6df0; --primary-glow:rgba(124,109,240,0.12); --primary-light:#9d91f5;
  --accent:#4de8c2; --accent-dim:rgba(77,232,194,0.1);
  --text:#eae8f2; --text-secondary:#a09eb3; --text-muted:#6b6a7f;
  --border:#282838; --border-hover:#3a3a50;
  --gradient:linear-gradient(135deg,#7c6df0 0%,#4de8c2 100%);
  --gradient-wide:linear-gradient(135deg,#7c6df0 0%,#c084fc 50%,#4de8c2 100%);
  --radius:16px; --radius-sm:10px; --nav-height:64px;
}
html { scroll-behavior:smooth; }
html, body { overflow-x: hidden; }
body { font-family:'Inter',sans-serif; background:var(--bg); color:var(--text); padding-top:var(--nav-height); -webkit-font-smoothing:antialiased; }

nav { position:fixed; top:0; left:0; right:0; height:var(--nav-height); background:rgba(11,11,18,0.8); backdrop-filter:blur(12px); border-bottom:1px solid var(--border); z-index:100; transition:background 200ms ease; }
nav .container { max-width:1280px; margin:0 auto; height:100%; padding:0 24px; display:flex; align-items:center; justify-content:space-between; }
nav .nav-logo { display:flex; align-items:center; gap:10px; font-weight:700; color:var(--text); text-decoration:none; font-size:17px; }
nav .nav-logo svg { width:28px; height:28px; }
nav .nav-links { display:flex; align-items:center; gap:20px; }
nav .nav-links a { color:var(--text-secondary); text-decoration:none; font-size:14px; font-weight:500; transition:color 150ms ease; }
nav .nav-links a:hover { color:var(--text); }
nav .nav-cta { background:var(--gradient); color:#0b0b12 !important; padding:9px 18px; border-radius:10px; font-weight:600; display:flex; align-items:center; gap:8px; }

footer { border-top:1px solid var(--border); padding:48px 24px; text-align:center; }
footer .container { max-width:1100px; margin:0 auto; }
footer .footer-links { display:flex; justify-content:center; gap:28px; margin-bottom:18px; flex-wrap:wrap; }
footer .footer-links a { color:var(--text-secondary); text-decoration:none; font-size:14px; }
footer .footer-links a:hover { color:var(--text); }
footer .footer-copy { color:var(--text-muted); font-size:13px; margin-bottom:10px; }
footer .footer-green { color:var(--text-muted); font-size:12px; display:flex; align-items:center; justify-content:center; gap:6px; }

.gradient-text { background:var(--gradient-wide); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; background-size:200% 100%; animation:gradientShift 8s ease infinite; }
@keyframes gradientShift { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }


/* Layout: sidebar + content + TOC */
.docs-layout {
  display: grid;
  grid-template-columns: 260px minmax(0,1fr) 220px;
  gap: 48px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
@media (max-width: 1080px) {
  .docs-layout { grid-template-columns: 240px minmax(0,1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 720px) {
  .docs-layout { grid-template-columns: 1fr; padding: 16px 16px 64px; gap: 24px; }
  .docs-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 16px;
    padding-right: 0;
    overflow-y: visible;
  }
  /* Collapsible sidebar on mobile — open via the "Browse docs" toggle below */
  .docs-sidebar > .docs-sidebar-group,
  .docs-sidebar > h3,
  .docs-sidebar > ul { display: none; }
  .docs-sidebar.open > .docs-sidebar-group { display: block; }
  .docs-sidebar.open > h3,
  .docs-sidebar.open > ul { display: block; }
  .docs-sidebar-toggle {
    display: flex;
    align-items: center; justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
  }
  .docs-sidebar-toggle::after {
    content: '▾';
    transition: transform 200ms ease;
  }
  .docs-sidebar.open .docs-sidebar-toggle::after { transform: rotate(180deg); }
  /* Tap targets — bigger so fingers hit them */
  .docs-sidebar a { padding: 10px 12px; font-size: 15px; }
  .docs-sidebar a.indent { padding-left: 28px; font-size: 14px; }
  /* Content scaling for narrow screens */
  .docs-content h1 { font-size: 28px; }
  .docs-content h2 { font-size: 22px; margin-top: 36px; }
  .docs-content h3 { font-size: 17px; margin-top: 24px; }
  .docs-content p, .docs-content li { font-size: 15px; line-height: 1.65; }
  .docs-content .lead { font-size: 16px; margin-bottom: 24px; }
  .docs-content pre { font-size: 12.5px; padding: 12px 14px; }
  /* Remove the giant -22px anchor offset on mobile (it pushes off-screen) */
  .docs-content h2 .anchor,
  .docs-content h3 .anchor { display: none; }
  /* Code-copy button — hide on mobile (no hover trigger; long-press copy is OS-native) */
  .docs-content pre .code-copy-btn { display: none; }
  /* Hero on mobile */
  .docs-hero h1 { font-size: 32px; }
  .docs-hero p { font-size: 16px; }
  .docs-hero-btn { padding: 12px 18px; font-size: 14px; flex: 1; justify-content: center; }
  /* Breadcrumb wraps cleanly */
  .docs-breadcrumb { font-size: 12px; }
  .docs-breadcrumb a { display: inline; }
  /* FAQ — bigger tap target */
  .faq-q { padding: 14px 16px; font-size: 14.5px; }
  /* Card grids — ensure single column under 480 */
  .docs-card-grid { grid-template-columns: 1fr; }
  .docs-card { padding: 18px; }
}
.docs-sidebar-toggle { display: none; }
/* Mobile nav: with only theme-toggle + Download + GitHub, keep them inline
   instead of behind a hamburger. Higher specificity than the inline-style
   `nav .nav-links { position:fixed; ... }` rule on each page. */
@media (max-width: 768px) {
  body nav .nav-toggle,
  body nav .nav-overlay { display: none !important; }
  body nav .nav-links {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    flex-direction: row;
    align-items: center;
    padding: 0;
    gap: 12px;
    transform: none;
    border-left: none;
  }
  body nav .container { padding: 0 16px; gap: 12px; }
  body nav .nav-cta { padding: 7px 14px; font-size: 13px; }
}
@media (max-width: 480px) {
  /* Tighter still — collapse Download label, keep icon */
  body nav .nav-cta span { display: none; }
  body nav .nav-cta { padding: 7px 10px; }
  body nav .nav-logo { font-size: 16px; }
}

/* Sidebar */
.docs-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--nav-height) - 48px);
  overflow-y: auto;
  padding-right: 8px;
}
/* Collapsible group header */
.docs-sidebar-group { margin-bottom: 6px; }
.docs-sidebar-group-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: transparent; border: none; padding: 6px 4px;
  font: 700 11px/1 'Inter', sans-serif;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); cursor: pointer;
}
.docs-sidebar-group-toggle:hover { color: var(--text-secondary); }
.docs-sidebar-group-toggle::after {
  content: '▾'; font-size: 10px; transition: transform 200ms ease;
}
.docs-sidebar-group.collapsed .docs-sidebar-group-toggle::after { transform: rotate(-90deg); }
.docs-sidebar-group.collapsed > ul { display: none; }
.docs-sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 18px 0 8px;
  font-weight: 700;
}
.docs-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0 0 4px;
}
.docs-sidebar a {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: background 120ms ease, color 120ms ease;
}
.docs-sidebar a:hover {
  background: var(--bg-card);
  color: var(--text);
}
.docs-sidebar a.active {
  background: var(--primary-glow);
  color: var(--primary-light);
  font-weight: 600;
}
.docs-sidebar a.indent { padding-left: 26px; font-size: 13px; color: var(--text-muted); }
.docs-sidebar a.indent.active { color: var(--primary-light); }
.docs-search {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border 120ms ease;
}
.docs-search:focus { border-color: var(--primary-light); }

/* Content column */
.docs-content {
  min-width: 0;
}
.docs-content h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  background: var(--gradient-wide);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.docs-content .lead {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.6;
  margin-bottom: 32px;
}
.docs-content h2 {
  font-size: 26px;
  font-weight: 700;
  margin: 56px 0 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-height) + 24px);
}
.docs-content h3 {
  font-size: 19px;
  font-weight: 600;
  margin: 32px 0 12px;
  scroll-margin-top: calc(var(--nav-height) + 24px);
}
.docs-content p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 16px;
  font-size: 15.5px;
}
.docs-content a {
  color: var(--primary-light);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-hover);
}
.docs-content a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Anchor links on headings */
.docs-content h2,
.docs-content h3 {
  position: relative;
}
.docs-content h2 .anchor,
.docs-content h3 .anchor {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--text-muted);
  text-decoration: none;
  transition: opacity 120ms ease;
  border: none;
}
.docs-content h2:hover .anchor,
.docs-content h3:hover .anchor { opacity: 1; }

/* Lists */
.docs-content ul,
.docs-content ol { padding-left: 22px; margin: 0 0 16px; }
.docs-content li { color: var(--text-secondary); line-height: 1.7; margin: 4px 0; }

/* Code */
.docs-content code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
  color: var(--accent);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.docs-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 18px 0 24px;
  font-size: 13.5px;
  line-height: 1.55;
  position: relative;
}
.code-copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  font: 600 11px/1 'Inter', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0; transition: opacity 150ms ease, color 150ms ease, border-color 150ms ease;
}
.docs-content pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.code-copy-btn.copied { color: var(--accent); border-color: var(--accent); opacity: 1; }
.docs-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* Callout / note boxes */
.docs-callout {
  border-left: 3px solid var(--primary);
  background: var(--primary-glow);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin: 22px 0;
  color: var(--text);
}
.docs-callout.warn { border-left-color: #f5b252; background: rgba(245, 178, 82, 0.08); }
.docs-callout.success { border-left-color: var(--accent); background: var(--accent-dim); }
.docs-callout strong { color: var(--text); }

/* Tables */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 24px;
  font-size: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
/* Horizontally scrollable wrapper for wide comparison tables */
.docs-content .table-scroll {
  overflow-x: auto;
  margin: 18px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  -webkit-overflow-scrolling: touch;
}
.docs-content .table-scroll table {
  margin: 0;
  border: none;
  border-radius: 0;
  min-width: 1100px;
}
/* Smaller min-width for the compact 4-column mini-compare on Overview */
.docs-content .docs-mini-compare .table-scroll table { min-width: 540px; }
.docs-content .table-scroll th:first-child,
.docs-content .table-scroll td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-elevated);
  z-index: 1;
  border-right: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}
/* Subtly highlight the Binderus column (always 2nd) */
.docs-content .table-scroll th:nth-child(2),
.docs-content .table-scroll td:nth-child(2) {
  background: var(--primary-glow);
  color: var(--text);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.docs-content .table-scroll th:nth-child(2) {
  color: var(--primary-light);
}
.docs-content th,
.docs-content td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.docs-content th { background: var(--bg-elevated); color: var(--text); font-weight: 600; }
.docs-content tr:last-child td { border-bottom: none; }
.docs-content kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text);
}

/* TOC (right rail) */
.docs-toc {
  position: sticky;
  top: calc(var(--nav-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--nav-height) - 48px);
  overflow-y: auto;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.docs-toc h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 12px 12px;
  font-weight: 700;
}
.docs-toc ul { list-style: none; padding: 0; margin: 0; }
.docs-toc a {
  display: block;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.docs-toc a.h3 { padding-left: 24px; font-size: 12.5px; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--primary-light); border-left-color: var(--primary); }

/* Overview hero — used only on /docs/ landing */
.docs-hero { padding: 12px 0 28px; }
.docs-hero h1 { font-size: clamp(32px, 5vw, 48px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; }
.docs-hero p { font-size: 17px; color: var(--text-secondary); line-height: 1.6; max-width: 720px; margin: 0 0 22px; }
.docs-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.docs-hero-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  text-decoration: none; transition: transform 200ms ease, filter 200ms ease;
}
.docs-hero-btn.primary { background: var(--gradient); color: #0b0b12 !important; }
.docs-hero-btn.primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.docs-hero-btn.secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.docs-hero-btn.secondary:hover { border-color: var(--primary-light); }
/* Router cards on Overview */
.docs-router { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0 32px; }
@media (max-width: 800px) { .docs-router { grid-template-columns: 1fr; } }
.docs-router .docs-card { padding: 24px; }
.docs-router .docs-card h3 { font-size: 18px; margin-bottom: 8px; }
.docs-router .docs-card p { font-size: 14px; line-height: 1.55; }
.docs-router .docs-card .arrow {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 14px; color: var(--primary-light); font-size: 13px; font-weight: 600;
}
/* Compact comparison preview on Overview */
.docs-mini-compare { margin: 8px 0 28px; }
.docs-mini-compare table { font-size: 14px; }
.docs-mini-compare td:first-child, .docs-mini-compare th:first-child { font-weight: 600; }
.docs-mini-compare .seemore { display: inline-block; margin-top: 12px; font-size: 14px; color: var(--primary-light); text-decoration: none; }
.docs-mini-compare .seemore:hover { text-decoration: underline; }

/* Card grid (used on docs landing page) */
.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 32px 0;
}
.docs-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border 200ms ease, transform 200ms ease;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.docs-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
}
.docs-card .icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.docs-card .icon svg { width: 20px; height: 20px; stroke: var(--primary-light); fill: none; stroke-width: 2; }
.docs-card h3 { margin: 0 0 6px; font-size: 16px; }
.docs-card p { color: var(--text-secondary); font-size: 14px; margin: 0; line-height: 1.5; }

/* FAQ accordion */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.faq-q {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-q::after {
  content: '+';
  color: var(--primary-light);
  font-size: 22px;
  font-weight: 300;
  transition: transform 200ms ease;
}
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a {
  display: none;
  padding: 0 20px 16px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.65;
}
.faq-item.open .faq-a { display: block; }

/* Breadcrumbs */
.docs-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.docs-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  border: none;
}
.docs-breadcrumb a:hover { color: var(--text); }
.docs-breadcrumb span { margin: 0 8px; }


/* Nested sidebar (Settings -> tabs) */
.docs-sidebar ul.nested {
  margin: 0 0 4px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.docs-sidebar ul.nested a {
  font-size: 13.5px;
  padding: 5px 10px;
}
.docs-sidebar a.parent-active {
  color: var(--text);
}


/* ---------- Light mode overrides ---------- */
/* :root[data-theme-mode="light"] — higher specificity than the inline :root rule
   in each docs page, so these vars win regardless of stylesheet order */
:root[data-theme-mode="light"] {
  --bg: #ffffff;
  --bg-card: #f7f7fa;
  --bg-elevated: #ececf2;
  --surface: #e2e2ec;
  --primary: #6d5be0;
  --primary-glow: rgba(109, 91, 224, 0.10);
  --primary-light: #5a4cc7;
  --accent: #2da987;
  --accent-dim: rgba(45, 169, 135, 0.10);
  --text: #1a1a25;
  --text-secondary: #4f4f6e;
  --text-muted: #888899;
  --border: #e0e0e8;
  --border-hover: #c8c8d4;
}
[data-theme-mode="light"] body { background: var(--bg); color: var(--text); }
/* Set the nav background up-front for light mode so the first paint matches —
   otherwise the inline `<style>` rule `nav { background: rgba(11,11,18,0.8) }`
   wins until the inline JS sets `nav.style.background`, causing a dark→light
   flicker on every page navigation in light mode. */
:root[data-theme-mode="light"] nav {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
}
[data-theme-mode="light"] .docs-content code { background: var(--bg-card); color: #2da987; }
[data-theme-mode="light"] .docs-content pre { background: var(--bg-card); }
[data-theme-mode="light"] .docs-callout { background: rgba(109, 91, 224, 0.06); }
[data-theme-mode="light"] .docs-callout.warn { background: rgba(245, 178, 82, 0.10); }
[data-theme-mode="light"] .docs-callout.success { background: rgba(45, 169, 135, 0.08); }
[data-theme-mode="light"] .gradient-text {
  background: linear-gradient(135deg, #6d5be0 0%, #a04fe0 50%, #2da987 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Hide language picker on docs (English only for now) */
.i18n-picker { display: none !important; }

/* GitHub icon link in nav (matches main site) */
.nav-github {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--text-secondary);
  transition: color 150ms ease;
}
.nav-github:hover { color: var(--text); }

/* Theme toggle button in the nav */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 150ms ease, color 150ms ease;
}
.theme-toggle:hover { border-color: var(--primary-light); color: var(--primary-light); }
.theme-toggle svg { display: block; }
