/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计变量 */
:root {
  --color-dark: #21163C;
  --color-paper: #E9E8EA;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED926E;
  --color-border: #d1cfd4;

  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  --card-shadow-hover: 0 14px 32px -12px rgba(25, 21, 35, 0.4);

  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 960px;
  --line-height-base: 1.65;
  --h1-size: clamp(2rem, 4.6vw, 3.4rem);

  /* 默认取色（纸面） */
  --text-primary: var(--color-text);
  --text-secondary: #3a3644;
  --bg-surface: var(--color-paper);
  --brand: var(--color-brand);
  --accent: var(--color-accent);
}

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  background: var(--bg-surface);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
ul, ol { list-style: none; }

/* 容器与布局 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* 表面层颜色覆盖规则 */
.surface-dark {
  --text-primary: var(--color-paper);
  --text-secondary: #dcdbe0;
  --bg-surface: var(--color-dark);
  --brand: var(--color-accent);
  --accent: var(--color-accent);
  background: var(--color-dark);
}
.surface-card {
  --text-primary: var(--color-text);
  --text-secondary: #3a3644;
  --bg-surface: var(--color-paper);
  --brand: var(--color-brand);
  --accent: var(--color-accent);
  background: var(--color-paper);
}

/* 排版 */
h1, h2, h3 { line-height: 1.25; letter-spacing: 0; font-weight: 600; }
h1 { font-size: var(--h1-size); text-wrap: balance; margin-bottom: 0.8em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1.2em; }
h3 { font-size: 1.25rem; margin-bottom: 0.6em; }
p { margin-bottom: 1em; max-width: 38em; }
.text-secondary { color: var(--text-secondary); }
.hl { color: var(--brand); font-weight: 700; }
.surface-dark .hl { color: var(--accent); }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.5em;
  color: var(--brand);
}
.surface-dark .badge { color: var(--accent); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 52px;
  padding: 0 1.5em;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary {
  background: var(--accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(237, 146, 110, 0.35); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--text-primary);
  color: var(--text-primary);
}
.surface-dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn-secondary:hover { background: rgba(255,255,255,0.05); }

/* 卡片 */
.card {
  background: var(--bg-surface);
  border: var(--card-border) solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-2px); }

/* 网格与两栏 */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.reverse-mobile { flex-direction: row; }
@media (max-width: 768px) { .reverse-mobile { flex-direction: column; } }

/* 列表与定义列表 */
.list-disc { list-style: disc; padding-left: 1.5em; }
.list-disc li { margin-bottom: 0.5em; position: relative; }
.list-disc li::marker { color: var(--brand); }
.surface-dark .list-disc li::marker { color: var(--accent); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.5rem; }
.dl dt { font-weight: 700; margin-bottom: 0.3em; display: flex; align-items: center; gap: 0.5em; }
.dl dd { color: var(--text-secondary); margin-bottom: 1em; line-height: 1.6; }
.surface-dark .dl dd { color: #dcdbe0; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--color-border); border-radius: var(--radius-card); }
table { width: 100%; border-collapse: collapse; min-width: 400px; }
th, td { padding: 0.8em 1em; text-align: left; border-bottom: 1px solid var(--color-border); }
th { background: rgba(0,0,0,0.03); font-weight: 700; }
td strong { font-weight: 700; }
.surface-dark th { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
.surface-dark td { border-color: rgba(255,255,255,0.1); }

/* FAQ */
details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  margin-bottom: 0.8rem;
  background: var(--bg-surface);
  transition: background 0.2s ease;
}
summary {
  padding: 1rem 1.2rem;
  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.2em; font-weight: 400; }
details[open] summary::after { content: "−"; }
details[open] summary { border-bottom: 1px solid var(--color-border); }
details > div { padding: 1rem 1.2rem; color: var(--text-secondary); line-height: 1.6; }
.surface-dark details { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.03); }
.surface-dark details > div { color: #dcdbe0; }

/* 时间轴 */
.timeline { position: relative; padding-left: 2rem; border-left: 2px solid var(--border); margin-left: 0.5rem; }
.timeline-item { position: relative; margin-bottom: 2rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -2.55rem; top: 0.35rem;
  width: 12px; height: 12px; border-radius: 50%; background: var(--brand);
}
.surface-dark .timeline-item::before { background: var(--accent); }
.timeline-time { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.3rem; color: var(--brand); }
.surface-dark .timeline-time { color: var(--accent); }

/* 页头页脚 */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(233, 232, 234, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.surface-dark .site-header { background: rgba(33, 22, 60, 0.9); }
.site-header.scrolled { border-bottom-color: var(--color-border); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { color: var(--brand); }
.surface-dark .nav-links a:hover { color: var(--accent); }
.nav-links a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.surface-dark .nav-links a[aria-current="page"] { color: var(--accent); }
.footer {
  padding: 3rem 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.surface-dark .footer { border-top-color: rgba(255,255,255,0.1); }

/* =========================================
   SVG 动效系统
   ========================================= */
.hero-svg, .flow-svg {
  width: 100%;
  height: auto;
  max-width: 480px;
  margin-inline: auto;
}
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-line 3s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
.anim-float {
  animation: float 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.anim-pulse {
  animation: pulse-dots 4s ease-in-out infinite;
}
.anim-twinkle {
  animation: twinkle 5s ease-in-out infinite;
}
.anim-slide-in {
  animation: slide-in 2.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes draw-line {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0.1; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes pulse-dots {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}
@keyframes slide-in {
  0% { transform: translateX(-20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  .anim-draw, .anim-float, .anim-pulse, .anim-twinkle, .anim-slide-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 响应式微调 */
@media (max-width: 640px) {
  .grid-2, .grid-3, .dl-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0 var(--gap); }
  .nav-links { gap: 1rem; }
}
