/* ========== PC 文章详情页（布局参考 blog.html，无左侧站点导航） ========== */
.page-article {
  background: var(--bg-page);
  --article-sidebar-top: calc(var(--header-height) + 16px);
  --article-toc-height: 0px;
  --article-sidebar-gap: 12px;
  --article-sticky-shadow: 0 2px 6px -1px rgba(15, 23, 42, 0.08);
}

/* 页面布局：顶栏下方主内容 + 右侧栏，与 blog-layout 一致 */
.article-page-layout {
  display: flex;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 16px) 16px 32px;
  align-items: stretch;
}

.article-page-main {
  flex: 1;
  min-width: 0;
  background: var(--bg-white);
  border-radius: 8px;
  overflow: hidden;
}

.article-inner {
  display: flex;
  gap: 0;
  position: relative;
}

/* 面包屑 */
.article-breadcrumb {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-bottom: 16px;
}

.article-breadcrumb a:hover {
  color: var(--primary);
}

.article-breadcrumb-sep {
  margin: 0 6px;
}

/* 文章主区 */
.article-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 32px;
}

.article-header {
  margin-bottom: 20px;
}

.article-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.article-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.article-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: var(--font-xs);
  font-weight: 600;
}

.article-badge--topic {
  background: #e3f2fd;
  color: #1565c0;
}

.article-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.article-meta-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.article-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.article-meta-item svg {
  opacity: 0.65;
}

.article-like-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #ffcdd2;
  border-radius: 16px;
  background: #fff5f5;
  color: #e53935;
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.article-like-pill:hover {
  background: #ffebee;
}

.article-like-pill.is-liked {
  background: #e53935;
  border-color: #e53935;
  color: #fff;
}

/* 作者栏 */
.article-author-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.article-author-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.article-author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.article-author-name {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
}

.article-author-rank {
  display: block;
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-follow {
  flex-shrink: 0;
  height: 34px;
  padding: 0 18px;
  border: 1px solid var(--primary);
  border-radius: 17px;
  background: transparent;
  color: var(--primary);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-follow:hover {
  background: var(--primary-light);
}

.btn-follow.is-followed {
  border-color: var(--border);
  color: var(--text-muted);
  background: var(--bg-page);
}

.btn-follow--block {
  width: 100%;
  margin-top: 12px;
}

/* Tips / AI */
.article-tips {
  padding: 12px 14px;
  margin-bottom: 20px;
  border-radius: 6px;
  background: #fffbe6;
  border: 1px solid #ffe58f;
  font-size: var(--font-sm);
  color: #ad8b00;
  line-height: 1.6;
}

.article-tips code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
  font-size: var(--font-xs);
}

.article-ai-card {
  margin-bottom: 24px;
  padding: 16px 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f3f8ff 0%, #faf5ff 100%);
  border: 1px solid #e8eaf6;
}

.article-ai-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.article-ai-card-icon {
  color: var(--primary);
}

.article-ai-card-question {
  font-size: var(--font-md);
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.article-ai-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.article-ai-model {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.article-ai-ask-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
}

.article-ai-ask-btn:hover {
  text-decoration: underline;
}

/* 正文 */
.article-body {
  font-size: var(--font-base);
  line-height: 1.85;
  color: var(--text-primary);
  margin-bottom: 28px;
}

.article-body p {
  margin-bottom: 16px;
}

.article-body h2 {
  font-size: var(--font-xl);
  font-weight: 700;
  margin: 28px 0 14px;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
}

.article-body h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  margin: 22px 0 12px;
}

.article-body ul,
.article-body ol {
  margin: 0 0 16px 1.4em;
}

.article-body li {
  margin-bottom: 8px;
}

.article-body code {
  padding: 2px 6px;
  border-radius: 4px;
  background: #f5f5f5;
  font-size: 0.9em;
  color: #c7254e;
}

.article-body pre.article-code,
.article-body pre.hljs {
  margin: 16px 0;
  padding: 16px 18px;
  border-radius: 8px;
  background: #f6f8fa;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.article-body pre.article-code code,
.article-body pre.hljs code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: var(--font-sm);
  line-height: 1.6;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: var(--font-sm);
  display: block;
  overflow-x: auto;
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  min-width: 80px;
}

.article-body th {
  background: var(--bg-page);
  font-weight: 600;
}

.article-body a {
  color: var(--primary);
}

.article-body a:hover {
  text-decoration: underline;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.article-md-source {
  margin-top: 32px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff8e6;
  border: 1px dashed #f0c040;
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.article-md-source code {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-size: 0.92em;
}

.article-loading,
.article-error {
  color: var(--text-muted);
  text-align: center;
  padding: 48px 16px;
}

.article-toc-list .article-toc-sub a {
  padding-left: 12px;
  font-size: var(--font-sm);
}

.article-toc-list a.is-active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
}

.article-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
}

.article-body blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--border);
  background: var(--bg-page);
  color: var(--text-secondary);
}

/* 标签 */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-bottom: 28px;
}

.article-tag {
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  transition: all var(--transition);
}

.article-tag:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* 底部互动 */
.article-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.article-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.article-toolbar-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.article-toolbar-btn.is-active {
  border-color: #ffcdd2;
  background: #fff5f5;
  color: #e53935;
}

/* 评论区 */
.article-comments {
  margin-top: 8px;
}

.article-comments-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 20px;
}

.article-comments-count {
  color: var(--text-muted);
  font-weight: 400;
}

.article-comment-compose {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.article-comment-compose-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}

.article-comment-input-wrap {
  flex: 1;
}

.article-comment-input {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: var(--font-md);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}

.article-comment-input:focus {
  border-color: var(--primary);
}

.article-comment-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.article-comment-submit {
  height: 34px;
  padding: 0 20px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
}

.article-comment-submit:hover {
  background: var(--primary-hover);
}

.article-comment-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.article-comment-item {
  display: flex;
  gap: 12px;
}

.article-comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.article-comment-body {
  flex: 1;
  min-width: 0;
}

.article-comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.article-comment-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.article-comment-time {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.article-comment-text {
  font-size: var(--font-md);
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.article-comment-foot {
  display: flex;
  gap: 16px;
}

.article-comment-action {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--font-xs);
  cursor: pointer;
  padding: 0;
}

.article-comment-action:hover {
  color: var(--primary);
}

/* 右侧栏：目录单独吸顶，下方卡片随页面滚动 */
.article-page-sidebar {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
}

.article-page-sidebar .widget {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.article-page-sidebar .widget-title {
  font-size: var(--font-base);
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* 吸顶检测哨兵（不可见占位） */
.article-sticky-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
  visibility: hidden;
}

/* 目录吸顶容器：仅包裹目录，不做 padding 遮罩 */
.article-sidebar-pin {
  position: sticky;
  top: var(--article-sidebar-top);
  z-index: 2;
}

.article-sidebar-pin > .article-toc {
  position: relative;
  background: var(--bg-white);
  max-height: min(42vh, calc(100vh - var(--header-height) - 120px));
  overflow-y: auto;
  transition: box-shadow 0.25s ease;
}

.article-sidebar-pin > .article-toc.is-pinned {
  box-shadow: var(--article-sticky-shadow);
}

.article-sidebar-pin > .article-toc::-webkit-scrollbar {
  width: 4px;
}

.article-sidebar-pin > .article-toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 中间卡片：正常文档流，随页面滚动 */
.article-sidebar-middle {
  position: relative;
  z-index: 1;
}

/* 最后一卡：吸在目录下方，间距用 --article-sidebar-gap */
.article-sidebar-last-pin {
  position: sticky;
  top: calc(var(--article-sidebar-top) + var(--article-toc-height) + var(--article-sidebar-gap));
  z-index: 2;
}

.article-sidebar-last-pin > .article-sidebar-last {
  position: relative;
  background: var(--bg-white);
  transition: box-shadow 0.25s ease;
}

.article-sidebar-last-pin.is-pinned > .article-sidebar-last,
.article-sidebar-last-pin.is-covered > .article-sidebar-last {
  box-shadow: var(--article-sticky-shadow);
}

/* 撑满侧栏列高度，使 sticky 覆盖整篇正文（含评论区） */
.article-sidebar-spacer {
  flex: 1 1 auto;
  min-height: 0;
}

.article-toc {
  padding: 0;
}

.article-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-toc-list a {
  display: block;
  padding: 6px 0 6px 12px;
  border-left: 2px solid transparent;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.4;
  transition: all var(--transition);
}

.article-toc-list a:hover,
.article-toc-list a.is-active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-light);
}

.widget-author-card {
  text-align: center;
  padding: 8px 0;
}

.widget-author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 10px;
  object-fit: cover;
}

.widget-author-name {
  font-size: var(--font-base);
  font-weight: 600;
  margin-bottom: 4px;
}

.widget-author-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.widget-author-name a {
  color: inherit;
}

.widget-author-name a:hover {
  color: var(--primary);
}

/* 响应式 */
@media (max-width: 1024px) {
  .article-page-sidebar {
    display: none;
  }

  .article-main {
    padding: 20px 18px 24px;
  }

  .article-title {
    font-size: 22px;
  }
}

@media (max-width: 768px) {
  .article-page-layout {
    padding-left: 0;
    padding-right: 0;
  }

  .article-page-main {
    border-radius: 0;
  }

  .article-main {
    padding: 16px;
  }

  .article-toolbar {
    flex-wrap: wrap;
    gap: 12px;
  }
}
