/* ══════════════════════════════════════════════════════════════════════════
   content.css —「写作」板块页面的样式（小说 / 文章）

   只被 /writing /novels* /articles* 这几类页面加载，首页不引用它。
   因此本文件**不需要**担心影响首页：可以放心覆盖 .tag 这类通用类名。

   设计令牌全部取自 index.css 的 :root，不在这里硬编码任何色值。
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 页面骨架 ────────────────────────────────────────────────────────────── */
/* #header 是 fixed（min-height 64px + padding 10px），这里让出顶部空间 */
.content-page main {
  padding-top: 96px;
  padding-bottom: 72px;
  min-height: 60vh;
}

.content-narrow {
  max-width: 860px;
}

/* ── 面包屑 ──────────────────────────────────────────────────────────────── */
.content-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.content-crumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.content-crumb a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.content-crumb > span:last-child {
  color: var(--text-heading);
  font-weight: 500;
}

/* ── 标题区 ──────────────────────────────────────────────────────────────── */
.content-head {
  margin-bottom: 32px;
}

/* 覆盖 index.css 的 h1{font-size:48px} —— 48px 是首页 hero 的尺寸，
   内页正文页用它会把首屏撑得只剩标题。 */
.content-h1 {
  font-size: 32px;
  line-height: 1.3;
  margin-bottom: 12px;
}

.content-h2 {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 16px;
}

.content-lead {
  font-size: 16px;
  color: var(--text-muted);
}

.content-more {
  margin-top: 24px;
  font-size: 15px;
}

.content-more a {
  color: var(--primary);
  font-weight: 500;
}

.content-more a:hover {
  text-decoration: underline;
}

.content-empty {
  padding: 40px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  text-align: center;
  color: var(--text-muted);
}

.content-empty p + p {
  margin-top: 16px;
}

/* ── Tab ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.tabs .tab {
  position: relative;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  transition: var(--transition);
}

.tabs .tab:hover {
  color: var(--primary);
}

.tabs .tab.is-active {
  color: var(--primary);
}

.tabs .tab.is-active::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
}

/* 渐进增强：只有 JS 成功接管（.js-tabs 由 js/content.js 添加）时才隐藏面板。
   禁用 JS / 脚本加载失败时两个面板都可见 —— 内容不会凭空消失。 */
.js-tabs .tab-panel {
  display: none;
}

.js-tabs .tab-panel.is-shown {
  display: block;
}

/* ── 小徽标 ──────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  background: var(--primary-soft);
  color: var(--primary-hover);
  white-space: nowrap;
}

.chip--muted {
  background: var(--bg-muted);
  color: var(--text-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  background: var(--bg-muted);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── 小说：列表卡片 ──────────────────────────────────────────────────────── */
.novel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.novel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  transition: var(--transition);
}

.novel-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}

.novel-card__link {
  display: flex;
  gap: 16px;
  padding: 16px;
  height: 100%;
  color: inherit;
}

.novel-card__cover {
  flex: none;
  width: 96px;
  height: 128px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
}

.novel-card__cover--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-placeholder);
  background: var(--bg-muted);
}

.novel-card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.novel-card__title {
  font-size: 18px;
  line-height: 1.4;
  color: var(--text-heading);
  /* 书名过长时最多两行 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card__desc {
  font-size: 14px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card__meta {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── 文章：列表项 ────────────────────────────────────────────────────────── */
.article-list > .article-item + .article-item {
  border-top: 1px solid var(--border);
}

.article-item__link {
  display: block;
  padding: 22px 4px;
  color: inherit;
}

.article-item__link:hover {
  background: var(--bg-subtle);
}

.article-item__title {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text-heading);
  transition: var(--transition);
}

.article-item__link:hover .article-item__title {
  color: var(--primary);
}

.article-item__desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.article-item__meta,
.chapter__meta,
.article__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── 小说详情 ────────────────────────────────────────────────────────────── */
.novel-detail__head {
  display: flex;
  gap: 28px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.novel-detail__cover {
  flex: none;
  width: 168px;
  height: 224px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-muted);
}

.novel-detail__info {
  min-width: 0;
}

.novel-detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

/* 简介按纯文本处理（见 routes/content.js 里的 toPlainText）。
   注意：不要在这里写 white-space: pre-line —— 纯文本化会把换行压成空格，
   写了只会让人误以为换行会被保留。 */
.novel-detail__summary {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.novel-detail__toc {
  padding-top: 32px;
}

/* ── 章节目录 ────────────────────────────────────────────────────────────── */
.toc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toc li + li {
  border-top: 1px solid var(--border);
}

/* reset.css 把 ul/ol 的 list-style 清空了，这里显式给回编号以外的版式 */
.toc a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  color: inherit;
  min-height: 44px;
}

.toc a:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.toc__no {
  flex: none;
  min-width: 34px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-placeholder);
  text-align: right;
}

.toc__title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toc__words {
  flex: none;
  font-size: 13px;
  color: var(--text-placeholder);
}

/* ── 章节页 ──────────────────────────────────────────────────────────────── */
.chapter__head {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.chapter__book {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chapter__book::before {
  content: '《';
}

.chapter__book::after {
  content: '》';
}

.chapter__meta {
  margin-top: 10px;
}

.chapter__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

/* 没有上一章/下一章时用 span 占位，保持「上一章 / 目录 / 下一章」三者位置稳定 */
.btn.is-disabled {
  background: transparent;
  color: var(--text-placeholder);
  border-color: var(--border);
  cursor: not-allowed;
}

/* ── 文章详情 ────────────────────────────────────────────────────────────── */
.article__head {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article__meta {
  margin-bottom: 16px;
}

.article__summary {
  padding: 16px 20px;
  border-left: 3px solid var(--primary);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

.article__foot {
  margin-top: 48px;
  padding-top: 28px;
  padding-bottom: 0;          /* 抵消 index.css 裸 footer 规则的 24px 下内边距 */
  background: transparent;    /* 抵消 var(--dark) 的深色底，见下方说明 */
  color: inherit;             /* 抵消 color:#fff，避免以后往这里加文字时白底白字 */
  border-top: 1px solid var(--border);
}

/* ── 为什么这里必须复位（2026-10-12 修）────────────────────────────────
   index.css 里给站点页脚上色用的是一条裸元素选择器：

       footer { background: var(--dark); color: #fff; padding: 64px 0 24px; }

   它本意只管站点页脚，却会连带命中文章详情模板里的
   <footer class="article__foot">，于是：
       --dark                           = #0F172A   （元素被染成深色底）
       .btn-secondary 的 --text-heading = #0F172A   （按钮文字同色）
   前景与背景完全相同 →「← 全部文章」四个字 100% 看不见，
   并多出一条约 96px 高的深色通栏。

   修法选就地复位而不是改 index.css：本文件只被写作板块加载
   （/writing /novels* /articles*，首页不引用它），改动面最小、不波及首页。
   注意：CSS 注释不能嵌套，所以上面引用那条规则时没带它自带的注释。
   ─────────────────────────────────────────────────────────────────── */


/* ══════════════════════════════════════════════════════════════════════════
   .prose —— Markdown 渲染结果的排版
   容器内的标签由 services/markdown.js 的白名单决定，可能出现的元素：
   p br hr strong b em i del s sup sub blockquote ul ol li h2–h6 code pre a
   img table thead tbody tr th td
   （h1 被白名单排除，页面标题由模板输出，保证一个页面只有一个 h1）
   ══════════════════════════════════════════════════════════════════════════ */
.prose {
  font-size: 17px;
  line-height: 1.9;
  color: var(--text);
}

/* 相邻元素用 margin-top 控制间距：比给每个元素写 margin-bottom 更好维护，
   也不会在容器首尾留下多余空白。 */
.prose > * + * {
  margin-top: 1.15em;
}

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin-top: 2em;
  margin-bottom: 0.1em;
  color: var(--text-heading);
  line-height: 1.4;
}

.prose h2 { font-size: 24px; }
.prose h3 { font-size: 20px; }
.prose h4 { font-size: 18px; }
.prose h5,
.prose h6 { font-size: 16px; }

.prose a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--primary-hover);
}

.prose strong,
.prose b {
  font-weight: 700;
  color: var(--text-heading);
}

/* reset.css 清掉了 list-style，Markdown 的列表必须显式恢复，
   否则 ol/ul 会渲染成一堆没有标记的行。 */
.prose ul,
.prose ol {
  padding-left: 1.5em;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li::marker {
  color: var(--text-placeholder);
}

.prose li + li {
  margin-top: 0.4em;
}

.prose blockquote {
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.prose blockquote > * + * {
  margin-top: 0.8em;
}

.prose code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-muted);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.prose pre {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--dark);
  color: var(--on-dark);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
}

.prose pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.prose img {
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  border-radius: var(--radius);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.prose table {
  width: 100%;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* 表格在窄屏可横向滚动，而不是把整页顶出横向滚动条 */
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.prose thead th {
  background: var(--bg-subtle);
  color: var(--text-heading);
  font-weight: 600;
  white-space: nowrap;
}

.prose tbody tr:last-child th,
.prose tbody tr:last-child td {
  border-bottom: 0;
}

/* ── 窄屏 ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .content-page main {
    padding-top: 88px;
    padding-bottom: 56px;
  }

  .content-h1 {
    font-size: 26px;
  }

  .novel-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .novel-detail__head {
    flex-direction: column;
    gap: 20px;
  }

  .novel-detail__cover {
    width: 132px;
    height: 176px;
  }

  .prose {
    font-size: 16px;
    line-height: 1.85;
  }

  .chapter__nav {
    flex-direction: column;
  }

  .chapter__nav .btn {
    width: 100%;
  }
}
