/* =================================================================
 *  45 Chat — 文章模块样式
 *  ----------------------------------------------------------------
 *  作用域:首页 article-section / 列表页 / 详情页
 *
 *  设计原则:
 *  - 复用 6868chat-clone.css 的 CSS 变量(--c-primary / --c-fg 等)
 *  - 单页可滚动(覆盖首页 body{overflow:hidden})
 *  - 响应式:手机 1 列 / 平板 2 列 / 桌面 3~4 列
 *  - 与 45 Chat 视觉风格保持一致(白底 + 蓝主色 + 32px 圆角)
 * =================================================================
 */

/* ============================================================
 * 1. 全局 reset 覆盖 — 文章相关页面允许滚动 + 取消 height:100% 限制
 *    首页 main 内部的 article-section 也需要滚动,所以覆盖
 *    原因:6868chat-clone.css 把 html/body 锁成 height:100% 单屏布局,
 *         但子页(列表/详情/首页 Section)需要自然撑高文档高度
 * ============================================================ */
body.page-article-list,
body.page-article-detail,
body.page-home-article {
  overflow: auto;            /* 覆盖 6868chat-clone.css 的 overflow:hidden */
  height: auto;              /* 覆盖 6868chat-clone.css 的 html,body{height:100%},让 body 随内容撑高 */
  min-height: 100vh;
  background: var(--c-bg);
}

/* ============================================================
 * 2. 顶部导航(子页用) — 深色
 * ============================================================ */
.topbar--sub{
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h, 62px);
  padding: 0 var(--container-x, 32px);
  background: linear-gradient(180deg, #178AFF 0%, #0f6fd1 100%);
  box-shadow: 0 2px 12px rgba(23, 138, 255, .18);
  color: #fff;
}
.topbar--sub .topbar-brand{ color: #fff; }
.topbar--sub .topbar-name{ color: #fff; }
.topbar-back{
  color: rgba(255,255,255,.92);
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  transition: background .2s var(--ease);
}
.topbar-back:hover{ background: rgba(255,255,255,.16); color: #fff; }

/* ============================================================
 * 3. 主体容器
 * ============================================================ */
.article-page{
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px var(--container-x, 32px) 80px;
}

/* ============================================================
 * 4. 页面标题区(列表页)
 * ============================================================ */
.article-hero{
  text-align: left;
  padding: 24px 0 32px;
  border-bottom: 1px solid var(--c-line);
  margin-bottom: 32px;
}
.article-hero-title{
  font-size: 30px;
  font-weight: 700;
  color: var(--c-fg-strong);
  margin: 0 0 8px;
  letter-spacing: .5px;
}
.article-hero-desc{
  font-size: 14px;
  color: var(--c-fg-soft);
  margin: 0;
}
.article-hero-desc strong{
  color: var(--c-primary);
  font-weight: 600;
  font-size: 16px;
}

/* ============================================================
 * 5. 列表卡片
 * ============================================================ */
.article-list{
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
}
.article-card{
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 16px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  overflow: hidden;
}
.article-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(23, 138, 255, .12);
  border-color: rgba(23, 138, 255, .35);
}
.article-card-link{
  display: block;
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
}
.article-card-title{
  font-size: 17px;
  font-weight: 600;
  color: var(--c-fg-strong);
  margin: 0 0 8px;
  line-height: 1.5;
  /* 单行省略,避免标题过长撑高卡片 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-card:hover .article-card-title{ color: var(--c-primary); }

.article-card-meta{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--c-fg-soft);
}
.article-card-time{
  font-variant-numeric: tabular-nums;
}

/* ============================================================
 * 6. 标签 chip(详情页 / 列表页用)
 * ============================================================ */
.article-tag{
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: .3px;
}
.article-tag--md{
  background: rgba(23, 138, 255, .1);
  color: var(--c-primary);
}
.article-tag--html{
  background: rgba(255, 140, 23, .12);
  color: #d97a0a;
}

/* ============================================================
 * 7. 分页导航
 * ============================================================ */
.pager{
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 36px;
  padding: 18px 0;
  border-top: 1px solid var(--c-line);
}
.pager-edge, .pager-nav, .pager-page{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--c-line);
  color: var(--c-fg);
  font-size: 13px;
  text-decoration: none;
  transition: all .2s var(--ease);
  user-select: none;
}
.pager-edge:hover, .pager-nav:hover, .pager-page:hover{
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: rgba(23, 138, 255, .04);
}
.pager-page.is-current{
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  font-weight: 600;
  cursor: default;
}
.pager-page.is-current:hover{
  background: var(--c-primary);
  color: #fff;
}
.pager-edge.is-disabled, .pager-nav.is-disabled{
  color: #cfcfcf;
  background: #fafafa;
  cursor: not-allowed;
  border-color: var(--c-line);
}
.pager-edge.is-disabled:hover, .pager-nav.is-disabled:hover{
  border-color: var(--c-line);
  color: #cfcfcf;
  background: #fafafa;
}
.pager-pages{
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pager-ellipsis{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: var(--c-fg-soft);
  font-size: 13px;
  user-select: none;
}

/* ============================================================
 * 8. 状态块(error / empty)
 * ============================================================ */
.article-state{
  text-align: center;
  padding: 80px 24px;
  border-radius: 16px;
  background: #fafbfd;
  border: 1px dashed var(--c-line);
  margin: 40px 0;
}
.article-state--error{
  background: #fff5f5;
  border-color: rgba(220, 38, 38, .25);
}
.article-state-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  font-size: 24px;
  font-weight: 700;
  color: var(--c-fg-soft);
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.article-state--error .article-state-icon{
  color: #dc2626;
  background: #fff;
}
.article-state-title{
  font-size: 18px;
  font-weight: 600;
  color: var(--c-fg-strong);
  margin: 0 0 8px;
}
.article-state-desc{
  font-size: 14px;
  color: var(--c-fg-soft);
  margin: 0 0 20px;
}

/* ============================================================
 * 9. 详情页 — 文章主体
 * ============================================================ */
.article-detail{
  background: #fff;
  border-radius: 20px;
  padding: 40px 48px;
  box-shadow: 0 2px 16px rgba(0,0,0,.04);
  border: 1px solid var(--c-line);
}
.article-detail-head{
  border-bottom: 1px solid var(--c-line);
  padding-bottom: 20px;
  margin-bottom: 28px;
}
.article-detail-title{
  font-size: 28px;
  font-weight: 700;
  color: var(--c-fg-strong);
  line-height: 1.4;
  margin: 0 0 12px;
  word-break: break-word;
}
.article-detail-meta{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--c-fg-soft);
}
.article-detail-time{ font-variant-numeric: tabular-nums; }

/* === 正文 === */
.article-content{
  font-size: 15px;
  line-height: 1.85;
  color: #2a2a2a;
  word-break: break-word;
}
/* markdown 渲染后的标准元素 */
.article-content h1, .article-content h2, .article-content h3,
.article-content h4, .article-content h5, .article-content h6{
  margin: 1.6em 0 .8em;
  font-weight: 700;
  color: var(--c-fg-strong);
  line-height: 1.4;
}
.article-content h1{ font-size: 1.8em; border-bottom: 1px solid var(--c-line); padding-bottom: .3em; }
.article-content h2{ font-size: 1.5em; border-bottom: 1px solid var(--c-line); padding-bottom: .3em; }
.article-content h3{ font-size: 1.25em; }
.article-content h4{ font-size: 1.1em; }
.article-content p{ margin: 0 0 1em; }
.article-content a{
  color: var(--c-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.article-content a:hover{ border-bottom-color: var(--c-primary); }
.article-content ul, .article-content ol{
  margin: 0 0 1em;
  padding-left: 1.6em;
}
.article-content ul{ list-style: disc; }
.article-content ol{ list-style: decimal; }
.article-content li{ margin: .3em 0; }
.article-content code{
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: .9em;
  color: #d6336c;
}
.article-content pre{
  background: #1f2937;
  color: #e5e7eb;
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 13px;
  line-height: 1.6;
}
.article-content pre code{
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
.article-content blockquote{
  margin: 1em 0;
  padding: 8px 16px;
  border-left: 4px solid var(--c-primary);
  background: rgba(23, 138, 255, .04);
  color: #4b5563;
  border-radius: 0 6px 6px 0;
}
.article-content blockquote p{ margin: .3em 0; }
.article-content table{
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 14px;
}
.article-content th, .article-content td{
  border: 1px solid var(--c-line);
  padding: 8px 12px;
  text-align: left;
}
.article-content th{ background: #fafbfd; font-weight: 600; }
.article-content img{
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: .5em 0;
}
.article-content hr{
  border: 0;
  border-top: 1px solid var(--c-line);
  margin: 2em 0;
}

/* 无 JS 时的 fallback */
.article-content-raw{
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  background: #fafbfd;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--c-line);
}

/* === 上一篇 / 下一篇 === */
.article-sibling{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 40px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--c-line);
}
.article-sibling-cell{ min-width: 0; }
.article-sibling-next{ text-align: right; }
.article-sibling-link{
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  text-decoration: none;
  transition: all .2s var(--ease);
  min-width: 0;
}
.article-sibling-link:hover{
  border-color: var(--c-primary);
  background: rgba(23, 138, 255, .04);
}
.article-sibling-tag{
  display: block;
  font-size: 12px;
  color: var(--c-fg-soft);
  margin-bottom: 4px;
}
.article-sibling-title{
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-fg-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-sibling-link:hover .article-sibling-title{ color: var(--c-primary); }

/* === 推荐文章 === */
.article-recommend{
  margin: 40px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--c-line);
}
.article-recommend-title{
  font-size: 18px;
  font-weight: 700;
  color: var(--c-fg-strong);
  margin: 0 0 18px;
  position: relative;
  padding-left: 12px;
}
.article-recommend-title::before{
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 2px;
  background: var(--c-primary);
}
.article-recommend-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.article-recommend-link{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  text-decoration: none;
  transition: all .2s var(--ease);
  min-width: 0;
}
.article-recommend-link:hover{
  border-color: var(--c-primary);
  background: rgba(23, 138, 255, .04);
}
.article-recommend-item-title{
  font-size: 14px;
  font-weight: 600;
  color: var(--c-fg-strong);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-recommend-link:hover .article-recommend-item-title{ color: var(--c-primary); }
.article-recommend-item-time{
  font-size: 12px;
  color: var(--c-fg-soft);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
 * 10. 首页 — 最新文章 Section
 *    (放在 hero 下方,footer 上方)
 * ============================================================ */
.home-articles{
  position: relative;
  z-index: 1;                  /* 浮在 .bg-full 之上 */
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px var(--container-x, 32px) 64px;
}
.home-articles-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.home-articles-title{
  font-size: 24px;
  font-weight: 700;
  color: var(--c-fg-strong);
  margin: 0;
  position: relative;
  padding-left: 14px;
}
.home-articles-title::before{
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 2px;
  background: var(--c-primary);
}
.home-articles-more{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--c-primary);
  font-size: 14px;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  transition: background .2s var(--ease);
}
.home-articles-more:hover{ background: rgba(23, 138, 255, .08); }

.home-articles-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.home-article-card{
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  transition: all .25s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 96px;
}
.home-article-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(23, 138, 255, .14);
  border-color: rgba(23, 138, 255, .35);
}
.home-article-card-title{
  font-size: 15px;
  font-weight: 600;
  color: var(--c-fg-strong);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-article-card:hover .home-article-card-title{ color: var(--c-primary); }
.home-article-card-time{
  font-size: 12px;
  color: var(--c-fg-soft);
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}

.home-articles-empty{
  text-align: center;
  padding: 60px 20px;
  background: rgba(255,255,255,.6);
  border: 1px dashed var(--c-line);
  border-radius: 14px;
  color: var(--c-fg-soft);
  font-size: 14px;
}

/* ============================================================
 * 11. 页脚(子页用) — 浅色,与首页深色 footer 区分
 *    重要:.footer 在 6868chat-clone.css 是 position:absolute 钉视口底,
 *         子页必须改成 static 才能跟着 main 自然贴底
 * ============================================================ */
body.page-article-list .footer,
body.page-article-detail .footer,
body.page-home-article .footer{
  position: static;          /* 覆盖 6868chat-clone.css 的 position:absolute */
  margin-top: 0;
}
.footer--sub{
  background: #fafbfd;
  border-top: 1px solid var(--c-line);
  padding: 20px var(--container-x, 32px);
  text-align: center;
}
.footer--sub .footer-copy{
  color: var(--c-fg-soft);
  font-size: 12px;
}

/* ============================================================
 * 12. 响应式
 *    - 桌面 ≥ 1024px:推荐 4 列,首页 Section 4 列,详情页宽屏
 *    - 平板 768~1023:推荐 2 列,首页 Section 2 列
 *    - 手机 < 768px  :推荐 1 列,首页 Section 1 列,上下篇堆叠
 * ============================================================ */
@media (max-width: 1023px) {
  .article-detail{ padding: 28px 24px; }
  .article-detail-title{ font-size: 24px; }
  .home-articles-grid{ grid-template-columns: repeat(2, 1fr); }
  .article-recommend-grid{ grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .article-page{ padding: 20px 16px 60px; }
  .article-hero-title{ font-size: 24px; }
  .article-detail{ padding: 20px 16px; border-radius: 14px; }
  .article-detail-title{ font-size: 20px; }
  .article-sibling{ grid-template-columns: 1fr; }
  .article-sibling-next{ text-align: left; }
  .home-articles{ padding: 32px 16px 48px; }
  .home-articles-grid{ grid-template-columns: 1fr; }
  .article-recommend-grid{ grid-template-columns: 1fr; }
  .pager-edge, .pager-nav{ display: none; }   /* 手机只保留页码 */
  .topbar--sub{ padding: 0 16px; }
}
