/* ===========================================================================
   边境梗犬科普知识网 · 共享组件（三页共用）
   只放「会被复用两次以上」的东西：按钮、标签、条目卡、工具栏、正文与目录。
   布局类的一次性样式留在 style.css。
   =========================================================================== */

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { transform: translateY(-1px); }

.btn-olive { background: var(--olive); color: var(--on-accent); }
.btn-olive:hover { background: var(--olive-deep); }

.btn-outline { border-color: rgba(247, 243, 233, 0.6); color: var(--on-accent); }
.btn-outline:hover { border-color: var(--on-accent); background: rgba(247, 243, 233, 0.1); }

.btn-cream { background: var(--on-accent); color: var(--accent); }
.btn-cream:hover { background: #fffdf6; }

.btn-cream-ghost { border-color: rgba(247, 243, 233, 0.55); color: var(--on-accent); }
.btn-cream-ghost:hover { border-color: var(--on-accent); background: rgba(247, 243, 233, 0.12); }

.btn-solid { background: var(--accent); color: var(--on-accent); }
.btn-solid:hover { background: var(--accent-deep); }

.btn-ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------- 通用文字 */
.eyebrow {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------------------------------------------------------- 内页页头 */
.page-hero {
  background: var(--band);
  border-bottom: 1px solid var(--line);
  padding: 34px 0 32px;
}
.page-hero h1 {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: var(--fs-h1-page);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
}
.page-hero .lede {
  margin-top: 12px;
  max-width: 720px;
  font-size: var(--fs-lead);
  line-height: 1.75;
  color: var(--ink-2);
}
.page-hero .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------- 面包屑 */
.breadcrumb {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.breadcrumb a { color: var(--ink-2); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--line-strong); }
.breadcrumb .sep::after { content: "/"; }

/* 内页页头副标与列表页容器 */
.page-sub {
  margin-top: 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-2);
}
.list-wrap { padding: 26px 0 40px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.card-meta { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.01em; }

/* ---------------------------------------------------------- 筛选工具栏 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  padding: 12px 16px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.toolbar-label { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--accent-mid); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toolbar-sort { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sort-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.sort-btn[aria-pressed="true"] { background: var(--card); border-color: var(--line-strong); color: var(--ink); font-weight: 600; }
.toolbar-count { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ------------------------------------------------------- 条目卡网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 22px;
}
.entry-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.entry-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--accent-soft); }
.entry-card .tag { align-self: flex-start; }
.entry-card h3 {
  margin-top: 10px;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.45;
}
.entry-card h3 a:hover { color: var(--accent); }
.entry-card p { margin-top: 8px; font-size: 12.5px; line-height: 1.72; color: var(--ink-2); }
.entry-card .card-foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-arrow { color: var(--accent); }
.card-arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty-state {
  margin-top: 22px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}
.empty-state[hidden] { display: none; }

/* ------------------------------------------------------- 分类说明块 */
.list-description {
  margin-top: 30px;
  padding: 24px 26px;
  background: var(--card-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.list-description h2 { font-size: 19px; font-weight: 700; }
.list-description p { margin-top: 10px; max-width: 920px; font-size: 14px; line-height: 1.85; color: var(--ink-2); }

/* -------------------------------------------------- 相关分类 / 相关条目 */
.related {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.related h2 { font-size: 18px; font-weight: 700; }
.related-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 14px; }
.related-grid a {
  display: block;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.related-grid a:hover { border-color: var(--accent-mid); box-shadow: var(--shadow-card); }
.related-name { display: block; font-size: 14.5px; font-weight: 700; }
.related-desc { display: block; margin-top: 6px; font-size: 12px; line-height: 1.65; color: var(--ink-2); }

/* ------------------------------------------------------------- 详情页 */
.article-head { padding: 28px 0 24px; background: var(--band); border-bottom: 1px solid var(--line); }
.article-head .breadcrumb { margin-bottom: 18px; }
.article-head .tag { display: inline-block; }
.article-head h1 {
  margin-top: 10px;
  max-width: 900px;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: 0.01em;
}
.article-head .summary { margin-top: 14px; max-width: 760px; font-size: var(--fs-lead); line-height: 1.8; color: var(--ink-2); }
.article-head .source { margin-top: 16px; font-size: 12px; color: var(--ink-3); }

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) 280px;
  gap: 40px;
  justify-content: space-between;
  align-items: start;
  padding: 34px 0 10px;
}
.article-layout > aside.toc { grid-column: 2; grid-row: 1; }
.article-layout > article.article-body { grid-column: 1; grid-row: 1; }
.article-body { max-width: var(--measure); }
.article-body h2 {
  margin: 34px 0 12px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.42;
  scroll-margin-top: 90px;
}
.article-body h2:first-child { margin-top: 0; }
.article-body p { font-size: 15px; line-height: 1.95; color: var(--ink-2); }
.article-body p + p { margin-top: 12px; }
.article-body strong { color: var(--ink); font-weight: 700; }
.article-lead img { width: 100%; height: auto; border-radius: var(--radius-md); margin-bottom: 26px; }

.toc {
  position: sticky;
  top: 92px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.toc h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-3); }
.toc-toggle {
  display: none;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.toc ol { margin-top: 10px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: block;
  padding: 6px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.toc li:last-child a { border-bottom: 0; }
.toc a:hover { color: var(--accent); }
.toc a[aria-current="true"] { color: var(--accent); font-weight: 700; }
.toc-toggle { display: none; }

.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 34px; }
.article-nav a {
  display: block;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color var(--dur) var(--ease);
}
.article-nav a:hover { border-color: var(--accent-mid); }
.article-nav .dir { font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; }
.article-nav .title { display: block; margin-top: 6px; font-size: 14px; font-weight: 700; line-height: 1.5; }
.article-nav .next { text-align: right; }

@media (max-width: 1180px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .article-layout { grid-template-columns: 1fr; gap: 22px; padding-top: 24px; }
  .article-layout > aside.toc, .article-layout > article.article-body { grid-column: 1; }
  .article-layout > aside.toc { grid-row: 1; }
  .article-layout > article.article-body { grid-row: 2; }
  .article-body { max-width: none; }
  .toc { position: static; }
  .toc-toggle { display: block; }
  .toc ol { display: none; }
  .toc.is-open ol { display: block; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .page-hero { padding: 26px 0 24px; }
  .page-hero h1 { font-size: 32px; }
  .article-head h1 { font-size: 27px; }
  .toolbar-sort { margin-left: 0; }
  .card-grid { grid-template-columns: 1fr; }
  .article-body h2 { font-size: 20px; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { text-align: left; }
}

@media (max-width: 560px) {
  .related-grid { grid-template-columns: 1fr; }
  .list-description { padding: 20px; }
}

/* ============================================ 数据化补丁 v1.1 */
/* 列表卡片缩略图（demo 无此模块，数据库条目统一带图） */
.entry-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-sm);
  margin: -6px -8px 4px;
  background: var(--accent-soft);
}
.entry-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 卡片等高：标题与摘要截断 */
.entry-card h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  min-height: 3.05em;
}
.entry-card p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  min-height: 5.16em;
}

/* chips 改为服务端跳转链接后需要的样式 */
a.chip { display: inline-block; text-decoration: none; }
a.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* 分页 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.pager-btn {
  display: inline-block;
  min-width: 34px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  text-align: center;
  color: var(--ink-2);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.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: 700; }
.pager-gap { padding: 0 4px; color: var(--ink-3); font-size: 12.5px; }
.pager-info { margin-left: auto; font-size: 12px; color: var(--ink-3); }

/* 正文插图（demo 用 .article-lead 单张，数据化后按节穿插） */
.article-figure { margin: 18px 0 22px; }
.article-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
}

/* 相关条目卡：标题截断 */
.related-card h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

/* 首页侧栏列表项链接（数据化后是条目标题） */
.care-rows li a, .health-rows li a { color: inherit; }
.care-rows li a:hover, .health-rows li a:hover { color: var(--accent); }
.health-rows .card-meta { display: block; margin-top: 2px; }

/* 无目录时正文占满整行 */
.article-layout:not(:has(.toc)) { grid-template-columns: minmax(0, 1fr); max-width: 900px; }

@media (max-width: 900px) {
  .toolbar { gap: 10px 12px; }
  .chips { min-width: 0; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .chips::-webkit-scrollbar { height: 4px; }
  .chips::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
  .chip { white-space: nowrap; }
  .pager-info { margin-left: 0; width: 100%; }
}
