/* =========================================================
   article-detail.css
   - 详情页主体
   - 正文防溢出
   - 评论区
   - 点赞 / 分享 / 稍后阅读三按钮同排
   ========================================================= */

.article-page {
  background: var(--bg);
  padding: 40px 0;
}

/* 阅读进度条 */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  height: 3px;
  background: rgba(15, 23, 42, 0.08);
}

.reading-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #fb7185, #f97316);
  transition: width 120ms linear;
}

/* 页面容器 */
.article-container {
  --detail-card-radius: 10px;
  --detail-card-border: #e5e7eb;
  --detail-card-bg: #f8fafc;
  --detail-muted-text: #6b7280;

  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  box-sizing: border-box;
}

/* PC 两列布局 */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px;
  align-items: flex-start;
  max-width: 100%;
  box-sizing: border-box;
}

.article-main {
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  overflow-x: hidden;
}

.article-sidebar {
  width: 320px;
  min-width: 0;
  box-sizing: border-box;
}

/* 目录 */
.article-toc {
  position: sticky;
  top: 24px;
}

.article-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-toc__list li {
  margin-top: 10px;
  line-height: 1.5;
}

.article-toc__list a {
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
}

.article-toc__list a:hover,
.article-toc__list a.is-active {
  color: #c81d25;
}

.article-toc__list a.is-active {
  font-weight: 600;
}

/* 面包屑 */
.article-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 16px;
  color: #666;
}

.article-breadcrumb::before {
  content: "";
  width: 3px;
  height: 18px;
  background: #ff6a00;
  display: inline-block;
}

.article-breadcrumb .crumb-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.article-breadcrumb .crumb-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article-breadcrumb .crumb-separator {
  color: #999;
}

/* 标题 */
.article-main > h1 {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 4.6vw, 3rem);
  line-height: 1.2;
  letter-spacing: 0.2px;
  color: #172033;
}

/* 元信息 */
.article-meta {
  margin: 10px 0 20px;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--detail-muted-text);
  font-size: 15px;
  line-height: 1.55;
  border: 1px solid var(--detail-card-border);
  border-radius: var(--detail-card-radius);
  background: var(--detail-card-bg);
}

.article-meta > * {
  display: inline-flex;
  align-items: center;
}

.article-meta__label {
  color: #8891a2;
  font-weight: 500;
}

.article-meta__value {
  color: #595959;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.article-meta__divider {
  color: #c8c8c8;
  margin: 0 2px;
}

/* 封面图 */
.article-cover--spaced {
  margin: 16px 0;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #f3f4f6;
}

.article-cover__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 正文 */
.content-text {
  max-width: 100%;
  box-sizing: border-box;
  font-size: 18px;
  line-height: 1.85;
  color: #374151;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  overflow-x: hidden;
}

.content-text * {
  box-sizing: border-box;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-text p,
.content-text li {
  color: inherit;
  opacity: 1;
}

.content-text a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-text img,
.content-text video,
.content-text embed,
.content-text object {
  max-width: 100%;
  height: auto;
  display: block;
}

.content-text iframe {
  max-width: 100%;
  display: block;
  border: 0;
}

.content-text table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

.content-text th,
.content-text td {
  border: 1px solid #999;
  padding: 6px 8px;
}

.content-text th {
  background: #f5f5f5;
  font-weight: 700;
}

.content-text blockquote {
  margin: 1em 0;
  padding: 0.6em 0.9em;
  border-left: 3px solid #f97316;
  background: color-mix(in srgb, var(--detail-card-bg) 74%, #fff7ed);
  color: #374151;
  border-radius: var(--detail-card-radius);
}

.content-text pre,
.content-text code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.content-text pre {
  margin: 1em 0;
  padding: 10px 12px;
  border-radius: var(--detail-card-radius);
  background: #111827;
  color: #f9fafb;
  line-height: 1.6;
}

.content-text code {
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.06);
}

.content-text pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

/* 正文折叠 */
.content-text--collapsed {
  max-height: 980px;
  overflow: hidden;
}

.content-text-fade {
  height: 58px;
  margin-top: -58px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 70%);
  pointer-events: none;
  position: relative;
}

.content-expand-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 14px;
}

.content-expand-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* 图集 */
.content-text figure {
  margin: 16px 0;
  padding: 0;
}

.content-text figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}

.content-text figure figcaption {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.65;
  opacity: .9;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 视频 */
.content-text .video-embed,
.content-text .video-embed-native {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 20px 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  clear: both;
}

.content-text p:has(> .video-embed),
.content-text p:has(> .video-embed-native) {
  margin: 20px 0;
  padding: 0;
}

.content-text p > .video-embed,
.content-text p > .video-embed-native {
  margin: 0;
}

.content-text .video-embed::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: 56.25%;
}

.content-text .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
  display: block;
  border: 0;
  background: #000;
}

.content-text .video-embed-native::before {
  display: none;
}

.content-text .video-embed-native video {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  background: #000;
  object-fit: contain;
}

.content-text .video-link-fallback {
  margin: 16px 0;
  line-height: 1.8;
  word-break: break-all;
}

.content-text .video-link-fallback a {
  text-decoration: underline;
}

/* 标签 */
.article-tag-box {
  margin-top: 20px;
  font-size: 0.95rem;
  color: var(--muted);
}

.article-tag-box .tag-link {
  color: var(--accent);
  text-decoration: underline;
  margin-right: 8px;
  font-weight: 600;
}

.article-tag-box .tag-link:hover {
  color: var(--primary);
  text-decoration-thickness: 2px;
}

.article-tag-empty {
  color: #ccc;
}

/* 上一篇 / 下一篇 */
.article-container .article-nav {
  display: flex;
  justify-content: space-between;
  margin: 40px 0;
  padding: 20px 0;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

.article-container .article-nav .nav-item {
  flex: 1;
  min-width: 0;
}

.article-container .article-nav .nav-item.next {
  text-align: right;
}

.article-container .article-nav .nav-item small,
.article-nav__label {
  color: #999;
  display: block;
  margin-bottom: 5px;
}

.article-container .article-nav .nav-item a {
  color: #2c3e50;
  font-weight: 700;
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-container .article-nav .nav-item a:hover {
  color: var(--accent);
}

/* 点赞 / 分享 / 稍后阅读 */
.action-bar,
.article-container .action-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 40px 0;
}

.action-bar button,
.action-bar a,
.article-container .action-bar button,
.article-container .action-bar a {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  cursor: pointer;
}

.action-bar .like-btn {
  background: var(--accent);
  color: #fff;
  border: none;
}

.action-bar .like-btn:disabled {
  background: #dfe4ea;
  color: #a4b0be;
  cursor: default;
}

.action-bar .share-btn {
  background: #2f3542;
  color: #fff;
  border: none;
}

.action-bar .like-btn:active,
.action-bar .share-btn:active {
  transform: scale(0.95);
}

/* 侧边栏 */
.sidebar-block {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  background: #fafafa;
}

.sidebar-block h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #333;
}

/* 详情页右栏列表：在公共 .sidebar-list 基础上做详情页差异覆盖 */
.article-sidebar .sidebar-list li {
  gap: 6px;
  padding: 10px 0;
}

.article-sidebar .sidebar-list a {
  line-height: 1.6;
}

.article-sidebar .sidebar-list .meta {
  font-size: 12px;
  color: #999;
}

.article-sidebar .sidebar-list .empty {
  color: #999;
  padding: 8px 0;
}

/* 作者卡片 */
.sidebar-author-card {
  background: #fff;
  border-radius: 12px;
}

.sidebar-author-card__head {
  text-align: center;
}

.sidebar-author-card__avatar-wrap {
  width: 112px;
  height: 112px;
  margin: 4px auto 14px;
  border-radius: 50%;
  border: 1px solid #ececec;
  display: block;
  overflow: visible;
  position: relative;
  background: #fff;
  text-decoration: none;
}

.sidebar-author-card__head img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.sidebar-author-card__badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #f7ad2b;
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  text-align: center;
}

.sidebar-author-card__head h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.22;
}

.sidebar-author-card__head h3 a {
  color: #333;
  text-decoration: none;
}

.sidebar-author-card__head p {
  margin: 8px 0 0;
  color: #666;
  font-size: 14px;
}

.sidebar-author-card__stats {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
}

.sidebar-author-card__stats::before {
  content: "";
  grid-column: 2;
  grid-row: 1;
  width: 1px;
  height: 44px;
  background: #e9e9e9;
}

.sidebar-author-card__stats div {
  text-align: center;
}

.sidebar-author-card__stats strong {
  display: block;
  font-size: 34px;
  color: #333;
  line-height: 1.1;
  font-weight: 700;
}

.sidebar-author-card__stats span {
  display: block;
  margin-top: 4px;
  color: #777;
  font-size: 14px;
}

/* 评论区 */
.comment-section--enhanced {
  margin-top: 30px;
  border-top: 2px solid #333;
  padding-top: 20px;
}

.comment-section--enhanced .comment-item--row {
  border-bottom: 1px solid #f0f0f0;
  padding: 15px 0;
}

.comment-section--enhanced .comment-item__meta {
  font-size: 13px;
  color: #999;
}

.comment-section--enhanced .comment-item__body {
  margin-top: 6px;
  color: #333;
  line-height: 1.65;
  white-space: pre-wrap;
}

.comment-section--enhanced .comment-item--new {
  background: #fffcf5;
}

.comment-section--enhanced .comment-empty-tip {
  color: #999;
  padding: 20px 0;
}

.comment-section--enhanced .comment-form-wrap {
  margin-top: 30px;
}

.comment-section--enhanced .comment-textarea,
.article-container #commentForm textarea,
.comment-form textarea {
  width: 100%;
  min-height: 88px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
}

.article-container #commentForm textarea,
.comment-form textarea {
  min-height: 100px;
  font-size: 14px;
  margin-bottom: 15px;
  display: block;
}

.comment-section--enhanced .comment-textarea:focus {
  outline: none;
  border-color: rgba(200, 29, 37, 0.45);
  box-shadow: 0 0 0 3px rgba(200, 29, 37, 0.12);
}

.comment-section--enhanced .comment-textarea:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.comment-section--enhanced .comment-input-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.comment-section--enhanced .comment-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.comment-section--enhanced .comment-submit-btn,
.comment-section--enhanced .comment-retry-btn,
.article-container .btn-submit {
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.comment-section--enhanced .comment-submit-btn,
.comment-section--enhanced .comment-retry-btn {
  border-radius: 4px;
  padding: 10px 20px;
}

.article-container .btn-submit {
  padding: 10px 30px;
  background: #2f3542;
  color: #fff;
  border-radius: 6px;
}

.comment-submit-btn {
  background: #333;
  color: #fff;
}

.comment-submit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.comment-retry-btn {
  background: #f59e0b;
  color: #fff;
}

.comment-char-tip {
  margin-left: auto;
  font-size: 13px;
  color: #6b7280;
}

.comment-char-tip.is-warning,
.comment-msg-tip.is-warning {
  color: #b45309;
}

.comment-char-tip.is-error,
.comment-msg-tip.is-error {
  color: #b91c1c;
}

.comment-msg-tip {
  margin-left: 2px;
  font-size: 14px;
  color: #666;
}

.comment-msg-tip.is-pending {
  color: #6b7280;
}

.comment-msg-tip.is-success {
  color: #15803d;
}

.comment-login-tip {
  text-align: center;
  padding: 20px;
  background: #f9f9f9;
}

.comment-login-link {
  color: #ff4757;
  font-weight: bold;
}

/* 焦点可访问性 */
.article-breadcrumb .crumb-link:focus-visible,
.content-expand-btn:focus-visible,
.sidebar-list a:focus-visible,
.comment-login-link:focus-visible,
.comment-submit-btn:focus-visible,
.comment-retry-btn:focus-visible,
.article-container .btn-submit:focus-visible,
.tag-link:focus-visible,
.article-nav a:focus-visible,
.like-btn:focus-visible,
.share-btn:focus-visible,
.sidebar-author-card__avatar-wrap:focus-visible,
.sidebar-author-card__head h3 a:focus-visible,
.global-back-to-top:focus-visible {
  outline: 2px solid rgba(200, 29, 37, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

.like-btn:focus-visible,
.share-btn:focus-visible {
  border-radius: 999px;
}

/* 平板和手机 */
@media (max-width: 960px) {
  .article-layout {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .article-main,
  .article-sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .article-sidebar {
    position: static;
    flex: none;
  }

  .article-toc {
    position: static;
  }

  .sidebar-block {
    padding: 14px;
    margin-bottom: 14px;
  }

  .sidebar-author-card__avatar-wrap {
    width: 92px;
    height: 92px;
    margin-bottom: 10px;
  }

  .sidebar-author-card__badge {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .sidebar-author-card__head h3 {
    font-size: 22px;
  }

  .sidebar-author-card__stats strong {
    font-size: 30px;
  }
}

/* 手机 */
@media (max-width: 600px) {
  .article-page {
    padding: 16px 0;
  }

  .article-container {
    width: min(100%, calc(100vw - 24px));
    margin: 0 auto;
    padding: 14px;
    border-radius: 10px;
  }

  .article-main > h1 {
    margin-bottom: 12px;
    font-size: clamp(1.7rem, 8.4vw, 2.25rem);
    line-height: 1.22;
  }

  .article-breadcrumb {
    gap: 6px;
    font-size: 14px;
    margin-bottom: 14px;
    white-space: normal;
    overflow: visible;
    flex-wrap: wrap;
  }

  .article-breadcrumb::before {
    height: 14px;
  }

  .article-breadcrumb .crumb-label,
  .article-breadcrumb .crumb-separator {
    display: none;
  }

  .article-breadcrumb .crumb-link {
    flex: 0 0 auto;
    padding: 2px 0;
  }

  .article-meta {
    margin: 10px 0 16px;
    padding: 8px 10px;
    font-size: 14px;
    gap: 4px;
  }

  .article-meta__divider {
    display: none;
  }

  .article-cover--spaced {
    margin: 12px 0;
    border-radius: 10px;
  }

  .content-text {
    font-size: 16px;
    line-height: 1.75;
  }

  .content-text p {
    margin: 0 0 1em;
  }

  .content-text h2,
  .content-text h3 {
    line-height: 1.35;
    margin: 1.1em 0 0.55em;
  }

  .content-text ul,
  .content-text ol {
    margin: 0 0 1em;
    padding-left: 1.2em;
  }

  .content-text li {
    margin: 0.35em 0;
  }

  .content-text table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 13px;
  }

  .content-text th,
  .content-text td {
    padding: 5px 6px;
  }

  .content-text blockquote {
    padding: 0.55em 0.75em;
    border-left-width: 2px;
  }

  .content-text pre {
    padding: 8px 10px;
    font-size: 13px;
  }

  .action-bar,
  .article-container .action-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 24px 0;
  }

  .action-bar button,
  .action-bar a,
  .article-container .action-bar button,
  .article-container .action-bar a {
    min-height: 42px;
    padding: 9px 5px;
    font-size: 13px;
    gap: 4px;
  }

  .comment-section--enhanced .comment-actions {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
  }

  .comment-submit-btn,
  .comment-retry-btn {
    padding: 9px 14px;
    border-radius: 999px;
  }

  .comment-section--enhanced .comment-item--row {
    padding: 12px 0;
  }

  .comment-section--enhanced .comment-item__meta {
    font-size: 12px;
  }

  .comment-section--enhanced .comment-item__body {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .comment-section--enhanced .comment-textarea {
    min-height: 96px;
    padding: 12px;
    border-radius: 10px;
  }

  .comment-section--enhanced .comment-input-hint {
    font-size: 12px;
    line-height: 1.55;
  }

  .comment-login-tip {
    padding: 16px;
    font-size: 14px;
  }

  .comment-char-tip,
  .comment-msg-tip {
    width: 100%;
    margin-left: 0;
  }

  .sidebar-block h3 {
    font-size: 15px;
  }

  .article-toc__list a {
    font-size: 13px;
    line-height: 1.45;
  }

  .sidebar-author-card__stats {
    margin-top: 14px;
  }

  .sidebar-author-card__stats strong {
    font-size: 24px;
  }

  .sidebar-author-card__stats span {
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .action-bar,
  .article-container .action-bar {
    gap: 6px;
  }

  .action-bar button,
  .action-bar a,
  .article-container .action-bar button,
  .article-container .action-bar a {
    font-size: 12px;
    padding-left: 3px;
    padding-right: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress__bar,
  .global-back-to-top {
    transition: none;
  }

  .global-back-to-top.is-visible {
    transform: none;
  }
}
