/* ===================================================================
   Claude Code Wiki — Stylesheet
   =================================================================== */

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

:root {
  --sidebar-w: 280px;
  --content-max: 820px;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Colors — warm light palette */
  --bg: #fafaf9;
  --bg-sidebar: #1a1a2e;
  --bg-card: #ffffff;
  --bg-code: #1e1e2e;
  --bg-code-inline: #f1f0ee;
  --bg-table-stripe: #f7f6f4;
  --bg-callout: #fefce8;
  --border: #e5e3df;
  --border-callout: #eab308;
  --text: #1a1a1a;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  --accent: #4A90D9;
  --accent-hover: #3b7cc9;
  --accent-bg: #e8f0fe;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
}

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

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

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

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: #fff;
}

.logo-icon {
  font-size: 1.6rem;
  color: var(--accent);
}

.logo-title {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 0.68rem;
  color: var(--text-sidebar);
  margin-top: 0.1rem;
}

.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
}

.nav-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sidebar);
  padding: 0.5rem 1.25rem 0.35rem;
  font-weight: 600;
}

.sidebar-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.42rem 1.25rem;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.sidebar-nav a:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.04);
}

.sidebar-nav a.active {
  color: var(--text-sidebar-active);
  background: rgba(74,144,217,0.12);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  min-width: 1.4rem;
  font-weight: 500;
}

/* --- Main Content --- */
.content {
  margin-left: var(--sidebar-w);
  padding: 2.5rem 3rem 4rem;
  max-width: calc(var(--content-max) + 6rem);
}

article { max-width: var(--content-max); }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

h1 { font-size: 2rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--border); }
h2 { font-size: 1.45rem; margin-top: 2.5rem; margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.15rem; margin-top: 1.75rem; margin-bottom: 0.5rem; }
h4 { font-size: 1rem; margin-top: 1.25rem; margin-bottom: 0.4rem; }

p { margin-bottom: 1rem; }

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

strong { font-weight: 600; }

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

/* --- Lists --- */
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: 0.3rem; }
li > p { margin-bottom: 0.3rem; }

/* --- Blockquotes / Callouts --- */
blockquote.callout, blockquote {
  background: var(--bg-callout);
  border-left: 4px solid var(--border-callout);
  padding: 0.9rem 1.2rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: #78350f;
}

blockquote p:last-child { margin-bottom: 0; }

/* --- Inline Code --- */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code-inline);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-weight: 400;
}

/* --- Code Blocks --- */
.code-block {
  position: relative;
  margin: 1.25rem 0;
}

.code-lang {
  position: absolute;
  top: 0; right: 0;
  background: rgba(255,255,255,0.08);
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.25rem 0.6rem;
  border-radius: 0 6px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

pre {
  background: var(--bg-code);
  border-radius: 8px;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.06);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* Prism overrides */
.token.comment { color: #6b7280; }
.token.keyword { color: #c084fc; }
.token.string { color: #86efac; }
.token.function { color: #60a5fa; }
.token.number { color: #fbbf24; }
.token.operator { color: #94a3b8; }
.token.class-name { color: #67e8f9; }
.token.property { color: #fca5a5; }

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

thead {
  background: #f8f7f5;
}

th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) { background: var(--bg-table-stripe); }
tbody tr:hover { background: var(--accent-bg); }

td code {
  font-size: 0.82em;
  white-space: nowrap;
}

/* --- Mermaid Diagrams --- */
pre.mermaid {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--text);
  overflow-x: auto;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* --- Prev/Next Navigation --- */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prev-next a {
  display: inline-block;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  transition: all 0.15s ease;
  max-width: 48%;
}

.prev-next a:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  text-decoration: none;
}

.prev-next .next { text-align: right; margin-left: auto; }

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Index / Landing Page --- */
.hero {
  text-align: center;
  padding: 2rem 0 2.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  border: none;
  padding: 0;
  margin-bottom: 0.3rem;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 1rem;
}

.hero-desc {
  max-width: 600px;
  margin: 0 auto 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin: 2rem 0;
}

.toc-card {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s ease;
}

.toc-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(74,144,217,0.1);
  text-decoration: none;
  transform: translateY(-1px);
}

.toc-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 1.6rem;
  padding-top: 0.15rem;
}

.toc-title {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.4;
}

.index-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.index-section h2 {
  border: none;
  padding: 0;
}

/* --- Mobile Sidebar Toggle --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-toggle { display: block; }

  .content {
    margin-left: 0;
    padding: 1.5rem 1.25rem 3rem;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }

  .hero h1 { font-size: 1.8rem; }

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

  .prev-next {
    flex-direction: column;
  }

  .prev-next a { max-width: 100%; }
}

@media (max-width: 600px) {
  html { font-size: 15px; }
  pre { font-size: 0.78rem; padding: 0.8rem; }
  th, td { padding: 0.4rem 0.6rem; }
}

/* --- Wiki: Nav Groups --- */
.nav-group { margin-bottom: 0.5rem; }
.nav-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding: 0.6rem 1.25rem 0.25rem;
  font-weight: 700;
}

/* --- Wiki: Breadcrumbs --- */
.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

/* --- Wiki: See Also --- */
.see-also {
  margin-top: 2.5rem;
  padding: 1.25rem;
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.see-also h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  padding: 0;
  border: none;
}
.see-also ul { list-style: none; padding: 0; margin: 0; }
.see-also li { margin-bottom: 0.3rem; }
.see-also a { font-weight: 500; font-size: 0.88rem; }

/* --- Wiki: Footnotes --- */
.footnotes { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); }
.footnotes ol { padding-left: 1.5rem; }
.footnotes li { margin-bottom: 0.4rem; }
sup a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* --- Print --- */
@media print {
  .sidebar, .sidebar-toggle, .back-to-top, .see-also, .breadcrumb { display: none !important; }
  .content { margin-left: 0; padding: 0; max-width: 100%; }
  pre { white-space: pre-wrap; word-break: break-word; }
  pre.mermaid { page-break-inside: avoid; }
}

/* Search */
.sidebar-search { padding: 0.5rem 1rem; }
.sidebar-search input {
  width: 100%; padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; color: #e4e4e4; font-size: 0.85rem;
  outline: none; transition: border-color 0.2s;
}
.sidebar-search input:focus { border-color: rgba(255,255,255,0.3); }
.sidebar-search input::placeholder { color: rgba(255,255,255,0.35); }
.search-results {
  display: none; position: absolute; left: 1rem; right: 1rem;
  background: #1e1e2e; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; margin-top: 0.25rem; max-height: 400px;
  overflow-y: auto; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.search-result {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; text-decoration: none; color: #e4e4e4;
  border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.85rem;
}
.search-result:hover { background: rgba(255,255,255,0.06); }
.search-title { flex: 1; }
.search-cat {
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 4px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.search-empty { padding: 0.75rem; color: rgba(255,255,255,0.4); font-size: 0.85rem; text-align: center; }
