/* ============ 基础样式 - Cloudflare风格 ============ */
:root {
  --primary: #f38020;
  --primary-dark: #e06a10;
  --primary-light: #fff4ef;
  --accent: #1a1a1a;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f8fa;
  --bg-tertiary: #eef0f5;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s ease;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

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

img {
  max-width: 100%;
  height: auto;
}

/* ============ 容器 ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============ 顶部导航 ============ */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 72px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 导航栏智能显隐 - 向下滚动隐藏 */
.header.hidden {
  transform: translateY(-100%);
}

/* 滚动后添加阴影 */
.header.scrolled {
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, #ff9a56 100%);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(243, 128, 32, 0.3);
}

.logo-icon.small {
  width: 32px;
  height: 32px;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-item {
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

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

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item-tea {
  color: #f5576c;
}

.nav-item-tea:hover,
.nav-item-tea.active {
  color: #f5576c;
  background: #fff0f3;
}

/* 讨论区导航按钮 */
.nav-item-discussion {
  position: relative;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea !important;
  border: 1px solid rgba(102, 126, 234, 0.3);
  font-weight: 600;
}

.nav-item-discussion:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%) !important;
  color: #667eea !important;
  border-color: rgba(102, 126, 234, 0.5);
}

.nav-item-discussion .pulse-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: #f5576c;
  border-radius: 50%;
  animation: pulse-nav 1.5s infinite;
}

@keyframes pulse-nav {
  0% { box-shadow: 0 0 0 0 rgba(245, 87, 108, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(245, 87, 108, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 87, 108, 0); }
}

.online-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  background: #f5576c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  margin-left: 4px;
}

/* 在线动态点 */
.online-dot-animated {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #48c78e;
  border-radius: 50%;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: var(--transition);
  border: 1px solid transparent;
}

.search-box:focus-within {
  background: var(--bg-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.1);
}

.search-input {
  width: 180px;
  height: 40px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
}

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

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.search-btn:hover {
  color: var(--primary);
}

.publish-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #ff9a56 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(243, 128, 32, 0.3);
}

.publish-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 128, 32, 0.4);
}

/* ============ 搜索结果浮层 ============ */
.search-results {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  max-height: 480px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
  overflow: hidden;
  border: 1px solid var(--border);
}

.search-results.active {
  display: block;
}

.search-results-inner {
  max-height: 480px;
  overflow-y: auto;
}

.search-result-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--bg-secondary);
}

.search-result-item h4 {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-weight: 500;
}

.search-result-item h4 mark {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0 2px;
  border-radius: 2px;
}

.search-result-item p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-item time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ============ 底部 ============ */
.footer {
  background: var(--accent);
  color: #999;
  padding: 48px 0 24px;
  margin-top: 80px;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid #333;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 15px;
}

.footer-desc {
  font-size: 13px;
}

.footer-bottom {
  text-align: center;
  padding-top: 24px;
  font-size: 13px;
  color: #666;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .header-inner {
    gap: 20px;
  }
  
  .nav {
    display: none;
  }
  
  .logo-text {
    display: none;
  }
}

@media (max-width: 768px) {
  .header {
    height: 64px;
  }
  
  .header-inner {
    height: 64px;
  }
  
  .hamburger-btn {
    display: flex;
  }
  
  .search-input {
    width: 120px;
  }
  
  .publish-btn span {
    display: none;
  }
  
  .publish-btn {
    padding: 10px 14px;
  }
  
  .search-results {
    width: calc(100% - 48px);
    left: 24px;
    transform: none;
  }
}

/* ============ 移动端底部导航 ============ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  transition: var(--transition);
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
  color: var(--primary);
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
  }
  
  /* 为底部导航留出空间 */
  body {
    padding-bottom: 80px;
  }
  
  .footer {
    padding-bottom: 80px;
  }
}

/* ============ PWA 安装提示 ============ */
.pwa-install-prompt {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 9999;
  padding: 16px;
  animation: slideUp 0.3s ease;
}

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

.pwa-prompt-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-prompt-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.pwa-prompt-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pwa-prompt-text strong {
  font-size: 16px;
  color: var(--text-primary);
}

.pwa-prompt-text span {
  font-size: 13px;
  color: var(--text-secondary);
}

.pwa-prompt-btn {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.pwa-prompt-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

/* ============ PWA 触摸优化 ============ */
@media (max-width: 768px) {
  /* 增大触摸区域 */
  .nav-item,
  .mobile-nav-item,
  .post-card-link,
  .btn,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 禁用双击缩放 */
  * {
    touch-action: manipulation;
  }
  
  /* 平滑滚动 */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 字体响应式 */
  body {
    font-size: 16px;
  }
  
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  
  /* 链接无下划线 */
  a {
    text-decoration: none;
  }
  
  /* 按钮样式优化 */
  .btn, button {
    border-radius: 12px;
    font-size: 16px;
  }
}

/* ============ 页脚统计 ============ */
.footer-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-wrap: wrap;
}

.footer-stat-item {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
}

.footer-stat-item strong {
  color: #fff;
  font-weight: 600;
}

.footer-stat-separator {
  color: rgba(255,255,255,0.3);
}

/* ============ 讨论区头部 ============ */
.discussion-header {
  height: 56px;
}

.discussion-header .header-inner {
  height: 56px;
}

.logo-text-single {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.online-badge-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
}

.online-dot-sm {
  width: 8px;
  height: 8px;
  background: #52c41a;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

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

/* ============ 移动端底部导航 ============ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid #eee;
  display: none;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  z-index: 99;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
  }
  
  .header {
    height: 56px;
  }
  
  .header-inner {
    height: 56px;
  }
  
  body {
    padding-bottom: 80px;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  color: #999;
  font-size: 11px;
  text-decoration: none;
  border-radius: 8px;
  min-width: 60px;
}

.mobile-nav-item .nav-icon {
  font-size: 20px;
}

.mobile-nav-item.active,
.mobile-nav-item:hover {
  color: var(--primary);
}

/* ============ 移动端汉堡菜单 ============ */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--primary-light);
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============ 移动端全屏导航覆盖层 ============ */
.mobile-nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, background 0.3s ease, visibility 0.3s;
}

.mobile-nav-overlay.open {
  opacity: 1;
  visibility: visible;
  background: rgba(0,0,0,0.5);
}

/* 导航面板 - 从右侧滑入 */
.mobile-nav-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 80%;
  max-width: 320px;
  height: 100%;
  background: #fff;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

.mobile-nav-panel.shown {
  transform: translateX(0);
}

.mobile-nav-header {
  flex-shrink: 0;
  height: 60px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.mobile-nav-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.mobile-nav-close {
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.mobile-nav-close:hover {
  background: var(--bg-secondary);
}

.mobile-nav-links {
  flex: 1;
  background: #fff;
  padding: 8px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav-link {
  display: block;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  border-left: 3px solid transparent;
}

.mobile-nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
}

.mobile-nav-footer {
  flex-shrink: 0;
  padding: 16px 24px calc(16px + var(--safe-area-bottom));
  border-top: 1px solid var(--border);
  background: #fff;
}

.mobile-nav-publish {
  display: block;
  text-align: center;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.mobile-nav-publish:hover {
  background: var(--primary-dark);
}

/* ============ 移动端底部导航安全区域 ============ */
@media (max-width: 768px) {
  .mobile-nav {
    padding-bottom: var(--safe-area-bottom);
  }
  
  body {
    padding-bottom: calc(64px + var(--safe-area-bottom));
  }
  
  .footer {
    padding-bottom: calc(80px + var(--safe-area-bottom));
  }
}

/* ============ 移动端超小屏优化 (≤ 375px) ============ */
@media (max-width: 375px) {
  .header-actions {
    gap: 8px;
  }
  
  .search-input {
    width: 80px !important;
  }
  
  .publish-btn span {
    display: none;
  }
  
  .publish-btn {
    padding: 10px 12px;
    min-width: auto;
  }
  
  .hero-title {
    font-size: 22px;
  }
  
  .hero-tags {
    gap: 6px;
  }
  
  .hero-tag {
    padding: 5px 10px;
    font-size: 12px;
  }
  
  .post-card-link {
    padding: 14px;
  }
  
  .post-title {
    font-size: 16px;
  }
  
  .article-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ============ 文章页移动端优化 ============ */
@media (max-width: 768px) {
  .article-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
  }
  
  .article-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .article-title {
    font-size: 24px;
    line-height: 1.3;
  }
  
  .article-tags {
    gap: 6px;
  }
  
  .article-tags .tag {
    padding: 4px 10px;
    font-size: 12px;
  }
  
  .article-footer {
    padding: 16px 0;
  }
  
  .article-nav {
    flex-direction: column;
    gap: 12px;
  }
  
  .related-posts {
    margin-top: 32px;
    padding-top: 24px;
  }
  
  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 375px) {
  .article-title {
    font-size: 20px;
  }
  
  .article-content {
    font-size: 15px;
  }
  
  .article-content h2 {
    font-size: 18px;
  }
  
  .article-content h3 {
    font-size: 16px;
  }
}

/* ============ 移动端触摸反馈 ============ */
@media (max-width: 768px) {
  /* 按钮点击态 */
  .publish-btn:active,
  .mobile-nav-publish:active,
  .cta-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
  }
  
  /* 卡片点击态 */
  .post-card:active {
    transform: scale(0.98);
  }
  
  .post-card-featured:active {
    transform: scale(0.98);
  }
  
  /* 链接点击态 */
  .mobile-nav-link:active {
    background: var(--primary-light);
  }
  
  .hero-tag:active {
    transform: scale(0.95);
  }
  
  /* 底部导航点击态 */
  .mobile-nav-item:active {
    transform: scale(0.9);
    color: var(--primary);
  }
  
  /* 搜索按钮点击态 */
  .search-btn:active {
    background: var(--primary-light);
  }
  
  /* 汉堡按钮点击态 */
  .hamburger-btn:active {
    background: var(--primary-light);
  }
  
  /* 相关文章卡片 */
  .related-card:active {
    transform: scale(0.98);
    border-color: var(--primary);
  }
  
  /* 讨论区入口 */
  .discussion-hero-card:active {
    transform: scale(0.98);
  }
}
