/* Deppy Book — Tutorial & Reference */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #7c3aed;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-code: #1e293b;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --info: #0284c7;
  --sidebar-w: 280px;
  --content-max: 820px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

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

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  overflow-y: auto;
  padding: 1.5rem 0;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-header {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.sidebar nav ul { list-style: none; }
.sidebar nav > ul > li { margin-bottom: 0.25rem; }
.sidebar nav .section-title {
  display: block;
  padding: 0.35rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.75rem;
}
.sidebar nav a {
  display: block;
  padding: 0.3rem 1.25rem 0.3rem 1.75rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar nav a:hover {
  background: rgba(37, 99, 235, 0.06);
  color: var(--primary);
}
.sidebar nav a.active {
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
  background: rgba(37, 99, 235, 0.08);
}
.sidebar nav ul ul a { padding-left: 2.5rem; font-size: 0.8rem; }

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

/* ── Typography ── */
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.75rem; color: var(--text); }
h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 2rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--border); }
h3 { font-size: 1.15rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
h4 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--text-muted); }

p { margin-bottom: 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 1rem 1.5rem; }
li { margin-bottom: 0.3rem; }

blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background: rgba(37, 99, 235, 0.04);
  border-radius: 0 6px 6px 0;
}

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

/* ── Code ── */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: #f1f5f9;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #be185d;
}
pre {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
  position: relative;
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.code-label {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-family: var(--font-sans);
}

/* Syntax highlighting (inline — no external deps) */
.kw { color: #c084fc; }          /* keywords: def, class, if, return */
.fn { color: #60a5fa; }          /* function names */
.st { color: #86efac; }          /* strings */
.cm { color: #64748b; font-style: italic; } /* comments */
.ty { color: #fbbf24; }          /* types */
.op { color: #f472b6; }          /* operators */
.nb { color: #f97316; }          /* numbers/builtins */
.dc { color: #22d3ee; }          /* decorators */
.pr { color: #a78bfa; }          /* proof terms */

/* ── Callout Boxes ── */
.note, .warning, .tip, .important, .exercise {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin: 1.25rem 0;
  font-size: 0.92rem;
  border-left: 4px solid;
}
.note { background: #eff6ff; border-color: var(--info); }
.note::before { content: "ℹ️ Note"; font-weight: 700; display: block; margin-bottom: 0.4rem; color: var(--info); }
.warning { background: #fffbeb; border-color: var(--warning); }
.warning::before { content: "⚠️ Warning"; font-weight: 700; display: block; margin-bottom: 0.4rem; color: var(--warning); }
.tip { background: #f0fdf4; border-color: var(--success); }
.tip::before { content: "💡 Tip"; font-weight: 700; display: block; margin-bottom: 0.4rem; color: var(--success); }
.important { background: #fef2f2; border-color: var(--error); }
.important::before { content: "🔴 Important"; font-weight: 700; display: block; margin-bottom: 0.4rem; color: var(--error); }
.exercise { background: #faf5ff; border-color: var(--accent); }
.exercise::before { content: "✏️ Exercise"; font-weight: 700; display: block; margin-bottom: 0.4rem; color: var(--accent); }

/* Verification badge */
.verified {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #dcfce7;
  color: #15803d;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.verified::before { content: "✅"; }
.rejected {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.rejected::before { content: "❌"; }

/* Side-by-side comparison */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}
.compare > div { min-width: 0; }
.compare h4 { margin-top: 0; text-align: center; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}
th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { font-weight: 600; background: var(--bg-alt); }
tr:hover td { background: rgba(37, 99, 235, 0.03); }

/* ── Navigation (prev/next) ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 45%;
  transition: border-color 0.15s;
}
.page-nav a:hover { border-color: var(--primary); text-decoration: none; }
.page-nav .label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.page-nav .title { font-weight: 600; color: var(--text); }

/* ── Proof Steps ── */
.proof-steps {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1rem 0;
}
.proof-steps h4 { margin: 0 0 0.75rem; color: var(--accent); }
.proof-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}
.proof-step:last-child { border-bottom: none; }
.step-num {
  min-width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
}
.step-content { flex: 1; }
.step-content code { font-size: 0.82em; }

/* ── Mobile ── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1.1rem;
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 2rem 1.25rem; }
  .menu-toggle { display: block; }
  .compare { grid-template-columns: 1fr; }
}
