/* ========== 1. CSS变量与主题系统 ========== */
:root {
  --bg: #f9f7f4;
  --card: #ffffff;
  --text: #3a3a38;
  --sub: #8a8a88;
  --accent: #96a3a3;
  --border: #e6e2dc;

  /* 二次元风格扩展色 */
  --gradient-primary: linear-gradient(135deg, #ffb6c1 0%, #dda0dd 50%, #b0c4de 100%);
  --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
  --shadow-soft: 0 4px 20px rgba(176, 196, 222, 0.25);
  --shadow-glow: 0 0 20px rgba(255, 182, 193, 0.4);

  /* 动效常量 */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);

  /* 圆角体系 */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* 暗色模式变量覆盖 */
body.dark {
  --bg: #1a1a2e;
  --card: #252540;
  --text: #e0e0ff;
  --sub: #a0a0c0;
  --accent: #c9a0dc;
  --border: #3a3a5c;
  --gradient-card: linear-gradient(145deg, rgba(37,37,64,0.9), rgba(37,37,64,0.7));
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ========== 2. 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  line-height: 1.7;
  transition: background var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--gradient-primary);
  border-radius: 4px;
}

/* 文字选中效果 */
::selection {
  background: rgba(255, 182, 193, 0.4);
  color: var(--text);
}

/* ========== 3. 导航栏通用 ========== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 30px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 99;
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
}

.logo {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.logo:hover {
  transform: scale(1.05);
  text-shadow: 0 0 8px rgba(255, 182, 193, 0.5);
}

.menu {
  display: flex;
  gap: 24px;
}
.menu a {
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  position: relative;
  transition: color var(--transition-fast);
}
.menu a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: width var(--transition-normal);
  border-radius: 2px;
}
.menu a:hover {
  color: var(--accent);
}
.menu a:hover::after {
  width: 100%;
}

.toggle-dark {
  cursor: pointer;
  font-size: 14px;
  color: var(--sub);
  user-select: none;
  transition: all var(--transition-fast);
}
.toggle-dark:hover {
  transform: rotate(2deg) scale(1.1);
}

.hamburger {
  display: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
  transition: transform var(--transition-fast);
}
.hamburger:hover {
  transform: scale(1.1);
}

/* 移动端菜单 */
.mobile-menu {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  width: 100%;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 20px 30px;
  flex-direction: column;
  gap: 16px;
  z-index: 98;
  transform: translateY(-100%);
  opacity: 0;
  transition: all var(--transition-normal);
}
.mobile-menu.show {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
.mobile-menu a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

/* ========== 4. 通用容器与标题 ========== */
.container {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 20px;
}

.section {
  margin-bottom: 50px;
}

.section-title {
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.section-title::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: 2px;
}
.section-title .section-more {
  float: right;
  font-size: 14px;
  font-weight: normal;
  color: var(--sub);
  text-decoration: none;
  line-height: 2.4;
  transition: color var(--transition-fast);
}
.section-title .section-more:hover {
  color: var(--accent);
}

/* ========== 5. 通用卡片组件 ========== */
.blog-grid, .tool-grid {
  display: grid;
  gap: 20px;
}
.blog-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.tool-grid {
  grid-template-columns: repeat(2, 1fr);
}

.blog-card, .tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
}
.blog-card:hover, .tool-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-glow);
  border-color: transparent;
}

.blog-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  transition: transform var(--transition-slow);
}
.blog-card:hover img {
  transform: scale(1.05);
}

/* 懒加载淡入 + 滚动入场（让 effects.js / lazyload.js 在博客页真正生效） */
.blog-card img {
  opacity: 0;
  transition: opacity var(--transition-normal), transform var(--transition-slow);
}
.blog-card img.loaded {
  opacity: 1;
}

.blog-card {
  opacity: 0;
  transform: translateY(16px);
}
.blog-card.animate-in {
  opacity: 1;
  transform: translateY(0);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-info {
  padding: 15px;
}
.blog-title {
  font-size: 16px;
  margin-bottom: 6px;
}
.blog-meta {
  font-size: 12px;
  color: var(--sub);
}
.blog-views {
  font-size: 12px;
  color: var(--sub);
  margin-top: 4px;
}

.tool-card {
  padding: 22px;
  text-align: center;
  background: var(--gradient-card);
  backdrop-filter: blur(10px);
}
.tool-card small {
  display: block;
  color: var(--sub);
  font-size: 12px;
  margin-top: 4px;
}

/* ========== 6. 灯箱通用 ========== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-img {
  max-width: 90%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  transform: scale(0.9);
  transition: transform var(--transition-normal);
}
.lightbox.active .lightbox-img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 30px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-fast);
}
.lightbox-close:hover {
  transform: rotate(90deg) scale(1.2);
}

.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  padding: 0 16px;
  user-select: none;
  transition: all var(--transition-fast);
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-prev:hover, .lightbox-next:hover {
  transform: translateY(-50%) scale(1.2);
  text-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.lightbox-bottom {
  margin-top: 16px;
  color: #fff;
  text-align: center;
}
.lightbox-exif {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 8px;
}
.lightbox-download {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid #fff;
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all var(--transition-fast);
}
.lightbox-download:hover {
  background: #fff;
  color: #333;
}

/* ========== 7. 回到顶部 ========== */
.back-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: none;
  z-index: 97;
  box-shadow: var(--shadow-soft);
  transition: all var(--transition-normal);
}
.back-top.show {
  display: block;
}
.back-top:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

/* ========== 8. 页脚通用 ========== */
.footer {
  text-align: center;
  padding: 30px;
  font-size: 14px;
  color: var(--sub);
  border-top: 1px solid var(--border);
}
.footer-icp {
  margin-top: 6px;
  font-size: 12px;
  color: var(--sub);
  opacity: 0.85;
}
.footer--cover {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 12px 20px;
  border-top: none;
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}
.footer--cover .footer-icp {
  color: rgba(255, 255, 255, 0.6);
}
.social-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0;
}
.social-link {
  font-size: 22px;
  color: var(--sub);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.social-link:hover {
  color: var(--accent);
  transform: translateY(-3px) scale(1.1);
}

/* 图片懒加载占位 */
.album-item, .blog-card img, .article-cover {
  background: #ddd;
}
body.dark .album-item, body.dark .blog-card img, body.dark .article-cover {
  background: #333;
}

/* 头像光晕效果 */
.about-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box,
              var(--gradient-primary) border-box;
  box-shadow: 0 0 20px rgba(255, 182, 193, 0.3);
  animation: avatarGlow 3s ease-in-out infinite;
}
@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 182, 193, 0.3); }
  50% { box-shadow: 0 0 30px rgba(221, 160, 223, 0.5); }
}

/* ========== 9. 响应式基础 ========== */
@media (max-width:768px) {
  .menu { display: none; }
  .hamburger { display: block; }
  .tool-grid { grid-template-columns: 1fr; }
  .album-wrap { columns: 2; }
  .about-box { flex-direction: column; text-align: center; }
  .article-title { font-size: 24px; }
}
