/* ============================================================
   article.css — 博客文章阅读页 v4（read-*）
   雾林英雄带 + 深色阅读卡片（与舞台同系，无大块白底）+ 侧栏目录
   ============================================================ */

body:has(main.read) #main-nav {
  display: none !important;
}

body:has(main.read) .read-bar {
  top: 0;
}

body:has(main.read) .read-hero {
  padding-top: 28px;
}

body:has(main.read) .read-rail {
  top: 20px;
}

main.read {
  position: relative;
  z-index: 1;
  padding-top: 0;
  padding-bottom: 0;
}

main.read:has(.read-outro) {
  padding-bottom: 0;
}

.read-bar {
  position: fixed;
  top: var(--nav-height, 68px);
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 9998;
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
  transition: transform 0.1s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .read-bar { transition: none; }
}

.read-hero {
  padding: calc(var(--nav-height, 68px) + 28px) 0 40px;
  border-bottom: 1px solid #e5e7eb;
  background:
    radial-gradient(ellipse 90% 80% at 50% -30%, rgba(16, 185, 129, 0.07) 0%, transparent 55%),
    linear-gradient(180deg, rgba(15,23,42,0.07) 0%, rgba(15,23,42,0.07) 100%);
}

.read-hero__inner {
  max-width: var(--nav-inner-max, 1180px);
  margin: 0 auto;
  padding: 0 20px;
}

.read-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #059669;
  text-decoration: none;
  margin-bottom: 16px;
}

.read-back:hover { color: #111827; }

.read-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 18px;
}

.read-crumb a { color: #059669; text-decoration: none; }
.read-crumb a:hover { text-decoration: underline; }
.read-crumb-sep { color: #6b7280; user-select: none; }
.read-crumb-current { color: #374151; font-weight: 700; }

.read-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #111827;
  background: #d1fae5;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.read-title {
  font-size: clamp(26px, 4.2vw, 40px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.045em;
  color: #111827;
  margin: 0 0 14px;
  max-width: 18em;
}

.read-meta {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.read-stage {
  padding: 32px 0 48px;
  background-color: #f9fafb;
  background-image:
    radial-gradient(ellipse 110% 70% at 8% -5%, rgba(16, 185, 129, 0.06) 0%, transparent 52%),
    radial-gradient(ellipse 90% 55% at 102% 108%, rgba(16, 185, 129, 0.06) 0%, transparent 48%);
}

.read-wrap {
  max-width: var(--nav-inner-max, 1180px);
  margin: 0 auto;
  padding: 0 20px;
}

.read-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 28px 36px;
  align-items: start;
}

.read-paper {
  position: relative;
  color: #374151;
  border-radius: 22px;
  border: 1px solid #e5e7eb;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 0 0 1px rgba(0, 0, 0, 0.2) inset,
    0 24px 60px -28px rgba(15,23,42,0.08),
    0 8px 24px -12px rgba(15,23,42,0.06);
  overflow: hidden;
  background-color: #f9fafb;
  background-image:
    radial-gradient(ellipse 95% 65% at 50% -18%, rgba(94, 234, 212, 0.1) 0%, transparent 46%),
    linear-gradient(172deg, rgba(15,23,42,0.07) 0%, rgba(15,23,42,0.07) 100%);
}

.read-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
  background-image:
    radial-gradient(circle at 92% 6%, rgba(16, 185, 129, 0.05) 0%, transparent 22%),
    radial-gradient(rgba(16, 185, 129, 0.04) 0.55px, transparent 0.55px);
  background-size: auto, 4px 4px;
}

.read-paper::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 0 40px -8px rgba(16,185,129,0.15) inset;
  pointer-events: none;
  z-index: 0;
}

.read-prose {
  position: relative;
  z-index: 1;
  padding: 36px clamp(22px, 4.5vw, 44px) 40px;
  font-size: 17px;
  line-height: 1.92;
  letter-spacing: 0.018em;
}

.read-sec + .read-sec {
  margin-top: 8px;
  padding-top: 28px;
  border-top: 1px solid #f3f4f6;
}

.read-lead {
  font-size: 1.08em;
  line-height: 1.88;
  color: #374151;
  padding: 18px 20px 20px 22px;
  margin: 0 0 0.5em;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #10b981;
  box-shadow: 0 4px 22px -8px rgba(15,23,42,0.06);
}

/* ── Prose element styles (§1 checklist) ── */

/* Headings */
.article-body h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 900;
  color: #059669;
  margin: 1.5rem 0 0.85rem;
  padding: 0 0 0.55rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
  border-bottom: 1px solid #e5e7eb;
}

.article-body h2::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #a7f3d0, #10b981);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.25);
}

.article-body h3 {
  font-size: clamp(1.05rem, 1.8vw, 1.18rem);
  font-weight: 800;
  color: #111827;
  margin: 1.35rem 0 0.65rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body h4 {
  font-size: 1.02rem;
  font-weight: 700;
  color: #374151;
  margin: 1.1rem 0 0.5rem;
  line-height: 1.45;
}

.article-body h5 {
  font-size: 0.96rem;
  font-weight: 700;
  color: #6b7280;
  margin: 0.9rem 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Text */
.article-body p {
  margin: 0 0 1.1em;
  color: #374151;
}

.article-body strong {
  color: #111827;
  font-weight: 800;
}

.article-body b {
  color: #111827;
  font-weight: 800;
}

.article-body em {
  font-style: italic;
  color: #374151;
}

.article-body a {
  color: #059669;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-body a:hover { color: #047857; }

.article-body code {
  font-size: 0.88em;
  background: #ffffff;
  padding: 0.12em 0.42em;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  color: #065f46;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body kbd {
  display: inline-block;
  font-size: 0.82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 0.1em 0.5em;
  border: 1px solid #d1d5db;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f9fafb;
  color: #374151;
  box-shadow: 0 1px 0 #d1d5db;
}

.article-body del {
  text-decoration: line-through;
  color: #9ca3af;
}

.article-body mark {
  background: #fef9c3;
  color: #713f12;
  padding: 0.05em 0.25em;
  border-radius: 3px;
}

/* Lists */
.article-body ul {
  margin: 0.6em 0 1em;
  padding-left: 1.35em;
  color: #374151;
}

.article-body ol {
  margin: 0.6em 0 1em;
  padding-left: 1.35em;
  color: #374151;
}

.article-body li {
  margin-bottom: 0.45em;
  line-height: 1.7;
}

.article-body dl {
  margin: 0.8em 0 1.1em;
  padding: 14px 18px;
  background: #f0fdf4;
  border-radius: 10px;
  border: 1px solid rgba(16,185,129,0.2);
}

.article-body dt {
  font-weight: 800;
  color: #059669;
  margin-bottom: 2px;
  margin-top: 12px;
}

.article-body dt:first-child { margin-top: 0; }

.article-body dd {
  margin: 0 0 6px 16px;
  color: #374151;
  font-size: 0.96em;
  line-height: 1.65;
}

/* Code blocks */
.article-body pre {
  background: #1e293b;
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 1.2em 0;
  border: 1px solid #334155;
  box-shadow: 0 4px 16px -6px rgba(15,23,42,0.15);
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.87em;
  line-height: 1.65;
  overflow-wrap: normal;
  word-break: normal;
}

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.25em;
  font-size: 0.94em;
  line-height: 1.55;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.article-body thead { }

.article-body tbody { }

.article-body tr { }

.article-body th {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-weight: 800;
  color: #059669;
  background: rgba(16,185,129,0.12);
  border-bottom: 2px solid rgba(16,185,129,0.3);
}

.article-body td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
}

.article-body tbody tr:last-child td { border-bottom: none; }
.article-body tbody tr:hover td { background: #f9fafb; }

/* Blockquote & HR */
.article-body blockquote {
  margin: 1.4em 0;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(16,185,129,0.25);
  border-left: 3px solid rgba(16, 185, 129, 0.5);
  background: #f0fdf4;
  font-size: 16px;
  line-height: 1.75;
  color: #374151;
}

.article-body blockquote strong { color: #059669; }
.article-body blockquote p { margin: 0; }

.article-body hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 2em 0;
}

/* Media */
.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  loading: lazy;
}

/* 插图区 – cover & inline figures */
.read-figure {
  margin: 1.75em 0 1.5em;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 12px 36px -16px rgba(15,23,42,0.08);
}

.read-figure__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: stretch;
  background: linear-gradient(180deg, rgba(15,23,42,0.07) 0%, rgba(15,23,42,0.07) 100%);
}

.read-figure__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  min-height: 160px;
}

.read-figure__cell + .read-figure__cell {
  border: 1px solid #e5e7eb;
}

.read-figure img {
  width: min(100%, 220px);
  height: auto;
  display: block;
  object-fit: contain;
}

.read-figure--diagram .read-figure__cell {
  min-height: 0;
  padding: 14px 16px 10px;
}

.read-figure--diagram img {
  width: 100%;
  max-width: 100%;
  max-height: none;
}

.read-figure__cap {
  margin: 0;
  padding: 12px 16px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #6b7280;
  background: #ffffff;
  border-top: 1px solid #f3f4f6;
}

.read-figure--solo .read-figure__grid {
  grid-template-columns: 1fr;
}

.read-figure--solo .read-figure__cell {
  padding: 0;
  min-height: auto;
}

.read-figure--solo img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  border-radius: 14px;
}

.read-figure--solo.read-figure--diagram .read-figure__cell {
  padding: 14px 16px 10px;
}

.read-figure--solo.read-figure--diagram img {
  width: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0;
}

.article-body figure {
  margin: 1.75em 0 1.5em;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 12px 36px -16px rgba(15,23,42,0.08);
}

.article-body figure img {
  width: 100%;
  border-radius: 0;
}

.article-body figcaption {
  padding: 10px 16px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  background: #ffffff;
  border-top: 1px solid #f3f4f6;
  line-height: 1.5;
}

/* Details/Summary */
.article-body details {
  margin: 1.2em 0;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.article-body summary {
  padding: 14px 16px;
  font-weight: 700;
  color: #059669;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: #f0fdf4;
}

.article-body summary::-webkit-details-marker { display: none; }

.article-body summary::before {
  content: '▶ ';
  font-size: 0.8em;
  color: #10b981;
}

.article-body details[open] summary::before { content: '▼ '; }

.article-body details > *:not(summary) {
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
}

/* FAQ block — .read-faq sits alongside .article-body (not nested inside it),
   so it needs its own copies of the heading/details styling above. */
.read-faq h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 900;
  color: #059669;
  margin: 0 0 0.85rem;
  padding: 0 0 0.55rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  border-bottom: 1px solid #e5e7eb;
}

.read-faq h2::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #a7f3d0, #10b981);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.25);
}

.read-faq-item {
  margin: 0 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.read-faq-item:last-child { margin-bottom: 0; }

.read-faq-item summary {
  padding: 14px 16px;
  font-weight: 700;
  color: #059669;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: #f0fdf4;
}

.read-faq-item summary::-webkit-details-marker { display: none; }

.read-faq-item summary::before {
  content: '▶ ';
  font-size: 0.8em;
  color: #10b981;
}

.read-faq-item[open] summary::before { content: '▼ '; }

.read-faq-item p {
  margin: 0;
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  color: #374151;
}

/* Callout */
.read-callout {
  margin: 1.4em 0;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(16,185,129,0.25);
  border-left: 3px solid rgba(16, 185, 129, 0.5);
  background: #f0fdf4;
  font-size: 16px;
  line-height: 1.75;
  color: #374151;
}

.read-callout strong { color: #059669; }

/* Sidebar */
.read-rail {
  position: sticky;
  top: calc(var(--nav-height, 68px) + 20px);
  align-self: start;
  min-width: 0;
}

.read-toc {
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  margin-bottom: 14px;
}

.read-toc[hidden] { display: none !important; }

.read-toc__hd {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9ca3af;
}

.read-toc__ul { list-style: none; margin: 0; padding: 0; }
.read-toc__ul li { margin-bottom: 6px; min-width: 0; }

.read-toc a {
  display: block;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: #374151;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.read-toc a:hover { color: #111827; background: rgba(16,185,129,0.15); }
.read-toc a.is-active { color: #059669; border-left-color: #10b981; background: rgba(16,185,129,0.15); }

.read-rail__more { display: flex; flex-direction: column; gap: 8px; }

.read-rail__btn {
  display: block;
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  background: rgba(187, 247, 208, 0.16);
  color: #111827;
  border: 1px solid #e5e7eb;
}

.read-rail__btn:hover { background: rgba(187, 247, 208, 0.26); border-color: #9ca3af; }
.read-rail__btn--ghost { background: #ffffff; color: #111827; border-color: #9ca3af; }
.read-rail__btn--ghost:hover { border-color: rgba(16,185,129,0.35); }

/* CTA footer */
.read-outro {
  padding: 48px 0 64px;
  background: linear-gradient(180deg, rgba(15,23,42,0.07) 0%, rgba(15,23,42,0.07) 100%);
}

.read-outro .container {
  max-width: var(--nav-inner-max, 1180px);
  margin: 0 auto;
  padding: 0 20px;
}

.read-outro__card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px 28px;
  padding: 26px 28px;
  border-radius: 18px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 20px 50px -24px rgba(15,23,42,0.08);
}

.read-outro__copy { flex: 1; min-width: 220px; }

.read-outro__eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #059669;
}

.read-outro__card h2 {
  margin: 0 0 8px;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 900;
  color: #111827;
  letter-spacing: -0.03em;
}

.read-outro__card p { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.6; color: #374151; }

.read-outro__actions .btn-primary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 14px;
}

@media (max-width: 960px) {
  .read-grid { grid-template-columns: 1fr; }
  .read-rail { position: static; order: -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .read-toc { grid-column: 1 / -1; }
  .read-toc__ul { display: flex; flex-wrap: wrap; gap: 6px; }
  .read-toc__ul li { margin: 0; min-width: 0; max-width: 100%; }
  .read-toc a { margin: 0; padding: 6px 10px; border-left: none; border: 1px solid #e5e7eb; border-radius: 999px; font-size: 12px; }
  .read-rail__more { flex-direction: row; flex-wrap: wrap; }
  .read-rail__btn { flex: 1; min-width: 120px; }
}

@media (max-width: 680px) {
  .read-figure__grid { grid-template-columns: 1fr; }
  .read-figure__cell + .read-figure__cell { border-left: none; border: 1px solid #e5e7eb; }
}

@media (max-width: 560px) {
  .read-prose { font-size: 16px; padding: 24px 18px 28px; }
  .read-outro__card { flex-direction: column; align-items: stretch; padding: 22px 18px; }
  .read-outro__actions .btn-primary { width: 100%; }
}

main.read + #main-footer { margin-top: 0; }
