/* ==========================================================================
   Article Page Styles — inff.cc
   Clean, responsive article layout with dark mode support.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Article Canvas (main container)
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   1. Article Canvas (main container) — unified with homepage/category
   -------------------------------------------------------------------------- */
.article-canvas {
  max-width: var(--container-max, 860px);
  padding: 2.5rem 2rem;
}

@media (max-width: 1200px) {
  .article-canvas {
    max-width: var(--container-max, 860px);
    padding: 2.5rem 1.5rem;
  }
}

@media (max-width: 768px) {
  .article-canvas {
    max-width: 100%;
    padding: 1.5rem 1rem;
  }
}

/* --------------------------------------------------------------------------
   2. Article Header
   -------------------------------------------------------------------------- */
.article__header {
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   3. Category Link
   -------------------------------------------------------------------------- */
.article__category {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #c0392b);
  text-transform: uppercase;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   4. Date
   -------------------------------------------------------------------------- */
.article__date {
  font-size: 12px;
  color: var(--muted, #999);
  margin-left: 1rem;
}

/* --------------------------------------------------------------------------
   5. Featured Image
   -------------------------------------------------------------------------- */
.article__featured {
  margin: 1.5rem 0;
  border-radius: 6px;
  overflow: hidden;
}

.article__featured img {
  width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   6. Article Title
   -------------------------------------------------------------------------- */
.article-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.25;
  margin: 1.25rem 0 0.75rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   7. Article Subtitle
   -------------------------------------------------------------------------- */
.article-subtitle {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   8. Article Meta
   -------------------------------------------------------------------------- */
.article__meta {
  font-size: 12px;
  color: var(--muted, #888);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   9. Separator
   -------------------------------------------------------------------------- */
.article__separator {
  border: none;
  border-top: 1px solid var(--border, #e8e8e8);
  margin: 0 0 2rem;
}

/* --------------------------------------------------------------------------
   10. Article Body / Rich Text
   -------------------------------------------------------------------------- */
.article__body,
.article-body,
.payload-richtext {
  max-width: 100%;
  font-size: 17px;
  line-height: 1.8;
}

.article__body p,
.payload-richtext p {
  margin-bottom: 1.5em;
  text-align: justify;
}

@media (max-width: 768px) {
  .article__body,
.article-body,
  .payload-richtext {
    max-width: 100%;
    font-size: 16px;
  }

  .article__body p,
  .payload-richtext p {
    text-align: left;
  }
}

/* --------------------------------------------------------------------------
   11. Tags
   -------------------------------------------------------------------------- */
.article__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2rem 0;
}

.article__tags .tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-2, #f5f5f5);
  border-radius: 20px;
  font-size: 12px;
  text-decoration: none;
  color: var(--fg);
}

/* --------------------------------------------------------------------------
   12. Sources
   -------------------------------------------------------------------------- */
.article__sources {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.article__sources-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .article__sources-list {
    grid-template-columns: 1fr;
  }
}

.source-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--border, #eee);
  border-radius: 6px;
}

.source-card__name {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.source-card__title {
  font-size: 14px;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   13. Share Buttons
   -------------------------------------------------------------------------- */
.article__share {
  display: flex;
  gap: 12px;
  margin: 2rem 0;
}

.article__share button,
.article__share a {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  background: none;
}

/* --------------------------------------------------------------------------
   14. Related Articles
   -------------------------------------------------------------------------- */
.article__related {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article__related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .article__related-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   15. Rich Text Headings
   -------------------------------------------------------------------------- */
.payload-richtext h2,
.article__body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2em 0 0.8em;
}

.payload-richtext h3,
.article__body h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   16. Blockquote
   -------------------------------------------------------------------------- */
.payload-richtext blockquote,
.article__body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  font-style: italic;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   17. Type Badges
   -------------------------------------------------------------------------- */
.type-badge {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
}

.type-badge--feature {
  background: #fef3cd;
}

.type-badge--explainer {
  background: #d1ecf1;
}

.type-badge--special {
  background: #f8d7da;
}

/* --------------------------------------------------------------------------
   18. Reading Progress Bar
   -------------------------------------------------------------------------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.2s ease;
}

/* --------------------------------------------------------------------------
   19. Back-to-Top Button
   -------------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent, #c0392b);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 999;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   20. Dark Mode
   -------------------------------------------------------------------------- */
[data-mode="dark"] .article__tags .tag {
  background: var(--bg-2, #2a2a2a);
  color: var(--fg, #e0e0e0);
}

[data-mode="dark"] .source-card {
  border-color: var(--border, #333);
  background: var(--bg-2, #1e1e1e);
}

[data-mode="dark"] .source-card__title {
  color: var(--fg, #e0e0e0);
}

[data-mode="dark"] .article__separator {
  border-top-color: var(--border, #333);
}

[data-mode="dark"] .article__share button,
[data-mode="dark"] .article__share a {
  border-color: var(--border, #444);
  color: var(--fg, #e0e0e0);
}

[data-mode="dark"] .type-badge--feature {
  background: #3d3520;
  color: #fef3cd;
}

[data-mode="dark"] .type-badge--explainer {
  background: #1a3040;
  color: #d1ecf1;
}

[data-mode="dark"] .type-badge--special {
  background: #3d2025;
  color: #f8d7da;
}

[data-mode="dark"] .article__related {
  border-top-color: var(--border, #333);
}

[data-mode="dark"] .article__sources {
  border-top-color: var(--border, #333);
}

[data-mode="dark"] .reading-progress {
  background: var(--accent, #e74c3c);
}

[data-mode="dark"] .back-to-top {
  background: var(--accent, #e74c3c);
}

/* ── Related articles: card grid (not full-width images) ──── */

/* ── Related articles — desktop ───────────────────────── */
.article-related {
  overflow: hidden;
  max-width: 100%;
  margin-top: 2rem;
}

.article-related h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--fg);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  overflow: hidden;
  max-width: 100%;
}

.related-card {
  text-decoration: none;
  color: var(--fg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border, #eee);
  transition: box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.related-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.related-card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.related-card-body {
  padding: 12px;
  min-width: 0;
}

.related-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.related-card-date {
  font-size: 11px;
  color: var(--muted, #999);
  margin-top: 6px;
  display: block;
}

/* ── Related articles — mobile ───────────────────────── */
@media (max-width: 768px) {
  .related-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .related-card {
    flex-direction: row;
    align-items: stretch;
  }

  .related-card-cover {
    width: 100px;
    height: auto;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
  }

  .related-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
  }

  .related-card-title {
    font-size: 14px;
    -webkit-line-clamp: 3;
    overflow-wrap: break-word;
  }
}
/* --------------------------------------------------------------------------
   Article Meta Line — unified author/date/time row
   -------------------------------------------------------------------------- */
.article-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin: 0.75rem 0 1.5rem;
  font-family: var(--font-ui, system-ui, sans-serif);
}

.article-meta-line .meta-sep {
  margin: 0 0.4em;
  opacity: 0.5;
}

.article-meta-line .meta-date {
  color: var(--muted, #6b7280);
}

.article-header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.meta-category-link {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent, #1a3a6b);
  text-decoration: none;
  border-bottom: 2px solid var(--accent, #1a3a6b);
  padding-bottom: 2px;
}

.meta-category-link:hover {
  opacity: 0.7;
}

.article-divider {
  border: none;
  border-top: 1px solid var(--border, #e5e7eb);
  margin: 1.5rem 0;
}
/* === CHAPTER RAIL (desktop) === */
.chapter-rail {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: clamp(8px, calc(50vw - 700px), 100px);
  width: 170px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  font-family: var(--font-mono, var(--font-ui, system-ui));
  font-size: 11px;
  line-height: 1.4;
  z-index: 10;
  scrollbar-width: none;
}
.chapter-rail::-webkit-scrollbar { display: none; }
.chapter-rail-list { list-style: none; padding: 0; margin: 0; }
.chapter-rail-group { margin-bottom: 1px; }
.chapter-rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s, opacity .15s;
  opacity: 0.55;
}
.chapter-rail-item:hover { color: var(--fg); opacity: 1; }
.chapter-rail-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
  color: var(--fg);
  opacity: 1;
}
.chapter-rail-item.active { color: var(--accent); opacity: 1; font-weight: 600; }
.chapter-rail-item.sub { padding-left: 16px; font-size: 10px; opacity: 0.7; }
.chapter-rail-item.sub.active { opacity: 1; }
.chapter-rail-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
  transition: background .2s, border-color .2s, transform .2s;
}
.chapter-rail-item.active .chapter-rail-dot {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
}
.chapter-rail-item.sub .chapter-rail-dot { width: 5px; height: 5px; }
.chapter-rail-label {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow: hidden;
}
/* Collapsible children */
.chapter-rail-children {
  list-style: none;
  padding: 0;
  margin: 2px 0 4px;
  animation: rail-expand .2s ease-out;
}
@keyframes rail-expand {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chapter-rail-progress {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
@media (max-width: 1199px) { .chapter-rail { display: none; } }

/* === MOBILE FAB WITH PROGRESS RING === */
.toc-fab {
  z-index: 150;
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface, #fff);
  border: 2px solid var(--border);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 150;
  transition: transform .15s, box-shadow .15s;
  padding: 0;
  align-items: center;
  justify-content: center;
}
.toc-fab:hover { transform: scale(1.06); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
@media (max-width: 1199px) { .toc-fab {
  display: flex; } }
.toc-fab-ring {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  transform: rotate(-90deg);
}
.toc-fab-ring-bg {
  fill: none;
  stroke: var(--border-soft);
  stroke-width: 2.5;
}
.toc-fab-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset .15s linear;
}
.toc-fab-text {
  font-family: var(--font-mono, var(--font-ui, system-ui));
  font-size: 11px;
  font-weight: 700;
  color: var(--fg);
  z-index: 1;
}

/* === BOTTOM SHEET === */
.toc-sheet-overlay {
  z-index: 9999;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
}
.toc-sheet {
  width: 100%;
  max-height: 75vh;
  background: var(--surface, #fff);
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  animation: sheet-up .25s ease-out;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.toc-sheet-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 1;
}
.toc-sheet-title {
  font-family: var(--font-mono, var(--font-ui, system-ui));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc-sheet-progress {
  font-family: var(--font-mono, var(--font-ui, system-ui));
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.toc-sheet-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.toc-sheet-list {
  list-style: none;
  padding: 8px 20px;
  margin: 0;
}
.toc-sheet-group { border-bottom: 1px solid var(--border-soft); }
.toc-sheet-group:last-child { border-bottom: none; }
.toc-sheet-group > button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 0 10px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  transition: color .12s;
}
.toc-sheet-group > button:hover { color: var(--accent); }
.toc-sheet-group > button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 2px;
}
.toc-sheet-group > button.active { color: var(--accent); font-weight: 700; }
.toc-sheet-group.active-group { background: var(--surface-warm); margin: 0 -20px; padding: 0 20px; border-radius: 4px; }
.toc-sheet-sub {
  list-style: none;
  padding: 0 0 8px 16px;
  margin: 0;
}
.toc-sheet-sub button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 0;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--fg-2);
  cursor: pointer;
}
.toc-sheet-sub button:hover { color: var(--accent); }
.toc-sheet-sub button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 2px;
}
.toc-sheet-sub button.active { color: var(--accent); font-weight: 600; }




/* ── Source Cards — single column card layout ─────────── */
.sources-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.sources-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent, #1a3a6b);
  margin-bottom: 1rem;
  font-family: var(--font-ui, system-ui, sans-serif);
}

.sources-count,
.sources-langs {
  color: var(--accent, #1a3a6b);
}

.sources-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.source-card {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.source-card:hover {
  border-color: var(--accent, #1a3a6b);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.source-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.source-card-flag {
  font-size: 0.9rem;
  line-height: 1;
}

.source-card-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent, #1a3a6b);
  font-family: var(--font-ui, system-ui, sans-serif);
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-card-lang {
  font-size: 0.65rem;
  color: var(--muted, #6b7280);
  background: var(--surface, #f4f5f7);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-card-excerpt {  font-size: 0.85rem;  line-height: 1.5;  color: var(--fg-2, #444);  margin: 0;  display: -webkit-box;  -webkit-line-clamp: 2;  -webkit-box-orient: vertical;  overflow: hidden;}
/* Dark mode */
@media (prefers-color-scheme: dark) {
  .source-card {
    border-color: var(--border, #2a2a44);
  }
  .source-card:hover {
    border-color: var(--accent, #6a9fd8);
  }
}


/* ── Cover Image Prompt Reveal ── */
.cover-wrapper {  position: relative;  overflow: hidden;  border-radius: 8px;  background: var(--surface, #f0f0f0);  max-width: 100%;  box-sizing: border-box;}.article-cover {  max-width: 100%;  overflow: hidden;  margin: 2rem 0;}
.cover-prompt-btn {
  opacity: 0;
  transition: opacity 0.2s;
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
}
.cover-prompt-btn:hover,
.cover-prompt-btn.active {
  opacity: 1;
  background: rgba(0,0,0,0.7);
  color: #fff;
  transform: scale(1.05);
}
.prompt-panel {  max-height: 0;  overflow: hidden;  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;  opacity: 0;  padding: 0 1rem;  background: var(--surface, #f4f5f7);  border: 1px solid var(--border, #d4d6dc);  border-top: none;  border-radius: 0 0 6px 6px;}.prompt-panel--open {  max-height: 300px;  opacity: 1;  padding: 0.75rem 1rem;}.prompt-info {  display: flex;  flex-direction: column;  gap: 0.4rem;}.prompt-row {  display: flex;  align-items: flex-start;  gap: 0.5rem;  font-size: 0.78rem;  line-height: 1.5;  color: var(--fg-2, #444);}.prompt-row-label {  white-space: nowrap;  opacity: 0.6;  min-width: 60px;  color: var(--muted, #6b7280);}.prompt-row-value {  color: var(--fg, #1a1a2e);  font-family: var(--font-mono, monospace);  font-size: 0.72rem;  word-break: break-word;}.prompt-actions {  margin-top: 0.5rem;  padding-top: 0.4rem;  border-top: 1px solid var(--border, #d4d6dc);}.prompt-copy-btn {  background: none;  border: 1px solid var(--border, #d4d6dc);  color: var(--muted, #6b7280);  padding: 0.25rem 0.6rem;  border-radius: 4px;  cursor: pointer;  font-size: 0.7rem;  display: inline-flex;  align-items: center;  gap: 0.3rem;  transition: all 0.15s ease;}.prompt-copy-btn:hover {  background: var(--surface-warm, #eef0f5);  color: var(--fg, #1a1a2e);}.copy-done {  color: var(--accent, #1a3a6b);}

/* ── Cover image: aspect-ratio placeholder + fade-in ──── */
.cover-wrapper {  position: relative;  overflow: hidden;  border-radius: 8px;  background: var(--surface, #f0f0f0);  max-width: 100%;  box-sizing: border-box;}.article-cover {  max-width: 100%;  overflow: hidden;  margin: 2rem 0;}

.cover-img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cover-img.loaded {
  opacity: 1;
}

/* Shimmer animation while loading */
.cover-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: shimmer 1.5s infinite;
}

.cover-img.loaded ~ .cover-wrapper::before,
.cover-wrapper:has(.cover-img.loaded)::before {
  display: none;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Force no horizontal overflow on mobile (Safari fix) ──── */
.article-canvas {
  overflow-x: hidden;
}

.article-cover,
.article-cover .cover-wrapper,
.article-cover .cover-wrapper img {
  max-width: 100% !important;
  box-sizing: border-box;
}

/* ── Inline article images (▲ photo captions) ──── */
.article-inline-image {
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

.article-inline-image img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}

.article-inline-image figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted, #666);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
  padding: 0 1rem;
}

/* Caption-only variant (no image available) */
.article-inline-image--caption-only {
  border-left: 3px solid var(--accent, #ccc);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  text-align: left;
}

.article-inline-image--caption-only figcaption {
  margin-top: 0;
  font-size: 0.9rem;
}

/* ── Generic article figure (for ![alt](url) patterns) ──── */
.article-figure {
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

.article-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}

.article-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted, #666);
  font-style: italic;
  line-height: 1.5;
}

/* ── Embed blocks ──── */
.block-embed {
  margin: 2rem 0;
}

.block-embed.embed-video {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}

.block-embed.embed-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.block-embed.embed-chart iframe,
.block-embed.embed-map iframe,
.block-embed.embed-generic iframe {
  width: 100%;
  min-height: 400px;
  border: none;
}

/* ── Markdown tables ──── */
.block-table-wrapper {
  margin: 2rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.block-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.block-table th,
.block-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #ddd);
  text-align: left;
}

.block-table th {
  background: var(--bg-muted, #f5f5f5);
  font-weight: 600;
}

.block-table tbody tr:nth-child(even) {
  background: var(--bg-muted, #fafafa);
}

/* --------------------------------------------------------------------------
   21. Article Body — Paragraph Spacing (improved readability)
   -------------------------------------------------------------------------- */
.article-body p,
.article__body p,
.payload-richtext p {
  margin-bottom: 1.5em;
}

.article-body p + p,
.article__body p + p,
.payload-richtext p + p {
  margin-top: 0;
}

/* --------------------------------------------------------------------------
   22. Explainer Article Template — Enhanced Readability
   -------------------------------------------------------------------------- */

/* When article has .type-badge-explainer in the header, apply explainer styles
   to the body content within the same .article-canvas */
.article-canvas:has(.type-badge-explainer) .article-body {
  font-size: 1.05rem;
  line-height: 1.9;
}

.article-canvas:has(.type-badge-explainer) .article-body p {
  margin-bottom: 1.6em;
}

/* Lede paragraph (first paragraph) — subtle left accent */
.article-canvas:has(.type-badge-explainer) .article-body .payload-richtext > p:first-child {
  border-left: 3px solid var(--accent, #1a3a6b);
  padding-left: 1rem;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--fg);
}

/* Inline images in explainer articles — generous spacing */
.article-canvas:has(.type-badge-explainer) .article-inline-image {
  margin: 2.5em 0;
}

/* Dark mode adjustments for explainer lede */
[data-mode="dark"] .article-canvas:has(.type-badge-explainer) .article-body .payload-richtext > p:first-child {
  border-left-color: var(--accent, #6a9fd8);
}

/* === Multi-panel cover (4-panel narrative) === */
.cover-panels {
  position: relative;
  width: 100%;
}

/* Desktop: auto-fade slideshow */
@media (min-width: 769px) {
  .cover-panels {
    aspect-ratio: 1200/630;
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface, #1a1a1a);
  }
  .cover-panel-item {
    position: absolute;
    inset: 0;
    opacity: 0;
  }
  .cover-panel-item:nth-child(1) {
    opacity: 1;
    animation: fade-first 16s infinite;
  }
  .cover-panel-item:nth-child(2) { animation: fade-panel 16s infinite; animation-delay: 4s; }
  .cover-panel-item:nth-child(3) { animation: fade-panel 16s infinite; animation-delay: 8s; }
  .cover-panel-item:nth-child(4) { animation: fade-panel 16s infinite; animation-delay: 12s; }
  .cover-panel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  @keyframes fade-first {
    0%, 25% { opacity: 1; }
    28%, 97% { opacity: 0; }
    100% { opacity: 1; }
  }
  @keyframes fade-panel {
    0%, 3% { opacity: 0; }
    6%, 25% { opacity: 1; }
    28%, 100% { opacity: 0; }
  }
}

/* Mobile: vertical stack */
@media (max-width: 768px) {
  .cover-panels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: unset;
  }
  .cover-panel-item {
    position: static;
    opacity: 1;
    animation: none;
  }
  .cover-panel-item img {
    width: 100%;
    display: block;
  }
}

.panels-prompt-btn {
  position: relative;
  margin-top: 8px;
}

.cover-wrapper:hover .cover-prompt-btn { opacity: 1; }

/* === ARTICLE PREV/NEXT NAVIGATION === */
.diplo-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft, #e5e7eb);
}
.diplo-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: inherit;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-soft, #e5e7eb);
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
}
.diplo-nav-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.diplo-nav-item--next { text-align: right; }
.diplo-nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted, #999);
  letter-spacing: 0.03em;
}
.diplo-nav-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 640px) {
  .diplo-nav { flex-direction: column; gap: 0.75rem; }
  .diplo-nav-item--next { text-align: left; }
}

/* Breadcrumb navigation */
.article-breadcrumb {
  font-size: 0.8rem;
  color: var(--fg-muted, #666);
  margin-bottom: 1rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-breadcrumb a {
  color: var(--fg-muted, #666);
  text-decoration: none;
}
.article-breadcrumb a:hover {
  text-decoration: underline;
}
.breadcrumb-sep {
  margin: 0 0.4em;
  opacity: 0.5;
}
.breadcrumb-current {
  color: var(--fg, #333);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Masthead Logo === */
.masthead-logo {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.masthead-logo--dark { display: none; }
.masthead-logo--light { display: inline-block; }

[data-mode="dark"] .masthead-logo--dark { display: inline-block; }
[data-mode="dark"] .masthead-logo--light { display: none; }
