/* ============================================================
   话题发现页 - 样式表
   主色: #ff2c65 | 背景: #0a0a0a | 暗色主题
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS 变量系统
   ---------------------------------------------------------- */
:root {
  --color-primary: #ff2c65;
  --color-primary-light: #ff5c8a;
  --color-primary-dark: #d9144a;
  --color-primary-rgb: 255, 44, 101;

  --color-bg: #0a0a0a;
  --color-bg-secondary: #111111;
  --color-bg-card: rgba(255, 255, 255, 0.04);
  --color-bg-glass: rgba(10, 10, 10, 0.88);

  --color-text: #ffffff;
  --color-text-secondary: rgba(255, 255, 255, 0.55);
  --color-text-muted: rgba(255, 255, 255, 0.3);
  --color-text-placeholder: rgba(255, 255, 255, 0.25);

  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-light: rgba(255, 255, 255, 0.1);
  --color-divider: rgba(255, 255, 255, 0.05);

  --color-shadow-primary: rgba(var(--color-primary-rgb), 0.35);
  --color-shadow-card: rgba(0, 0, 0, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --header-height: 56px;
  --bottom-nav-height: 56px;

  --font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
}

/* ----------------------------------------------------------
   2. 基础重置
   ---------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

input, button, textarea {
  font: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

/* ----------------------------------------------------------
   3. 顶部导航栏
   ---------------------------------------------------------- */
.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, var(--safe-top));
  background: var(--color-bg-glass);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-normal);
}

.header-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.header-back-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.header-search-form {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-search-box {
  flex: 1;
  height: 38px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.header-search-box:focus-within {
  border-color: rgba(var(--color-primary-rgb), 0.4);
  background: rgba(255, 255, 255, 0.09);
}

.header-search-box .search-icon {
  font-size: 13px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.header-search-box input {
  flex: 1;
  height: 100%;
  font-size: 14px;
  color: var(--color-text);
}

.header-search-box input::placeholder {
  color: var(--color-text-placeholder);
}

/* ----------------------------------------------------------
   4. Banner 区域
   ---------------------------------------------------------- */
.topic-banner {
  position: relative;
  margin: 16px;
  padding: 28px 24px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #ff6b35 50%, #ffc107 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: fadeIn 0.6s ease;
}

.topic-banner::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  animation: bannerFloat 6s ease-in-out infinite;
}

.topic-banner::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 30%;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  animation: bannerFloat 8s ease-in-out infinite reverse;
}

.topic-banner-content {
  position: relative;
  z-index: 1;
}

.topic-banner-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.topic-banner-title i {
  margin-right: 6px;
}

.topic-banner-desc {
  font-size: 13px;
  opacity: 0.9;
  line-height: 1.6;
}

/* ----------------------------------------------------------
   5. 分类标签横滑
   ---------------------------------------------------------- */
.category-scroll-wrapper {
  padding: 0 16px;
  margin-bottom: 4px;
}

.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 12px 0;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  padding: 7px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.category-chip:active {
  transform: scale(0.95);
}

.category-chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  border-color: transparent;
  box-shadow: 0 2px 12px var(--color-shadow-primary);
}

/* ----------------------------------------------------------
   6. Tab 切换栏
   ---------------------------------------------------------- */
.tab-bar {
  position: relative;
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 13px 0;
  font-size: 14px;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-normal);
}

.tab-item.active {
  color: var(--color-text);
  font-weight: 600;
}

.tab-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 33.333%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 3px 3px 0 0;
  transition: transform var(--transition-slow);
  will-change: transform;
}

/* ----------------------------------------------------------
   7. 话题卡片网格
   ---------------------------------------------------------- */
.topic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
}

.topic-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: transform var(--transition-fast), box-shadow var(--transition-normal);
  animation: slideUp 0.4s ease both;
}

.topic-card:nth-child(2) { animation-delay: 0.05s; }
.topic-card:nth-child(3) { animation-delay: 0.1s; }
.topic-card:nth-child(4) { animation-delay: 0.15s; }
.topic-card:nth-child(5) { animation-delay: 0.2s; }
.topic-card:nth-child(6) { animation-delay: 0.25s; }

.topic-card:active {
  transform: scale(0.97);
  box-shadow: 0 4px 20px var(--color-shadow-card);
}

/* 封面区 */
.topic-card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.topic-card-cover .cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.topic-card:active .cover-image {
  transform: scale(1.05);
}

.topic-card-cover .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* HOT 徽章 */
.hot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 10px;
  background: linear-gradient(135deg, var(--color-primary), #ff6b6b);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  box-shadow: 0 2px 8px var(--color-shadow-primary);
}

/* 信息区 */
.topic-card-body {
  padding: 12px;
}

.topic-card-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-card-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-card-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.topic-card-stats .stat-dot {
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.topic-card-stats i {
  font-size: 10px;
  margin-right: 2px;
}

/* ----------------------------------------------------------
   8. 搜索结果列表
   ---------------------------------------------------------- */
.search-result-header {
  padding: 16px 16px 8px;
}

.search-result-count {
  font-size: 13px;
  color: var(--color-text-muted);
}

.search-result-list {
  padding: 0 16px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:active {
  opacity: 0.7;
}

.search-result-item .result-icon-box {
  width: 50px;
  height: 50px;
  background: rgba(var(--color-primary-rgb), 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.search-result-item .result-info {
  flex: 1;
  min-width: 0;
}

.search-result-item .result-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-arrow {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   9. 空状态
   ---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
  animation: fadeIn 0.5s ease;
}

.empty-state .empty-icon {
  font-size: 52px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 14px;
  line-height: 1.6;
}

/* ----------------------------------------------------------
   10. 底部导航栏
   ---------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-height);
  background: var(--color-bg-glass);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--color-border);
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 0;
  min-width: 48px;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav-item.active {
  color: var(--color-text);
}

.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-item .nav-label {
  line-height: 1;
}

/* 发布按钮凸起 */
.nav-item.nav-publish {
  position: relative;
  top: -10px;
}

.publish-btn {
  width: 46px;
  height: 34px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 16px var(--color-shadow-primary);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.publish-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px var(--color-shadow-primary);
}

/* ----------------------------------------------------------
   11. Toast 提示
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
}

.toast-message {
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.8s forwards;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------------------------
   12. 加载更多按钮
   ---------------------------------------------------------- */
.load-more-wrapper {
  display: flex;
  justify-content: center;
  padding: 24px 16px 32px;
}

.load-more-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 32px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.load-more-btn:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.97);
}

.load-more-btn i {
  font-size: 12px;
}

/* ----------------------------------------------------------
   13. 动画
   ---------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes bannerFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

@keyframes toastIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.85); }
}

/* ----------------------------------------------------------
   14. 页面主体
   ---------------------------------------------------------- */
.page-body {
  padding-top: calc(var(--header-height) + var(--safe-top) + 10px);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
  overflow-y: auto;
  height: 100vh;
  -webkit-overflow-scrolling: touch;
}

/* Tab 内容区 */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ----------------------------------------------------------
   15. 响应式适配
   ---------------------------------------------------------- */
@media (min-width: 768px) {
  .page-body,
  .topic-grid,
  .search-result-list,
  .tab-bar,
  .category-scroll-wrapper,
  .load-more-wrapper,
  .search-result-header {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }

  .topic-banner {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }

  .page-header,
  .bottom-nav {
    max-width: 420px;
    left: 50%;
    transform: translateX(-50%);
  }

  .bottom-nav {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}
