/* ================================================================
   ARTICLE STYLES — typography, TOC, code blocks, math, social share
   Usage: <link rel="stylesheet" href="../../shared/article.css">
   (Add to /content/articles/*.html pages)
   ================================================================ */

/* ── Article layout ───────────────────────────────────────────── */
.article-body {
  max-width: 72ch;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
  font-size: var(--text-base, 1rem);
  line-height: 1.8;
  color: var(--color-text);
}

/* ── Headings ─────────────────────────────────────────────────── */
.article-body h1 {
  font-size: var(--text-4xl, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 1rem;
}
.article-body h2 {
  font-size: var(--text-2xl, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.75rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: 80px;
}
.article-body h3 {
  font-size: var(--text-xl, 1.25rem);
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.65rem;
  scroll-margin-top: 80px;
}
.article-body h4 {
  font-size: var(--text-base, 1rem);
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-muted-2);
}

/* ── Paragraphs & lists ───────────────────────────────────────── */
.article-body p {
  margin-bottom: 1.2rem;
}
.article-body ul,
.article-body ol {
  padding-left: 1.6rem;
  margin-bottom: 1.2rem;
}
.article-body li {
  margin-bottom: 0.35rem;
}
.article-body li > p {
  margin-bottom: 0.35rem;
}

/* ── Inline elements ──────────────────────────────────────────── */
.article-body strong {
  font-weight: 700;
  color: var(--color-text);
}
.article-body em {
  font-style: italic;
}
.article-body a {
  color: #818cf8;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.article-body a:hover {
  color: #6366f1;
}
.article-body code {
  font-family: var(--font-mono, monospace);
  font-size: 0.875em;
  background: rgba(99, 102, 241, 0.1);
  color: #a78bfa;
  padding: 0.15em 0.38em;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── Code blocks ──────────────────────────────────────────────── */
.article-body pre {
  background: #0d1117;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.4rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.65;
}
.article-body pre code {
  background: transparent;
  color: #e6edf3;
  padding: 0;
  border-radius: 0;
  white-space: pre;
  font-size: inherit;
}

/* ── Blockquotes ──────────────────────────────────────────────── */
.article-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.4rem;
  border-left: 3px solid #818cf8;
  background: rgba(99, 102, 241, 0.07);
  border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
  color: var(--color-muted-2);
  font-style: italic;
}
.article-body blockquote cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.875rem;
  color: #818cf8;
}

/* ── Callout / info boxes ─────────────────────────────────────── */
.callout {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg, 12px);
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  line-height: 1.65;
}
.callout--info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.callout--tip {
  background: rgba(34, 197, 94, 0.09);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.callout--warning {
  background: rgba(251, 191, 36, 0.09);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.callout--danger {
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.callout-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ── Math blocks (KaTeX) ──────────────────────────────────────── */
.math-block {
  overflow-x: auto;
  margin: 1.5rem 0;
  text-align: center;
}
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* ── Article metadata ─────────────────────────────────────────── */
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-muted-2);
}
.article-meta .meta-date::before {
  content: "📅 ";
}
.article-meta .meta-time::before {
  content: "⏱ ";
}
.article-meta .meta-tag {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Table of Contents ────────────────────────────────────────── */
.toc {
  background: var(--color-surface, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  padding: 1.1rem 1.4rem;
  margin: 1.75rem 0 2.5rem;
  font-size: var(--text-sm, 0.875rem);
}
.toc-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  counter-reset: toc-counter;
}
.toc-item {
  counter-increment: toc-counter;
}
.toc-item--sub {
  padding-left: 1.4rem;
}
.toc-link {
  color: var(--color-muted-2);
  text-decoration: none;
  line-height: 1.55;
  display: block;
  padding: 0.1rem 0;
  transition: color 0.15s;
}
.toc-link:hover,
.toc-link--active {
  color: #818cf8;
}
.toc-link--active {
  font-weight: 600;
}

/* ── Social share bar ─────────────────────────────────────────── */
.article-share {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.article-share-label {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-muted);
  font-weight: 600;
}
.article-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.article-share-btn:hover {
  border-color: #818cf8;
  transform: translateY(-1px);
}

/* ── Article navigation (prev/next) ──────────────────────────── */
.art-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  font-size: var(--text-sm, 0.875rem);
}
@media (max-width: 540px) {
  .art-nav {
    grid-template-columns: 1fr;
  }
}
.art-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  color: var(--color-text);
  text-decoration: none;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.art-nav-link:hover {
  border-color: #818cf8;
  transform: translateY(-2px);
}
.art-nav-link--next {
  text-align: right;
}
.art-nav-dir {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.art-nav-title {
  font-weight: 600;
  color: #818cf8;
}

/* ── Horizontal rule ──────────────────────────────────────────── */
.article-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

/* ── Images ───────────────────────────────────────────────────── */
.article-body img {
  max-width: 100%;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--color-border);
  display: block;
  margin: 1.5rem auto;
}
.article-body figure {
  margin: 1.5rem 0;
  text-align: center;
}
.article-body figcaption {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin-top: 0.5rem;
}

/* ── Tables ───────────────────────────────────────────────────── */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  overflow-x: auto;
  display: block;
}
.article-body th {
  background: var(--color-surface);
  font-weight: 700;
  text-align: left;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  color: var(--color-muted-2);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.article-body td {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  vertical-align: top;
}
.article-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Print styles ─────────────────────────────────────────────── */
@media print {
  .article-body {
    max-width: 100%;
    padding: 0;
    font-size: 11pt;
    color: #000;
    background: #fff;
  }
  .article-body h2,
  .article-body h3 {
    page-break-after: avoid;
    color: #000;
    border-color: #ccc;
  }
  .article-body pre {
    background: #f5f5f5;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
  .article-body pre code {
    color: #333;
  }
  .article-body a {
    color: #000;
    text-decoration: underline;
  }
  .article-body a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }
  .article-body blockquote {
    border-left-color: #999;
    background: #f9f9f9;
    color: #333;
  }
  .toc,
  .article-share,
  .art-nav {
    display: none;
  }
  .callout {
    border: 1px solid #ccc;
    background: #f9f9f9;
  }
}
