/* ================================================================
   ensemble-mcp Documentation Theme
   Design system extracted from ensemble-mcp-presentation.html
   with doc-specific layout (topbar, sidebar, content area).
   ================================================================ */

/* ── Theme Variables (Dark) ─────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg: #0b0f0d;
  --bg-soft: #10151291;
  --bg-card: #111815;
  --ink: #e8ece8;
  --ink-dim: #a8b0aa;
  --ink-soft: #6b7570;
  --rule: #1f2a24;
  --rule-hi: #2a3a33;
  --accent: #10b981;
  --accent-2: #f59e0b;
  --accent-3: #3b82f6;
  --accent-4: #ef4444;
  --accent-5: #8b5cf6;
  --accent-6: #ec4899;
  --glow: rgba(16,185,129,.12);
  --grid: rgba(255,255,255,.025);
  --code-bg: #0d1311;
  --shadow-lg: 0 30px 80px -20px rgba(0,0,0,.6);
  --noise-op: .025;
}

/* ── Theme Variables (Light) ────────────────────────────────────── */
:root[data-theme="light"] {
  --bg: #faf8f3;
  --bg-soft: #f2efe6;
  --bg-card: #ffffff;
  --ink: #14201b;
  --ink-dim: #4a5751;
  --ink-soft: #8a948e;
  --rule: #d9d2c4;
  --rule-hi: #b8ae9b;
  --accent: #047857;
  --accent-2: #b45309;
  --accent-3: #1d4ed8;
  --accent-4: #b91c1c;
  --accent-5: #6d28d9;
  --accent-6: #be185d;
  --glow: rgba(4,120,87,.08);
  --grid: rgba(0,0,0,.035);
  --code-bg: #efeadb;
  --shadow-lg: 0 30px 80px -20px rgba(55,40,20,.18);
  --noise-op: .04;
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background .45s ease, color .45s ease;
}

/* ── Font Utilities ─────────────────────────────────────────────── */
.serif  { font-family: 'Google Sans', sans-serif; }
.mono   { font-family: 'Google Sans Code', ui-monospace, 'SF Mono', 'Menlo', monospace; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--rule);
  transition: background .45s ease, border-color .45s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand a {
  font-family: 'Google Sans Code', monospace;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color .3s;
}
.brand a:hover { color: var(--ink); }
.brand a strong {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: .1em;
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: .6; transform: scale(.85); }
  50%      { opacity: 1;  transform: scale(1.1); }
}
.brand-suffix {
  color: var(--ink-soft);
  font-weight: 400;
  margin-left: 2px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctrl {
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: 'Google Sans Code', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: all .3s ease;
  white-space: nowrap;
}
.ctrl:hover {
  color: var(--ink);
  border-color: var(--rule-hi);
  background: var(--bg-soft);
}
.ctrl svg { width: 14px; height: 14px; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 260px;
  padding: 20px 12px 48px;
  overflow-y: auto;
  border-right: 1px solid var(--rule);
  background: var(--bg);
  z-index: 90;
  transition: transform .35s cubic-bezier(.4,0,.2,1), background .45s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-hi) transparent;
}
.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--rule-hi); border-radius: 4px; }

.sidebar-section { margin-bottom: 20px; }
.sidebar-heading {
  font-family: 'Google Sans Code', monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 8px 12px 6px;
  font-weight: 500;
}
.sidebar-link {
  display: block;
  padding: 5px 12px;
  border-radius: 6px;
  font-family: 'Google Sans', sans-serif;
  font-size: 13.5px;
  color: var(--ink-dim);
  text-decoration: none;
  transition: all .2s ease;
  line-height: 1.45;
}
.sidebar-link:hover {
  color: var(--ink);
  background: var(--bg-soft);
}
.sidebar-link.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 500;
}
.sidebar-divider {
  height: 1px;
  background: var(--rule);
  margin: 12px 12px;
}

/* ── Sidebar Toggle (Mobile) ───────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 101;
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all .3s;
}
.sidebar-toggle:hover {
  border-color: var(--rule-hi);
  background: var(--bg-soft);
}
.sidebar-toggle svg { width: 18px; height: 18px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 89;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Main Content ───────────────────────────────────────────────── */
.content {
  margin-left: 260px;
  padding: 80px 48px 80px;
  max-width: 960px;
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────────── */
.content h1 {
  font-family: 'Google Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(32px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 12px;
}
.content h1 + p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-dim);
}

.content h2 {
  font-family: 'Google Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin-top: 48px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 72px;
}
.content h3 {
  font-family: 'Google Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-top: 36px;
  margin-bottom: 10px;
  scroll-margin-top: 72px;
}
.content h4 {
  font-family: 'Google Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
  margin-top: 24px;
  margin-bottom: 8px;
}

.content p,
.content li {
  color: var(--ink-dim);
  font-size: 15.5px;
  line-height: 1.65;
}
.content p       { margin-bottom: 14px; }
.content p:last-child { margin-bottom: 0; }
.content p strong,
.content li strong { color: var(--ink); font-weight: 600; }
.content em      { font-style: italic; }

.content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  transition: border-color .2s;
}
.content a:hover { border-bottom-color: var(--accent); }

.content ul,
.content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.content li { margin-bottom: 5px; }

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

/* ── Tables ─────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 24px;
}
table th, table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table th {
  font-family: 'Google Sans Code', monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  border-bottom: 1px solid var(--rule-hi);
  padding: 10px 16px;
}
table td { color: var(--ink-dim); }
table td:first-child { color: var(--ink); font-weight: 500; }
table tr:hover td {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}
table.mono-data td {
  font-family: 'Google Sans Code', monospace;
  font-size: 13px;
}

/* ── Code Blocks ────────────────────────────────────────────────── */
pre.code, code.inline {
  font-family: 'Google Sans Code', monospace;
  background: var(--code-bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
pre.code {
  padding: 20px 22px;
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  position: relative;
  margin-bottom: 20px;
}
pre.code::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
code.inline {
  display: inline;
  padding: 2px 7px;
  font-size: .88em;
  border-radius: 3px;
}
.code-comment { color: var(--ink-soft); }
.code-string  { color: var(--accent-2); }
.code-key     { color: var(--accent); }
.code-num     { color: var(--accent-5); }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 28px;
  position: relative;
  transition: border-color .3s ease;
  margin-bottom: 20px;
}
.card:hover { border-color: var(--rule-hi); }

/* ── Chips ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Google Sans Code', monospace;
  font-size: 11px;
  letter-spacing: .05em;
  padding: 4px 10px;
  border: 1px solid var(--rule-hi);
  border-radius: 999px;
  color: var(--ink-dim);
  background: var(--bg-soft);
}
.chip-accent {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.chip-warn {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent-2) 40%, transparent);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

/* ── Panels (Callouts / Notes / Tips / Warnings) ────────────────── */
.panel {
  padding: 20px 24px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 0 6px 6px 0;
  margin-bottom: 20px;
}
.panel h5 {
  font-family: 'Google Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
}
.panel p {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--ink-dim);
}
.panel p:last-child { margin-bottom: 0; }
.panel pre.code { margin-bottom: 0; }
.panel.panel-blue {
  border-left-color: var(--accent-3);
  background: color-mix(in srgb, var(--accent-3) 6%, transparent);
}
.panel.panel-amber {
  border-left-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 6%, transparent);
}
.panel.panel-red {
  border-left-color: var(--accent-4);
  background: color-mix(in srgb, var(--accent-4) 6%, transparent);
}

/* ── Mermaid Diagrams ───────────────────────────────────────────── */
.mermaid-wrap {
  padding: 28px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-card);
  overflow-x: auto;
  margin-bottom: 20px;
}
.mermaid { display: flex; justify-content: center; }
.mermaid svg { max-width: 100%; height: auto; }

/* ── ASCII Diagram Blocks ───────────────────────────────────────── */
pre.diagram {
  font-family: 'Google Sans Code', monospace;
  background: var(--code-bg);
  color: var(--ink-dim);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 20px 22px;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin-bottom: 20px;
}

/* ── Quick Links Grid ───────────────────────────────────────────── */
.quick-links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.quick-links li {
  margin-bottom: 0;
}

/* ── Responsive: Mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .content {
    margin-left: 0;
    padding: 72px 20px 48px;
    max-width: 100%;
  }
  .topbar {
    padding-left: 56px;
  }
  .brand-suffix { display: none; }
  .controls .ctrl span { display: none; }
  .controls .ctrl { padding: 0 8px; }
}

@media (max-width: 480px) {
  .content h1 { font-size: 26px; }
  .content h2 { font-size: 20px; }
  pre.code { font-size: 12px; padding: 14px 16px; }
  table { font-size: 12px; }
  table th, table td { padding: 8px 10px; }
}

/* ── Overflow Table Wrapper ─────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 24px;
}
.table-wrap table { margin-bottom: 0; }
