/* ====================================================================
   Mesh Craft Documentation — Shared Stylesheet
   ==================================================================== */

:root {
  --bg:           #0f1117;
  --bg-surface:   #1a1d27;
  --bg-card:      #22263a;
  --bg-code:      #161926;
  --border:       #2e3250;
  --accent:       #6c8ef5;
  --accent-hover: #8aabff;
  --text:         #d4d8f0;
  --text-muted:   #7a80a0;
  --text-heading: #eef0ff;
  --green:        #3ecf8e;
  --yellow:       #f5c842;
  --red:          #f56c6c;
  --orange:       #f5a442;
  --sidebar-w:    260px;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius:       6px;
  --shadow:       0 2px 12px rgba(0,0,0,0.4);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

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

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent) 0%, #4a6ee0 100%);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

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

.sidebar-logo .logo-name {
  font-size: 15px; font-weight: 700;
  color: var(--text-heading); line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 11px; color: var(--text-muted); letter-spacing: 0.04em;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

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

.nav-section-title {
  padding: 6px 18px 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}

.nav-section a {
  display: block;
  padding: 6px 18px;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-section a:hover,
.nav-section a.active {
  background: rgba(108,142,245,0.12);
  color: var(--accent-hover);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-footer a { color: var(--text-muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--accent); }

/* ── Main content ───────────────────────────────────────────────── */

#content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 36px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted);
}

.topbar-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--accent); }
.topbar-breadcrumb .sep { color: var(--border); }

.topbar-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

#searchInput {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 13px;
  width: 200px;
  outline: none;
  transition: border-color 0.15s;
}

#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--text-muted); }

.page-body {
  padding: 40px 48px 60px;
  max-width: 900px;
  width: 100%;
}

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

h1 {
  font-size: 2rem; font-weight: 800;
  color: var(--text-heading); line-height: 1.25;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.4rem; font-weight: 700;
  color: var(--text-heading); line-height: 1.3;
  margin: 2.2em 0 0.6em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-heading);
  margin: 1.8em 0 0.5em;
}

h4 {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 1.5em 0 0.4em;
}

p { margin-bottom: 1em; }

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

ul, ol { margin: 0.5em 0 1em 1.5em; }
li { margin-bottom: 0.3em; }

strong { color: var(--text-heading); }
em { color: var(--text-muted); font-style: italic; }

/* ── Page header ───────────────────────────────────────────────── */

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 { margin-bottom: 0.4em; }

.page-header .subtitle {
  font-size: 1.05rem; color: var(--text-muted);
}

.page-header .tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  color: #b0c4ff;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  overflow-x: auto;
  margin: 1em 0 1.4em;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.88rem;
  color: #c9d8ff;
  line-height: 1.6;
}

.lang-label {
  position: absolute; top: 8px; right: 12px;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.table-wrap { overflow-x: auto; margin: 1em 0 1.4em; }

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

th {
  background: var(--bg-card);
  color: var(--text-heading);
  font-weight: 600; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108,142,245,0.05); }

/* ── Callout boxes ─────────────────────────────────────────────── */

.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 1em 0 1.4em;
  border-left: 4px solid;
  display: flex; gap: 12px; align-items: flex-start;
}

.callout-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.callout.note   { background: rgba(108,142,245,0.08); border-color: var(--accent); }
.callout.warn   { background: rgba(245,200,66,0.08);  border-color: var(--yellow); }
.callout.danger { background: rgba(245,108,108,0.08); border-color: var(--red); }
.callout.tip    { background: rgba(62,207,142,0.08);  border-color: var(--green); }
.callout.todo   { background: rgba(245,164,66,0.08);  border-color: var(--orange); }

.callout.note   .callout-icon { color: var(--accent); }
.callout.warn   .callout-icon { color: var(--yellow); }
.callout.danger .callout-icon { color: var(--red); }
.callout.tip    .callout-icon { color: var(--green); }
.callout.todo   .callout-icon { color: var(--orange); }

.callout-body { flex: 1; }
.callout-body strong { display: block; margin-bottom: 4px; font-size: 0.9rem; }
.callout-body p:last-child { margin-bottom: 0; }

/* ── Badges / status chips ─────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.badge.done    { background: rgba(62,207,142,0.2); color: var(--green); }
.badge.partial { background: rgba(245,200,66,0.2); color: var(--yellow); }
.badge.planned { background: rgba(108,142,245,0.2); color: var(--accent); }
.badge.wip     { background: rgba(245,164,66,0.2); color: var(--orange); }

/* ── Feature tables ────────────────────────────────────────────── */

.feature-table td:last-child { text-align: center; }

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

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
  display: block;
  color: var(--text);
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}

.card-icon { font-size: 24px; margin-bottom: 10px; }
.card-title { font-weight: 700; color: var(--text-heading); margin-bottom: 6px; font-size: 1rem; }
.card-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

/* ── Section divider ───────────────────────────────────────────── */

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

/* ── Page nav (prev/next) ──────────────────────────────────────── */

.page-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.page-nav a {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px; color: var(--text); text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.page-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-nav .prev::before { content: "←"; }
.page-nav .next::after  { content: "→"; }
.page-nav .empty { flex: 1; }

/* ── Search results ────────────────────────────────────────────── */

#searchResults {
  position: absolute;
  top: 52px; right: 36px;
  width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

#searchResults.visible { display: block; }

.search-result-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(108,142,245,0.1); }
.search-result-item a { color: var(--text); text-decoration: none; display: block; }

.sri-title { font-weight: 600; color: var(--text-heading); font-size: 14px; }
.sri-path  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sri-excerpt { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* ── Syntax highlight (minimal manual) ─────────────────────────── */

.kw  { color: #7eb6f6; }
.str { color: #98c379; }
.cmt { color: #5c6370; font-style: italic; }
.num { color: #d19a66; }
.tag { color: #e06c75; }
.atr { color: #61afef; }
.val { color: #98c379; }
.cls { color: #e5c07b; }

/* ── Responsive (hamburger for mobile) ──────────────────────────── */

#menuToggle {
  display: none;
  background: none; border: none;
  color: var(--text); cursor: pointer;
  font-size: 20px; padding: 4px;
}

@media (max-width: 860px) {
  body { flex-direction: column; }

  #sidebar {
    position: fixed; left: -280px; top: 0; height: 100vh;
    transition: left 0.25s; z-index: 300;
    width: 260px;
  }

  #sidebar.open { left: 0; }

  #menuToggle { display: block; }

  .page-body { padding: 24px 20px 48px; }

  .topbar { padding: 0 16px; }

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

/* ── Misc utils ─────────────────────────────────────────────────── */

.text-muted    { color: var(--text-muted); }
.text-green    { color: var(--green); }
.text-yellow   { color: var(--yellow); }
.text-red      { color: var(--red); }
.text-accent   { color: var(--accent); }
.mono          { font-family: var(--font-mono); font-size: 0.9em; }
.mt1 { margin-top: 0.5rem; } .mt2 { margin-top: 1rem; } .mt3 { margin-top: 1.5rem; }
.mb1 { margin-bottom: 0.5rem; } .mb2 { margin-bottom: 1rem; }

/* ── Diagram / arch box ─────────────────────────────────────────── */

.arch-diagram {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 1em 0 1.4em;
  overflow-x: auto;
}

.arch-diagram pre {
  background: none; border: none; padding: 0; margin: 0;
}

.arch-row {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 8px;
}

.arch-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
}

.arch-box.accent { border-color: var(--accent); color: var(--accent); }
.arch-box.green  { border-color: var(--green);  color: var(--green); }
.arch-box.yellow { border-color: var(--yellow); color: var(--yellow); }

.arch-arrow { color: var(--text-muted); font-size: 18px; }
