/* =========================================
   SafeW 全局样式与共享设计系统
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 色板 */
  --bg-dark: #141838;
  --bg-paper: #FCFCFD;
  --text-body: #151723;
  --brand: #142CEB;
  --accent: #6EAFED;

  /* 结构变量 */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;

  /* 字体与排版 */
  --font-main: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --lh-tight: 1.15;
  --lh-normal: 1.75;
}

/* --- 基础重置与容器 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--lh-normal);
  color: var(--text-body);
  background-color: var(--bg-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: opacity 0.2s ease; }
a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }
ul, ol { list-style: none; }

/* 上下文取色覆盖 */
.dark-surface {
  --c-text: var(--bg-paper);
  --c-text-muted: rgba(252, 252, 253, 0.85);
  --c-highlight: var(--accent);
  --c-bg: var(--bg-dark);
  --c-card-bg: rgba(255, 255, 255, 0.06);
}
.paper-surface {
  --c-text: var(--text-body);
  --c-text-muted: #4b5563;
  --c-highlight: var(--brand);
  --c-bg: var(--bg-paper);
  --c-card-bg: #F3F4F6;
}

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}
.section {
  padding-block: var(--section-y);
  background-color: var(--c-bg);
  color: var(--c-text);
}

/* --- 排版组件 --- */
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-highlight);
  margin-bottom: 0.75rem;
}
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: var(--lh-tight);
  color: var(--c-text);
}
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-block: 0.5em 0.25em; }
h3 { font-size: 1.25rem; margin-block: 0.4em 0.2em; }
p { max-width: 38em; margin-block: 0.5em 0; color: var(--c-text-muted); }
.hl { color: var(--c-highlight); font-weight: 600; }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 52px;
  padding-inline: 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--c-highlight); outline-offset: 2px; }
.btn-primary {
  background-color: var(--accent);
  color: var(--bg-dark);
}
.btn-primary:hover { background-color: #5A9FDB; }
.btn-secondary {
  background: transparent;
  color: var(--c-text);
  border: 1px solid currentColor;
}
.btn-secondary:hover { background: rgba(128,128,128,0.08); }
.btn-icon { width: 20px; height: 20px; stroke-width: 1.8; }

/* --- 卡片与面板 --- */
.card {
  background-color: var(--c-card-bg);
  border: var(--card-border) solid transparent;
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: clamp(1rem, 2vw, 1.5rem);
}
.panel {
  background-color: var(--c-card-bg);
  border-radius: var(--radius-card);
  padding: var(--gap);
  position: relative;
  overflow: hidden;
}

/* --- 表格 --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-align: left;
}
th, td { padding: 0.75rem 1rem; border-bottom: 1px solid rgba(128,128,128,0.2); }
th { font-weight: 600; color: var(--c-text); }
td { color: var(--c-text-muted); }
tr:last-child td { border-bottom: none; }

/* --- FAQ --- */
details {
  background: var(--c-card-bg);
  border-radius: var(--radius-card);
  margin-bottom: 0.75rem;
  padding: 1rem;
}
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--c-text);
  list-style: none;
  position: relative;
  padding-right: 1.5rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: var(--c-highlight);
}
details[open] summary::after { content: "−"; }
details p { margin-top: 0.75rem; font-size: 0.95rem; }

/* --- 页头与页脚 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(252, 252, 253, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-block: 0.75rem;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.1rem; }
.logo img { height: 28px; width: auto; }
.nav { display: flex; gap: 1.5rem; align-items: center; }
.nav a { font-size: 0.95rem; font-weight: 500; color: var(--text-body); }
.nav a:hover { color: var(--brand); }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.site-footer {
  background: var(--bg-dark);
  color: var(--bg-paper);
  padding-block: 2.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: rgba(252,252,253,0.7);
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1rem; }
.footer-links a { color: rgba(252,252,253,0.8); }
.footer-links a:hover { color: var(--accent); }

/* --- 响应式布局微调 --- */
@media (max-width: 768px) {
  .nav { display: none; } /* 移动端简化处理，实际项目可加汉堡菜单 */
  .hero-grid { flex-direction: column; }
  .magazine-layout { flex-direction: column; }
  .toc-sidebar { position: static; flex: none; width: 100%; }
}

/* =========================================
   SVG 动效系统
   ========================================= */
/* 基础 SVG 容器 */
.svg-visual { width: 100%; height: auto; max-width: 100%; }
.svg-visual path, .svg-visual circle, .svg-visual rect, .svg-visual line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 线条绘制动画 */
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: svgDraw 4s ease-in-out infinite alternate;
}
@keyframes svgDraw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 气泡浮动 */
.anim-float {
  animation: svgFloat 6s ease-in-out infinite alternate;
}
@keyframes svgFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* 呼吸圆点 */
.anim-breathe {
  animation: svgPulse 3s ease-in-out infinite alternate;
}
@keyframes svgPulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* 同心轨道呼吸 */
.anim-orbit {
  transform-box: fill-box;
  transform-origin: center;
  animation: svgOrbit 12s linear infinite;
}
@keyframes svgOrbit {
  0% { transform: scale(0.95) rotate(0deg); opacity: 0.6; }
  50% { transform: scale(1.05) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.95) rotate(360deg); opacity: 0.6; }
}

/* 通知滑入 */
.anim-slide-in {
  animation: svgSlide 5s ease-in-out infinite alternate;
}
@keyframes svgSlide {
  0% { transform: translateX(-12px); opacity: 0.3; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  [class*="anim-"], .svg-visual * {
    animation: none !important;
    transition: none !important;
  }
}
