/* ===========================================================================
   公共组件：页头页脚之外的可复用块（分类页 / 详情页 / 首页共用）
   变量来自 tokens.css；页面级布局与首页专属块留在 style.css。
   =========================================================================== */

/* ===========================================================================
   内页：分类页 + 详情页（共用首页 token 与组件）
   =========================================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span[aria-hidden] { color: var(--ink-3); opacity: .6; }

.main-nav a.is-current { color: var(--accent); font-weight: 700; }

/* ------------------------------------------------------------- 分类页 */
.page-hero {
  background: var(--band);
  padding: 22px 0 26px;
}
.page-hero h1 {
  margin-top: 12px;
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 800;
  letter-spacing: .01em;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.page-hero .kicker { font-size: 13px; margin-left: 2px; }
.page-lead {
  margin-top: 8px;
  font-size: 19px;
  font-weight: 700;
}
.page-desc {
  margin-top: 8px;
  max-width: 760px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.65;
}

.list-layout { display: block; padding-top: 22px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 14px;
}
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
  margin-right: 2px;
}
.chip {
  border: 1px solid rgba(47, 51, 48, .18);
  background: rgba(255, 255, 255, .5);
  color: var(--ink-2);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color .16s, color .16s, border-color .16s;
}
.chip:hover { border-color: var(--accent-mid); color: var(--accent); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.sort-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
}
.sort-btn.is-active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.count { font-size: 12.5px; color: var(--ink-3); margin-left: 6px; }

.card-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.entry-card { background: #fcf9f3; border-radius: 14px; box-shadow: var(--shadow-card); }
.entry-card > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 18px 14px;
  gap: 6px;
}
.entry-card .tag {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent);
}
.entry-card h2 { font-size: 16px; line-height: 1.45; font-weight: 700; margin: 0; }
.entry-card h3 { font-size: 16px; line-height: 1.45; font-weight: 700; }
.entry-card p { font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.entry-card .more { margin-top: auto; padding-top: 8px; color: var(--accent); }
.entry-card .more svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.entry-card:hover { box-shadow: 0 8px 20px rgba(47, 51, 48, .1); }
.entry-card:hover h3 { color: var(--accent); }

.empty-state {
  margin-top: 16px;
  padding: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
  background: var(--card);
  border-radius: 14px;
}

.list-description {
  margin-top: 22px;
  padding: 24px 26px;
  background: var(--card);
  border-radius: var(--radius-card);
}
.list-description h2 { font-size: 19px; font-weight: 800; }
.list-description p {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.8;
  max-width: 900px;
}

.related-cats { margin-top: 22px; }
.related-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.related-list a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 12px;
  transition: background-color .16s, transform .16s;
}
.related-list a:hover { background: #e5e1d2; transform: translateY(-2px); }
.related-list strong { display: block; font-size: 14.5px; }
.related-list span { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------------- 详情页 */
.article-head {
  background: var(--band);
  padding: 22px 0 30px;
}
.article-tag {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
}
.article-head h1 {
  margin-top: 8px;
  font-size: clamp(27px, 3.1vw, 40px);
  line-height: 1.25;
  font-weight: 800;
  max-width: 900px;
}
.article-lead {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
  max-width: 780px;
  line-height: 1.65;
}
.article-source {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(47, 51, 48, .14);
  font-size: 12.5px;
  color: var(--ink-3);
  max-width: 780px;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: start;
  padding-top: 26px;
}
.article-body { grid-column: 1; grid-row: 1; }
.toc { grid-column: 2; grid-row: 1; }
.article-body { max-width: 720px; }
.article-figure { margin-bottom: 18px; }
.article-figure img { width: 100%; border-radius: 14px; }
.article-figure figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.article-body h2 {
  margin-top: 30px;
  padding-top: 4px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  scroll-margin-top: 90px;
}
.article-body h2:first-of-type { margin-top: 8px; }
.article-body p {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-2);
}

.toc {
  position: sticky;
  top: 84px;
  background: var(--card);
  border-radius: 14px;
  padding: 16px 18px;
}
.toc-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.toc-toggle svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-3);
}
.toc ol { margin-top: 8px; display: grid; gap: 2px; }
.toc a {
  display: block;
  padding: 5px 8px;
  border-left: 2px solid transparent;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.toc a:hover { color: var(--accent); }
.toc a.is-active {
  color: var(--accent);
  font-weight: 700;
  border-left-color: var(--accent);
  background: rgba(81, 102, 79, .08);
}

.article-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}
.article-nav a {
  padding: 16px 18px;
  background: var(--card);
  border-radius: 14px;
  transition: background-color .16s;
}
.article-nav a:hover { background: #e5e1d2; }
.article-nav span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .05em; }
.article-nav strong { display: block; margin-top: 5px; font-size: 14.5px; line-height: 1.5; }
.article-nav .nav-next { text-align: right; }

.related-entries {
  margin-top: 28px;
  padding: 20px 22px 24px;
  background: var(--card-soft);
  border-radius: var(--radius-card);
}
.related-entries .related-list { margin-top: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 1024px) {
  .card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .related-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .article-body, .toc { grid-column: 1; }
  .article-body { grid-row: 2; }
  .toc { grid-row: 1; position: static; padding: 12px 14px; }
  .toc-toggle { display: flex; }
  .toc-body { margin-top: 10px; }
  .toc-body[hidden] { display: none; }
  .toc-title { display: none; }
  .article-body { max-width: none; }
}

@media (max-width: 760px) {
  .card-list { grid-template-columns: minmax(0, 1fr); }
  .related-list, .related-entries .related-list { grid-template-columns: minmax(0, 1fr); }
  .article-nav { grid-template-columns: minmax(0, 1fr); }
  .article-nav .nav-next { text-align: left; }
  .page-desc, .list-description p { font-size: 13.5px; }
  .toolbar { padding: 10px 12px; }
  .chip { padding: 5px 11px; font-size: 12.5px; }
}

/* ------------------------------------------------- 数据对接补充（v1.2） */
/* 列表卡片缩略图：数据库无图时回填主题图，容器需块级 + 固定比例 */
.entry-card .entry-thumb {
  display: block;
  margin: -16px -18px 10px;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--accent-soft);
}
.entry-card .entry-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.entry-card > a { gap: 8px; }
.entry-card h2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.entry-card p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 分类页 chip 直接作为服务端分类链接，需补按钮化基样式 */
a.chip { text-decoration: none; display: inline-block; }
a.chip.is-active { pointer-events: none; }

/* 服务端分页 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(47, 51, 48, .18);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .5);
  font-size: 13px;
  color: var(--ink-2);
}
.pager-btn:hover { border-color: var(--accent-mid); color: var(--accent); }
.pager-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.pager-gap { color: var(--ink-3); font-size: 13px; padding: 0 2px; }

/* 详情页正文引用与内链微调 */
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.card-note a { color: var(--accent); font-weight: 600; text-decoration: underline; }
