/* ============================================================
   AlgoMLN Wiki — wiki.css
   ============================================================ */

/* Reuse root variables from parent, re-declare for standalone use */
:root {
  --bg: #080c0a;
  --bg2: #0d1410;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --surface-strong: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(100,200,100,0.25);
  --green: #5a9040;
  --green-light: #7dc85a;
  --green-dim: #3a6028;
  --green-glow: rgba(90,144,64,0.15);
  --text: #e8f0e4;
  --text-dim: rgba(232,240,228,0.62);
  --text-muted: rgba(232,240,228,0.35);
  --teal: #2a8a7a;
  --teal-light: #3ab8a4;
  --amber: rgba(232,196,100,0.9);
  --sidebar-w: 260px;
  --nav-h: 60px;
  --content-maxw: 820px;
}
[data-theme="light"] {
  --bg: #f4f7f2;
  --bg2: #e8ede5;
  --surface: rgba(0,0,0,0.035);
  --surface-hover: rgba(0,0,0,0.06);
  --surface-strong: rgba(0,0,0,0.05);
  --border: rgba(0,0,0,0.08);
  --border-hover: rgba(60,140,40,0.32);
  --green: #4a7a30;
  --green-light: #3a6a20;
  --green-dim: #6aa040;
  --green-glow: rgba(60,120,30,0.10);
  --text: #1a2418;
  --text-dim: rgba(20,36,18,0.62);
  --text-muted: rgba(20,36,18,0.42);
  --teal: #1a6a5a;
  --teal-light: #1a8a76;
  --amber: rgba(140,100,20,0.9);
}

/* ---------- BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s, color 0.25s;
  line-height: 1.5;
}
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(90,144,64,0.08), transparent 35%),
    radial-gradient(circle at 85% 70%, rgba(42,138,122,0.06), transparent 35%);
  filter: blur(80px);
  opacity: 0.7;
  animation: ambientMove 24s ease-in-out infinite alternate;
}
@keyframes ambientMove {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(2%,-1%,0) scale(1.04); }
}

/* ---------- WIKI NAV ---------- */
.wiki-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(8,12,10,0.80);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  transition: background 0.25s;
}
[data-theme="light"] .wiki-nav { background: rgba(244,247,242,0.85); }
.wiki-nav-inner {
  width: 100%;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.wiki-nav-left {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}
.wiki-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.2s;
  white-space: nowrap;
}
.wiki-back-link:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-hover);
}
.wiki-back-link svg { width: 13px; height: 13px; }
.wiki-nav-title {
  font-family: 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wiki-nav-title span { color: var(--green-light); }

.wiki-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.version-selector {
  position: relative;
}
.version-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Cascadia Code', monospace;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
}
.version-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}
.version-btn svg { width: 12px; height: 12px; transition: transform 0.2s; }
.version-selector.open .version-btn svg { transform: rotate(180deg); }
.version-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: rgba(13,18,13,0.97);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
[data-theme="light"] .version-menu { background: rgba(232,237,229,0.97); }
.version-selector.open .version-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.version-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  font-family: 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.version-option:hover { background: var(--surface-hover); }
.version-option.active { color: var(--green-light); background: rgba(90,144,64,0.08); }
.version-option .v-badge {
  font-size: 9px;
  background: rgba(90,144,64,0.15);
  border: 1px solid rgba(90,144,64,0.25);
  color: var(--green-light);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}
.version-option.latest .v-badge { display: inline-block; }
.version-option:not(.latest) .v-badge { display: none; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface-hover); }
.theme-toggle svg { width: 14px; height: 14px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar-toggle svg { width: 16px; height: 16px; }

/* ---------- LAYOUT ---------- */
.wiki-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  padding-top: var(--nav-h);
  position: relative;
  z-index: 1;
}

/* ---------- SIDEBAR ---------- */
.wiki-sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 28px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.wiki-sidebar::-webkit-scrollbar { width: 4px; }
.wiki-sidebar::-webkit-scrollbar-track { background: transparent; }
.wiki-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
[data-theme="light"] .wiki-sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }

.sidebar-group { margin-bottom: 4px; }
.sidebar-group-label {
  font-family: 'Cascadia Code', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 20px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  font-size: 13.5px;
  color: var(--text-dim);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
  line-height: 1.4;
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--surface);
}
.sidebar-link.active {
  color: var(--green-light);
  border-left-color: var(--green-light);
  background: rgba(90,144,64,0.06);
  font-weight: 500;
}
[data-theme="light"] .sidebar-link.active {
  background: rgba(74,122,48,0.06);
}
.sidebar-sub {
  padding-left: 14px;
}
.sidebar-sub .sidebar-link {
  font-size: 12.5px;
  padding: 5px 20px 5px 34px;
}
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

/* ---------- CONTENT ---------- */
.wiki-content {
  max-width: var(--content-maxw);
  padding: 52px 56px 96px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- WIKI TYPOGRAPHY ---------- */
.wiki-content h1 {
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.1;
}
.wiki-content .page-subtitle {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 8px;
}
.wiki-content .page-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.wiki-content .page-meta .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Cascadia Code', monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid;
  line-height: 1.4;
}
.badge-stable { color: var(--green-light); background: rgba(90,144,64,0.10); border-color: rgba(90,144,64,0.28); }
.badge-wip { color: var(--amber); background: rgba(232,196,100,0.08); border-color: rgba(232,196,100,0.22); }
.badge-version-sm { color: var(--text-muted); background: var(--surface); border-color: var(--border); }
[data-theme="light"] .badge-wip { background: rgba(140,100,20,0.06); border-color: rgba(140,100,20,0.20); }

.wiki-content h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-top: 56px;
  margin-bottom: 16px;
  scroll-margin-top: calc(var(--nav-h) + 20px);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.wiki-content h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 32px;
  margin-bottom: 10px;
  scroll-margin-top: calc(var(--nav-h) + 20px);
}
.wiki-content h4 {
  font-family: 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--green-light);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-top: 24px;
  margin-bottom: 8px;
  opacity: 0.85;
}
.wiki-content p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.wiki-content ul, .wiki-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}
.wiki-content li {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.wiki-content a {
  color: var(--green-light);
  text-decoration: none;
  border-bottom: 1px solid rgba(90,144,64,0.30);
  transition: border-color 0.2s;
}
.wiki-content a:hover { border-color: var(--green-light); }
.wiki-content strong { color: var(--text); font-weight: 600; }

/* Inline code */
.wiki-content :not(pre) > code {
  font-family: 'Cascadia Code', monospace;
  font-size: 0.875em;
  color: var(--green-light);
  background: var(--surface-strong);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
}
[data-theme="light"] .wiki-content :not(pre) > code { color: var(--green); }

/* Code blocks */
.code-block {
  position: relative;
  background: rgba(6,9,10,0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 6px 0 24px;
}
[data-theme="light"] .code-block { background: rgba(216,224,210,0.7); }
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.code-lang {
  font-family: 'Cascadia Code', monospace;
  font-size: 10px;
  color: var(--green-light);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.8;
}
.copy-btn {
  font-family: 'Cascadia Code', monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: color 0.2s;
  padding: 2px 0;
}
.copy-btn:hover { color: var(--text-dim); }
.code-block pre {
  padding: 18px 20px;
  margin: 0;
  overflow-x: auto;
  font-family: 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-dim);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Syntax highlight spans */
.kw  { color: #7dc85a; }
.fn  { color: #3ab8a4; }
.num { color: #e8c460; }
.cmt { color: rgba(232,240,228,0.28); font-style: italic; }
.str { color: #c8a06a; }
.key { color: #a0c0e8; }
[data-theme="light"] .kw  { color: #3a6a20; }
[data-theme="light"] .fn  { color: #1a7a6a; }
[data-theme="light"] .num { color: #8a6010; }
[data-theme="light"] .cmt { color: rgba(20,36,18,0.30); }
[data-theme="light"] .str { color: #8a5020; }
[data-theme="light"] .key { color: #305080; }

/* ---------- WIKI TABLE ---------- */
.wiki-table-wrap {
  overflow-x: auto;
  margin: 6px 0 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.wiki-table th {
  font-family: 'Cascadia Code', monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-strong);
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.wiki-table td {
  padding: 13px 18px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
  vertical-align: top;
}
.wiki-table tr:last-child td { border-bottom: none; }
.wiki-table tr:hover td { background: var(--surface); }
.wiki-table td code {
  font-family: 'Cascadia Code', monospace;
  font-size: 0.875em;
  color: var(--teal-light);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.wiki-table td strong { color: var(--text); }

/* ---------- CALLOUT BOXES ---------- */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 10px;
  margin: 6px 0 24px;
  font-size: 14px;
  line-height: 1.65;
}
.callout-note {
  background: rgba(42,138,122,0.08);
  border: 1px solid rgba(42,138,122,0.22);
  color: var(--text-dim);
}
.callout-warn {
  background: rgba(232,196,100,0.06);
  border: 1px solid rgba(232,196,100,0.20);
  color: var(--text-dim);
}
.callout-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.callout p { margin: 0; font-size: 14px; color: inherit; }
.callout code {
  font-family: 'Cascadia Code', monospace;
  font-size: 0.875em;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
}

/* ---------- CAPABILITY CARD ---------- */
.capability-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 6px 0 24px;
}
.capability-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  transition: border-color 0.2s, transform 0.2s;
}
.capability-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.capability-name {
  font-family: 'Cascadia Code', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-light);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.capability-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ---------- WIKI FOOTER ---------- */
.wiki-footer {
  max-width: var(--content-maxw);
  margin: 0 auto;
  padding: 32px 56px 48px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.wiki-footer-copy {
  font-family: 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.wiki-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.2s;
}
.wiki-footer-link:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface-hover); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
  .wiki-content { padding: 40px 36px 72px; }
}
@media (max-width: 720px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    z-index: 80;
    width: var(--sidebar-w);
    height: calc(100vh - var(--nav-h));
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    background: rgba(8,12,10,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
  }
  [data-theme="light"] .wiki-sidebar { background: rgba(244,247,242,0.97); }
  .wiki-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .wiki-content { padding: 36px 24px 72px; }
  .wiki-nav-title { display: none; }
  .capability-grid { grid-template-columns: 1fr; }
  .wiki-footer { padding: 28px 24px 40px; }
}
@media (max-width: 480px) {
  .wiki-content { padding: 28px 18px 64px; }
  .wiki-nav-inner { padding: 0 16px; }
}
