/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 配色层 */
  --color-dark: #13102D;
  --color-paper: #D6D4ED;
  --color-text: #171523;
  --color-brand: #2714EB;
  --color-accent: #89ED6E;

  /* 结构变量 */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(23, 21, 35, 0.3);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;

  /* 排版变量 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-base: 1.55;
}

/* --- 主题上下文覆盖 --- */
.theme-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.theme-dark .hl { color: var(--color-accent); }
.theme-dark .badge, .theme-dark a:not(.btn):not(.btn-primary) { color: var(--color-accent); }
.theme-dark header, .theme-dark footer { background-color: var(--color-dark); border-color: rgba(255,255,255,0.1); }

.theme-light {
  background-color: var(--color-paper);
  color: var(--color-text);
}
.theme-light .hl { color: var(--color-brand); }
.theme-light .badge, .theme-light a:not(.btn):not(.btn-primary) { color: var(--color-brand); }
.theme-light header, .theme-light footer { background-color: var(--color-paper); border-color: rgba(0,0,0,0.1); }

/* 浅色卡片嵌套在深色面时恢复纸面取色规则 */
.light-card {
  background-color: var(--color-paper);
  color: var(--color-text);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
}
.light-card .hl { color: var(--color-brand); }
.light-card .badge, .light-card a:not(.btn) { color: var(--color-brand); }

/* --- 基础重置 --- */
*, *::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);
  line-height: var(--line-height-base);
  font-size: 16px;
  background-color: var(--color-paper);
  color: var(--color-text);
  overflow-x: hidden;
  width: 100vw;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: opacity 0.2s ease; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- 排版 --- */
h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.25; margin-bottom: 0.8em; }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); line-height: 1.2; margin-bottom: 0.6em; }
p { margin-bottom: var(--gap); max-width: 38em; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5em;
  padding: 0.25em 0.6em;
  border-radius: 6px;
  background: rgba(128,128,128,0.1);
}

/* --- 布局容器 --- */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); width: 100%; box-sizing: border-box; }
section { padding: var(--section-y) 0; overflow-x: hidden; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); align-items: start; width: 100%; box-sizing: border-box; }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; width: 100%; box-sizing: border-box; }
.text-center { text-align: center; }

/* --- 组件：按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0 1.5em; height: 48px; border-radius: var(--radius-btn);
  font-weight: 600; cursor: pointer; border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-primary:hover { background: #7de064; }
.btn-secondary { background: transparent; border: 1px solid currentColor; color: inherit; }
.btn-secondary:hover { background: rgba(128,128,128,0.08); }

/* --- 组件：卡片 --- */
.card {
  background: var(--color-paper);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
  border: var(--card-border);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 14px 32px -12px rgba(23, 21, 35, 0.35); }

/* --- 组件：表格 --- */
table { width: 100%; border-collapse: collapse; margin: var(--gap) 0; font-size: 0.95em; }
th, td { padding: 0.75em 1em; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.1); }
th { font-weight: 700; }
.theme-dark th, .theme-dark td { border-bottom-color: rgba(255,255,255,0.1); }
.light-card table th, .light-card table td { border-bottom-color: rgba(0,0,0,0.1); }

/* --- 组件：FAQ --- */
details { margin-bottom: var(--gap); border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: var(--gap); }
.theme-dark details { border-bottom-color: rgba(255,255,255,0.1); }
.summary-q { cursor: pointer; font-weight: 600; list-style: none; position: relative; padding-left: 1.5em; }
.summary-q::-webkit-details-marker { display: none; }
.summary-q::before { content: '+'; position: absolute; left: 0; font-weight: 700; }
details[open] .summary-q::before { content: '-'; }
.answer-a { margin-top: 0.5em; color: inherit; opacity: 0.9; }

/* --- 组件：页头页脚 --- */
header { position: sticky; top: 0; z-index: 100; border-bottom-width: 1px; border-bottom-style: solid; padding: 0.75em 0; backdrop-filter: saturate(180%) blur(8px); }
nav { display: flex; justify-content: space-between; align-items: center; }
.nav-links { display: flex; gap: var(--gap); align-items: center; }
.nav-links a { font-weight: 500; padding: 0.4em 0; }
.nav-links a[aria-current="page"], .nav-links a:hover { font-weight: 700; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); padding-top: var(--gap); }
.footer-col h4 { margin-bottom: 0.5em; }
.footer-col a { display: block; margin-bottom: 0.4em; opacity: 0.8; }
.footer-col a:hover { opacity: 1; }

/* --- SVG 动效基础 --- */
.svg-panel { width: 100%; height: auto; max-width: 100%; }
.svg-panel svg { width: 100%; height: auto; display: block; }
.svg-child { transform-box: fill-box; transform-origin: center; }

/* 路径描边流动 */
@keyframes dashPulse {
  0%, 100% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: 1; }
}
@keyframes dotFlow {
  to { stroke-dashoffset: -100; }
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.draw-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: dashPulse 4s ease-in-out infinite; }
.flow-dot { pathLength: 1; stroke-dasharray: 0.04 0.96; animation: dotFlow 3s linear infinite; }
.float-layer { animation: floatY 5s ease-in-out infinite; }
.breathe-icon { animation: breathe 3.5s ease-in-out infinite; }
.slide-item { animation: slideUp 0.8s ease forwards; opacity: 0; }
.slide-item:nth-child(2) { animation-delay: 0.15s; }
.slide-item:nth-child(3) { animation-delay: 0.3s; }

/* 减少动态效果 */
@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;
  }
  .draw-line, .flow-dot, .float-layer, .breathe-icon, .slide-item {
    animation: none !important;
  }
}

/* --- 响应式微调 --- */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav-links .hide-mobile { display: none; }
  h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
}
