/* ============================================================
   LearnCodebase — Static site styles
   Clean, documentation-style design with light/dark support.
   ============================================================ */

/* --- Reset & Tokens ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;

  /* Light theme */
  --bg:          #ffffff;
  --bg-subtle:   #f6f8fa;
  --bg-muted:    #eef1f5;
  --bg-card:     #ffffff;
  --border:      #d1d9e0;
  --border-light:#e8ecf0;
  --text:        #1f2328;
  --text-muted:  #636c76;
  --text-faint:  #8b949e;
  --accent:      #0969da;
  --accent-soft: #ddf4ff;
  --accent-text: #0550ae;
  --code-bg:     #f6f8fa;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:   0 4px 12px rgba(0,0,0,.08);

  --sidebar-w: 280px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0d1117;
    --bg-subtle:   #161b22;
    --bg-muted:    #21262d;
    --bg-card:     #161b22;
    --border:      #30363d;
    --border-light:#21262d;
    --text:        #e6edf3;
    --text-muted:  #8b949e;
    --text-faint:  #484f58;
    --accent:      #58a6ff;
    --accent-soft: #122d4d;
    --accent-text: #79c0ff;
    --code-bg:     #161b22;
    --shadow:      0 1px 3px rgba(0,0,0,.3);
    --shadow-lg:   0 4px 12px rgba(0,0,0,.4);
  }
}

[data-theme="dark"] {
  --bg:          #0d1117;
  --bg-subtle:   #161b22;
  --bg-muted:    #21262d;
  --bg-card:     #161b22;
  --border:      #30363d;
  --border-light:#21262d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-faint:  #484f58;
  --accent:      #58a6ff;
  --accent-soft: #122d4d;
  --accent-text: #79c0ff;
  --code-bg:     #161b22;
  --shadow:      0 1px 3px rgba(0,0,0,.3);
  --shadow-lg:   0 4px 12px rgba(0,0,0,.4);
}

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

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

/* --- Sidebar ----------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  border-radius: 6px;
  letter-spacing: .5px;
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.sidebar-toggle:hover { background: var(--bg-muted); }

.sidebar-repo {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.repo-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.repo-link:hover { color: var(--accent); text-decoration: none; }

.sidebar-stages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  padding: 8px 16px 4px;
}

.stage-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--text);
  border-left: 2px solid transparent;
  transition: background .15s, border-color .15s;
}
.stage-link:hover {
  background: var(--bg-muted);
  text-decoration: none;
}
.stage-link.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.stage-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}
.stage-link.active .stage-number {
  background: var(--accent);
  color: #fff;
}

.stage-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stage-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.stage-meta {
  font-size: 11px;
  color: var(--text-faint);
}
.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-text {
  font-size: 11px;
  color: var(--text-faint);
}

/* --- Main Content ------------------------------------------ */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  max-width: 900px;
  padding: 40px 48px 80px;
}

/* --- Index Page --------------------------------------------- */
.page-header {
  margin-bottom: 32px;
}
.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
}

.overview-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  min-width: 100px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-text);
  letter-spacing: -.01em;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
}

.overview-intro {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 640px;
  margin-bottom: 40px;
}
.overview-intro p + p { margin-top: 12px; }

/* --- Timeline ---------------------------------------------- */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: 24px;
  color: var(--text);
}
.section-title svg { color: var(--text-muted); flex-shrink: 0; }

.timeline-track {
  position: relative;
  padding-left: 24px;
}
.timeline-track::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}

.timeline-stage {
  position: relative;
  display: block;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--text);
}
.timeline-stage:hover { text-decoration: none; }
.timeline-stage:hover .timeline-card {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.timeline-dot {
  position: absolute;
  left: -21px;
  top: 18px;
  width: 12px;
  height: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 50%;
  z-index: 1;
}
.timeline-dot.emphasis {
  background: var(--accent);
  border-color: var(--accent);
}

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 16px 20px;
  transition: border-color .15s, box-shadow .15s;
}
.timeline-dates {
  font-size: 12px;
  color: var(--text-faint);
}
.timeline-title {
  font-size: 16px;
  font-weight: 600;
  margin: 4px 0;
}
.timeline-versions {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.timeline-commits {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 12px;
}
.timeline-tags {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

/* --- Stage Page --------------------------------------------- */
.stage-header { margin-bottom: 32px; }

.stage-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.nav-link:hover { background: var(--bg-muted); text-decoration: none; color: var(--accent); }
.nav-link small {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
}

.stage-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.stage-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: 12px;
}

.stage-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.meta-item svg { color: var(--text-faint); }

.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --- Narrative --------------------------------------------- */
.narrative {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 40px;
}
.narrative h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.narrative h2:first-child { margin-top: 0; }
.narrative h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}
.narrative p {
  margin: 0 0 14px;
  color: var(--text);
}
.narrative ul, .narrative ol {
  margin: 0 0 14px;
  padding-left: 24px;
}
.narrative li {
  margin-bottom: 4px;
}
.narrative code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 1px 5px;
  background: var(--code-bg);
  border-radius: 3px;
  border: 1px solid var(--border-light);
}
.narrative pre {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.narrative pre code {
  padding: 0;
  background: none;
  border: none;
}
.narrative blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 16px 0;
  background: var(--bg-subtle);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
  font-style: italic;
}
.narrative strong { font-weight: 600; }
.narrative a { color: var(--accent); }
.narrative a:hover { text-decoration: underline; }

/* --- Feature Cards ----------------------------------------- */
.features { margin-bottom: 36px; }

.feature-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 20px 24px;
  transition: border-color .15s, box-shadow .15s;
}
.feature-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.feature-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.feature-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
.feature-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.feature-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.feature-changelog {
  margin-bottom: 12px;
}
.feature-changelog summary {
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  font-weight: 500;
}
.feature-changelog summary:hover { color: var(--accent); }
.feature-changelog p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: 6px;
  line-height: 1.6;
}

/* --- Code Snippets ----------------------------------------- */
.snippet {
  margin: 12px 0;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}
.snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  font-family: var(--font-mono);
}
.snippet-file { color: var(--text-muted); }
.snippet-lines { color: var(--text-faint); }

.snippet pre {
  margin: 0;
  padding: 12px 16px;
  background: var(--code-bg);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.snippet code {
  font-family: var(--font-mono);
}
.snippet-caption {
  display: block;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg-muted);
  border-top: 1px solid var(--border-light);
  font-style: italic;
}

/* --- Feature Links ----------------------------------------- */
.feature-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  margin-top: 12px;
}
.link-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.link-label {
  color: var(--text-faint);
  font-weight: 500;
}
.commit-link, .issue-link {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  background: var(--bg-muted);
  border-radius: 4px;
  color: var(--accent);
  transition: background .15s;
}
.commit-link:hover, .issue-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

/* --- Issues Section ---------------------------------------- */
.issues-section { margin-bottom: 36px; }

.issues-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}
.issue-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
  font-size: 13px;
}
.issue-item:last-child { border-bottom: none; }
.issue-item:hover { background: var(--bg-subtle); text-decoration: none; }

.issue-number {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 48px;
}
.issue-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.issue-labels {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.issue-label {
  font-size: 11px;
  padding: 1px 6px;
  background: var(--bg-muted);
  border-radius: 12px;
  color: var(--text-muted);
}

/* --- Stage Bottom Nav -------------------------------------- */
.stage-nav-bottom {
  display: flex;
  justify-content: space-between;
  padding-top: 32px;
  border-top: 1px solid var(--border-light);
  margin-top: 48px;
}
.stage-nav-bottom .nav-link {
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 14px;
}
.stage-nav-bottom .nav-link:hover {
  border-color: var(--accent);
}
.stage-nav-bottom .nav-next { text-align: right; }

/* --- Semantic Tags ----------------------------------------- */
.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.4;
}

.tag-architecture    { background: #dbeafe; color: #1e40af; }
.tag-llm-providers   { background: #fce7f3; color: #9d174d; }
.tag-extension-api   { background: #ede9fe; color: #5b21b6; }
.tag-tui             { background: #d1fae5; color: #065f46; }
.tag-web-ui          { background: #fef3c7; color: #92400e; }
.tag-agent-runtime   { background: #fee2e2; color: #991b1b; }
.tag-cli             { background: #e0e7ff; color: #3730a3; }
.tag-devex           { background: #f0fdf4; color: #166534; }
.tag-performance     { background: #fff7ed; color: #9a3412; }
.tag-reliability     { background: #fef2f2; color: #b91c1c; }
.tag-ecosystem       { background: #f0fdfa; color: #134e4a; }
.tag-breaking        { background: #fef08a; color: #854d0e; }
.tag-slack-bot       { background: #ede9fe; color: #6b21a8; }
.tag-vllm-pods       { background: #cffafe; color: #155e75; }

@media (prefers-color-scheme: dark) {
  .tag-architecture    { background: #1e3a5f; color: #93c5fd; }
  .tag-llm-providers   { background: #4a1942; color: #f9a8d4; }
  .tag-extension-api   { background: #3b1f6e; color: #c4b5fd; }
  .tag-tui             { background: #064e3b; color: #6ee7b7; }
  .tag-web-ui          { background: #78350f; color: #fcd34d; }
  .tag-agent-runtime   { background: #7f1d1d; color: #fca5a5; }
  .tag-cli             { background: #312e81; color: #a5b4fc; }
  .tag-devex           { background: #14532d; color: #86efac; }
  .tag-performance     { background: #7c2d12; color: #fdba74; }
  .tag-reliability     { background: #7f1d1d; color: #fca5a5; }
  .tag-ecosystem       { background: #134e4a; color: #5eead4; }
  .tag-breaking        { background: #713f12; color: #fde047; }
  .tag-slack-bot       { background: #4c1d95; color: #c4b5fd; }
  .tag-vllm-pods       { background: #164e63; color: #67e8f9; }
}

/* Also apply dark tag styles to explicit dark theme */
[data-theme="dark"] .tag-architecture    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .tag-llm-providers   { background: #4a1942; color: #f9a8d4; }
[data-theme="dark"] .tag-extension-api   { background: #3b1f6e; color: #c4b5fd; }
[data-theme="dark"] .tag-tui             { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .tag-web-ui          { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .tag-agent-runtime   { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .tag-cli             { background: #312e81; color: #a5b4fc; }
[data-theme="dark"] .tag-devex           { background: #14532d; color: #86efac; }
[data-theme="dark"] .tag-performance     { background: #7c2d12; color: #fdba74; }
[data-theme="dark"] .tag-reliability     { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .tag-ecosystem       { background: #134e4a; color: #5eead4; }
[data-theme="dark"] .tag-breaking        { background: #713f12; color: #fde047; }
[data-theme="dark"] .tag-slack-bot       { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .tag-vllm-pods       { background: #164e63; color: #67e8f9; }

/* --- Theme Toggle ------------------------------------------ */
#theme-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
#theme-toggle:hover { background: var(--bg-muted); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  .icon-sun { display: none; }
  .icon-moon { display: block; }
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-toggle { display: block; }

  .content {
    margin-left: 0;
    padding: 24px 20px 60px;
  }

  /* Floating hamburger when sidebar is closed */
  .mobile-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
  }

  .overview-stats { gap: 12px; }
  .stat { min-width: 80px; padding: 12px 14px; }

  .feature-header { flex-direction: column; }
  .stage-meta-bar { gap: 10px; }
}

@media (max-width: 500px) {
  .overview-stats { flex-direction: column; }
  .stage-nav { flex-direction: column; gap: 8px; }
  .stage-nav-bottom { flex-direction: column; gap: 12px; }
}
