/* =============================================================================
   CommunityHub — forum.css
   ============================================================================= */

/* =============================================================================
   Forum page layout
   ============================================================================= */
.ch-forum-page {
  padding: var(--spacing-lg) 0;
}

.ch-forum-layout {
  align-items: start;
}

/* =============================================================================
   Left sidebar — category nav
   ============================================================================= */
.ch-forum-left-sidebar { position: sticky; top: calc(var(--nav-height) + 16px); }

.ch-cat-nav { display: flex; flex-direction: column; }

.ch-cat-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0 var(--spacing-md);
  height: 32px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.ch-cat-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.ch-cat-item.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.ch-cat-icon { font-size: 14px; flex-shrink: 0; }
.ch-cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-cat-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* =============================================================================
   Forum main content
   ============================================================================= */
.ch-forum-main { display: flex; flex-direction: column; gap: var(--spacing-md); min-width: 0; }

.ch-forum-tabs {
  justify-content: flex-start;
  height: 44px;
  max-width: 100%;
}

.ch-tabs-spacer { flex: 1; }

/* =============================================================================
   Forum thread list — classic forum table style
   ============================================================================= */
.ch-forum-posts {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ch-forum-posts::before {
  content: 'Topic' ' ' 'Replies' ' ' 'Views' ' ' 'Last Reply';
  display: none;
}

.ch-forum-posts .ch-forum-posts-header,
.ch-forum-posts-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 72px 72px 180px;
  gap: var(--spacing-md);
  padding: 10px var(--spacing-lg);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  align-items: center;
}
.ch-forum-posts-header span:nth-child(3),
.ch-forum-posts-header span:nth-child(4) { text-align: center; }

.ch-thread-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 72px 72px 180px;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-border-light);
  align-items: center;
  transition: background var(--transition-fast);
}
.ch-thread-row:last-child { border-bottom: none; }
.ch-thread-row:hover { background: var(--color-bg); }

.ch-thread-row.is-pinned {
  background: linear-gradient(180deg, rgba(245,158,11,0.06), transparent 70%);
}

.ch-thread-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.ch-thread-pin {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 12px;
  background: #fbbf24;
  border-radius: 999px;
  padding: 1px 3px;
  line-height: 1;
}

.ch-thread-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.ch-thread-title-row {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-xs);
  flex-wrap: nowrap;
}

.ch-thread-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--font-size-md);
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}
.ch-thread-title a {
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.ch-thread-title a:hover { color: var(--color-primary); }
.ch-thread-flag { flex: 0 0 auto; font-size: 14px; }
.ch-thread-title-row .ch-report-btn { margin-top: 1px; }

.ch-thread-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.4;
}
.ch-thread-meta a { color: var(--color-text-secondary); text-decoration: none; }
.ch-thread-meta a:hover { color: var(--color-primary); }
.ch-thread-cat-link {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--color-text-secondary) !important;
}
.ch-thread-sep { opacity: 0.5; }

.ch-thread-col { text-align: center; }
.ch-thread-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.1;
}
.ch-thread-stat strong {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text-primary);
}
.ch-thread-stat span {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ch-thread-last {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 0;
  padding-right: 80px;
  text-align: left;
}
.ch-thread-last-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.ch-thread-last-user {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-thread-last-time {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* =============================================================================
   Right sidebar
   ============================================================================= */
.ch-forum-right-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  position: sticky;
  top: calc(var(--nav-height) + 16px);
}

/* Stats grid */
.ch-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  text-align: center;
}

.ch-stat-item { }

.ch-stat-number {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
}

.ch-stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* Hot topics */
.ch-hot-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border-light);
}
.ch-hot-item:last-child { border-bottom: none; }

.ch-hot-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.ch-hot-rank.is-top {
  background: var(--color-primary);
  color: #fff;
}

.ch-hot-title {
  flex: 1;
  font-size: var(--font-size-xs);
  color: var(--color-text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.ch-hot-title:hover { color: var(--color-primary); }

.ch-hot-views {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Card quick links */
.ch-card-links .ch-card-body { display: flex; flex-direction: column; gap: 0; }

/* =============================================================================
   Single forum post
   ============================================================================= */
.ch-forum-single-page { padding: var(--spacing-xl) 0; }

.ch-forum-single-header {
  position: relative;
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.ch-forum-single-header-inner { min-width: 0; }

.ch-forum-single-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--font-size-3xl);
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
}

.ch-forum-single-title-row {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.ch-forum-single-title-row .ch-report-btn {
  margin-top: 3px;
}

.ch-forum-single-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.ch-forum-single-body {
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
  font-size: var(--font-size-md);
  line-height: 1.8;
  color: var(--color-text-secondary);
}

.ch-forum-action-spacer {
  flex: 1 1 auto;
  min-width: var(--spacing-md);
}

.ch-forum-share-label {
  flex: 0 0 auto;
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 1100px) {
  .ch-forum-layout { grid-template-columns: var(--sidebar-left-width) 1fr; }
  .ch-forum-right-sidebar { display: none; }
  .ch-thread-row,
  .ch-forum-posts-header { grid-template-columns: 44px minmax(0, 1fr) 60px 60px 140px; }
}

@media (max-width: 768px) {
  .ch-forum-layout { grid-template-columns: 1fr; }
  .ch-forum-left-sidebar { display: none; }
  .ch-forum-right-sidebar { position: static; display: flex; }
  .ch-stats-grid { grid-template-columns: repeat(4, 1fr); }
  .ch-thread-row,
  .ch-forum-posts-header { grid-template-columns: 40px minmax(0, 1fr) 56px 120px; }
  .ch-thread-row .ch-thread-col.ch-thread-stat:nth-of-type(3) { display: none; } /* hide Views on tablet */
  .ch-forum-posts-header span:nth-child(4) { display: none; }
}

@media (max-width: 520px) {
  .ch-thread-row,
  .ch-forum-posts-header { grid-template-columns: 36px minmax(0, 1fr) 48px; padding: var(--spacing-sm) var(--spacing-md); gap: var(--spacing-sm); }
  .ch-thread-last { display: none; }
  .ch-forum-posts-header span:nth-child(5) { display: none; }
  .ch-thread-icon { width: 32px; height: 32px; font-size: 16px; }
  .ch-thread-title { font-size: var(--font-size-sm); }

  .ch-forum-single-page { padding: var(--spacing-md) 0 var(--spacing-xl); }
  .ch-forum-single-header,
  .ch-forum-single-body {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
  }
  .ch-forum-single-title-row {
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
  }
  .ch-forum-single-title {
    font-size: 22px;
    line-height: 1.22;
  }
  .ch-forum-single-meta .ch-author-link {
    flex: 1 1 100%;
  }
  .ch-forum-action-bar {
    align-items: stretch;
    gap: var(--spacing-sm);
  }
  .ch-forum-action-bar .ch-btn {
    min-width: 0;
  }
  .ch-forum-action-spacer {
    display: none;
  }
  .ch-forum-share-label {
    width: 100%;
  }
  .ch-forum-action-bar .ch-share-btn {
    flex: 1 1 100%;
  }
  .ch-post-card-reward {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--spacing-sm);
    text-align: left;
  }
  .ch-comment-area.ch-card {
    padding: var(--spacing-lg) !important;
  }
  .ch-comment-inner {
    padding: var(--spacing-md) !important;
  }
}

/* =============================================================================
   Forum easter-egg (surprise card) — floating button
   ============================================================================= */
.ch-forum-egg {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  border: 3px solid #fff;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
  z-index: 50;
  animation: ch-egg-float 3s ease-in-out infinite;
  transition: transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ch-forum-egg:hover { transform: scale(1.08); }
.ch-forum-egg:active { transform: scale(0.96); }

.ch-forum-egg-emoji {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.ch-forum-egg-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #ef4444;
  opacity: 0.6;
  animation: ch-egg-pulse 2s ease-out infinite;
  pointer-events: none;
}

.ch-forum-egg.is-found {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: none;
  opacity: 0.7;
}
.ch-forum-egg.is-found .ch-forum-egg-pulse { display: none; }
.ch-forum-egg.is-found:hover { transform: none; }

.ch-forum-egg.is-bursting {
  animation: ch-egg-burst 0.6s ease-out;
}

@keyframes ch-egg-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes ch-egg-pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0;   }
}

@keyframes ch-egg-burst {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.7); }
  50%  { transform: scale(1.25); box-shadow: 0 0 0 24px rgba(239, 68, 68, 0);   }
  100% { transform: scale(1);   box-shadow: 0 0 0 0   rgba(239, 68, 68, 0);   }
}

@media (max-width: 520px) {
  .ch-forum-egg { right: 16px; bottom: 80px; width: 52px; height: 52px; }
  .ch-forum-egg-emoji { font-size: 22px; }
}
