/* ==================== 主题变量定义 ==================== */

/* 深色主题（默认） */
:root,
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --border: #30363d;
  --green: #3fb950;
  --purple: #a371f7;
  --orange: #f0883e;
  --red: #ff7b72;
  --font-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  
  /* 导航栏背景 */
  --nav-bg: rgba(13, 17, 23, 0.9);
  
  /* 代码块 */
  --code-bg: #161b22;
  --code-text: #c9d1d9;
  
  /* 滚动条 */
  --scrollbar-track: #21262d;
  --scrollbar-thumb: #30363d;
  --scrollbar-thumb-hover: #484f58;
  
  /* Matrix 背景透明度 */
  --matrix-opacity: 0.1;
  --matrix-color: #58a6ff;
  
  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 4px 20px rgba(88, 166, 255, 0.2);
}

/* 浅色主题 */
[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --text: #24292f;
  --text-muted: #57606a;
  --accent: #0969da;
  --accent-dim: #0550ae;
  --border: #d0d7de;
  --green: #1a7f37;
  --purple: #8250df;
  --orange: #bf5700;
  --red: #cf222e;
  
  /* 导航栏背景 */
  --nav-bg: rgba(246, 248, 250, 0.95);
  
  /* 代码块 */
  --code-bg: #f6f8fa;
  --code-text: #24292f;
  
  /* 滚动条 */
  --scrollbar-track: #f0f0f0;
  --scrollbar-thumb: #c1c1c1;
  --scrollbar-thumb-hover: #a8a8a8;
  
  /* Matrix 背景透明度 */
  --matrix-opacity: 0.06;
  --matrix-color: #0969da;
  
  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-accent: 0 4px 20px rgba(9, 105, 218, 0.15);
}

/* ==================== 主题切换按钮 ==================== */
.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.theme-toggle .sun-icon {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

.theme-toggle .moon-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="light"] .theme-toggle .sun-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="light"] .theme-toggle .moon-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

/* ==================== 全局过渡效果 ==================== */
body,
body *:not(script):not(style) {
  transition: background-color 0.3s ease, 
              border-color 0.3s ease, 
              color 0.3s ease,
              box-shadow 0.3s ease;
}

/* 排除动画元素的过渡 */
.floating-symbol,
.steam-line,
.code-line,
#matrix-bg,
[class*="animate"],
[class*="typing"] {
  transition: none !important;
}

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ==================== 浅色主题特殊调整 ==================== */

/* 导航栏 */
[data-theme="light"] nav {
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Logo 颜色 */
[data-theme="light"] .logo {
  color: var(--accent);
}

/* 卡片阴影 */
[data-theme="light"] .blog-item,
[data-theme="light"] .sidebar-card,
[data-theme="light"] .category-card,
[data-theme="light"] .tag-card,
[data-theme="light"] .project-card,
[data-theme="light"] .comment-item,
[data-theme="light"] .terminal,
[data-theme="light"] .profile-card {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .blog-item:hover,
[data-theme="light"] .sidebar-card:hover,
[data-theme="light"] .category-card:hover,
[data-theme="light"] .tag-card:hover,
[data-theme="light"] .project-card:hover {
  box-shadow: var(--shadow-md);
}

/* 代码块 */
[data-theme="light"] .article-content pre {
  background: #f6f8fa;
  border-color: var(--border);
}

[data-theme="light"] .article-content p code {
  background: #eff1f3;
  color: #0550ae;
}

/* 引用块 */
[data-theme="light"] .article-content blockquote {
  background: #f6f8fa;
  border-left-color: var(--accent);
}

/* 终端样式 */
[data-theme="light"] .terminal-header {
  background: #e6e8eb;
}

[data-theme="light"] .terminal-body {
  background: #1e1e1e;
  color: #d4d4d4;
}

[data-theme="light"] .terminal-prompt {
  color: #4ec9b0;
}

[data-theme="light"] .terminal-output {
  color: #9cdcfe;
}

/* 按钮样式 */
[data-theme="light"] .load-more-btn,
[data-theme="light"] #to-top,
[data-theme="light"] .share-btn {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .load-more-btn:hover,
[data-theme="light"] #to-top:hover,
[data-theme="light"] .share-btn:hover {
  box-shadow: var(--shadow-md);
}

/* 标签样式 */
[data-theme="light"] .blog-tag,
[data-theme="light"] .article-tag {
  background: var(--accent);
  color: #fff;
}

/* 热门标签 */
[data-theme="light"] .hot-tag-item {
  background: var(--bg);
}

[data-theme="light"] .tag-count {
  background: var(--accent);
}

/* 热门博客排名 */
[data-theme="light"] .hot-blog-item {
  background: var(--bg);
}

/* 评论区 */
[data-theme="light"] .comment-form,
[data-theme="light"] .comment-item {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .comment-reply {
  background: rgba(9, 105, 218, 0.06);
}

/* 表单输入 */
[data-theme="light"] .form-input {
  background: var(--bg);
}

[data-theme="light"] .form-input:focus {
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

/* 目录侧边栏 */
[data-theme="light"] .toc {
  box-shadow: var(--shadow-sm);
}

/* 文章导航 */
[data-theme="light"] .post-nav-item {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .post-nav-item:hover {
  box-shadow: var(--shadow-md);
}

/* 技能进度条 */
[data-theme="light"] .skill-bar {
  background: #e6e8eb;
}

/* 统计卡片 */
[data-theme="light"] .stat-item {
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .stat-item:hover {
  box-shadow: var(--shadow-md);
}

/* 搜索框 */
[data-theme="light"] .nav-search-form {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .nav-search-form:focus-within {
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

/* 时间线 */
[data-theme="light"] .blog-list::before {
  background: var(--border);
}

[data-theme="light"] .blog-item::before {
  background: var(--bg-card);
  border-color: var(--accent);
}

/* 浮动程序员动画容器 */
[data-theme="light"] .floating-coder-container.with-bg {
  background: linear-gradient(135deg, #e8eef5 0%, #dce4ed 100%);
  box-shadow: var(--shadow-md);
}

/* 页脚 */
[data-theme="light"] footer {
  background: var(--bg-card);
}

/* ==================== 文章详情页浅色主题调整 ==================== */

/* 文章标题 - 原本是 #fff */
[data-theme="light"] .article-header h1 {
  color: #1f2328;
}

/* 文章内容中的标题 */
[data-theme="light"] .article-content h2 {
  color: var(--accent);
}

[data-theme="light"] .article-content h3 {
  color: #1f2328;
}

[data-theme="light"] .article-content strong {
  color: #1f2328;
}

/* 页面标题 */
[data-theme="light"] .page-title {
  color: var(--accent);
}

/* 侧边栏标题 */
[data-theme="light"] .sidebar-title {
  color: var(--text);
}

[data-theme="light"] .sidebar-section-title {
  color: var(--accent);
}

/* 个人简介名字 */
[data-theme="light"] .profile-name {
  color: #1f2328;
}

/* 分类/标签卡片名称 */
[data-theme="light"] .category-name,
[data-theme="light"] .tag-name {
  color: #1f2328;
}

/* 热门博客标题 */
[data-theme="light"] .hot-blog-title {
  color: var(--text);
}

/* 博客列表标题 */
[data-theme="light"] .blog-title {
  color: var(--text);
}

/* 评论作者 */
[data-theme="light"] .comment-author {
  color: var(--accent);
}

/* 目录标题 */
[data-theme="light"] .toc-title {
  color: var(--accent);
}

/* 评论区标题 */
[data-theme="light"] .comments-title {
  color: var(--accent);
}

/* 分享区标题 */
[data-theme="light"] .share-title {
  color: var(--text-muted);
}

/* 上下篇导航标题 */
[data-theme="light"] .post-nav-title {
  color: var(--text);
}

[data-theme="light"] .post-nav-item:hover .post-nav-title {
  color: var(--accent);
}
