/* SynapseOS Documentation — Catppuccin Mocha Theme */

:root {
  --base:     #1e1e2e;
  --mantle:   #181825;
  --crust:    #11111b;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --text:     #cdd6f4;
  --lavender: #b4befe;
  --blue:     #89b4fa;
  --sapphire: #74c7ec;
  --teal:     #94e2d5;
  --green:    #a6e3a1;
  --yellow:   #f9e2af;
  --peach:    #fab387;
  --red:      #f38ba8;
  --mauve:    #cba6f7;
  --pink:     #f5c2e7;

  --sidebar-w: 280px;
  --header-h:  60px;
  --radius:    8px;
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--base);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--mantle);
  border-right: 1px solid var(--surface0);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--surface0);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue), var(--mauve));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--mantle); font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex; flex-direction: column;
}

.sidebar-logo-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
}

.sidebar-logo-sub {
  font-size: 0.72rem;
  color: var(--overlay0);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 24px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 2px; }

.nav-section {
  margin-bottom: 2px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--overlay0);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.nav-section-header:hover { color: var(--subtext0); }

.nav-section-header .chevron {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform var(--transition);
}

.nav-section.open .chevron { transform: rotate(90deg); }

.nav-section-links {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.nav-section.open .nav-section-links { max-height: 600px; }

.nav-link {
  display: block;
  padding: 6px 20px 6px 32px;
  font-size: 0.84rem;
  color: var(--subtext0);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface0);
  border-left-color: var(--surface2);
}

.nav-link.active {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  border-left-color: var(--blue);
  font-weight: 500;
}

.nav-home {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  margin: 0 8px 8px;
  font-size: 0.84rem;
  color: var(--subtext0);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.nav-home:hover { background: var(--surface0); color: var(--text); }
.nav-home.active { background: color-mix(in srgb, var(--blue) 10%, transparent); color: var(--blue); }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--surface0);
  flex-shrink: 0;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--overlay0);
}

.version-badge span {
  background: var(--surface0);
  color: var(--blue);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
}

/* ── Top Bar ──────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--header-h);
  background: color-mix(in srgb, var(--base) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface0);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 12px;
  z-index: 90;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--overlay0);
  flex: 1;
}

.breadcrumb a { color: var(--subtext0); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb .sep { color: var(--surface2); }
.breadcrumb .current { color: var(--subtext1); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  color: var(--subtext0);
  border-radius: var(--radius);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.topbar-btn:hover { background: var(--surface1); color: var(--text); }

/* ── Main Content ────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--header-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-hero {
  padding: 48px 48px 36px;
  border-bottom: 1px solid var(--surface0);
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 4%, transparent) 0%, transparent 100%);
}

.page-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 25%, transparent);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.page-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--subtext0);
  max-width: 640px;
  line-height: 1.6;
}

.content {
  padding: 40px 48px 64px;
  max-width: 960px;
  width: 100%;
}

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

.content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  margin: 48px 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--surface0);
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.content h2:first-child { margin-top: 0; }

.content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--lavender);
  margin: 32px 0 14px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--subtext1);
  margin: 24px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.content p { margin-bottom: 14px; color: var(--subtext1); line-height: 1.75; }

.content a { color: var(--blue); text-decoration: none; }
.content a:hover { text-decoration: underline; color: var(--lavender); }

.content ul, .content ol {
  margin: 0 0 16px 22px;
  color: var(--subtext1);
}

.content li { margin-bottom: 5px; line-height: 1.7; }

.content strong { color: var(--text); font-weight: 600; }
.content em { color: var(--subtext0); font-style: italic; }

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

.content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--surface0);
  color: var(--peach);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--surface1);
}

.content pre {
  background: var(--crust);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin: 16px 0 24px;
  position: relative;
}

.content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.6;
}

.pre-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--overlay0);
  margin-top: 16px;
}

.pre-header + pre {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 0;
}

.lang-tag {
  font-family: 'JetBrains Mono', monospace;
  color: var(--blue);
  font-weight: 600;
}

/* Syntax highlight classes */
.kw  { color: var(--mauve); }
.ty  { color: var(--blue); }
.fn  { color: var(--sapphire); }
.st  { color: var(--green); }
.cm  { color: var(--overlay1); font-style: italic; }
.nm  { color: var(--peach); }
.op  { color: var(--teal); }
.pp  { color: var(--yellow); }

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

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 0.87rem;
}

.content thead th {
  background: var(--surface0);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--surface1);
  white-space: nowrap;
}

.content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface0) 30%, transparent); }
.content tbody tr:hover { background: color-mix(in srgb, var(--surface0) 60%, transparent); }

.content td {
  padding: 9px 14px;
  border: 1px solid var(--surface0);
  color: var(--subtext1);
  vertical-align: top;
  line-height: 1.5;
}

.content td code { font-size: 0.82em; }

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

.callout {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border-left: 3px solid;
  margin: 20px 0;
}

.callout-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.callout-body { font-size: 0.88rem; color: var(--subtext1); line-height: 1.65; }
.callout-body strong { display: block; margin-bottom: 3px; }

.callout.info   { background: color-mix(in srgb, var(--blue)   8%, transparent); border-color: var(--blue);   }
.callout.warn   { background: color-mix(in srgb, var(--yellow) 8%, transparent); border-color: var(--yellow); }
.callout.danger { background: color-mix(in srgb, var(--red)    8%, transparent); border-color: var(--red);    }
.callout.tip    { background: color-mix(in srgb, var(--green)  8%, transparent); border-color: var(--green);  }

.callout.info .callout-icon   { color: var(--blue);   }
.callout.warn .callout-icon   { color: var(--yellow); }
.callout.danger .callout-icon { color: var(--red);    }
.callout.tip .callout-icon    { color: var(--green);  }

/* ── Simple Numbered Timeline ──────────────────────────────────────────── */

.timeline { display: flex; flex-direction: column; gap: 4px; margin: 20px 0; }

.tl-item {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface0);
}
.tl-item:last-child { border-bottom: none; }

.tl-dot {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(137,180,250,0.12);
  border: 1px solid rgba(137,180,250,0.25);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700;
}

.tl-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.tl-desc  { font-size: 0.86rem; color: var(--subtext0); line-height: 1.6; }

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0 24px;
}

.card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--surface1); }

.card-icon { font-size: 1.4rem; margin-bottom: 10px; }
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.card-desc  { font-size: 0.81rem; color: var(--overlay1); line-height: 1.5; }

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge.blue   { background: color-mix(in srgb, var(--blue)   15%, transparent); color: var(--blue);   border: 1px solid color-mix(in srgb, var(--blue)   30%, transparent); }
.badge.green  { background: color-mix(in srgb, var(--green)  15%, transparent); color: var(--green);  border: 1px solid color-mix(in srgb, var(--green)  30%, transparent); }
.badge.yellow { background: color-mix(in srgb, var(--yellow) 15%, transparent); color: var(--yellow); border: 1px solid color-mix(in srgb, var(--yellow) 30%, transparent); }
.badge.red    { background: color-mix(in srgb, var(--red)    15%, transparent); color: var(--red);    border: 1px solid color-mix(in srgb, var(--red)    30%, transparent); }
.badge.mauve  { background: color-mix(in srgb, var(--mauve)  15%, transparent); color: var(--mauve);  border: 1px solid color-mix(in srgb, var(--mauve)  30%, transparent); }

/* ── Divider ───────────────────────────────────────────────────────────── */

.divider {
  border: none;
  border-top: 1px solid var(--surface0);
  margin: 32px 0;
}

/* ── Page Navigation ─────────────────────────────────────────────────── */

.page-nav {
  display: flex;
  gap: 12px;
  padding: 24px 48px 32px;
  border-top: 1px solid var(--surface0);
  margin-top: auto;
}

.page-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 20px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all var(--transition);
  flex: 1;
  max-width: 280px;
}

.page-nav-btn:hover { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 5%, var(--mantle)); }

.page-nav-btn.next { margin-left: auto; text-align: right; }

.page-nav-label { font-size: 0.72rem; color: var(--overlay0); text-transform: uppercase; letter-spacing: 0.06em; }
.page-nav-title { font-size: 0.9rem; color: var(--subtext1); font-weight: 500; }
.page-nav-btn:hover .page-nav-title { color: var(--blue); }

/* ── Architecture Diagram ─────────────────────────────────────────────── */

.arch-diagram {
  background: var(--crust);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 24px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  margin: 16px 0 24px;
}

/* ── Illustration Figures ─────────────────────────────────────────────── */

.figure {
  background: var(--crust);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  margin: 20px 0 28px;
  text-align: center;
}

.figure-img {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.figure-caption {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--overlay0);
  font-style: italic;
}

.home-hero-img {
  width: 100%;
  max-width: 720px;
  height: auto;
  display: block;
  margin: 28px auto 0;
}

/* ── On-Page TOC ──────────────────────────────────────────────────────── */

.toc {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 0 0 36px;
}

.toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--overlay0);
  margin-bottom: 12px;
}

.toc ol { margin: 0 0 0 16px; }
.toc li { margin-bottom: 4px; }

.toc a {
  font-size: 0.84rem;
  color: var(--subtext0);
  text-decoration: none;
  transition: color var(--transition);
}

.toc a:hover { color: var(--blue); }

/* ── Back to Top ──────────────────────────────────────────────────────── */

#backToTop {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 40px; height: 40px;
  background: var(--surface1);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  z-index: 200;
}

#backToTop.visible { opacity: 1; pointer-events: all; }
#backToTop:hover { background: var(--blue); border-color: var(--blue); color: var(--mantle); }

/* ── Index / Home Page ────────────────────────────────────────────────── */

.home-hero {
  padding: 64px 48px 48px;
  border-bottom: 1px solid var(--surface0);
}

.home-hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.home-hero-title {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.home-hero-title .accent { color: var(--blue); }

.home-hero-desc {
  font-size: 1.05rem;
  color: var(--subtext0);
  max-width: 580px;
  line-height: 1.65;
  margin-bottom: 28px;
}

.home-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary { background: var(--blue); color: var(--mantle); }
.btn-primary:hover { background: var(--lavender); }

.btn-outline {
  background: transparent;
  color: var(--subtext1);
  border-color: var(--surface1);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: color-mix(in srgb, var(--blue) 6%, transparent); }

.home-stats {
  display: flex;
  gap: 32px;
  padding: 24px 48px;
  border-bottom: 1px solid var(--surface0);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.stat-label { font-size: 0.78rem; color: var(--overlay0); }

.home-sections {
  padding: 40px 48px;
}

.home-sections-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--overlay0);
  margin-bottom: 20px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.section-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all var(--transition);
}

.section-card:hover {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 5%, var(--mantle));
  transform: translateY(-1px);
}

.section-card-num {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  border-radius: 4px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.section-card-body { flex: 1; }
.section-card-title { font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.section-card-desc  { font-size: 0.78rem; color: var(--overlay1); line-height: 1.4; }

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

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-280px);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.5);
  }

  .main {
    margin-left: 0;
  }

  .topbar { left: 0; padding: 0 20px; }
  .menu-toggle { display: flex; }

  .page-hero, .content, .home-hero, .home-sections { padding-left: 24px; padding-right: 24px; }
  .home-stats { padding-left: 24px; padding-right: 24px; }
  .page-nav { padding-left: 24px; padding-right: 24px; }

  .home-hero-title { font-size: 2rem; }
  .page-title { font-size: 1.6rem; }
}
