/* Hermes-Agent Book - Clean Technical Documentation Style */

:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-code: #f6f8fa;
  --bg-nav: #161b22;
  --bg-nav-hover: #1f2937;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-nav: #d1d5db;
  --text-nav-active: #ffffff;
  --accent: #3b82f6;
  --accent-light: #eff6ff;
  --accent-dark: #1d4ed8;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --code-text: #111827;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --pink: #ec4899;
  --pink-light: #fce7f3;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 280px;
  --content-max-width: 900px;
  --header-height: 60px;
  --card-radius: 12px;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --section-gap: 32px;
  --card-padding: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-code: #1c2128;
    --bg-nav: #010409;
    --bg-nav-hover: #161b22;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --accent: #60a5fa;
    --accent-light: #1e3a5f;
    --accent-dark: #3b82f6;
    --border: #30363d;
    --border-light: #21262d;
    --code-text: #e5e7eb;
    --success-light: #064e3b;
    --warning-light: #451a03;
    --danger-light: #450a0a;
    --purple-light: #2e1065;
    --pink-light: #500724;
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
}

/* Navigation */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-nav);
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h1 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .version {
  font-size: 11px;
  color: #9ca3af;
  background: rgba(255,255,255,0.08);
  padding: 3px 8px;
  border-radius: 10px;
  margin-left: auto;
  font-weight: 500;
}

.nav-section {
  padding: 8px 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6b7280;
  padding: 12px 20px 4px;
}

.nav-item {
  display: block;
  padding: 8px 20px;
  color: var(--text-nav);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-nav-hover);
  color: var(--text-nav-active);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-left-color: #3b82f6;
}

.nav-item.sub {
  padding-left: 32px;
  font-size: 13px;
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-wrapper {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 48px 56px 80px;
}

/* Typography */
h1 { font-size: 2.2em; font-weight: 700; margin: 0 0 24px; line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: 1.5em; font-weight: 700; margin: 56px 0 20px; padding-top: 32px; border-top: 1px solid var(--border); line-height: 1.3; letter-spacing: -0.01em; }
h2:first-of-type { border-top: none; margin-top: 0; }
h3 { font-size: 1.15em; font-weight: 650; margin: 32px 0 14px; line-height: 1.4; }
h4 { font-size: 1em; font-weight: 650; margin: 24px 0 10px; }

p { margin: 0 0 16px; }

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

strong { font-weight: 600; }
em { font-style: italic; }

/* Chapter header */
.chapter-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 2px solid var(--border);
}

.chapter-number {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.chapter-title { font-size: 2.2em; font-weight: 750; margin-bottom: 12px; letter-spacing: -0.02em; }
.chapter-subtitle { font-size: 1.15em; color: var(--text-secondary); font-weight: 400; }

/* Learning guide boxes */
.guide-box {
  border-radius: var(--card-radius);
  padding: 20px 24px;
  margin: 28px 0;
}

.guide-box.target { background: var(--accent-light); border: 1px solid rgba(59, 130, 246, 0.2); }
.guide-box.prerequisite { background: var(--warning-light); border: 1px solid rgba(245, 158, 11, 0.25); }
.guide-box.gain { background: var(--success-light); border: 1px solid rgba(16, 185, 129, 0.25); }
.guide-box.warning { background: var(--danger-light); border: 1px solid rgba(239, 68, 68, 0.25); }

.guide-box h4 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
}

.guide-box ul { margin: 0; padding-left: 20px; }
.guide-box li { margin: 6px 0; }

/* ========== ARCHITECTURE DIAGRAMS ========== */

/* Module Diagram - Cards */
.module-diagram {
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.layer {
  position: relative;
}

.layer-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  padding-left: 4px;
}

.layer-cards {
  display: grid;
  gap: 12px;
}

.layer-cards.single { grid-template-columns: 1fr; }
.layer-cards.two { grid-template-columns: repeat(2, 1fr); }
.layer-cards.three { grid-template-columns: repeat(3, 1fr); }
.layer-cards.four { grid-template-columns: repeat(4, 1fr); }

.layer-cards.auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--card-shadow-hover);
}

.card.accent {
  background: var(--accent-light);
  border-color: rgba(59, 130, 246, 0.3);
}

.card.success {
  background: var(--success-light);
  border-color: rgba(16, 185, 129, 0.3);
}

.card.warning {
  background: var(--warning-light);
  border-color: rgba(245, 158, 11, 0.3);
}

.card.purple {
  background: var(--purple-light);
  border-color: rgba(139, 92, 246, 0.3);
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.card-icon.blue { background: #dbeafe; color: #2563eb; }
.card-icon.green { background: #d1fae5; color: #059669; }
.card-icon.purple { background: #ede9fe; color: #7c3aed; }
.card-icon.orange { background: #fed7aa; color: #ea580c; }
.card-icon.pink { background: #fce7f3; color: #db2777; }
.card-icon.gray { background: var(--gray-100); color: var(--gray-600); }

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

/* Architecture Flow - Arrow Connectors */
.arrow-down {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  color: var(--accent);
  font-size: 20px;
  opacity: 0.6;
}

.arrow-down::before {
  content: '↓';
}

.arrow-bidirectional {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-secondary);
  font-size: 16px;
}

/* Architecture Grid */
.architecture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}

@media (max-width: 640px) {
  .architecture-grid {
    grid-template-columns: 1fr;
  }
}

/* Flow Diagram - Mermaid Container */
.mermaid-container {
  margin: 28px 0;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow-x: auto;
}

.mermaid-container h4 {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mermaid {
  display: flex;
  justify-content: center;
}

/* Process Flow - Horizontal Steps */
.process-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 28px 0;
  overflow-x: auto;
  padding: 8px 0;
}

.process-step {
  flex: 1;
  min-width: 140px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px;
  position: relative;
  transition: all 0.2s ease;
}

.process-step:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
}

.process-step::after {
  content: '→';
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 18px;
  z-index: 1;
}

.process-step:last-child::after {
  display: none;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.step-title {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 6px;
}

.step-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Data Flow Diagram */
.data-flow {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 28px 0;
}

.data-flow-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  transition: all 0.2s ease;
}

.data-flow-item:hover {
  border-color: var(--accent);
}

.data-flow-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.data-flow-content {
  flex: 1;
}

.data-flow-title {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 4px;
}

.data-flow-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.data-flow-arrow {
  color: var(--accent);
  font-size: 18px;
}

/* Three Tier Memory */
.memory-tiers {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 28px 0;
}

.memory-tier {
  padding: 24px;
  border-radius: var(--card-radius);
  position: relative;
  padding-left: 32px;
}

.memory-tier::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

.memory-tier.tier-1 {
  background: var(--accent-light);
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.memory-tier.tier-1::before { background: var(--accent); }

.memory-tier.tier-2 {
  background: var(--purple-light);
  border: 1px solid rgba(139, 92, 246, 0.2);
}
.memory-tier.tier-2::before { background: var(--purple); }

.memory-tier.tier-3 {
  background: var(--success-light);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.memory-tier.tier-3::before { background: var(--success); }

.tier-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.tier-title {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 6px;
}

.tier-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.tier-meta {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.6;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 750;
  color: var(--accent);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Code blocks */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 20px 0;
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 13.5px;
  line-height: 1.65;
}

code {
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
}

pre code {
  background: none;
  padding: 0;
  font-size: 13.5px;
}

.code-file {
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  .code-file { background: #1c2128; }
}

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

/* Highlight boxes */
.callout {
  padding: 18px 22px;
  border-radius: var(--card-radius);
  margin: 24px 0;
  border: 1px solid var(--border);
}

.callout.info { background: var(--accent-light); border-color: rgba(59, 130, 246, 0.25); }
.callout.tip { background: var(--success-light); border-color: rgba(16, 185, 129, 0.25); }
.callout.warning { background: var(--warning-light); border-color: rgba(245, 158, 11, 0.25); }

.callout-title {
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

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

th { 
  background: var(--gray-50); 
  font-weight: 650; 
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

@media (prefers-color-scheme: dark) {
  th { background: #1c2128; }
  tr:hover td { background: #1c2128; }
}

/* Lists */
ul, ol { margin: 16px 0; padding-left: 22px; }
li { margin: 8px 0; line-height: 1.6; }

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent);
  padding: 16px 20px;
  margin: 24px 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--gray-50);
  border-radius: 0 var(--card-radius) var(--card-radius) 0;
}

/* Summary box */
.chapter-summary {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 28px;
  margin: 36px 0;
}

.chapter-summary h3 {
  margin: 0 0 16px;
  padding-top: 0;
  border-top: none;
  font-size: 16px;
}

.chapter-summary p { margin: 0 0 12px; }
.chapter-summary ul { margin: 0; }

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

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

/* Chapter navigation */
.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  display: block;
  padding: 20px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  text-decoration: none;
  transition: all 0.2s ease;
}

.chapter-nav a:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }

.chapter-nav .nav-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 6px;
}

.chapter-nav .nav-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-nav);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .content-wrapper {
    padding: 80px 24px 60px;
  }
  
  h1 { font-size: 1.8em; }
  h2 { font-size: 1.35em; }
  
  .chapter-nav {
    grid-template-columns: 1fr;
  }
  
  .layer-cards.two,
  .layer-cards.three,
  .layer-cards.four {
    grid-template-columns: 1fr;
  }
  
  .process-flow {
    flex-direction: column;
  }
  
  .process-step::after {
    display: none;
  }
}

/* Search */
.search-box {
  padding: 12px 16px;
  margin: 8px 16px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: white;
  font-size: 14px;
}

.search-box input::placeholder {
  color: #6b7280;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Print */
@media print {
  .sidebar, .menu-toggle { display: none; }
  .main-content { margin-left: 0; }
}

/* Audio Player */
.audio-player {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 20px 24px;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-title {
  color: white;
  font-weight: 600;
  font-size: 14px;
  opacity: 0.9;
}

.audio-player audio {
  width: 100%;
  height: 40px;
  border-radius: 20px;
  outline: none;
}

.audio-player audio::-webkit-media-controls-panel {
  background: rgba(255,255,255,0.95);
}

@media (max-width: 768px) {
  .audio-player {
    padding: 16px 20px;
    margin: 16px 0;
  }
}
