/* ═══════════════════════════════════════════════════
   Logicfire Docs — CSS
   ═══════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-code: #f3f4f8;
  --bg-topnav: rgba(255,255,255,.92);
  --text: #1e1e2e;
  --text-secondary: #5c5c7a;
  --text-muted: #8888a4;
  --border: #e4e6ef;
  --border-light: #eff0f6;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --accent-light: rgba(108,92,231,.08);
  --accent-glow: rgba(108,92,231,.18);
  --pro-accent: #e8475f;
  --pro-light: rgba(232,71,95,.08);
  --green: #2ecc71;
  --orange: #f39c12;
  --red: #e74c3c;
  --blue: #3498db;
  --sidebar-w: 260px;
  --topnav-h: 56px;
  --toc-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --font: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-serif: 'Lora', Georgia, serif;
}

[data-theme="dark"] {
  --bg: #13131a;
  --bg-card: #1a1a26;
  --bg-sidebar: #16161f;
  --bg-code: #1e1e2e;
  --bg-topnav: rgba(19,19,26,.94);
  --text: #e0e0ee;
  --text-secondary: #9999b8;
  --text-muted: #666688;
  --border: #2a2a3c;
  --border-light: #222233;
  --accent: #a78bfa;
  --accent-hover: #8b6ff0;
  --accent-light: rgba(167,139,250,.1);
  --accent-glow: rgba(167,139,250,.2);
  --pro-accent: #f06292;
  --pro-light: rgba(240,98,146,.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; border-radius: var(--radius); }

/* ── Progress Bar ── */
#progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: 9999;
  background: linear-gradient(90deg, var(--accent), var(--pro-accent));
  width: 0%; transition: width .1s;
}

/* ── Top Nav ── */
#topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topnav-h);
  background: var(--bg-topnav);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
}

.nav-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--accent-light); color: var(--accent); }

#hamburger { display: none; }

.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.logo-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--pro-accent));
  color: #fff; font-weight: 600; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.logo-name { font-weight: 600; font-size: 14px; }
.logo-version {
  font-size: 11px; color: var(--text-muted); background: var(--bg-code);
  padding: 2px 7px; border-radius: 4px;
}

#nav-search-wrap {
  position: relative; flex: 1; max-width: 420px; margin-left: auto;
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-muted); pointer-events: none;
}
#nav-search {
  width: 100%; height: 36px; padding: 0 12px 0 32px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 13px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
#nav-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#nav-search::placeholder { color: var(--text-muted); }

#search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 360px; overflow-y: auto; display: none; z-index: 200;
}
#search-results.active { display: block; }
.search-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--accent-light); }
.search-item-title { font-weight: 500; font-size: 13px; color: var(--text); }
.search-item-section { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.nav-actions { display: flex; align-items: center; gap: 4px; margin-left: 8px; }

/* ── Sidebar ── */
#sidebar {
  position: fixed; top: var(--topnav-h); left: 0;
  width: var(--sidebar-w); height: calc(100vh - var(--topnav-h));
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 0; z-index: 90;
  transition: transform .25s ease;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 4px; }
.nav-section-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); cursor: pointer;
  user-select: none;
}
.nav-section-label svg { width: 12px; height: 12px; transition: transform .2s; flex-shrink: 0; }
.nav-section.collapsed .nav-section-label svg { transform: rotate(-90deg); }
.nav-section.collapsed .nav-links { display: none; }

.nav-links { padding: 0 8px; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; margin: 1px 0;
  font-size: 13px; color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s, color .12s;
  text-decoration: none; position: relative;
}
.nav-link svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .7; }
.nav-link:hover { background: var(--accent-light); color: var(--text); }
.nav-link.active {
  background: var(--accent-light); color: var(--accent); font-weight: 500;
}
.nav-link.active svg { opacity: 1; }

.nav-link-badge {
  font-size: 9px; font-weight: 600; padding: 1px 5px;
  border-radius: 3px; margin-left: auto; text-transform: uppercase;
}
.badge-new { background: var(--pro-light); color: var(--pro-accent); }

#sidebar-overlay {
  position: fixed; inset: 0; z-index: 89; background: rgba(0,0,0,.4);
  display: none; opacity: 0; transition: opacity .25s;
}
#sidebar-overlay.active { display: block; opacity: 1; }

/* ── Main Content ── */
#shell {
  margin-left: var(--sidebar-w);
  margin-top: var(--topnav-h);
  display: flex; min-height: calc(100vh - var(--topnav-h));
}

#content {
  flex: 1; max-width: 100%; padding: 32px 40px 80px;
  margin: 0 auto;
}

/* ── TOC ── */
#toc {
  position: sticky; top: calc(var(--topnav-h) + 24px);
  width: var(--toc-w); flex-shrink: 0; padding: 0 16px;
  height: fit-content; max-height: calc(100vh - var(--topnav-h) - 48px);
  overflow-y: auto;
}
.toc-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); margin-bottom: 12px;
}
.toc-link {
  display: block; padding: 4px 0 4px 12px; font-size: 12px;
  color: var(--text-muted); border-left: 2px solid var(--border);
  transition: color .12s, border-color .12s; text-decoration: none;
}
.toc-link:hover { color: var(--text); }
.toc-link.active { color: var(--accent); border-color: var(--accent); font-weight: 500; }
.toc-link.toc-h3 { padding-left: 24px; font-size: 11.5px; }

/* ── Sections ── */
.doc-section { display: none; }
.doc-section.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Breadcrumbs ── */
.breadcrumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.bc-item { font-size: 12px; color: var(--text-muted); }
.bc-item a { color: var(--text-muted); }
.bc-item a:hover { color: var(--accent); }
.bc-item.current { color: var(--text-secondary); font-weight: 500; }
.bc-sep { font-size: 11px; color: var(--text-muted); }

/* ── Page Tags ── */
.page-tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--accent);
  background: var(--accent-light); padding: 3px 10px; border-radius: 4px;
  margin-bottom: 10px;
}
.page-tag.pro-tag { color: var(--pro-accent); background: var(--pro-light); }

/* ── Typography ── */
h1 {
  font-size: 32px; font-weight: 600; line-height: 1.25;
  color: var(--text); margin-bottom: 8px; letter-spacing: -.3px;
}
.page-subtitle {
  font-size: 16px; line-height: 1.6; color: var(--text-secondary);
  margin-bottom: 32px; max-width: 640px;
}

h2 {
  font-size: 22px; font-weight: 600; color: var(--text);
  margin: 40px 0 16px; padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
h2:first-of-type { border-top: none; }

h3 { font-size: 17px; font-weight: 600; color: var(--text); margin: 24px 0 10px; }

p { margin-bottom: 14px; color: var(--text-secondary); }
p + ul, p + ol { margin-top: -6px; }

ul, ol { padding-left: 24px; margin-bottom: 16px; color: var(--text-secondary); }
li { margin-bottom: 6px; }
li strong { color: var(--text); }

code {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg-code); padding: 2px 6px; border-radius: 4px;
  color: var(--accent);
}

/* ── Tables ── */
.params-table {
  width: 100%; border-collapse: collapse; margin: 16px 0 24px;
  font-size: 13.5px;
}
.params-table th {
  text-align: left; padding: 10px 12px; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted);
  background: var(--bg); border-bottom: 2px solid var(--border);
}
.params-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary); vertical-align: top;
}
.params-table td:first-child { color: var(--text); font-weight: 500; }
.params-table tr:hover td { background: var(--accent-light); }
.params-table code { font-size: 12px; }

/* ── Code Blocks ── */
.code-block {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 16px 0 20px; overflow: hidden;
}
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--border-light); font-size: 12px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.copy-btn {
  font-size: 11px; font-weight: 500; padding: 3px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-card); color: var(--text-muted); cursor: pointer;
  transition: all .15s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.code-block pre {
  padding: 14px 16px; margin: 0; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  color: var(--text);
}
.code-block code { background: none; padding: 0; color: inherit; }

/* ── Callouts ── */
.callout {
  display: flex; gap: 12px; padding: 16px;
  border-radius: var(--radius); margin: 20px 0;
  border: 1px solid var(--border);
}
.callout-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; }
.callout-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.callout-body p { margin-bottom: 6px; font-size: 14px; }
.callout-body p:last-child { margin-bottom: 0; }
.callout.tip { background: rgba(108,92,231,.05); border-color: rgba(108,92,231,.2); }
.callout.warning { background: rgba(243,156,18,.05); border-color: rgba(243,156,18,.2); }
.callout.note { background: rgba(52,152,219,.05); border-color: rgba(52,152,219,.2); }

/* ── Steps ── */
.steps { margin: 16px 0 24px; }
.step {
  display: flex; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.step:last-child { border-bottom: none; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.step-body { flex: 1; }
.step-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.step-body p { margin-bottom: 0; font-size: 14px; }

/* ── Collapsibles ── */
.collapsible { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; }
.collapsible-trigger {
  display: flex; align-items: center; width: 100%;
  padding: 12px 16px; font-size: 14px; font-weight: 500;
  color: var(--text); background: var(--bg-card); border: none;
  cursor: pointer; text-align: left; font-family: var(--font);
  transition: background .12s;
}
.collapsible-trigger::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); margin-right: 12px; flex-shrink: 0;
  transition: transform .2s;
}
.collapsible.open .collapsible-trigger::before { transform: rotate(45deg); }
.collapsible-trigger:hover { background: var(--accent-light); }
.collapsible-content {
  display: none; padding: 0 16px 14px 34px; font-size: 14px;
  color: var(--text-secondary);
}
.collapsible.open .collapsible-content { display: block; }

/* ── Nav Footer ── */
.nav-footer {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.nav-card {
  display: block; padding: 14px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; min-width: 180px;
  transition: border-color .15s, box-shadow .15s;
}
.nav-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.nav-card-dir { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.nav-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.nav-card.next { text-align: right; margin-left: auto; }

/* ── Mobile TOC ── */
.mobile-toc { display: none; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  #toc { display: none; }
  .mobile-toc {
    display: block; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px; margin-bottom: 24px;
  }
  .mobile-toc-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .6px; color: var(--text-muted); margin-bottom: 8px;
  }
  .mobile-toc a {
    display: block; padding: 4px 0; font-size: 13px; color: var(--text-secondary);
  }
}

@media (max-width: 768px) {
  #hamburger { display: flex; }
  #sidebar { transform: translateX(-100%); z-index: 100; }
  #sidebar.open { transform: translateX(0); }
  #shell { margin-left: 0; }
  #content { padding: 20px 16px 60px; }
  h1 { font-size: 26px; }
  .nav-footer { flex-direction: column; }
  .nav-card { min-width: unset; }
  .nav-card.next { text-align: left; margin-left: 0; }
  .logo-name { display: none; }
  .params-table { font-size: 12px; }
  .params-table th, .params-table td { padding: 8px; }
}
