/* ==========================================================================
   AtomCode docs — shared layout, theme and prose styles
   ========================================================================== */

:root {
  --bg-primary: #020617;
  --bg-secondary: #0f172a;
  --bg-card: rgba(255,255,255,0.03);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-body: #cbd5e1;
  --border-color: rgba(255,255,255,0.06);
  --code-bg: #0d1117;
  --code-border: rgba(255,255,255,0.06);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255,255,255,0.85);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-body: #334155;
  --border-color: rgba(15,23,42,0.1);
  --code-bg: #f1f5f9;
  --code-border: rgba(15,23,42,0.08);
}

html, body { overflow-x: hidden; max-width: 100vw; }
* { box-sizing: border-box; }
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Nav */
nav.docs-nav { background: rgba(2,6,23,0.85); backdrop-filter: blur(16px); transition: all 0.3s ease; }
[data-theme="light"] nav.docs-nav { background: rgba(248,250,252,0.92); border-color: rgba(15,23,42,0.08) !important; }
[data-theme="light"] nav.docs-nav .text-slate-400 { color: #475569 !important; }
[data-theme="light"] nav.docs-nav .text-slate-300 { color: #334155 !important; }
[data-theme="light"] nav.docs-nav .text-slate-500 { color: #64748b !important; }
[data-theme="light"] nav.docs-nav .bg-white\/5 { background: rgba(15,23,42,0.05); }
[data-theme="light"] nav.docs-nav .hover\:bg-white\/10:hover { background: rgba(15,23,42,0.08); }
[data-theme="light"] nav.docs-nav .border-white\/5 { border-color: rgba(15,23,42,0.08) !important; }

/* Sidebar */
.docs-sidebar {
  font-size: 0.875rem;
}
.docs-sidebar > div {
  font-family: 'Inter', sans-serif;
}
.docs-sidebar nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  margin-left: -0.75rem;
  border-radius: 0.5rem;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}
.docs-sidebar nav a:hover {
  background: rgba(139,92,246,0.08);
  color: #e2e8f0;
}
.docs-sidebar nav a[aria-current="page"] {
  background: rgba(139,92,246,0.12);
  color: #a78bfa;
  font-weight: 600;
}
[data-theme="light"] .docs-sidebar nav a { color: #475569; }
[data-theme="light"] .docs-sidebar nav a:hover { background: rgba(124,58,237,0.08); color: #0f172a; }
[data-theme="light"] .docs-sidebar nav a[aria-current="page"] {
  background: rgba(124,58,237,0.12);
  color: #7c3aed;
}

/* Mobile sidebar — collapsed by default, shown when toggled */
@media (max-width: 767px) {
  .docs-sidebar { display: none; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); }
  .docs-sidebar.open { display: block; }
}

/* ------------ Prose ------------ */
.prose-docs {
  color: var(--text-body);
  line-height: 1.7;
  font-size: 0.95rem;
}
.prose-docs h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.prose-docs .lede {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}
.prose-docs h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2.75rem;
  margin-bottom: 0.875rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
  scroll-margin-top: 5rem;
}
.prose-docs h2:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.prose-docs h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.75rem;
  margin-bottom: 0.625rem;
  scroll-margin-top: 5rem;
}
.prose-docs p { margin-bottom: 1rem; }
.prose-docs strong { color: var(--text-primary); font-weight: 600; }
.prose-docs ul, .prose-docs ol {
  margin: 0 0 1.25rem 0;
  padding-left: 1.5rem;
}
.prose-docs ul { list-style: disc; }
.prose-docs ul ul { list-style: circle; margin-top: 0.375rem; margin-bottom: 0.375rem; }
.prose-docs ol { list-style: decimal; }
.prose-docs li { margin-bottom: 0.375rem; }
.prose-docs a {
  color: #a78bfa;
  text-decoration: underline;
  text-decoration-color: rgba(167,139,250,0.35);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.prose-docs a:hover {
  color: #c4b5fd;
  text-decoration-color: #a78bfa;
}
[data-theme="light"] .prose-docs a { color: #7c3aed; text-decoration-color: rgba(124,58,237,0.35); }
[data-theme="light"] .prose-docs a:hover { color: #5b21b6; }

/* Inline code */
.prose-docs :not(pre) > code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.85em;
  background: rgba(139,92,246,0.14);
  color: #c4b5fd;
  padding: 0.15em 0.42em;
  border-radius: 0.3rem;
  white-space: nowrap;
}
[data-theme="light"] .prose-docs :not(pre) > code {
  background: rgba(124,58,237,0.1);
  color: #6d28d9;
}

/* Code blocks */
.prose-docs pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: #e2e8f0;
}
[data-theme="light"] .prose-docs pre { color: #0f172a; }
.prose-docs pre code { font-family: inherit; font-size: inherit; color: inherit; background: transparent; padding: 0; }

/* Tables */
.prose-docs table {
  width: 100%;
  margin: 1rem 0 1.5rem;
  border-collapse: collapse;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prose-docs thead { background: rgba(139,92,246,0.04); }
[data-theme="light"] .prose-docs thead { background: rgba(124,58,237,0.05); }
.prose-docs th, .prose-docs td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top;
}
.prose-docs th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.prose-docs tr:last-child td { border-bottom: none; }
.prose-docs td code { white-space: nowrap; }

/* Blockquote */
.prose-docs blockquote {
  border-left: 3px solid #8b5cf6;
  padding: 0.625rem 1rem;
  margin: 1rem 0 1.5rem;
  color: var(--text-secondary);
  background: rgba(139,92,246,0.05);
  border-radius: 0 0.5rem 0.5rem 0;
}
[data-theme="light"] .prose-docs blockquote { background: rgba(124,58,237,0.05); }

/* Callouts */
.callout {
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  margin: 1rem 0 1.5rem;
  border: 1px solid;
  font-size: 0.875rem;
}
.callout strong { display: block; margin-bottom: 0.25rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.callout p { margin-bottom: 0; }
.callout-info { background: rgba(14,165,233,0.08); border-color: rgba(14,165,233,0.3); color: #7dd3fc; }
.callout-info strong { color: #0ea5e9; }
.callout-warn { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); color: #fcd34d; }
.callout-warn strong { color: #f59e0b; }
.callout-tip  { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.callout-tip strong { color: #10b981; }
[data-theme="light"] .callout-info { color: #075985; }
[data-theme="light"] .callout-info strong { color: #0369a1; }
[data-theme="light"] .callout-warn { color: #78350f; }
[data-theme="light"] .callout-warn strong { color: #b45309; }
[data-theme="light"] .callout-tip  { color: #065f46; }
[data-theme="light"] .callout-tip strong { color: #047857; }

/* Card grid (used on docs index) */
.doc-card {
  display: block;
  padding: 1.25rem 1.375rem;
  border-radius: 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  text-decoration: none !important;
  transition: all 0.2s ease;
}
.doc-card:hover {
  border-color: rgba(139,92,246,0.4);
  transform: translateY(-1px);
  background: rgba(139,92,246,0.05);
}
.doc-card h3 {
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin: 0 0 0.35rem 0 !important;
  padding: 0 !important;
  border: none !important;
}
.doc-card p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 !important;
  line-height: 1.55;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbd5e1; }

/* ── Docs search ── */
.docs-search-wrap { position: relative; margin-bottom: 1rem; }
#searchInput {
  width: 100%;
  padding: 0.5rem 0.75rem;
  padding-right: 3rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: 'Inter', system-ui, sans-serif;
  outline: none;
  transition: border-color 0.15s ease;
}
#searchInput::placeholder { color: var(--text-secondary); opacity: 0.6; }
#searchInput:focus { border-color: #8b5cf6; }
.docs-search-wrap::after {
  content: '⌘K';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.625rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  pointer-events: none;
  opacity: 0.6;
}
.docs-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  max-height: 24rem;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
[data-theme="light"] .docs-search-results { box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.search-item {
  display: block;
  padding: 0.625rem 0.875rem;
  text-decoration: none !important;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.1s ease;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(139,92,246,0.08); }
.search-page {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b5cf6;
  margin-bottom: 0.125rem;
}
.search-heading {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}
.search-snippet {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.search-snippet mark {
  background: rgba(139,92,246,0.25);
  color: #c4b5fd;
  border-radius: 2px;
  padding: 0 2px;
}
[data-theme="light"] .search-snippet mark {
  background: rgba(124,58,237,0.15);
  color: #5b21b6;
}
.search-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Tailwind utility overrides in light theme (nav only) */
[data-theme="light"] .hover\:text-brand-400:hover { color: #7c3aed !important; }
