/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 0. 设计变量与上下文覆盖 */
:root {
  /* 基础色板 */
  --color-dark: #231334;
  --color-paper: #F5F3F7;
  --color-text: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* 结构 Token */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  --line-h-body: 1.55;

  /* 默认上下文（纸面） */
  --fg-primary: var(--color-text);
  --fg-secondary: var(--color-text);
  --fg-muted: #5A5260;
  --link-color: var(--color-brand);
  --badge-color: var(--color-brand);
  --bg-surface: var(--color-paper);
}

/* 上下文类：深色面 */
.bg-dark {
  --fg-primary: var(--color-paper);
  --fg-secondary: var(--color-paper);
  --fg-muted: #C4BDD0;
  --link-color: var(--color-accent);
  --badge-color: var(--color-accent);
  --bg-surface: var(--color-dark);
}

/* 上下文类：浅色卡片（置于深色面上时恢复纸面取色） */
.bg-card {
  --fg-primary: var(--color-text);
  --fg-secondary: var(--color-text);
  --fg-muted: #5A5260;
  --link-color: var(--color-brand);
  --badge-color: var(--color-brand);
  --bg-surface: var(--color-paper);
}

/* 1. 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg-surface);
  color: var(--fg-primary);
  line-height: var(--line-h-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--link-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }

/* 容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

/* 2. 排版系统 */
.section-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--badge-color);
  margin-bottom: 0.6rem;
  position: relative;
  padding-left: 1.2em;
}
.section-tag::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 0.6em; height: 2px;
  background: currentColor;
}

h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.15;
  color: var(--fg-primary);
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); letter-spacing: -0.02em; margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1.5rem; }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: 0.8rem; }

.hl { color: var(--link-color); font-weight: 600; }

p { margin-bottom: 1rem; max-width: 38em; }
strong { font-weight: 600; }

/* 3. 布局网格 */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* 4. 组件：按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0 1.2em; height: 48px; min-height: 48px;
  border-radius: var(--radius-btn); font-weight: 600; font-size: 0.95rem;
  cursor: pointer; border: none; transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn:focus-visible { outline: 3px solid var(--link-color); outline-offset: 2px; }
.btn-primary {
  background: var(--color-accent); color: var(--color-dark);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.15);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 3px 3px 0 rgba(0,0,0,0.2); }
.btn-secondary {
  background: transparent; color: var(--fg-primary);
  border: 2px solid var(--fg-primary);
}
.btn-secondary:hover { background: var(--fg-primary); color: var(--bg-surface); }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.5rem 0; }

/* 5. 组件：卡片 */
.card {
  background: var(--bg-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.card-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  stroke: var(--link-color); stroke-width: 1.8; fill: none;
}

/* 6. 组件：表格 */
.data-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.data-table th, .data-table td {
  padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--fg-muted);
}
.data-table th { font-weight: 600; color: var(--fg-primary); }
.data-table td { color: var(--fg-secondary); }
@media (max-width: 600px) {
  .data-table, .data-table thead, .data-table tbody, .data-table th, .data-table td, .data-table tr {
    display: block; width: 100%;
  }
  .data-table tr { margin-bottom: 1rem; border: 1px solid var(--fg-muted); border-radius: 8px; }
  .data-table th, .data-table td { padding: 0.6rem; border-bottom: none; }
  .data-table th { background: rgba(0,0,0,0.03); border-radius: 8px 8px 0 0; }
}

/* 7. 组件：FAQ */
.faq-item { border-bottom: 1px solid var(--fg-muted); margin-bottom: 1rem; }
.faq-item summary {
  padding: 1rem 0; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 0.6rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: "+"; font-size: 1.2rem; color: var(--link-color); font-weight: 700;
  transition: transform 0.2s;
}
.faq-item[open] summary::before { transform: rotate(45deg); }
.faq-item p { margin-top: 0.5rem; color: var(--fg-secondary); font-size: 0.95rem; }

/* 8. 页头与页脚 */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245, 243, 247, 0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--fg-muted);
}
.bg-dark .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.6rem; font-weight: 700; font-size: 1.1rem; color: var(--fg-primary); }
.logo img { height: 28px; width: auto; }
.nav { display: flex; gap: 1.5rem; align-items: center; }
.nav a { color: var(--fg-secondary); font-weight: 500; font-size: 0.95rem; }
.nav a:hover { color: var(--link-color); }
.nav a[aria-current="page"] { color: var(--link-color); font-weight: 700; }
@media (max-width: 768px) {
  .nav { display: none; }
}
.site-footer {
  padding: 2rem 0; border-top: 1px solid var(--fg-muted);
  text-align: center; color: var(--fg-muted); font-size: 0.9rem;
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1rem; }
.footer-links a { color: var(--fg-secondary); }

/* 9. SVG 动效体系 */
svg { width: 100%; height: auto; }
svg .draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }
svg .flow-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }

@keyframes float-stack {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes float-delay {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dash-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes flow-move {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.anim-float { animation: float-stack 4s ease-in-out infinite; }
.anim-float-delay { animation: float-delay 5s ease-in-out infinite 1s; }
.anim-breathe { animation: breathe 3s ease-in-out infinite; }
.anim-slide { animation: slide-up 0.6s ease-out forwards; }
.anim-draw { animation: dash-draw 1.2s ease-out forwards; }
.anim-flow { animation: flow-move 2s linear infinite; }

/* 旋转中心修正 */
.anim-spin {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 10. 无障碍：减少动态效果 */
@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-float, .anim-float-delay, .anim-breathe, .anim-slide, .anim-draw, .anim-flow, .anim-spin {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
  }
}
