/**
 * =====================================================
 * 全局样式文件 (global.css)
 * =====================================================
 * 说明：
 * - 定义深色科技主题的核心样式变量
 * - 提供通用工具类、动画效果、组件基础样式
 * - 蓝紫渐变霓虹主题（#6366f1 -> #8b5cf6）
 * - 使用 Inter 字体作为主字体，JetBrains Mono 用于代码块
 * =====================================================
 */

/* =====================================================
 * 一、CSS 自定义属性（设计变量）
 * =====================================================
 * 使用 :root 定义全局 CSS 变量，便于统一管理和主题切换
 */
:root {
  /* 背景色 - 深色科技风格 */
  --bg-primary: #0f172a;    /* 主背景色：深蓝灰 */
  --bg-secondary: #1e293b;  /* 次背景色：稍浅的深蓝灰 */
  --bg-tertiary: #334155;   /* 第三背景色：用于卡片等 */

  /* 文字颜色 */
  --text-primary: #e2e8f0;    /* 主文字色：浅灰白 */
  --text-secondary: #94a3b8;  /* 次文字色：中灰 */
  --text-muted: #64748b;      /* 辅助文字色：深灰 */

  /* 主题色 - 蓝紫渐变霓虹 */
  --neon-start: #6366f1;  /* 霓虹渐变起点：靛蓝 */
  --neon-end: #8b5cf6;    /* 霓虹渐变终点：紫色 */
  --neon-glow: rgba(99, 102, 241, 0.5);  /* 霓虹光晕颜色 */

  /* 边框与分割线 */
  --border-color: rgba(148, 163, 184, 0.15);  /* 半透明边框色 */
  --border-hover: rgba(148, 163, 184, 0.3);   /* 悬停边框色 */

  /* 阴影效果 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-neon: 0 0 20px var(--neon-glow);  /* 霓虹发光阴影 */

  /* 圆角 */
  --radius-sm: 0.375rem;   /* 小圆角 6px */
  --radius-md: 0.5rem;     /* 中圆角 8px */
  --radius-lg: 1rem;       /* 大圆角 16px */
  --radius-full: 9999px;   /* 完全圆角 */

  /* 过渡动画 */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* =====================================================
 * 二、全局重置与基础样式
 * =====================================================
 * 确保所有浏览器使用一致的样式基准
 */

/* 导入 Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* 全局基础样式 */
*,
*::before,
*::after {
  box-sizing: border-box;     /* 统一盒模型 */
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;    /* 平滑滚动效果 */
  font-size: 16px;            /* 基准字号 */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;           /* 舒适的行高 */
  -webkit-font-smoothing: antialiased;   /* 字体抗锯齿（Mac） */
  -moz-osx-font-smoothing: grayscale;    /* 字体抗锯齿（Windows） */
  overflow-x: hidden;         /* 禁止横向溢出 */
}

/* 代码块使用等宽字体 */
code,
pre,
.code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* 链接默认样式 */
a {
  color: var(--neon-start);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--neon-end);
}

/* 图片响应式 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 移除列表默认样式 */
ul,
ol {
  list-style: none;
}

/* 按钮基础样式 */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

/* 输入框基础样式 */
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

/* =====================================================
 * 三、滚动条样式（Webkit 浏览器）
 * =====================================================
 * 自定义滚动条以匹配深色科技主题
 */
::-webkit-scrollbar {
  width: 8px;       /* 垂直滚动条宽度 */
  height: 8px;      /* 水平滚动条高度 */
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neon-start);
}

/* =====================================================
 * 四、通用工具类
 * =====================================================
 * 提供常用样式类，方便页面快速布局
 */

/* 容器居中 */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* 网格布局工具 */
.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

.gap-8 {
  gap: 2rem;
}

/* Flex 布局工具 */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

/* 间距工具 */
.mt-4  { margin-top: 1rem; }
.mt-8  { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.mt-16 { margin-top: 4rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-8  { margin-bottom: 2rem; }

/* 文字对齐 */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

/* 字体大小 */
.text-sm   { font-size: 0.875rem; }   /* 14px */
.text-base { font-size: 1rem; }        /* 16px */
.text-lg   { font-size: 1.125rem; }   /* 18px */
.text-xl   { font-size: 1.25rem; }    /* 20px */
.text-2xl  { font-size: 1.5rem; }     /* 24px */
.text-3xl  { font-size: 1.875rem; }   /* 30px */
.text-4xl  { font-size: 2.25rem; }    /* 36px */
.text-5xl  { font-size: 3rem; }       /* 48px */

/* 字体粗细 */
.font-light   { font-weight: 300; }
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }

/* 文字颜色 */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-neon      { color: var(--neon-start); }

/* 显示控制 */
.hidden   { display: none; }
.block    { display: block; }
.inline-block { display: inline-block; }

/* 圆角 */
.rounded-sm  { border-radius: var(--radius-sm); }
.rounded-md  { border-radius: var(--radius-md); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* 阴影 */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* =====================================================
 * 五、霓虹主题效果
 * =====================================================
 * 蓝紫渐变霓虹效果的核心样式
 */

/* 渐变文字效果 */
.text-gradient {
  background: linear-gradient(135deg, var(--neon-start), var(--neon-end));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 霓虹发光边框 */
.neon-border {
  border: 1px solid var(--border-color);
  transition: all var(--transition-base);
}

.neon-border:hover {
  border-color: var(--neon-start);
  box-shadow: var(--shadow-neon);
}

/* 霓虹按钮 */
.btn-neon {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--neon-start), var(--neon-end));
  color: white;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-neon:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-neon);
  color: white;
}

.btn-neon:active {
  transform: translateY(0);
}

/* 轮廓按钮（霓虹边框） */
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--neon-start);
  color: var(--neon-start);
  transition: all var(--transition-base);
}

.btn-outline:hover {
  background: var(--neon-start);
  color: white;
  box-shadow: var(--shadow-neon);
}

/* 霓虹分割线 */
.neon-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-start), var(--neon-end), transparent);
  border: none;
  margin: 2rem 0;
}

/* =====================================================
 * 六、卡片基础样式
 * =====================================================
 * 用于工具、项目、博客等卡片组件的统一风格
 */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.card-icon {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--neon-start), var(--neon-end));
  color: white;
  font-size: 1.25rem;
}

/* =====================================================
 * 七、标签/徽章样式
 * =====================================================
 * 用于技术标签、分类标签的展示
 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.badge:hover {
  background: var(--neon-start);
  color: white;
}

/* =====================================================
 * 八、动画效果
 * =====================================================
 * 定义常用 CSS 动画关键帧及工具类
 */

/* 渐入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.6s ease forwards;
}

/* 霓虹脉冲动画 */
@keyframes neonPulse {
  0%, 100% {
    box-shadow: 0 0 10px var(--neon-glow), 0 0 20px var(--neon-glow);
  }
  50% {
    box-shadow: 0 0 20px var(--neon-glow), 0 0 40px var(--neon-glow);
  }
}

.animate-neon-pulse {
  animation: neonPulse 2s ease-in-out infinite;
}

/* 打字机光标动画 */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.animate-blink {
  animation: blink 1s step-end infinite;
}

/* 延迟动画类 */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* =====================================================
 * 九、分区标题样式
 * =====================================================
 * 用于各模块（工具、项目、博客等）的标题统一样式
 */
.section-title {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
}

.section-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 3rem;
}

/* =====================================================
 * 十、导航栏样式
 * =====================================================
 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.85);   /* 半透明背景 */
  backdrop-filter: blur(12px);          /* 毛玻璃效果 */
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-base);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
  color: var(--neon-start);
  background: rgba(99, 102, 241, 0.1);
}

/* =====================================================
 * 十一、页脚样式
 * =====================================================
 */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
}

/* =====================================================
 * 十二、响应式断点
 * =====================================================
 * 适配不同屏幕尺寸
 */

/* 平板端（宽度 <= 1024px） */
@media (max-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* 移动端（宽度 <= 768px） */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 2rem;
  }

  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* 小屏手机（宽度 <= 480px） */
@media (max-width: 480px) {
  .card {
    padding: 1rem;
  }

  .btn-neon,
  .btn-outline {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
  }
}
