/* ============================================
   Base Variables & Typography
   配色方案：紫色主色 + 暖色强调
   ============================================ */

:root {
  /* --- 主色系：紫色 --- */
  --color-primary: #7c3aed;
  --color-primary-hover: #6d28d9;
  --color-primary-active: #5b21b6;
  --color-primary-light: #a78bfa;
  --color-primary-lighter: #ddd6fe;
  --color-primary-bg: #f5f3ff;

  /* --- 强调色：琥珀 --- */
  --color-accent: #f59e0b;
  --color-accent-hover: #d97706;
  --color-accent-light: #fde68a;

  /* --- 中性色 --- */
  --color-white: #ffffff;
  --color-bg: #fafafa;
  --color-bg-alt: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* --- 文字 --- */
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;

  /* --- 语义色 --- */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;

  /* --- 字体 --- */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'Fira Code', 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* --- 字号系统（1.25 比例尺） --- */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.75rem;     /* 60px */

  /* --- 间距系统（8px 基线） --- */
  --space-1: 0.25rem;     /* 4px */
  --space-2: 0.5rem;      /* 8px */
  --space-3: 0.75rem;     /* 12px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-8: 2rem;        /* 32px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */

  /* --- 圆角 --- */
  --radius-sm: 0.375rem;    /* 6px */
  --radius-md: 0.5rem;      /* 8px */
  --radius-lg: 0.75rem;     /* 12px */
  --radius-xl: 1rem;        /* 16px */
  --radius-2xl: 1.5rem;     /* 24px */
  --radius-full: 9999px;

  /* --- 阴影 --- */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgb(124 58 237 / 0.15);

  /* --- 过渡 --- */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* --- 布局 --- */
  --container-max: 1200px;
  --container-narrow: 800px;
  --header-height: 64px;
}

/* ====== 暗色主题 ====== */
[data-theme="dark"] {
  --color-primary: #a78bfa;
  --color-primary-hover: #c4b5fd;
  --color-primary-active: #ddd6fe;
  --color-primary-light: #7c3aed;
  --color-primary-lighter: #4c1d95;
  --color-primary-bg: #1e1b4b;

  --color-accent: #fbbf24;
  --color-accent-hover: #fcd34d;
  --color-accent-light: #92400e;

  --color-bg: #0f172a;
  --color-bg-alt: #1e293b;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-border-light: #1e293b;

  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-text-inverse: #0f172a;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4);
  --shadow-glow: 0 0 20px rgb(167 139 250 / 0.1);
}

/* ====== 基础重置 & 排版 ====== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ====== 排版层级 ====== */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  color: var(--color-text);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

/* ====== 容器 ====== */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ====== 主要内容区域 ====== */
.main-content {
  min-height: calc(100vh - var(--header-height) - 320px);
  padding-top: var(--header-height);
}

/* ====== 内容正文样式 ====== */
.content {
  font-size: var(--text-base);
  line-height: 1.8;
}

.content h2 {
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.content h3 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.content p {
  margin-bottom: var(--space-4);
}

.content ul,
.content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.content li {
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
}

.content blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-bg);
  border-radius: var(--radius-md);
}

/* ====== 选择器 ====== */
::selection {
  background-color: var(--color-primary-lighter);
  color: var(--color-text);
}

/* ====== 自定义滚动条 ====== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

/* ====== 锚点定位修正（固定导航栏遮挡） ====== */
:target {
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}

/* 同时给所有带 ID 的 section 预设 scroll-margin */
section[id],
article[id],
div[id] {
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}

/* ====== Animations ====== */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Staggered entrance for grid items */
.features-grid > .feature-card,
.tests-grid > .test-card,
.listing-grid > .test-card {
  animation: fade-in-up 0.6s ease both;
}

.features-grid > .feature-card:nth-child(1),
.tests-grid > .test-card:nth-child(1),
.listing-grid > .test-card:nth-child(1) {
  animation-delay: 0.05s;
}

.features-grid > .feature-card:nth-child(2),
.tests-grid > .test-card:nth-child(2),
.listing-grid > .test-card:nth-child(2) {
  animation-delay: 0.15s;
}

.features-grid > .feature-card:nth-child(3),
.tests-grid > .test-card:nth-child(3),
.listing-grid > .test-card:nth-child(3) {
  animation-delay: 0.25s;
}

/* Hero entrance */
.hero-content {
  animation: fade-in 0.8s ease both;
}

.hero-stats {
  animation: fade-in-up 0.6s ease 0.3s both;
}

/* Section entrance */
.features-section,
.tests-section,
.cta-section {
  animation: fade-in-up 0.8s ease both;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
