/* ========== 话题详情页（仿 CSDN activity topic） ========== */
.page-topic-detail {
  background: var(--bg-page);
}

.page-topic-detail .layout {
  display: block;
}

.page-topic-detail .main-content {
  margin-left: 0;
  width: 100%;
}

/* 面包屑 */
.topic-breadcrumb {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 8px 20px 0;
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.topic-breadcrumb a:hover {
  color: var(--primary);
}

.topic-breadcrumb-sep {
  margin: 0 6px;
}

/* Hero 横幅 */
.topic-detail-hero {
  position: relative;
  min-height: 200px;
  margin: 8px 20px 0;
  max-width: calc(var(--content-max-width) - 40px);
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
  overflow: hidden;
  color: #fff;
  display: flex;
  align-items: flex-end;
}

.topic-detail-hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1565c0 0%, #42a5f5 55%, #1e88e5 100%);
}

.topic-detail-hero-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
    linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, transparent 60%);
}

.topic-detail-hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 28px 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.topic-detail-hero-main {
  flex: 1;
  min-width: 0;
}

.topic-detail-tag {
  display: inline-block;
  font-size: var(--font-sm);
  font-weight: 500;
  padding: 2px 10px;
  background: rgba(255, 94, 59, 0.9);
  border-radius: 3px;
  margin-bottom: 10px;
}

.topic-detail-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
}

.topic-detail-desc {
  font-size: var(--font-md);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  max-width: 640px;
  margin-bottom: 14px;
}

.topic-detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: var(--font-sm);
  color: rgba(255, 255, 255, 0.75);
}

.topic-detail-stats strong {
  color: #fff;
  font-weight: 600;
}

.topic-detail-actions {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.topic-detail-btn-primary {
  padding: 10px 28px;
  font-size: var(--font-base);
  font-weight: 500;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
  white-space: nowrap;
}

.topic-detail-btn-primary:hover {
  background: var(--primary-hover);
}

.topic-detail-btn-outline {
  padding: 9px 20px;
  font-size: var(--font-md);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}

.topic-detail-btn-outline:hover {
  background: rgba(255, 255, 255, 0.22);
}

.topic-detail-btn-outline.is-followed {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

/* 内容区 */
.topic-detail-wrapper {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 20px 20px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

/* Tab 栏 */
.topic-detail-tabs-bar {
  background: var(--bg-white);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 16px;
  position: sticky;
  top: calc(var(--header-height) + 8px);
  z-index: 30;
}

.topic-detail-tabs {
  display: flex;
  gap: 4px;
}

.topic-detail-tab {
  padding: 14px 18px;
  font-size: var(--font-md);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.topic-detail-tab:hover {
  color: var(--text-primary);
}

.topic-detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

.topic-detail-sort {
  font-size: var(--font-sm);
  color: var(--text-muted);
  padding-right: 12px;
}

.topic-detail-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* 文章列表 — 每篇独立卡片 */
.topic-detail-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-article {
  display: block;
  background: var(--bg-white);
  border-radius: 8px;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition);
}

.topic-article:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.topic-article-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topic-article-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-page);
}

.topic-article-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-article-author {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.topic-article-author:hover {
  color: var(--primary);
}

.topic-article-time {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-left: auto;
}

.topic-article-rank {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--bg-page);
  color: var(--text-muted);
  font-size: var(--font-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topic-article-rank--top {
  background: var(--primary);
  color: #fff;
}

.topic-article-title {
  font-size: var(--font-lg);
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.topic-article:hover .topic-article-title {
  color: var(--primary);
}

.topic-article-summary {
  font-size: var(--font-md);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-article-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.topic-article-body {
  flex: 1;
  min-width: 0;
}

.topic-article-cover {
  flex-shrink: 0;
  width: 132px;
  height: 88px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-page);
}

.topic-article-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.topic-article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.topic-article-tag {
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: var(--font-xs);
}

.topic-detail-load {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

.topic-detail-load-btn {
  min-width: 140px;
  padding: 10px 24px;
  font-size: var(--font-md);
  color: var(--text-secondary);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}

.topic-detail-load-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* 右侧栏 */
.topic-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-sidebar-card {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 16px;
}

.topic-sidebar-title {
  font-size: var(--font-md);
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.topic-sidebar-text {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.75;
}

.topic-sidebar-text p {
  margin-bottom: 10px;
}

.topic-sidebar-text p:last-child {
  margin-bottom: 0;
}

.topic-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-sidebar-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topic-sidebar-rank-num {
  flex-shrink: 0;
  width: 20px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.topic-sidebar-rank-num--top {
  color: var(--primary);
}

.topic-sidebar-rank-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.topic-sidebar-rank-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-sidebar-rank-info {
  flex: 1;
  min-width: 0;
}

.topic-sidebar-rank-name {
  font-size: var(--font-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-sidebar-rank-name:hover {
  color: var(--primary);
}

.topic-sidebar-rank-meta {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.topic-related-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-related-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  transition: background var(--transition);
}

.topic-related-item:hover {
  background: var(--bg-page);
}

.topic-related-cover {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xs);
  font-weight: 700;
  color: #fff;
}

.topic-related-cover--purple {
  background: linear-gradient(135deg, #6a1b9a, #ab47bc);
}

.topic-related-cover--green {
  background: linear-gradient(135deg, #2e7d32, #66bb6a);
}

.topic-related-cover--orange {
  background: linear-gradient(135deg, #e65100, #ff9800);
}

.topic-related-name {
  font-size: var(--font-sm);
  font-weight: 500;
  line-height: 1.4;
}

.topic-related-meta {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 1024px) {
  .topic-detail-wrapper {
    grid-template-columns: 1fr;
  }

  .topic-detail-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  .topic-detail-hero {
    margin: 8px 12px 0;
    min-height: auto;
  }

  .topic-detail-hero-inner {
    padding: 20px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .topic-detail-title {
    font-size: 22px;
  }

  .topic-detail-actions {
    width: 100%;
  }

  .topic-detail-btn-primary,
  .topic-detail-btn-outline {
    flex: 1;
    text-align: center;
  }

  .topic-detail-wrapper {
    padding: 12px 12px 32px;
  }

  .topic-article-layout {
    flex-direction: column;
  }

  .topic-article-cover {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
