/* ================================================================
   AgentMesh Documentation — Stylesheet
   ================================================================ */

/* ─── Reset & Base ──────────────────────────────────────────────── */

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

:root {
  /* Dark theme (default) — navy-tinted palette */
  --bg:          #050b14;
  --bg-surface:  #0f1623;
  --bg-code:     #1a2035;
  --bg-hover:    #1a2438;
  --bg-nav:      #080f1e;
  --border:      #1e293b;
  --text:        #e2e8f0;
  --text-dim:    #94a3b8;
  --text-bright: #f8fafc;
  --accent:      #06b6d4;
  --accent-soft: #06b6d418;
  --accent-hover:#22d3ee;
  --green:       #4ade80;
  --red:         #f87171;
  --yellow:      #fbbf24;
  --cyan:        #22d3ee;
  --purple:      #a78bfa;
  --pink:        #f472b6;
  --radius:      8px;
  --radius-lg:   16px;
  --shadow:      0 2px 16px rgba(0,0,0,0.4);
  --max-width:   860px;
  --nav-width:   260px;
  --font-body:   'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

[data-theme="light"] {
  --bg:          #f8fafc;
  --bg-surface:  #ffffff;
  --bg-code:     #f1f5f9;
  --bg-hover:    #e2e8f0;
  --bg-nav:      #f1f5f9;
  --border:      #cbd5e1;
  --text:        #1e293b;
  --text-dim:    #64748b;
  --text-bright: #0f172a;
  --accent:      #0891b2;
  --accent-soft: #0891b212;
  --accent-hover:#0e7490;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
}

::selection {
  background-color: #06b6d4;
  color: white;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  color: var(--text-bright);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.4rem; margin-bottom: 1rem; }
h2 { font-size: 1.7rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }
h4 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }

p {
  margin-bottom: 1rem;
  max-width: 65ch;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

strong { color: var(--text-bright); }

ul, ol {
  margin: 0 0 1rem 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

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

/* ─── Layout: Sidebar Nav ──────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width);
  height: 100vh;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  display: block;
  padding: 24px 24px 20px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-bright);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.sidebar-brand:hover {
  text-decoration: none;
  color: var(--text-bright);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 12px;
  flex: 1;
}

.sidebar-nav li {
  margin-bottom: 2px;
}

.sidebar-nav a {
  display: block;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  color: var(--text-bright);
  background: var(--bg-hover);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-footer a {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.sidebar-footer a:hover {
  color: var(--accent);
}

/* Content wrapper — shifts content right of sidebar */
.content-wrapper {
  margin-left: var(--nav-width);
  min-height: 100vh;
}

/* Mobile top bar — hidden on desktop */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  height: 56px;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-topbar .sidebar-brand {
  padding: 0;
  font-size: 1.1rem;
}

/* Sidebar backdrop — mobile overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
}

.sidebar-backdrop.visible {
  display: block;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text-bright);
  border-color: var(--text-dim);
}

/* Hamburger (mobile only) */
.hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

/* ─── Layout: Page Content ──────────────────────────────────────── */

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.page-wide {
  max-width: 1000px;
}

/* ─── Hero (home page) ──────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 80px 24px 60px;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 1.2rem;
  letter-spacing: -0.03em;
}

.hero .subtitle {
  font-size: 1.2rem;
  color: var(--text-dim);
  max-width: 540px;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 28px;
  border-radius: 9999px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  cursor: pointer;
  border: none;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #050b14;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #050b14;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
  border-color: var(--text-dim);
}

/* ─── Cards ─────────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 2rem 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.card:hover {
  border-color: var(--accent);
  background: linear-gradient(to bottom, var(--accent-soft), var(--bg-surface));
  box-shadow: 0 4px 24px rgba(6, 182, 212, 0.08);
}

.card-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
  display: block;
}

.card h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.55;
}

.card a {
  color: inherit;
  text-decoration: none;
}

.card a:hover { text-decoration: none; }

/* Linked cards */
a.card {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.card:hover { text-decoration: none; }

/* ─── Code Blocks ───────────────────────────────────────────────── */

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

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

.code-block {
  position: relative;
}

.code-block .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.code-block .copy-btn:hover {
  color: var(--text-bright);
}

.code-block .copy-btn.copied {
  color: var(--green);
}

/* Code language label */
.code-block .code-lang {
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  opacity: 0.6;
}

/* Syntax highlighting (manual classes) */
.kw  { color: #c084fc; } /* keywords — purple */
.fn  { color: #22d3ee; } /* functions — cyan */
.str { color: #4ade80; } /* strings — green */
.num { color: #fb923c; } /* numbers — orange */
.cm  { color: #475569; } /* comments — slate */
.tp  { color: #f472b6; } /* types — pink */
.op  { color: #94a3b8; } /* operators / punctuation — slate */

[data-theme="light"] .kw  { color: #7c3aed; }
[data-theme="light"] .fn  { color: #0891b2; }
[data-theme="light"] .str { color: #16a34a; }
[data-theme="light"] .num { color: #ea580c; }
[data-theme="light"] .cm  { color: #94a3b8; }
[data-theme="light"] .tp  { color: #db2777; }
[data-theme="light"] .op  { color: #64748b; }

/* ─── Tables ────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-bright);
  background: var(--bg-surface);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

tr:hover td {
  background: var(--bg-hover);
}

td code {
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ─── Callout Boxes ─────────────────────────────────────────────── */

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.callout p { margin: 0; }

.callout-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.callout.tip    { border-left-color: var(--green); }
.callout.tip .callout-title { color: var(--green); }

.callout.warn   { border-left-color: var(--yellow); }
.callout.warn .callout-title { color: var(--yellow); }

.callout.danger { border-left-color: var(--red); }
.callout.danger .callout-title { color: var(--red); }

/* ─── Diagrams (inline SVG or text-based) ───────────────────────── */

.diagram {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 2rem 0;
  text-align: center;
  overflow-x: auto;
}

.diagram pre {
  background: none;
  border: none;
  text-align: left;
  display: inline-block;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.diagram-caption {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 12px;
}

/* ─── State Machine Diagram ─────────────────────────────────────── */

.state-machine {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin: 2rem 0;
}

.state {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 2px solid var(--border);
  background: var(--bg-surface);
}

.state.active  { border-color: var(--accent); color: var(--accent); }
.state.success { border-color: var(--green); color: var(--green); }
.state.error   { border-color: var(--red); color: var(--red); }
.state.pause   { border-color: var(--yellow); color: var(--yellow); }

.arrow {
  color: var(--text-dim);
  font-size: 1.2rem;
}

/* ─── Primitive Cards (How It Works) ────────────────────────────── */

.primitive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 2rem 0;
}

.primitive-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.25s, background 0.25s;
}

.primitive-card:hover {
  border-color: var(--accent);
  background: linear-gradient(to bottom, var(--accent-soft), var(--bg-surface));
}

.primitive-card .label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.primitive-card .direction {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.primitive-card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

/* ─── Steps (Getting Started) ───────────────────────────────────── */

.steps {
  counter-reset: step;
  margin: 2rem 0;
}

.step {
  position: relative;
  padding-left: 56px;
  margin-bottom: 3rem;
  min-height: 40px;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step h3 {
  margin-top: 4px;
  margin-bottom: 8px;
}

/* ─── Section Anchors ───────────────────────────────────────────── */

h2[id]::before,
h3[id]::before {
  content: '';
  display: block;
  height: 24px;
  margin-top: -24px;
  visibility: hidden;
  pointer-events: none;
}

/* ─── Footer ────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer a {
  color: var(--text-dim);
}

.footer a:hover {
  color: var(--accent);
}

/* ─── Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  html {
    scroll-padding-top: 72px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-topbar {
    display: flex;
  }

  .content-wrapper {
    margin-left: 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero .subtitle {
    font-size: 1rem;
  }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }

  .page {
    padding: 32px 16px 64px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .primitive-grid {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

/* ─── Mermaid Diagrams ─────────────────────────────────────────── */

.mermaid {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  margin: 2rem 0;
  text-align: center;
  overflow-x: auto;
}

/* ─── Network Topology Cards ──────────────────────────────────── */

.topology-grid {
  display: grid;
  gap: 32px;
  margin: 2rem 0;
}

.topology-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  transition: border-color 0.2s;
}

.topology-card:hover {
  border-color: var(--accent);
  background: linear-gradient(to bottom, var(--accent-soft), var(--bg-surface));
}

.topology-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.topology-card .scenario {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 16px;
}

.topology-card .mermaid {
  margin: 16px 0;
  padding: 24px 16px;
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Utility ───────────────────────────────────────────────────── */

.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 2rem; }

/* Gradient text */
.text-gradient {
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-warm {
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .text-gradient {
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .text-gradient-warm {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── MAPI Call-to-Action ─────────────────────────────────────── */

.mapi-cta {
  margin: 2rem 0;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-lg);
  padding: 2px;
}

.mapi-cta-inner {
  background: var(--bg-surface);
  border-radius: calc(var(--radius-lg) - 2px);
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.mapi-cta-text h3 {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--accent);
  margin: 0 0 8px;
}

.mapi-cta-text p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  max-width: 50ch;
  line-height: 1.55;
}

.mapi-cta-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .mapi-cta-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ─── Hero Background Glow ────────────────────────────────────── */

.hero {
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: rgba(139, 92, 246, 0.12);
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -10%;
  width: 600px;
  height: 600px;
  background: rgba(6, 182, 212, 0.06);
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
}

[data-theme="light"] .hero::before {
  background: rgba(139, 92, 246, 0.06);
}

[data-theme="light"] .hero::after {
  background: rgba(6, 182, 212, 0.04);
}
