/* ******************************************************************
   博客主样式表（已去冗余 + 变量化 + 分段注释）
   ****************************************************************** */

/* ===== 0. 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ----- 0.1 全局平滑过渡（减少重复写 transition） ----- */
* { transition: background-color .3s, color .3s, border-color .3s, box-shadow .3s; }

/* ----- 0.2 基础排版 ----- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-color);
}

a { color: var(--link-color); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* ===== 1. CSS 变量（亮色主题） ===== */
:root {
  --bg-color: #fafafa;
  --card-bg: #fff;
  --text-color: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border-color: #e1e8ed;
  --link-color: #3498db;
  --link-hover: #2980b9;
  --code-bg: #f8f9fa;
  --shadow: 0 2px 10px rgba(0,0,0,.1);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.15);
  --radius: 8px;
  --radius-s: 4px;
}

/* ===== 2. 暗色主题 ===== */
[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --card-bg: #2d3748;
  --text-color: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border-color: #4a5568;
  --link-color: #63b3ed;
  --link-hover: #3182ce;
  --code-bg: #2d3748;
  --shadow: 0 2px 10px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.4);
}

/* ===== 3. 布局框架 ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.main-content { min-height: calc(100vh - 120px); padding: 2rem 0; }

/* ===== 4. 头部 ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}
.header-content { display: flex; justify-content: space-between; align-items: center; }
.site-title { font-size: 1.5rem; font-weight: 700; }
.site-nav { display: flex; gap: 2rem; }

/* --- 主题切换按钮 --- */
.theme-toggle {
  width: 40px; height: 40px; border: 2px solid var(--border-color);
  border-radius: 50%; background: none; cursor: pointer; margin-left: 1rem;
}
.theme-toggle:hover { border-color: var(--link-color); transform: scale(1.1); }

/* ===== 5. 首页 Hero ===== */
.hero {
  text-align: center; padding: 4rem 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; border-radius: var(--radius); margin-bottom: 3rem;
}
.hero h2 { font-size: 2.5rem; font-weight: 300; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; opacity: .9; }

/* ===== 6. 文章列表（网格 + 卡片可点击） ===== */
.posts { max-width: 800px; margin: 0 auto; }
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2.5rem;                 /* 统一间距 */
}

/* --- 单张卡片 --- */
.post-item {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
}
.post-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

/* 链接覆盖整卡（保证无下划线） */
a.post-item-link {
  display: block; padding: 2rem; color: inherit; text-decoration: none;
}
a.post-item-link:hover { text-decoration: none; }

.post-item-title { font-size: 1.4rem; font-weight: 600; margin: 0 0 .5rem; }
.post-item-meta { color: var(--text-secondary); font-size: .9rem; margin-bottom: 1rem; }
.post-item-excerpt { color: var(--text-secondary); line-height: 1.6; }
.post-item-tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.tag {
  background: var(--code-bg); color: var(--text-secondary);
  padding: .3rem .8rem; border-radius: 20px; font-size: .8rem;
}
.post-item:hover .tag { background: var(--link-color); color: #fff; }

/* ===== 7. 文章详情页 ===== */
.post {
  max-width: 800px; margin: 0 auto; background: var(--card-bg);
  padding: 3rem; border-radius: var(--radius); box-shadow: var(--shadow);
}
.post-header { text-align: center; padding-bottom: 2rem; border-bottom: 1px solid var(--border-color); }
.post-title { font-size: 2.2rem; color: var(--text-color); margin-bottom: 1rem; }
.post-meta { color: var(--text-secondary); font-size: .9rem; }
.post-location { margin-left: 1rem; }
.post-location::before { content: "📍 "; }

.post-content { font-size: 1.1rem; line-height: 1.8; color: var(--text-color); }
.post-content h2, .post-content h3, .post-content h4 { margin: 2rem 0 1rem; color: var(--text-color); }
.post-content p { margin-bottom: 1.5rem; }
.post-content code { background: var(--code-bg); padding: .2rem .4rem; border-radius: var(--radius-s); font-size: .9em; }
.post-content pre { background: var(--code-bg); padding: 1.5rem; border-radius: var(--radius); overflow-x: auto; margin: 1.5rem 0; }
.post-content blockquote { border-left: 4px solid var(--link-color); padding-left: 1.5rem; margin: 1.5rem 0; font-style: italic; color: var(--text-secondary); }

.post-footer { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color); }

/* ===== 8. 文章底部导航 ===== */
.post-nav {
  max-width: 800px; margin: 2rem auto 0;
  display: flex; gap: 1rem;
}
.post-nav a {
  flex: 1; text-align: center; padding: 1rem;
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
}
.post-nav a:hover { transform: translateY(-2px); }

/* ===== 9. 分页 ===== */
.pagination {
  max-width: 800px; margin: 3rem auto 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pagination a { padding: .8rem 1.5rem; background: var(--code-bg); border-radius: var(--radius); }
.pagination a:hover { background: var(--link-color); color: #fff; }
.pagination-info { color: var(--text-secondary); }

.no-posts { text-align: center; padding: 3rem; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text-secondary); font-style: italic; }

/* ===== 10. 图片与画廊 ===== */
.image-container { margin: 1.5rem 0; text-align: center; }
.image-container img { max-width: 100%; height: auto; border-radius: var(--radius-s); box-shadow: var(--shadow); }
.image-container img:hover { transform: scale(1.02); }
.image-container figcaption { margin-top: .5rem; font-style: italic; color: var(--text-secondary); font-size: .9rem; }

.image-small { max-width: 300px;}
.image-medium { max-width: 600px; }
.image-large { max-width: 100%; }

.image-left { float: left; margin: 1rem 1.5rem 1.5rem 1rem; }
.image-right { float: right; margin: 0 0 1rem 1rem; }
.image-center { display: block; margin: 0 auto; }

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin: 2rem 0; }
.gallery-item { overflow: hidden; border-radius: var(--radius); }
.gallery-image img { width: 100%; height: 200px; object-fit: cover; transition: transform .3s; }
.gallery-image:hover img { transform: scale(1.1); }

/* ===== 11. 页脚 ===== */
.site-footer { background: var(--card-bg); color: var(--text-color); text-align: center; padding: 2rem 0; margin-top: 4rem; border-top: 1px solid var(--border-color); }

/* ===== 12. 响应式微调 ===== */
@media (max-width: 768px) {
  .header-content { flex-direction: column; gap: 1rem; }
  .site-nav { gap: 1rem; }
  .hero h2 { font-size: 2rem; }
  .post { padding: 2rem 1.5rem; }
  .post-title { font-size: 1.8rem; }
  .pagination { flex-direction: column; gap: 1rem; }
  .post-nav { flex-direction: column; }
  .gallery { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .image-left, .image-right { float: none; margin: 1rem 0; }
}

/* ===== 13. 评论区样式 ===== */
.comments-section {
  max-width: 800px;
  margin: 3rem auto 0;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--link-color);
}

.comments-section h3 {
  color: var(--text-color);
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
}

.giscus-container {
  transition: opacity 0.3s ease;
}

/* giscus主题适配 */
.giscus {
  color-scheme: light;
}

[data-theme="dark"] .giscus {
  color-scheme: dark;
}

/* 确保giscus iframe在容器内正确显示 */
.giscus-container iframe {
  width: 100% !important;
  border: none;
  border-radius: var(--radius);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .comments-section {
    margin: 2rem 1rem 0;
    padding: 1.5rem;
  }
  
  .comments-section h3 {
    font-size: 1.3rem;
  }
}

/* ===== 14. 摄影页面样式 ===== */

/* --- 14.1 摄影页面头部 --- */
.photography-header {
  text-align: center;
  padding: 3rem 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 3rem;
}

.photography-header h1 {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 1rem;
}

.photography-header p {
  font-size: 1.2rem;
  opacity: 0.9;
}

/* --- 14.2 照片集网格 --- */
.photography-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* --- 14.3 照片集卡片 --- */
.album-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.album-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
}

.album-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.album-cover {
  position: relative;
  height: 280px;
  overflow: hidden;
}

.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.album-card:hover .album-cover img {
  transform: scale(1.1);
}

/* --- 14.4 照片集信息覆盖层 --- */
.album-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  transform: translateY(60%);
  transition: transform 0.3s ease;
}

.album-card:hover .album-overlay {
  transform: translateY(0);
}

.album-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.album-desc {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.album-count {
  font-size: 0.8rem;
  opacity: 0.8;
  background: rgba(255,255,255,0.2);
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  display: inline-block;
}

/* --- 14.5 响应式调整 --- */
@media (max-width: 768px) {
  .photography-header {
    padding: 2rem 1rem;
  }
  
  .photography-header h1 {
    font-size: 2rem;
  }
  
  .photography-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0 1rem;
  }
  
  .album-cover {
    height: 220px;
  }
  
  .album-overlay {
    transform: translateY(0);
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
  }
}

/* ===== 15. 照片集详情页面样式 ===== */

/* --- 15.1 照片集头部 --- */
.album-detail {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.album-header {
  margin-bottom: 3rem;
}

.album-breadcrumb {
  margin-bottom: 2rem;
}

.album-breadcrumb a {
  color: var(--link-color);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.album-breadcrumb a:hover {
  color: var(--link-hover);
}

.album-info {
  text-align: center;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border-color);
}

.album-detail .album-title {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.album-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.album-meta time,
.album-meta .photo-count {
  background: var(--tag-bg);
  padding: 0.5rem 1rem;
  border-radius: 20px;
}

.album-description {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* --- 15.2 照片集内容描述 --- */
.album-content {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  margin-bottom: 3rem;
  line-height: 1.8;
  box-shadow: var(--shadow);
}

/* --- 15.3 照片展示网格 --- */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.photo-item {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.photo-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.photo-item img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.photo-item:hover img {
  transform: scale(1.05);
}

.photo-info {
  padding: 1rem;
}

.photo-caption {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.photo-location {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

/* --- 15.4 灯箱样式 --- */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.lightbox-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  color: #fff;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  transition: opacity 0.3s ease;
}

.lightbox-close:hover {
  opacity: 0.7;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 2rem;
  padding: 1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.3s ease;
  z-index: 1001;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
  left: 2rem;
}

.lightbox-next {
  right: 2rem;
}

#lightbox-image {
  max-width: 90%;
  max-height: 80%;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-info {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  padding: 1rem 2rem;
  border-radius: var(--radius);
  max-width: 80%;
}

.lightbox-info p {
  margin: 0.5rem 0;
}

#lightbox-counter {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* --- 15.5 响应式调整 --- */
@media (max-width: 768px) {
  .album-detail .album-title {
    font-size: 2rem;
  }
  
  .album-meta {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .photo-gallery {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .photo-item img {
    height: 200px;
  }
  
  .album-content {
    padding: 1.5rem;
  }
  
  .lightbox-content {
    padding: 1rem;
  }
  
  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
    padding: 0.8rem;
  }
  
  .lightbox-prev {
    left: 1rem;
  }
  
  .lightbox-next {
    right: 1rem;
  }
  
  .lightbox-close {
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
  }
  
  #lightbox-image {
    max-width: 95%;
    max-height: 75%;
  }
  
  .lightbox-info {
    bottom: 1rem;
    max-width: 90%;
    padding: 0.8rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .album-detail {
    padding: 0 0.5rem;
  }
  
  .album-info {
    padding: 1.5rem 0;
  }
  
  .album-detail .album-title {
    font-size: 1.8rem;
  }
}

/* ===== 16. 文章筛选控件样式 ===== */

/* --- 16.1 文章头部控件 --- */
.posts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.posts-header h3 {
  margin: 0; /* 重置标题margin，避免与你现有样式冲突 */
  color: var(--text-color);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* --- 16.2 标签筛选下拉框 --- */
.tag-filter-select {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-s);
  background: var(--card-bg);
  font-size: 0.9rem;
  color: var(--text-color);
  cursor: pointer;
  min-width: 140px;
  font-family: inherit; /* 继承你的字体设置 */
  transition: border-color 0.3s ease, box-shadow 0.3s ease; /* 使用你的过渡时间 */
}

.tag-filter-select:hover {
  border-color: var(--link-color);
}

.tag-filter-select:focus {
  outline: none;
  border-color: var(--link-color);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2); /* 使用你的link-color */
}

/* --- 16.3 暗色主题适配 --- */
[data-theme="dark"] .tag-filter-select:focus {
  box-shadow: 0 0 0 2px rgba(99, 179, 237, 0.2); /* 使用暗色主题的link-color */
}

/* --- 16.4 无结果提示 --- */
#no-results {
  /* 继承你现有的 .no-posts 样式，无需重复定义 */
}

/* --- 16.5 响应式调整 --- */
@media (max-width: 768px) {
  .posts-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
  }
  
  .filter-controls {
    width: 100%;
    justify-content: flex-end;
  }
  
  .tag-filter-select {
    min-width: 160px;
    padding: 0.7rem 1rem;
  }
}

@media (max-width: 480px) {
  .posts-header {
    gap: 1rem;
  }
  
  .filter-controls {
    justify-content: stretch;
  }
  
  .tag-filter-select {
    width: 100%;
    min-width: unset;
  }
}