/*
 * 网页版文章阅读页样式。
 * 排版取值与小程序 pages/article/detail/detail.wxss、detail.js 的正文内联样式一致
 * （小程序 rpx 按 1rpx = 0.5px 换算为网页 px），保证两端渲染结果对齐。
 * 页面外壳沿用网页端既有设计变量，正文使用小程序阅读配色。
 */
:root {
  --brand: #cf4b45;
  --brand-strong: #dc2626;
  --brand-soft: #fff3f1;
  --ink: #333942;
  --body: #333333;
  --muted: #8b929c;
  --meta: #999999;
  --line: #e5e7eb;
  --page: #f7f8fa;
  --surface: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--body);
  background: var(--page);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

a {
  -webkit-tap-highlight-color: transparent;
  /* 站点默认不给链接加下划线（分类导航等纯文字链接尤其需要），下划线只做 hover 反馈 */
  text-decoration: none;
}

/* ---------- 顶栏：改由 /site-nav.css + /site-nav.js 全站公共提供 ---------- */

/* ---------- 版面：左侧阅读导航 + 正文 + 右侧分类导航 ---------- */

.article-main {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  width: min(calc(100% - 56px), 1180px);
  margin: 0 auto;
  padding: 20px 0 40px;
}

.article-shell {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 760px;
}

/* 左侧阅读导航：正文 Markdown 标题生成的目录，当前阅读位置文字高亮 + 品牌竖条 */
.article-toc {
  position: sticky;
  top: 80px;
  flex: 0 0 180px;
  align-self: flex-start;
  max-height: calc(100vh - 104px);
  padding-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.article-toc[hidden] {
  display: none;
}

.toc-title {
  margin: 0 0 11px;
  color: var(--meta);
  font-size: 12.5px;
  letter-spacing: .1em;
}

.toc-nav {
  display: flex;
  flex-direction: column;
}

.toc-item {
  display: block;
  padding: 5px 0 5px 9px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  /* 每个标题固定一行：超出用省略号，完整标题由 .toc-tip 悬浮提示补足 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .16s, border-color .16s;
}

.toc-item:hover {
  color: var(--ink);
}

.toc-item.is-active {
  color: var(--brand);
  border-left-color: var(--brand);
}

/* 四级标题：三级标题的下级，再缩进一档 */
.toc-item.is-sub {
  padding-left: 21px;
  font-size: 12.5px;
}

/* 目录标题被省略号截断时，悬浮显示完整标题。
   浮层必须挂在 body 上：.article-toc 有 overflow-y:auto，子元素浮层会被裁掉。 */
.toc-tip {
  position: fixed;
  z-index: 60;
  display: none;
  max-width: 340px;
  padding: 6px 10px;
  color: #ffffff;
  background: rgba(38, 42, 48, .94);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
  pointer-events: none;
}

.toc-tip.is-on {
  display: block;
}

/* 右侧分类导航：纯文字纵向树，只展开当前文章所在分类，其余折叠可手动展开 */
.article-side {
  position: sticky;
  top: 80px;
  /* 分类栏宽度固定 10 个汉字宽（一级分类字号 14px × 10 = 140px） */
  flex: 0 0 140px;
  align-self: flex-start;
  max-height: calc(100vh - 104px);
  padding-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.article-side[hidden] {
  display: none;
}

.side-title {
  margin: 0 0 11px;
  color: var(--meta);
  font-size: 12.5px;
  letter-spacing: .1em;
}

.side-group + .side-group {
  margin-top: 15px;
}

.side-module-row {
  display: flex;
  align-items: center;
  width: 100%;
}

.side-module {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  /* 与分类列表页一致：500 而不是 600（中文在 550 会掉字重） */
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  transition: color .16s;
}

.side-module::before {
  content: "";
  width: 3px;
  height: 13px;
  flex: none;
  background: var(--brand);
  border-radius: 2px;
}

.side-module-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-module:hover,
.side-module.is-current {
  color: var(--brand);
}

/* 折叠按钮：图标排在分类文字之后、整行右对齐 */
.side-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color .16s, background-color .16s;
}

.side-toggle:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

.side-toggle svg {
  width: 13px;
  height: 13px;
  transition: transform .18s ease;
}

.side-group.is-open .side-toggle svg {
  transform: rotate(90deg);
}

.side-cards {
  display: flex;
  flex-direction: column;
  margin: 6px 0 0 11px;
}

.side-cards[hidden] {
  display: none;
}

.side-card {
  padding: 4px 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  transition: color .16s;
}

.side-card:hover,
.side-card.is-current {
  color: var(--brand);
}

.article-state {
  margin: 0;
  padding: 60px 0;
  color: var(--meta);
  font-size: 16px;
  text-align: center;
}

.article-header {
  padding: 19px 5px 12px;
}

.article-title {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 550;
  line-height: 1.42;
  letter-spacing: 0;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--meta);
  font-size: 16px;
}

.article-cate {
  color: var(--brand-strong);
}

/* 分类名是可点链接：hover 只做颜色加深，不加下划线（与站点其他纯文字链接一致） */
a.article-cate {
  transition: color .16s;
}

a.article-cate:hover,
a.article-cate:focus-visible {
  color: var(--brand);
  outline: none;
}

.article-meta .dot {
  color: #dddddd;
}

.article-tag {
  padding: 2px 6px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 10px;
  font-size: 16px;
}

/* ---------- 正文（对齐小程序文章详情排版） ---------- */

.article-body {
  padding: 17px 15px 9px;
  color: var(--body);
  background: var(--surface);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1.72;
  letter-spacing: 0;
  overflow-x: hidden;
}

.article-body p,
.article-body div {
  margin: 0 0 12px;
}

/* 注：正文 p/div 的字体/字号/行高/字间距/颜色/首行缩进不再在此硬写，
   改由采集时内联的原文排版样式决定（保留原文观感）；
   手动发布文章若无内联样式，则继承下方 .article-body 的基线值。 */

.article-body ul,
.article-body ol {
  margin: 0 0 12px;
  padding-left: 24px;
  list-style-position: outside;
}

.article-body ul {
  list-style-type: disc;
}

.article-body ol {
  list-style-type: decimal;
}

.article-body li {
  margin: 0 0 5px;
  padding-left: 2px;
}

.article-body h1 {
  margin: 20px 0 11px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 550;
  line-height: 1.42;
  letter-spacing: 0;
}

.article-body h2 {
  margin: 19px 0 10px;
  padding-left: 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 550;
  line-height: 1.42;
  letter-spacing: 0;
  border-left: 3px solid #e7a4a0;
}

.article-body h3 {
  margin: 18px 0 9px;
  padding-left: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 550;
  line-height: 1.45;
  letter-spacing: 0;
  border-left: 3px solid #efd4d2;
}

.article-body h4 {
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 550;
  line-height: 1.45;
  letter-spacing: 0;
}

.article-body h5,
.article-body h6 {
  margin: 15px 0 7px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 550;
  line-height: 1.45;
  letter-spacing: 0;
}

.article-body code {
  padding: 1px 4px;
  color: #a63d3d;
  background: var(--brand-soft);
  border-radius: 4px;
  font-size: .94em;
  letter-spacing: 0;
}

.article-body pre {
  margin: 12px 0;
  padding: 12px;
  color: var(--ink);
  background: #f7f7f9;
  border-radius: 6px;
  line-height: 1.6;
  letter-spacing: 0;
  overflow-x: auto;
  white-space: pre;
}

.article-body pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.article-body strong,
.article-body b {
  font-weight: 550;
  letter-spacing: 0;
}

.article-body blockquote {
  margin: 10px 0 14px;
  padding: 4px 0 4px 12px;
  color: #59616d;
  border-left: 3px solid #e7a4a0;
  line-height: 1.68;
  letter-spacing: 0;
}

.article-body hr {
  height: 1px;
  margin: 17px 0;
  border: 0;
  background: var(--line);
}

.article-body img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 14px 0;
  border-radius: 8px;
}

/* 采集内容排版归一化：figure/figcaption 统一居中图注 */
.article-body figure {
  margin: 14px 0;
  text-align: center;
}

.article-body figure img {
  margin: 0 auto;
}

.article-body figcaption {
  margin-top: 6px;
  color: #878d97;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.article-body a {
  color: var(--brand);
  text-decoration: none;
}

.article-body a:hover {
  text-decoration: underline;
}

.article-body table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: 16px;
}

.article-body th,
.article-body td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.article-body th {
  font-weight: 550;
  background: #fafbfc;
}

/* ---------- 付费提示与版权 ---------- */

.article-pay {
  margin-top: 12px;
  padding: 15px;
  background: var(--surface);
  border-radius: 8px;
}

.article-pay p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.article-pay .article-pay-title {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 550;
}

.article-copyright {
  margin: 12px 0 0;
  padding: 9px 11px;
  color: var(--meta);
  background: var(--surface);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- 网页 50% 截断引导 ---------- */

.article-web-limit {
  position: relative;
  margin-top: -66px;
  padding: 76px 15px 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 58%);
  border-radius: 0 0 8px 8px;
  pointer-events: none;
}

.web-limit-hint {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.web-limit-button {
  pointer-events: auto;
  margin-top: 12px;
  padding: 0 30px;
  min-height: 44px;
  color: #ffffff;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
}

.web-limit-button:hover {
  background: var(--brand-strong);
}

.web-limit-button:focus-visible {
  outline: 3px solid rgba(207, 75, 69, .25);
}

/* ---------- 小程序二维码弹层 ---------- */

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 20, 19, .55);
  backdrop-filter: blur(3px);
}

.qr-modal[hidden] {
  display: none;
}

.qr-panel {
  position: relative;
  width: min(92vw, 340px);
  padding: 26px 24px 24px;
  background: var(--surface);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

.qr-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.qr-close:hover {
  color: var(--ink);
  background: var(--page);
}

.qr-panel h3 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 550;
}

.qr-panel img {
  display: block;
  width: 208px;
  height: 208px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 10px;
}

.qr-tip {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* 付费面板内的小程序码 */

.article-pay-qr {
  display: flex;
  margin-top: 12px;
  padding-top: 12px;
  align-items: center;
  gap: 14px;
  border-top: 1px dashed var(--line);
}

.article-pay-qr img {
  display: block;
  flex: none;
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 8px;
}

.article-pay-qr span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* 中等宽度：阅读导航收起（正文 + 分类导航两列仍然放得下） */
@media (max-width: 1120px) {
  .article-toc {
    display: none;
  }
}

/* 窄屏：右侧分类导航也收起，正文回归单列阅读宽度 */
@media (max-width: 820px) {
  .article-main {
    width: 100%;
    padding: 20px 16px 40px;
  }

  .article-side {
    display: none;
  }
}

@media (max-width: 480px) {
  .article-main {
    padding: 12px 10px 32px;
  }

  .article-title {
    font-size: 21px;
  }
}
