/* article.css - 文章页样式 */

/* 文章页两栏布局 */
.article-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px;
}

.article-main.has-toc {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  align-items: flex-start;
}

/* 左侧目录边栏 */
.toc-sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  display: block;
}

.toc-sidebar .toc {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0;
}

.toc-sidebar .toc::-webkit-scrollbar {
  width: 4px;
}

.toc-sidebar .toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* 正文区域 */
.article-content {
  flex: 1;
  min-width: 0;
}

.article-header {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  font-size: 1.8rem;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.meta-origin {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.meta-origin:hover {
  text-decoration: underline;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* 目录 */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 30px;
}

.toc h4 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--accent);
}

.toc ul {
  list-style: none;
  padding: 0;
}

.toc li {
  padding: 4px 0;
}

.toc li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.toc li a:hover {
  color: var(--accent);
}

.toc .toc-h3 {
  padding-left: 16px;
  font-size: 0.8rem;
}

/* 目录当前项高亮 */
.toc li a.active {
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: 6px;
  margin-left: -8px;
}

/* 文章正文 */
.article-body {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text);
}

.article-body h2 {
  font-size: 1.3rem;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

.article-body h3 {
  font-size: 1.1rem;
  margin: 24px 0 12px;
  color: var(--text);
}

.article-body p {
  margin-bottom: 16px;
}

.article-body strong {
  color: #f8fafc;
}

.article-body a {
  color: var(--accent);
  text-decoration: none;
}

.article-body a:hover {
  text-decoration: underline;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 16px 0;
  border: 1px solid var(--border);
}

.article-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}

.article-body code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #fbbf24;
}

.article-body pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.article-body pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

.article-body ul, .article-body ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.article-body li {
  margin-bottom: 6px;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.article-body th {
  background: var(--bg-card);
  color: var(--accent);
}

/* 相关内容 */
.article-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* 文章统计栏 */
.article-stats {
  display: flex;
  gap: 24px;
  margin: 20px 0;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.stat-item.stat-likes:hover {
  color: var(--accent);
  cursor: pointer;
}

.stat-item.stat-likes.liked {
  color: var(--accent);
}

.stat-item.stat-shares:hover {
  color: var(--accent);
  cursor: pointer;
}

.stat-icon {
  font-size: 1.1rem;
}

.stat-count {
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.related-articles h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--accent);
}

.related-item {
  display: block;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s;
}

.related-item:hover {
  border-color: var(--accent);
}

.related-item .related-title {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.related-item .related-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 代码高亮覆盖 */
.highlight {
  background: var(--bg-card) !important;
}

/* 响应式 */
@media (max-width: 768px) {
  .article-main.has-toc {
    flex-direction: column;
    gap: 0;
  }
  .toc-sidebar {
    display: none;
  }
  .article-main {
    padding: 20px 16px;
  }
  .article-header h1 {
    font-size: 1.4rem;
  }
  .article-body {
    font-size: 0.95rem;
  }
}

@media (max-width: 1024px) {
  .toc-sidebar {
    width: 200px;
  }
}

/* ============ 白天模式覆盖 ============ */
[data-theme="light"] .article-body strong {
  color: #1e293b !important;
}

[data-theme="light"] .article-body code {
  color: #d97706 !important;
}

[data-theme="light"] .article-body {
  color: #1e293b;
}

[data-theme="light"] .toc-sidebar .toc {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .article-header {
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .article-stats {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .stat-item {
  color: #64748b;
}

[data-theme="light"] .stat-item.stat-likes:hover,
[data-theme="light"] .stat-item.stat-likes.liked {
  color: #2563eb;
}

[data-theme="light"] .stat-item.stat-shares:hover {
  color: #2563eb;
}

[data-theme="light"] .article-body blockquote {
  background: #f8fafc;
}

[data-theme="light"] .article-body pre {
  background: #f8fafc;
}

[data-theme="light"] .article-body th {
  background: #f8fafc;
}

[data-theme="light"] .related-item {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .article-footer {
  border-top-color: #e2e8f0;
}
