/* ═══════════════════════════════════════════════
   AI FROM THE GROUND UP — Design System
   Stripe-level dark theme
═══════════════════════════════════════════════ */

/* ── Override just-the-docs CSS variables ── */
:root {
  --body-background-color: #060a14;
  --sidebar-color:         #060a14;
  --nav-width:             252px;
  --body-text-color:       #334155;
  --body-heading-color:    #0f172a;
  --link-color:            #6366f1;

  /* ── Design tokens ── */
  --bg-page:    #060a14;
  --bg-surface: #0d1220;
  --bg-content: #ffffff;

  --border-dark:  rgba(255, 255, 255, 0.07);
  --border-light: #e2e8f0;

  --text-primary: #f8fafc;
  --text-muted:   #64748b;
  --text-reading: #334155;

  --indigo:       #6366f1;
  --indigo-light: #a5b4fc;
  --purple:       #a855f7;
  --purple-light: #d8b4fe;
  --rose:         #f43f5e;
  --sky:          #38bdf8;

  --sidebar-active-bg:     rgba(99, 102, 241, 0.08);
  --sidebar-active-border: #6366f1;
  --sidebar-active-text:   #a5b4fc;

  --topbar-height: 56px;
  --ease:          0.18s ease;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════ */
.site-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: var(--bg-page);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

.topbar-logo {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-logo span {
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-search {
  flex: 1;
  max-width: 280px;
  height: 32px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: #475569;
  font-size: 12px;
  cursor: text;
  margin-left: auto;
}
.topbar-search kbd {
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
  color: #334155;
  border: none;
}

.topbar-nav { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.topbar-link {
  font-size: 12px; color: #64748b;
  padding: 6px 12px; text-decoration: none;
  border-radius: 7px;
  transition: color var(--ease);
}
.topbar-link:hover { color: #cbd5e1; }

.topbar-cta {
  font-size: 12px; font-weight: 600;
  color: var(--indigo-light);
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  padding: 6px 14px; border-radius: 7px;
  text-decoration: none;
  transition: all var(--ease);
}
.topbar-cta:hover { background: rgba(99,102,241,0.22); color: #fff; }

/* ═══════════════════════════════════════════════
   PAGE SHELL
═══════════════════════════════════════════════ */
.page-shell {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-height);
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sidebar-nav {
  width: var(--nav-width);
  flex-shrink: 0;
  background: var(--bg-page);
  border-right: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 20px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

.sidebar-section { margin-bottom: 4px; }

.sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 20px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-label--ml   { color: rgba(99,102,241,0.75); }
.sidebar-label--dl   { color: rgba(168,85,247,0.75); }
.sidebar-label--soon { color: rgba(244,63,94,0.5); }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  font-size: 12.5px;
  color: #64748b;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
  line-height: 1.4;
}
.sidebar-link:hover { color: #cbd5e1; background: rgba(255,255,255,0.03); }
.sidebar-link.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}
.sidebar-link--disabled { opacity: 0.38; pointer-events: none; cursor: default; }

.sidebar-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
}
.sidebar-link.active .sidebar-dot { background: var(--indigo); opacity: 1; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.04);
  margin: 12px 20px;
}

/* ═══════════════════════════════════════════════
   TOC PANEL
═══════════════════════════════════════════════ */
.toc-panel {
  width: 200px;
  flex-shrink: 0;
  background: #fafafa;
  border-left: 1px solid var(--border-light);
  padding: 56px 20px 20px;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}
.toc-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 12px;
}
.toc-link {
  display: block;
  font-size: 11.5px;
  color: #94a3b8;
  padding: 5px 0 5px 10px;
  border-left: 2px solid #e2e8f0;
  text-decoration: none;
  line-height: 1.4;
  transition: all var(--ease);
}
.toc-link:hover { color: #475569; border-left-color: #c7d2fe; }
.toc-link.active { color: #4f46e5; border-left-color: var(--indigo); font-weight: 600; }
.toc-link--h3 { padding-left: 20px; font-size: 11px; }

/* ── Homepage: no sidebar / TOC ── */
.page-home .sidebar-nav,
.page-home .toc-panel { display: none; }
.page-home .main-content { max-width: 100%; padding: 0; background: var(--bg-page); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar-nav, .toc-panel { display: none; }
  .topbar-search { display: none; }
}

/* ═══════════════════════════════════════════════
   MAIN CONTENT — tutorial reading area
═══════════════════════════════════════════════ */
.main-content {
  flex: 1;
  min-width: 0;
  background: var(--bg-content);
}

/* just-the-docs wraps rendered content in .page-content */
.main-content .page-content,
.main-content > article {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* Headings */
.main-content h1 {
  font-size: 34px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin: 0 0 14px;
}
.main-content h2 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.025em;
  margin: 40px 0 12px;
  line-height: 1.3;
}
.main-content h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -0.015em;
  margin: 28px 0 10px;
}

/* Body text */
.main-content p {
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--text-reading);
  margin-bottom: 16px;
}
/* Lead — first p after h1 */
.main-content h1 + p {
  font-size: 16.5px;
  color: #64748b;
  line-height: 1.75;
  margin-bottom: 32px;
}

/* Links */
.main-content a {
  color: var(--indigo);
  text-decoration: none;
  border-bottom: 1px solid rgba(99,102,241,0.25);
  transition: border-color var(--ease);
}
.main-content a:hover { border-bottom-color: var(--indigo); }

/* Blockquote / callout */
.main-content blockquote {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--indigo);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 24px 0;
}
.main-content blockquote p { font-size: 14px; color: #475569; margin: 0; line-height: 1.65; }
.main-content blockquote strong { color: #0f172a; }

/* Inline code */
.main-content code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  color: #c026d3;
}

/* Code blocks */
.main-content pre {
  background: #0f172a !important;
  border-radius: 12px !important;
  padding: 20px !important;
  margin: 20px 0 !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}
.main-content pre code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: #e2e8f0 !important;
  font-size: 13px;
  line-height: 1.7;
}

/* HR */
.main-content hr { border: none; height: 1px; background: #f1f5f9; margin: 32px 0; }

/* Tables */
.main-content table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 24px 0; }
.main-content th { background: #f8fafc; font-weight: 600; color: #0f172a; padding: 10px 14px; border-bottom: 2px solid #e2e8f0; text-align: left; }
.main-content td { padding: 9px 14px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.main-content tr:hover td { background: #fafafa; }

/* Lists */
.main-content ul, .main-content ol { padding-left: 22px; margin-bottom: 16px; }
.main-content li { font-size: 15.5px; line-height: 1.75; color: var(--text-reading); margin-bottom: 4px; }

@media (max-width: 768px) {
  .main-content .page-content,
  .main-content > article { padding: 32px 20px 60px; }
  .main-content h1 { font-size: 26px; }
}
