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

/* 文章页：隐藏全站顶栏；阅读进度条与 hero 顶距改为贴视口上沿 */
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, rgba(22, 101, 52, 0.85), #22c55e, rgba(167, 243, 208, 0.75));
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.22);
  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 rgba(167, 243, 208, 0.1);
  background:
    radial-gradient(ellipse 90% 80% at 50% -30%, rgba(74, 222, 128, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, rgba(18, 40, 32, 0.95) 0%, rgba(14, 34, 26, 0.94) 55%, rgba(12, 30, 24, 0.96) 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: rgba(187, 247, 208, 0.95);
  text-decoration: none;
  margin-bottom: 16px;
}

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

.read-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(236, 253, 245, 0.42);
  margin: 0 0 18px;
}

.read-crumb a {
  color: rgba(167, 243, 208, 0.88);
  text-decoration: none;
}

.read-crumb a:hover {
  text-decoration: underline;
}

.read-crumb-sep {
  color: rgba(236, 253, 245, 0.22);
  user-select: none;
}

.read-crumb-current {
  color: rgba(236, 253, 245, 0.55);
  font-weight: 700;
}

.read-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(236, 253, 245, 0.92);
  background: rgba(167, 243, 208, 0.12);
  border: 1px solid rgba(167, 243, 208, 0.28);
  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: var(--fr-mist, #ecfdf5);
  margin: 0 0 14px;
  max-width: 18em;
}

.read-meta {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(236, 253, 245, 0.5);
}

/* 舞台：深绿底 + 柔光斑 + 斜向细线 + 点阵，避免大块平涂 */
.read-stage {
  padding: 32px 0 48px;
  background-color: rgba(10, 26, 20, 0.98);
  background-image:
    radial-gradient(ellipse 110% 70% at 8% -5%, rgba(74, 222, 128, 0.11) 0%, transparent 52%),
    radial-gradient(ellipse 90% 55% at 102% 108%, rgba(22, 101, 52, 0.42) 0%, transparent 48%),
    radial-gradient(ellipse 70% 45% at 48% 42%, rgba(15, 118, 110, 0.08) 0%, transparent 55%),
    repeating-linear-gradient(
      118deg,
      transparent 0,
      transparent 14px,
      rgba(167, 243, 208, 0.028) 14px,
      rgba(167, 243, 208, 0.028) 15px
    ),
    radial-gradient(rgba(167, 243, 208, 0.038) 1px, transparent 1px);
  background-size: auto, auto, auto, auto, 20px 20px;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat;
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0;
}

.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: rgba(226, 245, 236, 0.92);
  border-radius: 22px;
  border: 1px solid rgba(74, 222, 128, 0.2);
  box-shadow:
    0 1px 0 rgba(167, 243, 208, 0.07) inset,
    0 0 0 1px rgba(0, 0, 0, 0.2) inset,
    0 24px 60px -28px rgba(0, 0, 0, 0.45),
    0 8px 24px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  background-color: rgba(14, 34, 27, 0.92);
  background-image:
    radial-gradient(ellipse 95% 65% at 50% -18%, rgba(94, 234, 212, 0.1) 0%, transparent 46%),
    radial-gradient(ellipse 55% 42% at 108% 72%, rgba(34, 197, 94, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse 48% 38% at -5% 35%, rgba(74, 222, 128, 0.07) 0%, transparent 42%),
    radial-gradient(ellipse 60% 50% at 50% 118%, rgba(15, 118, 110, 0.14) 0%, transparent 48%),
    linear-gradient(172deg, rgba(20, 48, 38, 0.96) 0%, rgba(12, 32, 26, 0.98) 42%, rgba(10, 26, 22, 0.99) 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(167, 243, 208, 0.09) 0%, transparent 22%),
    radial-gradient(circle at 6% 94%, rgba(34, 197, 94, 0.08) 0%, transparent 24%),
    radial-gradient(rgba(236, 253, 245, 0.045) 0.55px, transparent 0.55px),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 47px,
      rgba(167, 243, 208, 0.04) 47px,
      rgba(167, 243, 208, 0.04) 48px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 47px,
      rgba(167, 243, 208, 0.035) 47px,
      rgba(167, 243, 208, 0.035) 48px
    );
  background-size: auto, auto, 4px 4px, auto, auto;
  background-repeat: no-repeat, no-repeat, repeat, repeat, repeat;
}

/* 内框线 + 内沿柔光 */
.read-paper::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 16px;
  border: 1px solid rgba(167, 243, 208, 0.1);
  box-shadow:
    0 0 40px -8px rgba(74, 222, 128, 0.06) inset,
    0 0 0 1px rgba(0, 0, 0, 0.12) 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 rgba(167, 243, 208, 0.12);
}

.read-lead {
  font-size: 1.08em;
  line-height: 1.88;
  color: rgba(220, 235, 228, 0.95);
  padding: 18px 20px 20px 22px;
  margin: 0 0 0.5em;
  border-radius: 14px;
  background: rgba(8, 22, 18, 0.45);
  border: 1px solid rgba(74, 222, 128, 0.16);
  border-left: 4px solid rgba(74, 222, 128, 0.5);
  box-shadow: 0 4px 22px -8px rgba(0, 0, 0, 0.35);
}

.read-prose > .read-sec:first-child p:first-of-type:not(.read-lead) {
  font-size: 1.05em;
  color: rgba(203, 230, 215, 0.92);
}

.read-prose h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 900;
  color: #bbf7d0;
  margin: 0 0 0.85rem;
  padding: 0 0 0.55rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(74, 222, 128, 0.22);
}

.read-prose h2::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #86efac, #22c55e);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.read-prose p {
  margin: 0 0 1.1em;
  color: rgba(204, 226, 214, 0.88);
}

.read-prose strong {
  color: #ecfdf5;
  font-weight: 800;
}

.read-prose a {
  color: #5eead4;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.read-prose a:hover {
  color: #99f6e4;
}

.read-prose code {
  font-size: 0.88em;
  background: rgba(6, 18, 14, 0.55);
  padding: 0.12em 0.42em;
  border-radius: 6px;
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: #d1fae5;
}

/* 插图区 */
.read-figure {
  margin: 1.75em 0 1.5em;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(74, 222, 128, 0.15);
  background: rgba(10, 26, 20, 0.55);
  box-shadow: 0 12px 36px -16px rgba(0, 0, 0, 0.4);
}

.read-figure__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: stretch;
  background: linear-gradient(180deg, rgba(14, 36, 28, 0.65) 0%, rgba(10, 28, 22, 0.5) 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-left: 1px solid rgba(167, 243, 208, 0.1);
}

.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;
  color: rgba(186, 230, 204, 0.88);
  background: rgba(8, 22, 18, 0.5);
  border-top: 1px solid rgba(167, 243, 208, 0.12);
}

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

.read-figure--solo .read-figure__cell {
  padding: 24px 20px 16px;
}

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

.read-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 1.5em 0;
  padding: 16px 20px;
  border-radius: 14px;
  background: rgba(8, 22, 18, 0.42);
  border: 1px solid rgba(74, 222, 128, 0.14);
}

.read-brand img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.read-brand__text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
  color: rgba(203, 230, 215, 0.88);
}

.read-brand__text strong {
  display: block;
  font-size: 15px;
  color: #bbf7d0;
}

.read-brand__sub {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(167, 243, 208, 0.72);
}

.read-callout {
  margin: 1.4em 0;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(74, 222, 128, 0.18);
  border-left: 3px solid rgba(74, 222, 128, 0.45);
  background: rgba(22, 101, 52, 0.22);
  font-size: 16px;
  line-height: 1.75;
  color: rgba(220, 240, 228, 0.92);
}

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

.read-check {
  list-style: none;
  padding: 0;
  margin: 0.9em 0 0.2em;
}

.read-check li {
  position: relative;
  padding: 12px 14px 12px 40px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid rgba(167, 243, 208, 0.12);
  background: rgba(8, 22, 18, 0.35);
  font-size: 16px;
  line-height: 1.68;
  color: rgba(204, 226, 214, 0.9);
}

.read-check li::before {
  content: '✓';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #4ade80;
  font-weight: 900;
  font-size: 14px;
}

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

.read-toc {
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px solid rgba(167, 243, 208, 0.16);
  background: rgba(15, 31, 24, 0.42);
  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: rgba(167, 243, 208, 0.75);
}

.read-toc__ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.read-toc__ul li {
  margin-bottom: 6px;
}

.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: rgba(236, 253, 245, 0.72);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 10px;
}

.read-toc a:hover {
  color: #ecfdf5;
  background: rgba(74, 222, 128, 0.08);
}

.read-toc a.is-active {
  color: #bbf7d0;
  border-left-color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

.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: rgba(236, 253, 245, 0.95);
  border: 1px solid rgba(167, 243, 208, 0.32);
}

.read-rail__btn:hover {
  background: rgba(187, 247, 208, 0.26);
  border-color: rgba(167, 243, 208, 0.45);
}

.read-rail__btn--ghost {
  background: rgba(15, 31, 24, 0.45);
  color: rgba(236, 253, 245, 0.85);
  border-color: rgba(167, 243, 208, 0.2);
}

.read-rail__btn--ghost:hover {
  border-color: rgba(74, 222, 128, 0.35);
  color: #ecfdf5;
}

/* 文末：与舞台同色带衔接，避免又一块跳变 */
.read-outro {
  padding: 48px 0 64px;
  background: linear-gradient(180deg, rgba(12, 30, 24, 0.98) 0%, rgba(14, 32, 26, 0.96) 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 rgba(167, 243, 208, 0.18);
  background: rgba(15, 31, 24, 0.75);
  box-shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.5);
}

.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: rgba(134, 239, 172, 0.95);
}

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

.read-outro__card p {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  color: rgba(236, 253, 245, 0.55);
}

.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;
  }

  .read-toc a {
    margin: 0;
    padding: 6px 10px;
    border-left: none;
    border: 1px solid rgba(167, 243, 208, 0.15);
    border-radius: 999px;
    font-size: 12px;
  }

  .read-toc a.is-active {
    border-color: rgba(74, 222, 128, 0.5);
    background: rgba(74, 222, 128, 0.15);
  }

  .read-rail__more {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .read-rail__btn {
    flex: 1;
    min-width: 120px;
  }
}

@media (max-width: 560px) {
  .read-paper::after {
    inset: 8px;
    border-radius: 14px;
  }

  .read-prose {
    font-size: 16px;
    padding: 24px 18px 28px;
  }

  .read-lead {
    padding: 14px 16px;
  }

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

  .read-figure__cell + .read-figure__cell {
    border-left: none;
    border-top: 1px solid rgba(167, 243, 208, 0.1);
  }

  .read-brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .read-rail {
    grid-template-columns: 1fr;
  }

  .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;
}
