/* ============================================================
   content.css  —  Article, code blocks, admonitions, page nav, TOC
   ============================================================ */

.content { flex: 1; }

.content-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 3rem;
  max-width: calc(var(--content-max) + var(--toc-w) + 3rem);
  margin: 0 auto;
  padding: 2.5rem 2rem 2rem;
  align-items: start;
}

/* ── Article headings ────────────────────────────────────── */
.article { min-width: 0; }

.article h1 {
  font-size: 1.875rem; font-weight: 800; color: var(--accent);
  margin-bottom: 1rem; letter-spacing: -0.02em; line-height: 1.25;
  scroll-margin-top: calc(var(--top-h) + 1rem);
}
.article h2 {
  font-size: 1.4rem; font-weight: 700; color: var(--fg);
  margin-top: 2.5rem; margin-bottom: 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--top-h) + 1rem);
}
.article h3 {
  font-size: 1.125rem; font-weight: 700; color: var(--fg);
  margin-top: 1.875rem; margin-bottom: 0.5rem;
  scroll-margin-top: calc(var(--top-h) + 1rem);
}
.article h4 { font-size: 1rem; font-weight: 600; margin-top: 1.5rem; }
.article h5, .article h6 { font-size: 0.925rem; font-weight: 600; margin-top: 1.25rem; }

/* Permalink */
.article .headerlink { opacity: 0; margin-left: 0.35rem; font-size: 0.8em; color: var(--fg2); transition: opacity var(--dur) var(--ease); }
.article h1:hover .headerlink,
.article h2:hover .headerlink,
.article h3:hover .headerlink { opacity: 1; }

/* ── Prose ───────────────────────────────────────────────── */
.article p    { margin-bottom: 1.25rem; }
.article strong { font-weight: 700; }
.article em     { font-style: italic; }
.article del    { color: var(--fg2); }

.article ul, .article ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.article li { margin-bottom: 0.3rem; }
.article li::marker { color: var(--accent); }
.article ul ul, .article ol ol { margin-top: 0.3rem; margin-bottom: 0; }

.article blockquote {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  padding: 0.875rem 1.125rem;
  border-radius: 0 var(--r) var(--r) 0;
  margin: 1.5rem 0; color: var(--fg2); font-style: italic;
}
.article blockquote p:last-child { margin-bottom: 0; }

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

.article img { border-radius: var(--r2); border: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Tables ──────────────────────────────────────────────── */
.article table {
  width: 100%; border-collapse: collapse;
  margin: 1.75rem 0; font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--r2); overflow: hidden;
}
.article thead { background: var(--bg2); }
.article th {
  padding: 0.65rem 1rem; text-align: left;
  font-weight: 700; font-size: 0.74rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent);
}
.article td { padding: 0.6rem 1rem; border-top: 1px solid var(--border); }
.article tr:hover td { background: color-mix(in srgb, var(--fg) 4%, transparent); }

/* ── Inline code ─────────────────────────────────────────── */
.article code {
  font-family: var(--font-mono); font-size: 0.855em;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--d-pink);
  padding: 0.15em 0.4em; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
[data-scheme="light"] .article code { color: #be185d; }
.article pre code { background: none; color: inherit; padding: 0; border: none; font-size: inherit; }

/* ── Code blocks ─────────────────────────────────────────── */
.article pre,
.article .highlight {
  background: var(--bg3) !important;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  margin: 1.5rem 0;
  overflow: auto; position: relative;
  transition: background var(--dur2) var(--ease), border-color var(--dur2) var(--ease);
}
.article pre code,
.article .highlight pre {
  display: block;
  padding: 1.125rem 1.375rem;
  font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.7;
  background: none !important; border: none; margin: 0; overflow-x: auto;
}

/* ── Admonitions ─────────────────────────────────────────── */
.article .admonition {
  border-radius: var(--r2); margin: 1.75rem 0;
  overflow: hidden; border: 1px solid;
}
.article .admonition-title {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1rem; font-weight: 700;
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0;
}
.article .admonition > p { padding: 0 1rem 1rem; margin: 0; }

.article .note    { border-color: var(--d-cyan);   }
.article .note    .admonition-title { background: color-mix(in srgb, var(--d-cyan) 12%, transparent);   color: var(--d-cyan);   }
.article .tip     { border-color: var(--d-green);  }
.article .tip     .admonition-title { background: color-mix(in srgb, var(--d-green) 12%, transparent);  color: var(--d-green);  }
.article .warning { border-color: var(--d-orange); }
.article .warning .admonition-title { background: color-mix(in srgb, var(--d-orange) 12%, transparent); color: var(--d-orange); }
.article .danger  { border-color: var(--d-red);    }
.article .danger  .admonition-title { background: color-mix(in srgb, var(--d-red) 12%, transparent);    color: var(--d-red);    }
.article .info    { border-color: var(--accent);   }
.article .info    .admonition-title { background: color-mix(in srgb, var(--accent) 12%, transparent);   color: var(--accent);   }

/* ── Page nav (prev / next) ──────────────────────────────── */
.page-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.pnav-slot { flex: 1; }
.pnav-slot--next { display: flex; justify-content: flex-end; }

.pnav-btn {
  display: inline-flex; align-items: center; gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r2); max-width: 100%;
  transition: border-color var(--dur) var(--ease);
  color: inherit;
}
.pnav-btn:hover { border-color: var(--accent); filter: none; }
.pnav-arrow { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }

.pnav-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.pnav-text--right { align-items: flex-end; }
.pnav-label { font-size: 0.69rem; color: var(--fg2); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.pnav-title {
  font-size: 0.83rem; font-weight: 600; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Table of contents ───────────────────────────────────── */
.toc {
  position: sticky;
  top: calc(var(--top-h) + 1.5rem);
  max-height: calc(100vh - var(--top-h) - 3rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface) transparent;
}
.toc-title {
  font-size: 0.67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--fg2); margin-bottom: 0.625rem;
  padding-left: 0.75rem; border-left: 2px solid var(--border);
}
.toc-list { list-style: none; border-left: 2px solid var(--border); }
.toc-list li { padding-left: 0.75rem; margin-bottom: 0.2rem; }
.toc-link { font-size: 0.82rem; color: var(--fg2); display: block; padding: 0.1rem 0; transition: color var(--dur) var(--ease); }
.toc-link:hover, .toc-link.is-active { color: var(--accent); filter: none; }
.toc-link.is-active { font-weight: 600; }
.toc-sublist { list-style: none; padding-left: 0.875rem; margin-top: 0.15rem; }
.toc-sublink { font-size: 0.775rem; color: var(--fg2); display: block; padding: 0.1rem 0; }
.toc-sublink:hover { color: var(--accent); filter: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .content-inner { grid-template-columns: 1fr; max-width: var(--content-max); }
  .toc { display: none; }
}
@media (max-width: 768px) {
  .content-inner { padding: 1.5rem 1.25rem; }
  .page-nav { flex-direction: column; }
  .pnav-slot--next { justify-content: flex-start; }
  .pnav-btn { max-width: 100%; }
  .pnav-title { max-width: 100%; }
}
