/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 1. 设计变量与基础重置 */
:root {
  /* 色板 */
  --color-dark: #231334;
  --color-paper: #F5F3F7;
  --color-body: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* 语义化取色（纸面默认） */
  --bg: var(--color-paper);
  --text: var(--color-body);
  --text-secondary: rgba(28, 21, 35, 0.7);
  --brand: var(--color-brand);
  --accent: var(--color-brand);
  --border: rgba(28, 21, 35, 0.08);
  --surface-alt: #EDEAF0;

  /* 结构 Token */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1120px;
  --header-h: 64px;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --fs-hero: clamp(2.4rem, 6vw, 4.5rem);
  --fs-h2: clamp(1.6rem, 3vw, 2.4rem);
  --fs-h3: clamp(1.25rem, 2vw, 1.5rem);
  --fs-body: 16px;
  --lh-tight: 1.1;
  --lh-normal: 1.75;
}

/* 深色面覆盖 */
.dark-bg {
  --bg: var(--color-dark);
  --text: var(--color-paper);
  --text-secondary: rgba(245, 243, 247, 0.7);
  --brand: var(--color-accent);
  --accent: var(--color-accent);
  --border: rgba(245, 243, 247, 0.1);
  --surface-alt: rgba(245, 243, 247, 0.05);
}

/* 深色背景内的浅色卡片恢复纸面取色 */
.card-light {
  --bg: var(--color-paper);
  --text: var(--color-body);
  --text-secondary: rgba(28, 21, 35, 0.7);
  --brand: var(--color-brand);
  --accent: var(--color-brand);
  --border: rgba(28, 21, 35, 0.08);
  --surface-alt: #EDEAF0;
  background-color: var(--bg);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* 2. 布局与容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.section {
  padding-block: var(--section-y);
  background-color: var(--bg);
}
.section-alt { background-color: var(--surface-alt); }
.grid-2 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }

/* 3. 排版系统 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--brand);
  margin-bottom: 0.5rem;
}
.badge::before {
  content: "";
  display: block;
  width: 12px;
  height: 2px;
  background-color: currentColor;
  border-radius: 2px;
}
h1 {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
h2 {
  font-size: var(--fs-h2);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}
h3 {
  font-size: var(--fs-h3);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}
p { margin-bottom: 1rem; max-width: 38em; }
.hl { color: var(--brand); font-weight: 700; }

/* 4. 组件：按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
}
.btn-primary {
  background-color: var(--accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--text);
}
.btn-secondary:hover { background: var(--border); }
.btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.btn svg { width: 20px; height: 20px; stroke-width: 1.8; }

/* 5. 组件：卡片与面板 */
.card {
  background-color: var(--bg);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-2px); }
.visual-panel {
  background-color: var(--dark-surface, var(--color-dark));
  border-radius: var(--radius-card);
  padding: var(--gap);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.visual-panel svg { width: 100%; height: auto; }

/* 6. 组件：表格 */
.table-wrap { overflow-x: auto; border-radius: var(--radius-card); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--bg); }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 700; background: var(--surface-alt); }
td:first-child { font-weight: 600; white-space: nowrap; }

/* 7. 组件：FAQ */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  background: var(--bg);
  transition: background 0.2s;
}
details[open] { background: var(--surface-alt); }
summary {
  padding: 16px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 1.2rem; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { padding: 0 16px 16px; margin: 0; }
details:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 8. 页头与页脚 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  backdrop-filter: blur(8px);
}
.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; }
.logo img { width: 32px; height: 32px; object-fit: contain; }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { font-weight: 500; font-size: 0.95rem; transition: color 0.2s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--brand); }
.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 48px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.footer-inner { display: flex; flex-direction: column; gap: 24px; align-items: center; text-align: center; }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }

/* 9. SVG 动效关键帧与工具类 */
/* 星点明灭 */
@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1); }
}
/* 连线流动 */
@keyframes flow-line {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
/* 气泡上浮 */
@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
/* 输入点呼吸 */
@keyframes breathe-dot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
/* 通知滑入 */
@keyframes slide-in {
  0% { opacity: 0; transform: translateX(12px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* 应用类 */
.anim-star { animation: twinkle 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-line { stroke-dasharray: 1; stroke-dashoffset: 0; animation: flow-line 3s linear infinite; }
.anim-bubble { animation: float-bubble 5s ease-in-out infinite; }
.anim-dot { animation: breathe-dot 2.5s ease-in-out infinite; }
.anim-slide { animation: slide-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .anim-star, .anim-line, .anim-bubble, .anim-dot, .anim-slide {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 10. 响应式适配 */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav { gap: 16px; }
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .visual-panel { aspect-ratio: 16/9; }
}
