/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 枫叶色系配色方案 */
:root {
  --primary: #d2691e;
  --primary-dark: #b8621a;
  --primary-light: #fef7f0;
  --secondary: #cd853f;
  --accent: #ff6b35;
  --text: #2d1810;
  --text-light: #8b4513;
  --text-muted: #a0522d;
  --background: #fffbf7;
  --card-bg: #ffffff;
  --border: #f4d7c7;
  --hover: #fff4ed;
  --warm-beige: #f5deb3;
  --maple-red: #ff4500;
  --focus-ring: rgba(210, 105, 30, 0.3);
}

/* 优化后的页面加载动画 - 减少同时触发的动画 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 优化bounce动画 - 减少变换幅度 */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-2px);
  }
  60% {
    transform: translateY(-1px);
  }
}

/* 移除body的动画，改为只在首次加载时应用 */
body {
  background-color: var(--background);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* 简化背景渐变 */
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255, 107, 53, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(205, 133, 63, 0.03) 0%, transparent 50%);
}

/* 优化导航栏 - 移除backdrop-filter减少GPU负担 */
header {
  background-color: var(--card-bg);
  border-bottom: 2px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  /* 移除backdrop-filter，改用普通阴影 */
  box-shadow: 0 2px 8px rgba(210, 105, 30, 0.08);
  /* 只在首次加载时应用动画 */
  animation: slideInLeft 0.6s ease-out;
}

nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 0;
}

nav ul li {
  display: inline-block;
}

nav a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 20px;
  transition: all 0.2s ease; /* 缩短过渡时间 */
  position: relative;
  outline: none;
  /* 启用GPU加速 */
  will-change: transform;
}

nav a:hover {
  color: white;
  background: linear-gradient(135deg, rgba(210, 105, 30, 0.8), rgba(205, 133, 63, 0.8));
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(210, 105, 30, 0.15); /* 减少阴影复杂度 */
}

nav a:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

nav a.active {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font-weight: 500;
  border-radius: 20px;
  box-shadow: 0 3px 8px rgba(210, 105, 30, 0.25); /* 减少阴影复杂度 */
}

nav a.active:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-1px);
}

nav a.active::after {
  content: "";
  position: absolute;
  bottom: -21px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
}

/* 主要内容区 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 30px;
  flex: 1;
}

/* 优化卡片样式 - 减少动画延迟和复杂度 */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
  transition: all 0.2s ease; /* 缩短过渡时间 */
  box-shadow: 0 2px 6px rgba(210, 105, 30, 0.04); /* 减少阴影复杂度 */
  /* 只在首次加载时应用动画 */
  animation: fadeInUp 0.4s ease-out;
  animation-fill-mode: both;
  will-change: transform; /* 启用GPU加速 */
}

.card:hover {
  border-color: var(--secondary);
  box-shadow: 0 4px 12px rgba(210, 105, 30, 0.08); /* 减少阴影复杂度 */
  transform: translateY(-1px); /* 减少变换幅度 */
}

/* 减少动画延迟 */
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

/* 优化按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--card-bg);
  color: var(--text);
  transition: all 0.2s ease; /* 缩短过渡时间 */
  cursor: pointer;
  position: relative;
  outline: none;
  will-change: transform; /* 启用GPU加速 */
}

/* 简化按钮波纹效果 */
.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s; /* 缩短动画时间 */
  pointer-events: none;
}

.btn:active::before {
  width: 150px; /* 减少波纹大小 */
  height: 150px;
}

.btn:hover {
  background-color: var(--hover);
  border-color: var(--secondary);
  transform: translateY(-1px);
  /* 移除bounce动画，减少复杂度 */
}

.btn:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(210, 105, 30, 0.15); /* 减少阴影复杂度 */
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-color: var(--primary-dark);
  box-shadow: 0 3px 8px rgba(210, 105, 30, 0.2); /* 减少阴影复杂度 */
  /* 移除bounce动画 */
}

.btn-primary:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 优化表单样式 */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--background);
  color: var(--text);
  transition: all 0.2s ease; /* 缩短过渡时间 */
  outline: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--focus-ring); /* 减少阴影复杂度 */
  transform: scale(1.01); /* 减少缩放幅度 */
}

.form-input:invalid {
  border-color: var(--maple-red);
  box-shadow: 0 0 0 2px rgba(255, 69, 0, 0.1);
}

.form-input.error {
  border-color: var(--maple-red);
  background-color: rgba(255, 69, 0, 0.05);
  animation: shake 0.3s ease-in-out; /* 缩短动画时间 */
}

/* 优化shake动画 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); } /* 减少摇摆幅度 */
  75% { transform: translateX(2px); }
}

.form-error {
  color: var(--maple-red);
  font-size: 12px;
  margin-top: 4px;
  display: none;
  animation: fadeInUp 0.2s ease; /* 缩短动画时间 */
}

.form-error.show {
  display: block;
}

.form-success {
  color: var(--primary);
  font-size: 12px;
  margin-top: 4px;
  display: none;
  animation: fadeInUp 0.2s ease; /* 缩短动画时间 */
}

.form-success.show {
  display: block;
}

/* 标题样式 */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.3;
}

h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }

/* 段落样式 */
p {
  color: var(--text-light);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* 链接样式 */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease; /* 缩短过渡时间 */
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* 页脚 */
footer {
  background: linear-gradient(135deg, var(--primary-light), var(--warm-beige));
  border-top: 2px solid var(--border);
  padding: 40px 0;
  margin-top: 60px;
}

footer .container {
  text-align: center;
  padding: 0 30px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

footer p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
  text-align: center;
}

/* 优化响应式设计 */
@media (max-width: 768px) {
  header {
    padding: 15px 0;
  }

  nav {
    padding: 0 20px;
  }

  nav ul {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  nav a {
    font-size: 14px;
    padding: 10px 16px;
  }

  .container {
    padding: 40px 20px;
  }

  .card {
    padding: 24px;
  }

  h1 { font-size: 28px; }
  h2 { font-size: 22px; }

  footer {
    padding: 30px 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 30px 15px;
  }

  .card {
    padding: 20px;
  }

  nav a {
    padding: 8px 12px;
    font-size: 13px;
  }

  .btn {
    padding: 10px 20px;
    font-size: 13px;
  }
}

/* 简化加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite; /* 改为linear使动画更流畅 */
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 工具提示 */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: var(--text);
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 5px 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.2s; /* 缩短过渡时间 */
  font-size: 12px;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* 优化滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--primary-light);
}

::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}

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

/* 渐变文字效果 */
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
}

/* 优化交互式元素 */
.interactive {
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease; /* 缩短过渡时间 */
  will-change: transform;
}

.interactive:hover {
  transform: scale(1.03); /* 减少缩放幅度 */
}

.interactive:active {
  transform: scale(0.97); /* 减少缩放幅度 */
}

/* 优化页面切换动画 */
.page-transition {
  animation: pageSlideIn 0.3s ease-out; /* 缩短动画时间 */
}

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px); /* 减少移动距离 */
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 添加首次加载动画类 */
.first-load {
  animation: fadeInUp 0.6s ease-out;
}

/* 性能优化：减少重绘和回流 */
.card,
.btn,
nav a,
.form-input {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
