/* MOSOO Sovereign L1 — Official Cryptographic Documentation & Whitepaper Engine */
/* GitBook & Stripe Quality Luxury Technical Design System */

:root {
  /* Light Theme (Default) */
  --bg-body: #fbfdfc;
  --bg-surface: #ffffff;
  --bg-card: #f4f8f6;
  --bg-card-hover: #edf4f0;
  --bg-sidebar: #f8faf9;
  --bg-code: #0f172a;
  --bg-modal: #ffffff;
  
  --border-subtle: rgba(5, 150, 105, 0.12);
  --border-card: rgba(5, 150, 105, 0.18);
  --border-focus: #059669;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-code: #e2e8f0;
  
  --bamboo-green: #059669;
  --bamboo-emerald: #10b981;
  --bamboo-light: #34d399;
  --bamboo-tint: rgba(16, 185, 129, 0.08);
  --bamboo-glow: rgba(5, 150, 105, 0.2);
  
  --accent-sky: #0284c7;
  --accent-purple: #7c3aed;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-dropdown: 0 12px 36px rgba(0, 0, 0, 0.15);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.25);
  
  --header-height: 64px;
  --sidebar-width: 290px;
  --toc-width: 240px;
}

[data-theme="dark"] {
  --bg-body: #070a09;
  --bg-surface: #0e1411;
  --bg-card: #131b17;
  --bg-card-hover: #18231d;
  --bg-sidebar: #0a0f0c;
  --bg-code: #080d0a;
  --bg-modal: #0e1411;
  
  --border-subtle: rgba(16, 185, 129, 0.15);
  --border-card: rgba(16, 185, 129, 0.25);
  --border-focus: #10b981;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-code: #f1f5f9;
  
  --bamboo-green: #10b981;
  --bamboo-emerald: #059669;
  --bamboo-light: #34d399;
  --bamboo-tint: rgba(16, 185, 129, 0.12);
  --bamboo-glow: rgba(16, 185, 129, 0.25);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-dropdown: 0 12px 36px rgba(0, 0, 0, 0.55);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.7);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.65;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Ambient Subtle Grid Background */
.docs-bg-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(5, 150, 105, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(5, 150, 105, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Header & Top Navbar
   ========================================================================== */
.docs-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-mobile-menu {
  display: none;
  background: var(--bamboo-tint);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-version {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  background: var(--bamboo-tint);
  color: var(--bamboo-green);
  border-radius: 999px;
  border: 1px solid rgba(5, 150, 105, 0.2);
  letter-spacing: 0.5px;
}

/* Header Search Trigger Button */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 260px;
}

.search-trigger:hover {
  border-color: var(--bamboo-green);
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.search-shortcut {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-dim);
}

/* Header Action Links */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-ext-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-ext-link:hover {
  color: var(--bamboo-green);
  background: var(--bamboo-tint);
}

.btn-theme {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-theme:hover {
  background: var(--bamboo-tint);
  border-color: var(--bamboo-green);
}

/* ==========================================================================
   Documentation Main Layout Structure
   ========================================================================== */
.docs-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  position: relative;
  z-index: 1;
}

/* Left Sidebar Navigation */
.docs-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  padding: 24px 16px 40px;
}

.docs-sidebar::-webkit-scrollbar {
  width: 5px;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

.sidebar-group {
  margin-bottom: 24px;
}

.sidebar-group-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 0 12px 8px;
}

.sidebar-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-nav-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  line-height: 1.4;
}

.sidebar-nav-item a:hover {
  color: var(--bamboo-green);
  background: var(--bamboo-tint);
}

.sidebar-nav-item.active a {
  color: var(--bamboo-green);
  background: var(--bamboo-tint);
  font-weight: 700;
  border-left: 3px solid var(--bamboo-green);
}

/* Center Article Content Area */
.docs-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  display: flex;
  justify-content: center;
}

.article-container {
  width: 100%;
  max-width: 820px;
}

/* Article Typography */
.article-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.article-breadcrumbs a {
  color: var(--text-dim);
  text-decoration: none;
}

.article-breadcrumbs span.sep {
  color: var(--border-card);
}

.article-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.18;
  color: var(--text-main);
  margin-bottom: 16px;
}

.article-lead {
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 24px;
}

.article-body h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text-main);
  margin: 40px 0 16px;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.article-body h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 28px 0 12px;
}

.article-body p {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.75;
}

.article-body strong {
  color: var(--text-main);
  font-weight: 700;
}

.article-body ul, .article-body ol {
  margin: 0 0 24px 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.75;
}

.article-body li {
  margin-bottom: 8px;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bamboo-tint);
  color: var(--bamboo-green);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Callout Alert Blocks */
.callout {
  padding: 20px;
  border-radius: var(--radius-lg);
  margin: 28px 0;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid transparent;
}

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

.callout-body {
  flex: 1;
  font-size: 14.5px;
  line-height: 1.65;
}

.callout-body h4 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
}

.callout-body p {
  margin-bottom: 0;
  font-size: 14px;
}

.callout-info {
  background: rgba(2, 132, 199, 0.07);
  border-color: rgba(2, 132, 199, 0.25);
  color: var(--text-main);
}
.callout-info .callout-body h4 { color: var(--accent-sky); }

.callout-crypto {
  background: var(--bamboo-tint);
  border-color: rgba(5, 150, 105, 0.3);
  color: var(--text-main);
}
.callout-crypto .callout-body h4 { color: var(--bamboo-green); }

.callout-warning {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.25);
  color: var(--text-main);
}
.callout-warning .callout-body h4 { color: var(--accent-amber); }

/* Mathematical Formula Cards */
.math-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin: 28px 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow-x: auto;
}

.math-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bamboo-green);
  margin-bottom: 10px;
}

.math-formula {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: nowrap;
}

.math-explanation {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Architecture Flowcards */
.arch-diagram {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin: 32px 0;
  box-shadow: var(--shadow-card);
}

.arch-step-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.arch-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
}

.arch-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bamboo-green);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.arch-step-content h5 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.arch-step-content p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.55;
}

/* Code Snippet Blocks */
.code-block {
  background: var(--bg-code);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  margin: 24px 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}

.btn-copy-code {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #e2e8f0;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s ease;
}

.btn-copy-code:hover {
  background: var(--bamboo-green);
  color: #ffffff;
}

.code-block pre {
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--text-code);
  line-height: 1.65;
}

/* Tables in Article */
.table-wrapper {
  overflow-x: auto;
  margin: 28px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.docs-table th {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.docs-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.docs-table tr:last-child td {
  border-bottom: none;
}

/* Previous / Next Chapter Cards */
.chapter-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--border-subtle);
}

.chapter-nav-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  text-decoration: none;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.chapter-nav-card:hover {
  border-color: var(--bamboo-green);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.nav-direction {
  font-size: 11px;
  font-weight: 800;
  color: var(--bamboo-green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.nav-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

/* Right Sidebar Table of Contents (On this page) */
.docs-toc {
  width: var(--toc-width);
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  padding: 40px 16px 40px 8px;
}

.toc-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 2px solid var(--border-subtle);
  padding-left: 12px;
}

.toc-item a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
  display: block;
  line-height: 1.4;
}

.toc-item a:hover {
  color: var(--bamboo-green);
}

.toc-item.active a {
  color: var(--bamboo-green);
  font-weight: 700;
}

/* ==========================================================================
   Universal Instant Search Modal
   ========================================================================== */
.search-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 20px;
}

.search-modal-backdrop.active {
  display: flex;
}

.search-modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}

.search-modal-input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text-main);
  outline: none;
}

.search-modal-input::placeholder {
  color: var(--text-dim);
}

.search-results {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-result-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s ease;
  cursor: pointer;
}

.search-result-item:hover, .search-result-item.selected {
  background: var(--bamboo-tint);
}

.search-result-chapter {
  font-size: 11px;
  font-weight: 800;
  color: var(--bamboo-green);
  text-transform: uppercase;
}

.search-result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.search-result-snippet {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.search-footer {
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   Mobile Responsive Breakpoints (100% Mobile Optimized)
   ========================================================================== */
@media (max-width: 1100px) {
  .docs-toc {
    display: none;
  }
  .docs-content {
    padding: 36px 32px 70px;
  }
}

@media (max-width: 860px) {
  .btn-mobile-menu {
    display: flex;
  }
  
  .search-trigger {
    min-width: unset;
    padding: 6px 10px;
  }
  
  .search-trigger span.search-text,
  .search-shortcut {
    display: none;
  }
  
  .header-actions .nav-ext-link {
    display: none;
  }

  /* Transform Left Sidebar into Off-Canvas Drawer */
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 82%;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    z-index: 99999;
    background: var(--bg-surface);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.35);
    padding: 24px 16px 40px;
  }

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

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99998;
  }

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

  .docs-content {
    padding: 24px 16px 60px;
  }

  .article-title {
    font-size: 28px;
    letter-spacing: -0.8px;
  }

  .article-lead {
    font-size: 15px;
  }

  .chapter-nav-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .math-formula {
    font-size: 13px;
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .docs-header {
    padding: 0 14px;
  }
  
  .brand-title {
    font-size: 16px;
  }
  
  .article-title {
    font-size: 24px;
  }
  
  .article-body h2 {
    font-size: 20px;
  }
  
  .article-body h3 {
    font-size: 16px;
  }
  
  .callout {
    padding: 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  .search-modal-backdrop {
    padding: 20px 10px;
  }
}
