/* components.css — 内页组件（分类页 / 详情页），颜色与尺度一律走 tokens.css */
@import url("tokens.css");

/* ---------------------------------------------------------------- 面包屑 */
.crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-5);
  color: var(--muted);
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--blue); }
.crumb span[aria-current] { color: var(--ink-2); font-weight: 600; }
.crumb li { list-style: none; }
.crumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; }
.crumb li + li::before { content: "/"; margin-right: 8px; color: #b6c1d2; }

/* -------------------------------------------------------------- 列表页头 */
.page-hero { padding: 26px 0 0; }
.page-title {
  margin-top: 12px;
  font-size: var(--fs-21);
  line-height: 1.2;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-intro {
  margin-top: 8px;
  max-width: 720px;
  font-size: var(--fs-8);
  line-height: 1.75;
  color: var(--muted);
}
.page-lead {
  margin-top: 8px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink-2);
  max-width: 720px;
  font-size: var(--fs-12);
  line-height: 1.7;
  color: var(--ink-soft);
}
.page-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-7);
  font-weight: 600;
  color: var(--ink-2);
}
.page-stats li { display: flex; align-items: center; gap: 7px; }
.page-stats li::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

/* ---------------------------------------------------------------- 工具条 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  margin-top: 18px;
  padding: 12px 18px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: var(--fs-7);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.chip:hover { border-color: #b9cbea; color: var(--blue); }
.chip[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--ink-invert);
}
.sort-wrap label { cursor: pointer; }
.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: var(--fs-7);
  color: var(--muted);
}
.sort-wrap select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
}
.count { font-size: var(--fs-7); color: var(--muted); }

/* -------------------------------------------------------------- 列表网格 */
.list-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 20px;
}
.list-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.list-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(18, 35, 63, 0.1); }
.list-card a { display: block; height: 100%; }
.card-media { position: relative; aspect-ratio: 3 / 1.75; overflow: hidden; background: var(--bg-elevated); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-tag {
  position: absolute;
  top: 10px; left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(9, 26, 38, 0.72);
  color: var(--ink-invert);
  font-size: var(--fs-1);
  font-weight: 600;
}
.card-body { padding: 13px 16px 16px; }
.card-body h2 { font-size: var(--fs-16); line-height: 1.35; color: var(--ink-2); }
.card-body p { margin-top: 5px; font-size: var(--fs-7); line-height: 1.65; color: var(--ink-soft); }
.card-more {
  margin-top: 10px;
  font-size: var(--fs-5);
  font-weight: 700;
  color: var(--blue);
}
.list-card:hover .card-more { text-decoration: underline; }

/* ------------------------------------------------------------ 分类说明区 */
.list-desc {
  margin-top: 22px;
  padding: 22px 26px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
}
.desc-label h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--fs-17);
  color: var(--ink-2);
}
.desc-label h2::before {
  content: "";
  width: 5px; height: 19px;
  border-radius: 2px;
  background: var(--blue);
}
.desc-label p { margin-top: 6px; font-size: var(--fs-5); color: var(--muted); }
.desc-body p { font-size: var(--fs-8); line-height: 1.95; color: var(--ink-soft); }
.desc-body p + p { margin-top: 8px; }

/* ---------------------------------------------------------------- 相关推荐 */
.related-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 22px;
}
.rel-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
}
.rel-card::after { content: "→"; color: var(--blue); font-size: var(--fs-14); }
.rel-card h2 { font-size: var(--fs-11); color: var(--ink-2); }
.rel-card p { margin-top: 3px; font-size: var(--fs-5); color: var(--muted); }
.rel-card span { color: var(--blue); font-size: var(--fs-14); }
.rel-card:hover h2 { color: var(--blue); }

/* -------------------------------------------------------------- 详情页头 */
.article-hero { padding: 26px 0 0; }
.article-title {
  margin-top: 14px;
  font-size: 46px;
  line-height: 1.15;
  color: var(--ink-2);
}
.article-sub {
  margin-top: 8px;
  font-size: var(--fs-16);
  line-height: 1.5;
  font-weight: 600;
  color: var(--blue);
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
  font-size: var(--fs-6);
  color: var(--muted);
}
.article-meta span { display: inline-flex; align-items: center; gap: 6px; }
.article-intro {
  margin-top: 14px;
  max-width: 780px;
  font-size: var(--fs-12);
  line-height: 1.85;
  color: var(--ink-soft);
}

/* -------------------------------------------------------------- 正文布局 */
.article-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 800px);
  gap: 40px;
  align-items: start;
  justify-content: center;
  margin-top: 26px;
}
.toc {
  position: sticky;
  top: 22px;
  padding: 16px 18px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
}
.toc h2 { font-size: var(--fs-6); letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.toc ol { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc li + li { margin-top: 2px; }
.toc a {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  font-size: var(--fs-7);
  line-height: 1.5;
  color: var(--ink-soft);
}
.toc a::before { content: counter(toc, decimal-leading-zero); color: #b6c1d2; font-weight: 700; font-size: var(--fs-4); }
.toc a:hover, .toc a.is-active { color: var(--blue); }

.article-body {
  padding: 26px 32px 30px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
}
.article-body > p:first-child {
  font-size: var(--fs-12);
  line-height: 1.9;
  color: var(--ink-2);
}
.article-body section { margin-top: 26px; }
.article-body h2 {
  padding-left: 12px;
  border-left: 4px solid var(--blue);
  font-size: var(--fs-19);
  line-height: 1.35;
  color: var(--ink-2);
}
.article-body section p {
  margin-top: 10px;
  font-size: var(--fs-12);
  line-height: 1.95;
  color: var(--ink-soft);
  text-align: justify;
}
.article-body strong { color: var(--ink-2); font-weight: 700; }
.article-body section { scroll-margin-top: 20px; }

/* -------------------------------------------------------------- 相关条目 */
.related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 16px;
}
.mini-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.06);
  overflow: hidden;
}
.mini-card img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; }
.mini-card h3 { padding: 9px 12px 0; font-size: var(--fs-8); color: var(--ink-2); }
.mini-card p { padding: 2px 12px 12px; font-size: var(--fs-5); line-height: 1.5; color: var(--muted); }
.mini-card:hover h3 { color: var(--blue); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
}
.section-head h2 { font-size: var(--fs-17); color: var(--ink-2); }
.section-head p { font-size: var(--fs-7); color: var(--muted); }

.empty-state {
  display: none;
  padding: 34px 0;
  text-align: center;
  font-size: var(--fs-8);
  color: var(--muted);
}
.empty-state.is-on { display: block; }

/* -------------------------------------------------------------- 响应式 */
@media (max-width: 1100px) {
  .list-grid { grid-template-columns: repeat(2, 1fr); }
  .article-layout { grid-template-columns: 1fr; gap: 18px; }
  .toc { position: static; }
  .toc ol { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .page-title { font-size: 30px; }
  .page-hero, .article-hero { padding-top: 18px; }
  .toolbar { gap: 10px; padding: 10px 12px; }
  .sort-wrap { margin-left: 0; width: 100%; }
  .list-grid { grid-template-columns: 1fr; gap: 14px; }
  .list-desc { grid-template-columns: 1fr; gap: 10px; padding: 18px; }
  .related-row { grid-template-columns: 1fr; }
  .article-title { font-size: 32px; }
  .article-sub { font-size: 17px; }
  .article-body { padding: 20px 18px 24px; }
  .article-body section p { font-size: 15px; line-height: 1.85; }
  .article-body h2 { font-size: 20px; }
  .related-grid { grid-template-columns: 1fr 1fr; }
  .section-head { flex-direction: column; gap: 4px; }
}

/* ---------------------------------------------------- 数据化补充（v1.1） */
/* 13 个分类的导航在桌面端横向滚动，避免换行撑高头部 */
@media (min-width: 981px) {
  .header-inner { gap: 16px; }
  .nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; }
}
@media (max-width: 980px) {
  .nav.open { max-height: calc(100vh - 69px); overflow-y: auto; }
}
@media (max-width: 640px) {
  .nav.open { max-height: calc(100vh - 62px); }
}

/* 列表卡片等高：标题与摘要最多两行 */
.card-body h2,
.list-card .card-body h2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-body p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.var-card h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.mini-card h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.pick h3 { word-break: break-word; }

/* 服务端分页 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 26px 0 6px;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 14px;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.pager-btn:hover,
.pager-btn.is-active { border-color: var(--blue); color: var(--blue); }
.pager-gap { padding: 0 6px; color: var(--muted); }

/* 正文配图 */
.article-body .article-figure { margin: 18px 0 4px; }
.article-body .article-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  object-fit: cover;
}

/* 无障碍跳转链接：默认移出可视区，聚焦时显示 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 12px;
  top: 12px;
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
