/* =========================================
   SafeW 全站共享样式
   设计变量、排版、组件、SVG 动效
   ========================================= */

:root {
  /* 色板 */
  --color-dark: #1B1231;
  --color-paper: #F4F3F7;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;

  /* 结构 Token */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  
  /* 字体与行高 */
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --lh-title: 1.25;
  --lh-body: 1.55;
  
  /* 状态色 */
  --text-on-dark: var(--color-paper);
  --text-on-paper: var(--color-body);
  --highlight-on-dark: var(--color-accent);
  --highlight-on-paper: var(--color-brand);
}

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--text-on-paper);
  background-color: var(--color-paper);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 容器 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* 排版 */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: 0;
  line-height: var(--lh-title);
}
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: var(--gap); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: calc(var(--gap) * 0.75); }
p { margin-bottom: var(--gap); max-width: 38em; }

/* 眉标 */
.badge-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: calc(var(--gap) * 0.5);
}
.paper-section .badge-label { color: var(--highlight-on-paper); }
.dark-section .badge-label { color: var(--highlight-on-dark); }

/* 强调词 */
.hl { font-weight: 700; }
.paper-section .hl { color: var(--highlight-on-paper); }
.dark-section .hl { color: var(--highlight-on-dark); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 1.5em;
  height: 48px;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  border: none;
}
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn-secondary {
  background: transparent;
  border: 2px solid var(--text-on-paper);
  color: var(--text-on-paper);
}
.dark-section .btn-secondary {
  border-color: var(--text-on-dark);
  color: var(--text-on-dark);
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* 图标辅助 */
.icon-svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* 卡片系统 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--gap);
}
.card {
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s ease;
}
.dark-section .card {
  background: rgba(255, 255, 255, 0.08);
}
.card:hover { transform: translateY(-4px); }
.card p { font-size: 0.95rem; color: inherit; opacity: 0.9; margin-bottom: 0; }

/* 表格 */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.6);
  padding: var(--gap);
}
.dark-section .table-wrapper {
  background: rgba(255, 255, 255, 0.08);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.75em 1em;
  text-align: left;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}
th { font-weight: 700; }
td:last-child { white-space: nowrap; }

/* FAQ / Details */
details {
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-card);
  padding: var(--gap);
  margin-bottom: var(--gap);
  transition: background 0.2s ease;
}
.dark-section details {
  background: rgba(255, 255, 255, 0.08);
}
summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  transition: transform 0.2s ease;
}
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: var(--gap); margin-bottom: 0; font-size: 0.95rem; }

/* 步骤徽标 */
.step-list { counter-reset: step-counter; list-style: none; }
.step-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 3rem;
  margin-bottom: var(--gap);
}
.step-list li::before {
  content: counter(step-counter, decimal-leading-zero);
  position: absolute;
  left: 0; top: 0;
  width: 2rem; height: 2rem;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

/* 页头页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 243, 247, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.dark-section .site-header { background: rgba(27, 18, 49, 0.9); border-bottom: 1px solid rgba(255,255,255,0.1); }
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.nav-links { display: flex; gap: var(--gap); align-items: center; }
.nav-links a {
  color: var(--text-on-paper);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5em;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.dark-section .nav-links a { color: var(--text-on-dark); }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: rgba(128,128,128,0.1); }
.footer {
  padding: var(--section-y) 0;
  border-top: 1px solid rgba(128,128,128,0.2);
  margin-top: var(--section-y);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gap);
}
.footer-links { display: flex; gap: var(--gap); }
.footer-links a { color: inherit; opacity: 0.8; text-decoration: none; }
.footer-links a:hover { opacity: 1; }

/* 区块背景交替 */
.paper-section { background-color: var(--color-paper); }
.dark-section { background-color: var(--color-dark); color: var(--text-on-dark); }
.light-card {
  background: var(--color-paper);
  color: var(--text-on-paper);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

/* SVG 通用缩放 */
.svg-viz {
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* SVG 动效 Keyframes */
@keyframes nodePulse {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes floatSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes dashDraw {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes breatheDots {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
@keyframes progressFill {
  0% { width: 0; }
  50% { width: 100%; }
  100% { width: 0; }
}
@keyframes fadeOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 动效类应用 */
.grid-node {
  animation: nodePulse 4s infinite ease-in-out;
  transform-origin: center;
}
.node-1 { animation-delay: 0s; }
.node-2 { animation-delay: 0.8s; }
.node-3 { animation-delay: 1.6s; }
.node-4 { animation-delay: 2.4s; }
.node-5 { animation-delay: 3.2s; }

.bubble-float { animation: floatSoft 6s infinite ease-in-out; }
.float-delay-1 { animation-delay: 1s; }
.float-delay-2 { animation-delay: 2s; }

.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dashDraw 4s infinite ease-in-out;
}

.dot-breathe circle {
  animation: breatheDots 3s infinite ease-in-out;
}
.dot-breathe circle:nth-child(2) { animation-delay: 0.3s; }
.dot-breathe circle:nth-child(3) { animation-delay: 0.6s; }

/* 进度条动画 */
.progress-fill {
  animation: progressFill 6s infinite ease-in-out;
}

/* 透明度闪烁动画 */
.fade-opacity {
  animation: fadeOpacity 4s infinite ease-in-out;
}

/* 响应式与无障碍 */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; height: auto; padding: var(--gap) 0; }
  .nav-links { 
    display: none; 
    flex-direction: column; 
    width: 100%; 
    background: inherit; 
    padding-bottom: var(--gap); 
    gap: 0.5rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; text-align: center; padding: 0.75em; }
  .menu-toggle { display: block; background: none; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; padding: 0.5em; }
  .card-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
}
@media (min-width: 769px) {
  .menu-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
