/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --accent:         #1d4ed8;
  --accent-light:   #3b82f6;
  --accent-bg:      #eff6ff;
  --accent-border:  #bfdbfe;
  --warn-bg:        #fffbeb;
  --warn-border:    #f59e0b;
  --warn-text:      #78350f;
  --sidebar-bg:     #0f172a;
  --sidebar-hover:  rgba(255,255,255,0.08);
  --sidebar-active: rgba(59,130,246,0.18);
  --code-bg:        #1e293b;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, 'Courier New', monospace;
}

/* ── Body ───────────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

/* ── Headings ───────────────────────────────────────────────────────────── */
.markdown h1 {
  font-size: 1.9rem;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.markdown h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
  padding-bottom: 0.3rem;
  margin-top: 2.25rem;
}

.markdown h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e3a5f;
  margin-top: 1.5rem;
}

.markdown h4 {
  font-weight: 600;
  color: #334155;
}

/* ── Links ──────────────────────────────────────────────────────────────── */
.markdown a {
  color: var(--accent-light);
  text-decoration: none;
}
.markdown a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Inline code ────────────────────────────────────────────────────────── */
.markdown code {
  font-family: var(--mono);
  font-size: 0.83em;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: #be185d;
}

/* ── Code blocks ────────────────────────────────────────────────────────── */
.markdown pre {
  background: var(--code-bg) !important;
  border-radius: 8px;
  border: 1px solid #334155;
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

.markdown pre code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: transparent !important;
  border: none;
  color: #e2e8f0;
  padding: 0;
}

/* Force dark background on highlighted blocks too */
.highlight > pre,
.highlight > div > pre {
  background: var(--code-bg) !important;
  border-radius: 8px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.markdown table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25rem 0;
  font-size: 0.9em;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.06);
}

.markdown table thead tr {
  background: var(--accent);
  color: #ffffff;
}

.markdown table th {
  padding: 0.6rem 1rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  font-size: 0.85em;
  letter-spacing: 0.02em;
}

.markdown table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

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

.markdown table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.markdown table tbody tr:hover {
  background: var(--accent-bg);
}

/* ── Blockquotes ────────────────────────────────────────────────────────── */
.markdown blockquote {
  border-left: 4px solid var(--accent-light);
  background: var(--accent-bg);
  padding: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
  color: #1e3a5f;
}

.markdown blockquote p {
  margin: 0;
}

/* ── GFM alerts (> [!WARNING], > [!NOTE], etc.) ─────────────────────────── */
.markdown blockquote.alert {
  border-left-width: 4px;
  border-left-style: solid;
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
}

.markdown blockquote.alert p {
  margin: 0.3rem 0;
}

.markdown blockquote.alert p:first-child {
  margin-top: 0;
}

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

/* Alert heading (the [!TYPE] label) */
.markdown blockquote.alert > p.alert-heading,
.markdown .alert-heading {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* WARNING — exam tips */
.markdown blockquote.alert-warning {
  background: var(--warn-bg);
  border-left-color: var(--warn-border);
  color: var(--warn-text);
}

.markdown blockquote.alert-warning > p.alert-heading,
.markdown blockquote.alert-warning .alert-heading {
  color: #b45309;
}

/* NOTE — resources */
.markdown blockquote.alert-note {
  background: var(--accent-bg);
  border-left-color: var(--accent-light);
  color: #1e3a5f;
}

.markdown blockquote.alert-note > p.alert-heading,
.markdown blockquote.alert-note .alert-heading {
  color: var(--accent);
}

/* TIP */
.markdown blockquote.alert-tip {
  background: #f0fdf4;
  border-left-color: #22c55e;
  color: #14532d;
}

/* IMPORTANT */
.markdown blockquote.alert-important {
  background: #faf5ff;
  border-left-color: #a855f7;
  color: #4a1d96;
}

/* ── Horizontal rules ───────────────────────────────────────────────────── */
.markdown hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 2rem 0;
}

/* ── Mermaid diagrams ───────────────────────────────────────────────────── */
.mermaid {
  text-align: center;
  margin: 1.5rem 0;
  background: #f8fafc;
  padding: 1.25rem 1rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  overflow-x: auto;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.book-menu,
.book-menu-content {
  background: var(--sidebar-bg) !important;
}

.book-menu nav {
  padding: 0.5rem;
}

.book-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.5rem;
}

.book-brand a {
  color: #f1f5f9 !important;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none !important;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* Sidebar nav links */
.book-menu a {
  color: #94a3b8 !important;
  font-size: 0.875rem;
  padding: 0.3rem 0.75rem;
  border-radius: 5px;
  display: block;
  text-decoration: none !important;
  transition: color 0.1s, background 0.1s;
  line-height: 1.5;
}

.book-menu a:hover {
  color: #e2e8f0 !important;
  background: var(--sidebar-hover);
}

/* Active / current page */
.book-menu a.active,
.book-menu a[aria-current="page"] {
  color: #93c5fd !important;
  background: var(--sidebar-active);
  font-weight: 600;
}

/* Collapse toggle buttons */
.book-menu label {
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.75rem 0.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Search box in sidebar ──────────────────────────────────────────────── */
.book-search {
  padding: 0.5rem;
}

.book-search input {
  background: rgba(255,255,255,0.07) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 6px;
  color: #e2e8f0 !important;
  font-size: 0.875rem;
  padding: 0.45rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

.book-search input::placeholder {
  color: #475569;
}

/* ── TOC ────────────────────────────────────────────────────────────────── */
.book-toc {
  font-size: 0.8rem;
  line-height: 1.5;
}

.book-toc > nav > ul > li > a {
  font-weight: 600;
}

/* ── Page breadcrumb / header ───────────────────────────────────────────── */
.book-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

/* ── LF column in overview tables (3rd column) ──────────────────────────── */
.markdown table td:nth-child(3):not(:only-child) {
  font-size: 0.78em;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* ── Status column (last column with ✅) ────────────────────────────────── */
.markdown table td:last-child {
  text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.book-footer {
  border-top: 1px solid #e2e8f0;
  margin-top: 3rem;
  padding-top: 1rem;
  color: #9ca3af;
  font-size: 0.8rem;
}
