/* ============================================================
   Logiq Documentation — styles
   ============================================================ */

:root {
  --sidebar-width: 280px;
  --content-width: 820px;

  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #fbfcfd;
  --bg-code: #f6f8fa;
  --fg: #0f172a;
  --fg-muted: #64748b;
  --fg-subtle: #94a3b8;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg: #eff6ff;
  --danger: #dc2626;

  --radius: 6px;
  --radius-lg: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html.dark {
  --bg: #0f172a;
  --bg-subtle: #0b1220;
  --bg-sidebar: #0b1220;
  --bg-code: #1e293b;
  --fg: #e2e8f0;
  --fg-muted: #94a3b8;
  --fg-subtle: #64748b;
  --border: #1e293b;
  --border-strong: #334155;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-bg: #1e3a5f;
  --danger: #f87171;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- State screens ---------- */

.state-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  color: var(--fg-muted);
}

.state-screen.error { color: var(--danger); }
.state-screen.error h2 { margin: 0; }
.state-screen .hint { font-size: 0.875rem; color: var(--fg-muted); max-width: 500px; }
.state-screen code { background: var(--bg-code); padding: 0.125rem 0.375rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.875em; color: var(--fg); }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */

.site { min-height: 100vh; }

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 15;
}
@media (min-width: 769px) {
  .backdrop { display: none !important; }
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }
  .sidebar.is-open { transform: translateX(0); }
}

.sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.125rem;
}
.brand-name { color: var(--fg); }
.brand-version {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-muted);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.search-wrap {
  padding: 0.75rem 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--fg-subtle); }
.search-hint {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--fg-subtle);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0 2rem;
}

.nav-section { margin-bottom: 0.5rem; }
.nav-section-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color 0.15s;
}
.nav-section-title:hover { color: var(--fg); }

.chevron {
  display: inline-block;
  transition: transform 0.15s;
  font-size: 1rem;
  line-height: 1;
}
.chevron.rotate-90 { transform: rotate(90deg); }

.nav-link {
  display: block;
  padding: 0.375rem 1rem 0.375rem 1.25rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 2px solid transparent;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.nav-link:hover { color: var(--fg); background: var(--bg-subtle); }
.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
  font-weight: 500;
}

.no-results {
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-align: center;
}

/* ---------- Main ---------- */

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 0 2rem 5rem;
}
@media (max-width: 768px) {
  .main { margin-left: 0; padding: 0 1rem 4rem; }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  margin: 0 -2rem;
  padding-left: 2rem;
  padding-right: 2rem;
}
@media (max-width: 768px) {
  .topbar { margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
}

.breadcrumb {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.breadcrumb-part { display: inline-flex; align-items: center; gap: 0.375rem; }
.breadcrumb-sep { color: var(--fg-subtle); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem 0.625rem;
  color: var(--fg);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--bg-subtle); }

.mobile-only { display: none; }
@media (max-width: 768px) { .mobile-only { display: inline-block; } }

/* ---------- Content ---------- */

.content {
  max-width: var(--content-width);
  margin: 2rem auto;
  font-size: 1rem;
}

.content h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}
.content h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}
.content h5, .content h6 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--fg-muted);
}

.content p { margin: 0.875rem 0; }
.content ul, .content ol { margin: 0.875rem 0; padding-left: 1.5rem; }
.content li { margin: 0.25rem 0; }
.content li > p { margin: 0.25rem 0; }

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

.content strong { font-weight: 600; }
.content em { font-style: italic; }

.content code {
  background: var(--bg-code);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--fg);
}

.content pre {
  background: var(--bg-code);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.55;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
}
.content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 1em;
  color: inherit;
}

.content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--fg-muted);
  font-style: italic;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9375rem;
}
.content th, .content td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.content th {
  font-weight: 600;
  background: var(--bg-subtle);
  border-bottom-color: var(--border-strong);
}

.content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  max-width: var(--content-width);
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
  max-width: 48%;
}
.bottom-nav a:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.nav-prev { align-items: flex-start; text-align: left; }
.nav-next { align-items: flex-end; text-align: right; margin-left: auto; }
.nav-label {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.nav-title { color: var(--accent); font-size: 0.9375rem; }

/* ---------- Syntax highlighting (highlight.js minimal) ---------- */

.hljs-keyword, .hljs-built_in, .hljs-type { color: #c792ea; }
.hljs-string, .hljs-number { color: #a5d6a7; }
.hljs-comment { color: #7f8b9e; font-style: italic; }
.hljs-function { color: #82aaff; }
.hljs-title { color: #ffcb6b; }
.hljs-attr, .hljs-attribute { color: #ffcb6b; }
.hljs-variable, .hljs-params { color: #eeffff; }
.hljs-literal { color: #f78c6c; }

html.dark .hljs-keyword, html.dark .hljs-built_in, html.dark .hljs-type { color: #c792ea; }
html.dark .hljs-string, html.dark .hljs-number { color: #c3e88d; }
html.dark .hljs-comment { color: #546e7a; }
html.dark .hljs-function { color: #82aaff; }
html.dark .hljs-title { color: #ffcb6b; }
html.dark .hljs-attr { color: #ffcb6b; }
html.dark .hljs-literal { color: #f78c6c; }

/* ---------- Scrollbar (subtle) ---------- */

.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

/* ---------- Print ---------- */

@media print {
  .sidebar, .topbar, .bottom-nav { display: none; }
  .main { margin-left: 0; padding: 0; }
  .content { max-width: none; }
}