/* 基础重置与变量定义（全局生效） */
:root {
  /* 品牌核心色 */
  --brand-primary: #2563eb;
  /* 主蓝色 */
  --brand-primary-light: #3b82f6;
  --brand-primary-dark: #1d4ed8;
  --brand-secondary: #10b981;
  /* 辅助绿 */

  /* 中性色 */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-700: #334155;
  --neutral-900: #1e293b;

  /* 功能色 */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* 通用尺寸 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 品牌LOGO样式 */
.brand-logo {
  width: 32px;
  /* 图标宽度，可根据实际logo大小调整 */
  height: 32px;
  /* 图标高度，保持与宽度一致 */
  object-fit: contain;
  /* 确保图片不变形 */
  border-radius: 4px;
  /* 轻微圆角，可选 */
}

/* 适配移动端 */
@media (max-width: 768px) {
  .brand-logo {
    width: 28px;
    height: 28px;
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--neutral-900);
  line-height: 1.5;
  /* body背景不固定，由各页面自行定义 */
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--brand-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

button,
.btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

/* 公共容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部导航样式（核心调整：透明背景，hover变实） */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  background-color: transparent;
  /* 默认透明背景 */
}

/* 鼠标悬停或滚动时导航栏变实 */
.site-header:hover,
.site-header.scrolled {
  background-color: white;
  /* 实色背景 */
  box-shadow: var(--shadow-sm);
  /* 增加阴影增强层次感 */
}

/* 品牌LOGO（适配透明/实色背景） */
.site-header .brand {
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.3s ease;
  color: var(--neutral-900);
  /* 默认深色文字（适配浅色页面） */
}

/* 若页面背景为深色，可在对应页面添加此类 */
.site-header.dark-bg .brand {
  color: white;
  /* 深色背景下的白色文字 */
}

.site-header:hover .brand,
.site-header.scrolled .brand {
  color: var(--brand-primary);
  /* 背景实色时LOGO变品牌色 */
}

/* 导航链接（适配透明/实色背景） */
.site-header nav {
  display: flex;
  gap: 24px;
}

.site-header nav a {
  font-weight: 500;
  padding: 6px 0;
  position: relative;
  transition: color 0.3s ease;
  color: var(--neutral-700);
  /* 默认灰色文字（适配浅色页面） */
}

/* 深色背景页面的导航文字 */
.site-header.dark-bg nav a {
  color: rgba(255, 255, 255, 0.8);
}

/* 背景变实时的导航文字 */
.site-header:hover nav a,
.site-header.scrolled nav a {
  color: var(--neutral-900);
}

.site-header.dark-bg:hover nav a,
.site-header.dark-bg.scrolled nav a {
  color: var(--neutral-900);
  /* 深色背景hover后统一深色文字 */
}

/* 导航链接hover效果 */
.site-header nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--brand-primary);
  transition: width 0.2s ease;
}

.site-header nav a:hover::after {
  width: 100%;
}

/* 当前页导航高亮 */
.site-header nav a.active {
  color: var(--brand-primary);
}

.site-header nav a.active::after {
  width: 100%;
}

/* 页脚样式 */
.site-footer {
  padding: 40px 20px 20px;
  color: var(--neutral-700);
  text-align: center;
  margin-top: 60px;
  background-color: transparent;
  /* 页脚背景也透明，由页面自行定义 */
}

.site-footer::before {
  content: '';
  display: block;
  width: 80px;
  height: 3px;
  background-color: var(--brand-primary);
  margin: 0 auto 20px;
  opacity: 0.5;
}

.site-footer a {
  margin: 0 8px;
  color: var(--neutral-700);
}

.site-footer a:hover {
  color: var(--brand-primary);
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--brand-primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--brand-secondary);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--brand-secondary-light);
}

/* 卡片样式 */
.card {
  display: block;
  background-color: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  color: inherit;
  text-decoration: none;
  border: 1px solid transparent;
}

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

.card .card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
  background-color: var(--neutral-50);
  padding: 16px;
}

.card .card-body {
  padding: 16px;
}

.card .card-title {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--neutral-900);
  font-weight: 600;
}

.card .card-desc {
  color: var(--neutral-700);
  font-size: 0.9rem;
}

/* 网格布局 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  margin: 30px 0;
}

/* 搜索框样式 */
.search {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: all 0.2s ease;
  background-color: white;
}

.search:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 回到顶部按钮 */
#back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  color: white;
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#back-to-top.show {
  opacity: 1;
  transform: translateY(0);
}

#back-to-top:hover {
  background-color: var(--brand-primary-light);
}

/* 响应式适配 */
@media (max-width: 768px) {
  .site-header {
    padding: 12px 16px;
  }

  .site-header nav {
    gap: 16px;
  }

  .btn {
    padding: 9px 16px;
    font-size: 0.9rem;
    width: 100%;
    margin: 8px 0;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
  }
}

/* 在公共样式的media query中补充 */
@media (max-width: 400px) {

  /* 超窄屏幕下的导航栏 */
  .site-header {
    padding: 10px 12px;
    /* 进一步缩小内边距 */
  }

  .site-header nav {
    gap: 10px;
    /* 导航链接间距缩小 */
  }

  .brand {
    font-size: 1.1rem;
    /* 品牌名字体缩小 */
  }

  .brand-logo {
    width: 26px;
    height: 26px;
    /* LOGO缩小 */
  }

  .site-header nav a {
    font-size: 0.85rem;
    /* 导航文字缩小 */
  }

  /* 网格布局适应超窄屏幕 */
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    /* 最小宽度进一步缩小 */
    gap: 12px;
    /* 网格间距缩小 */
  }

  /* 卡片文字缩小 */
  .card .card-title {
    font-size: 1rem;
  }

  .card .card-desc {
    font-size: 0.85rem;
  }
}