/* style.css - 新闻博客通用样式 */

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  color: #333;
  background: #f8f9fa;
  font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
  color: #1a1a1a;
  font-weight: 700;
}

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

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* 移除 position: fixed，使用 sticky */
header {
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: static; /* ✅ 改为 static，避免固定定位 */
  z-index: 1000;
}

.navbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.6em;
  font-weight: 700;
  color: #0033a0;
}

/* PC 端右侧：导航 + 搜索 */
.header-right {
  display: flex;           /* ✅ 水平排列 */
  align-items: center;
  gap: 20px;
}

/* 导航菜单：水平排列 */
.nav-menu {
  display: flex;           /* ✅ 关键：水平布局 */
  gap: 16px;               /* 菜单项间距 */
}

.nav-link {
  color: #333;
  text-decoration: none;
  font-weight: 500;
  font-size: 1em;
  padding: 0 8px;
}

.nav-link:hover {
  color: #0033a0;
}

/* 搜索框 */
.search-form {
  display: flex;
  gap: 8px;
}

.search-form input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9em;
  width: 180px;
}

.search-form button {
  background: none;
  border: 1px solid #ddd;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.search-form button:hover {
  background: #f0f0f0;
}

/* 手机端才显示汉堡 */
.navbar-toggler {
  background: none;
  border: none;
  font-size: 1.4em;
  cursor: pointer;
  color: #333;
  display: none; /* 默认隐藏 */
}

/* -----------------------------
   移动端抽屉菜单
------------------------------- */
.offcanvas-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: white;
  z-index: 1500;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 20px;
}

.offcanvas-menu.active {
  right: 0;
}

.offcanvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
}

.offcanvas-search {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  margin-bottom: 20px;
}

.offcanvas-nav a {
  display: block;
  padding: 12px 0;
  color: #333;
  font-size: 1.1em;
  border-bottom: 1px solid #f0f0f0;
}

.offcanvas-nav a:hover {
  color: #0033a0;
}

/* -----------------------------
   横向滚动 Banner
------------------------------- */
.horizontal-swiper {
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0;
  margin: 0 -15px;
}

.horizontal-swiper::-webkit-scrollbar {
  display: none;
}
.horizontal-swiper {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.swiper-wrapper {
  display: flex;
  gap: 16px;
  padding: 16px;
  flex-wrap: nowrap;
}

.swiper-slide {
  min-width: 280px;
  max-width: 300px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  flex: 0 0 auto;
  cursor: pointer;
  transition: transform 0.2s;
}

.swiper-slide:hover {
  transform: translateY(-3px);
}

.swiper-slide img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

/* -----------------------------
   分类标签
------------------------------- */
.category-badge {
  /* 布局 */
  display: inline-block !important;
  flex-shrink: 0;
  align-self: flex-start;   /* 在 flex 容器中左对齐 */

  /* 尺寸 */
  width: auto;
  max-width: 120px;
  min-width: 60px;
  padding: 4px 10px;

  /* 文本 */
  font-size: 0.8em;
  font-weight: 600;
  line-height: 1;
  color: white;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  /* 外观 */
  border-radius: 50px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);

  /* 禁止被拉伸 */
  margin: 0;
}

/* 分类颜色 */
.category-badge.category-technology { background: #0033a0; }
.category-badge.category-health      { background: #d92228; }
.category-badge.category-science     { background: #007acc; }
.category-badge.category-sports      { background: #ff6b00; }
.category-badge.category-business    { background: #28a745; }
.category-badge.category-entertainment { background: #9c27b0; }
.category-badge.category-general     { background: #6c757d; }

.swiper-slide h4 {
  font-size: 1em;
  margin: 0 10px;
  line-height: 1.4;
}

.swiper-slide p {
  font-size: 0.85em;
  color: #666;
  margin: 5px 10px;
}

/* -----------------------------
   文章卡片：左图右文
------------------------------- */
.article-card {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.3s;
}

.article-card:hover {
  transform: translateY(-3px);
}

.article-img {
  width: 200px;
  height: 150px;
  object-fit: cover;
  flex-shrink: 0;
  margin: 12px;
  border-radius: 8px;
}

.article-body {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.article-title {
  font-size: 1.2em;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.4;
}

.article-title:hover {
  color: #0033a0;
}

.article-meta {
  font-size: 0.9em;
  color: #666;
}

.article-excerpt {
  font-size: 0.95em;
  color: #555;
  line-height: 1.5;
}

.read-more {
  color: #0033a0;
  font-weight: 600;
  font-size: 0.9em;
  align-self: start;
  padding: 6px 12px;
  border: 1px solid #0033a0;
  border-radius: 6px;
  width: fit-content;
}

.read-more:hover {
  background: #0033a0;
  color: white;
}

/* -----------------------------
   侧边栏
------------------------------- */
.popular-list a {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  text-decoration: none;
  color: #333;
}

.popular-list img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
}

.popular-list .text {
  flex: 1;
}

.popular-list .category {
  font-size: 0.8em;
  color: #777;
  text-transform: uppercase;
}

.popular-list .title {
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1.4;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.category-btn {
  display: block;
  text-align: center;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9em;
  color: #555;
  text-decoration: none;
}

.category-btn:hover {
  background: #f8f9fa;
  color: #0033a0;
}

/* -----------------------------
   广告位
------------------------------- */
.ad-box {
  background: #f1f1f1;
  border: 1px dashed #ccc;
  padding: 20px;
  text-align: center;
  font-size: 0.9em;
  color: #777;
  margin: 20px 0;
}

/* -----------------------------
   尾部
------------------------------- */
footer {
  background: #1a1a1a;
  color: #ddd;
  padding: 40px 0;
  margin-top: 50px;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.footer-left {
  color: #fff;
}

.footer-logo {
  font-size: 1.5em;
  font-weight: 700;
  color: #00bfff;
  text-decoration: none;
}

.footer-left p {
  font-size: 0.9em;
  color: #aaa;
  margin-top: 8px;
}

.footer-right .footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.footer-links a {
  color: #ddd;
  font-size: 0.95em;
}

.footer-links a:hover {
  text-decoration: underline;
  color: #00bfff;
}

/* 详情页容器：最大 800px 居中 */
.article-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 15px;
}

.article-content h1 {
  font-size: 1.8em;
  color: #1a1a1a;
  margin: 20px 0;
  line-height: 1.3;
}

.article-content .content-body {
  font-size: 1.1em;
  line-height: 1.8;
  color: #333;
}

.article-content .content-body h3 {
  color: #0033a0;
  margin: 30px 0 15px;
}

.article-content .content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.related-section h3 {
  font-size: 1.4em;
  margin: 40px 0 20px;
  color: #333;
}

/* 内容参考声明样式 */
.content-reference {
  margin-top: 40px;
  font-size: 0.95em;
  line-height: 1.6;
  color: #555;
  background: #fff9e6;
  border-radius: 0 8px 8px 0;
}

.content-reference a {
  color: #d92228;
  text-decoration: underline;
}

.content-reference a:hover {
  color: #9c1717;
}

.content-reference strong {
  color: #333;
}

/* 分类模块 */
.category-module h2 {
  color: #1a1a1a;
  font-size: 1.5em;
  border-bottom: 2px solid #0033a0;
  padding-bottom: 8px;
  display: inline-block;
}

.category-module .horizontal-swiper {
  margin: 15px 0;
}

.category-module .swiper-slide h4 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 2.8em;
}


/* ===========================
   全新模板：错位瀑布流 + 动画
   =========================== */

/* 主容器 */
#category-sections {
  display: flex;
  flex-direction: column;
  gap: 50px;
  margin-bottom: 40px;
}

/* 分类模块标题 */
.category-module h2 {
  font-size: 1.8em;
  color: #e0b0ff;
  text-align: center;
  margin-bottom: 25px;
  text-shadow: 0 0 10px rgba(224, 176, 255, 0.5);
  letter-spacing: 1px;
  position: relative;
}

.category-module h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #7b2cbf, transparent);
}

/* 文章列表 */
.articles-staggered {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* 单篇文章 */
.article-staggered {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
  animation: staggerFadeIn 0.6s forwards;
}

.article-staggered:nth-child(odd) {
  align-self: flex-start;
  max-width: 800px;
}

.article-staggered:nth-child(even) {
  align-self: flex-end;
  max-width: 800px;
}

/* 动画延迟 */
.article-staggered:nth-child(1) { animation-delay: 0.1s; }
.article-staggered:nth-child(2) { animation-delay: 0.2s; }
.article-staggered:nth-child(3) { animation-delay: 0.3s; }
.article-staggered:nth-child(4) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 卡片容器 */
.staggered-card {
  display: flex;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1a1a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
  transition: transform 0.3s, box-shadow 0.3s;
}

.staggered-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(123, 44, 191, 0.25);
  border-color: #7b2cbf;
}

/* 图片 */
.staggered-img {
  width: 300px;
  height: 200px;
  object-fit: cover;
}

/* 内容区 */
.staggered-body {
  flex: 1;
  padding: 20px;
  color: white;
}

/* 分类标签 */
.staggered-category {
  display: inline-block;
  font-size: 0.8em;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 50px;
  background: #7b2cbf;
  color: white;
  margin-bottom: 10px;
}

.staggered-title {
  font-size: 1.3em;
  font-weight: 700;
  color: white;
  margin: 8px 0;
  line-height: 1.4;
}

.staggered-meta {
  font-size: 0.9em;
  color: #aaa;
  margin-bottom: 10px;
}

.staggered-excerpt {
  font-size: 0.95em;
  color: #ddd;
  line-height: 1.5;
  margin-bottom: 15px;
}

.staggered-link {
  color: #7b2cbf;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95em;
}

.staggered-link:hover {
  text-decoration: underline;
}

/* 查看更多按钮 */
.view-all-btn {
  display: block;
  margin: 30px auto 0;
  padding: 12px 30px;
  background: linear-gradient(90deg, #7b2cbf, #5a189a);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  width: fit-content;
  box-shadow: 0 4px 12px rgba(123, 44, 191, 0.3);
}

.view-all-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(123, 44, 191, 0.4);
}


/* -----------------------------
   响应式
------------------------------- */
@media (max-width: 991.98px) {
  .d-lg-none {
    display: block !important;
  }
  .d-lg-flex {
    display: none !important;
  }
  .header-right {
    /*flex-direction: column;*/
    /*align-items: stretch;*/
  }
  .search-form {
    margin-top: 10px;
    justify-content: center;
  }
  .search-form input {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .article-card {
    flex-direction: column;
  }
  .article-img {
    width: 100%;
    height: 200px;
  }
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  .footer-left p {
    text-align: center;
  }
  
  .staggered-card {
    flex-direction: column;
  }
  .staggered-img {
    width: 100%;
    height: 180px;
  }
  .article-staggered {
    align-self: stretch !important;
  }
  .category-module h2 {
    font-size: 1.5em;
  }
}
