/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计 Token --- */
:root {
  /* 色彩系统 */
  --color-dark: #231334;
  --color-paper: #F5F3F7;
  --color-body: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* 取色变量（自动跟随所在面） */
  --text-primary: var(--color-body);
  --text-secondary: var(--color-body);
  --text-heading: var(--color-body);
  --accent-color: var(--color-brand);
  --bg-base: var(--color-paper);
  --bg-card: #EDEAF0; /* 纸面上卡片微浅底色 */
  --divider: rgba(28, 21, 35, 0.08);

  /* 深色面覆盖变量 */
  .dark-surface {
    --text-primary: var(--color-paper);
    --text-secondary: rgba(245, 243, 247, 0.75);
    --text-heading: var(--color-paper);
    --accent-color: var(--color-accent);
    --bg-base: var(--color-dark);
    --bg-card: #2D1B3F; /* 深色面上卡片微深底色 */
    --divider: rgba(245, 243, 247, 0.1);
  }

  /* 几何与间距 */
  --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: 1280px;
  --line-height: 1.75;

  /* 字体 */
  --font-sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

/* --- 基础重置 --- */
*, *::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: 16px;
  line-height: var(--line-height);
  color: var(--text-primary);
  background: var(--bg-base);
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--accent-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }

/* --- 布局容器 --- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
  overflow-x: hidden;
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* --- 排版系统 --- */
.section { padding-top: var(--section-y); padding-bottom: var(--section-y); border-bottom: 1px solid var(--divider); }
.section:last-child { border-bottom: none; }
.section-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}
h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  margin-bottom: 1rem;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  margin-bottom: 1.5rem;
}
h3 {
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-heading);
  margin-bottom: 0.75rem;
}
p { margin-bottom: 1rem; max-width: 38em; }
.hl { color: var(--accent-color); font-weight: 700; }
.text-secondary { color: var(--text-secondary); }
.lead { font-size: clamp(1rem, 1.2vw, 1.15rem); line-height: 1.6; margin-bottom: 1.5rem; }

/* --- 组件：按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0 1.25rem;
  height: 48px;
  font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer; border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:focus-visible { outline: 3px solid var(--accent-color); outline-offset: 2px; }
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
}
.dark-surface .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.btn svg { width: 20px; height: 20px; stroke-width: 2; fill: none; stroke: currentColor; }

/* --- 组件：卡片 --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  position: relative;
}

/* --- 组件：表格 --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 400px; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--divider); }
th { font-weight: 700; color: var(--text-heading); }
td { color: var(--text-primary); }

/* --- 组件：FAQ --- */
details {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: var(--card-border);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
summary {
  padding: 1rem var(--gap);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-heading);
  list-style: none;
  position: relative;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  font-weight: 400; color: var(--accent-color);
}
details[open] summary::after { content: "−"; }
details p { padding: 0 1rem 1rem; margin: 0; color: var(--text-primary); }

/* --- 组件：步骤条 --- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); }
.step-item { padding: 1rem; background: var(--bg-card); border-radius: var(--radius-card); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--color-accent); color: var(--color-dark);
  font-weight: 800; font-size: 0.9rem;
  border-radius: 8px; margin-bottom: 0.5rem;
}

/* --- 组件：标签 --- */
.tag {
  display: inline-block; padding: 0.25rem 0.6rem;
  font-size: 0.75rem; font-weight: 700;
  background: rgba(125, 20, 235, 0.1); color: var(--accent-color);
  border-radius: 6px; margin-bottom: 0.5rem;
}
.dark-surface .tag { background: rgba(237, 210, 110, 0.15); color: var(--color-accent); }

/* --- 页头与页脚 --- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245, 243, 247, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--divider);
}
.dark-surface .site-header { background: rgba(35, 19, 52, 0.9); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; color: var(--text-heading); }
.logo img { width: 32px; height: 32px; object-fit: contain; }
.nav-links { display: none; gap: 1.5rem; }
@media (min-width: 768px) { .nav-links { display: flex; } }
.nav-links a { color: var(--text-primary); font-weight: 500; font-size: 0.95rem; }
.nav-links a[aria-current="page"] { color: var(--accent-color); font-weight: 700; }
.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--divider);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* --- 侧边索引布局 --- */
.page-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 1024px) {
  .page-layout { grid-template-columns: 220px 1fr; }
}
.side-nav {
  position: sticky; top: 80px;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.side-nav ul { display: flex; flex-direction: column; gap: 0.5rem; }
.side-nav a {
  display: block; padding: 0.5rem 0.75rem;
  font-size: 0.9rem; color: var(--text-secondary);
  border-radius: 8px; transition: background 0.2s, color 0.2s;
}
.side-nav a:hover, .side-nav a.active {
  background: rgba(125, 20, 235, 0.08);
  color: var(--accent-color);
}
.dark-surface .side-nav a:hover, .dark-surface .side-nav a.active {
  background: rgba(237, 210, 110, 0.1);
}

/* --- SVG 动效体系 --- */
.svg-container { width: 100%; height: auto; }
svg { width: 100%; height: auto; }

/* 描边绘制 */
.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-path 6s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
@keyframes draw-path {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 流动线 */
.flow-line {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flow-dash 4s linear infinite;
}
@keyframes flow-dash {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 浮动 */
.float-soft {
  animation: float-soft 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes float-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 呼吸点 */
.breathe-dot {
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* 滑入卡片 */
.slide-in-card {
  animation: slide-in 6s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: bottom center;
}
@keyframes slide-in {
  0%, 100% { transform: translateY(0); opacity: 0.95; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .draw-path, .flow-line, .float-soft, .breathe-dot, .slide-in-card {
    animation: none !important;
  }
}

/* --- 焦点与无障碍 --- */
:focus-visible { outline: 3px solid var(--accent-color); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
