/* =========================================
   SafeW 全局样式与变量
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #13102D;
  --color-paper: #D6D4ED;
  --color-body: #171523;
  --color-brand: #2714EB;
  --color-accent: #89ED6E;

  /* 结构 Token */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 1px solid rgba(23, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1120px;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --lh-tight: 1.25;
  --lh-body: 1.75;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--color-body);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
p, ul, ol, dl, table { margin: 0 0 var(--gap) 0; }
ul, ol { padding-left: 1.2em; }
li { margin-bottom: 0.5em; }

/* 容器与区块 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.bg-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.bg-dark .hl { color: var(--color-accent); }
.bg-dark a:not(.btn) { color: var(--color-accent); text-decoration-thickness: 1px; }
.bg-dark .card {
  background-color: var(--color-paper);
  color: var(--color-body);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}
.bg-dark .card .hl { color: var(--color-brand); }
.bg-dark .card a { color: var(--color-brand); }

.bg-paper {
  background-color: var(--color-paper);
  color: var(--color-body);
}
.bg-paper .hl { color: var(--color-brand); }
.bg-paper a:not(.btn) { color: var(--color-brand); text-decoration-thickness: 1px; }

/* 标题与眉标 */
.overline {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.6em;
}
.bg-paper .overline { color: var(--color-brand); }
.bg-dark .overline { color: var(--color-accent); }

h1, h2, h3 {
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: 0;
  margin-top: 0;
  margin-bottom: 0.6em;
}
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: 1.25rem; }
p { max-width: 38em; }

/* 按钮 */
.btn-group { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 1.5em; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding-inline: 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  text-decoration: none;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
  border: none;
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background-color: #7be05f; }

.btn-secondary {
  background: transparent;
  border: 1.5px solid currentColor;
}
.bg-paper .btn-secondary { color: var(--color-body); border-color: var(--color-body); }
.bg-dark .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.bg-paper .btn-secondary:hover { background-color: rgba(23, 21, 35, 0.06); }
.bg-dark .btn-secondary:hover { background-color: rgba(214, 212, 237, 0.08); }

/* 卡片与网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}
.card {
  background-color: #fff;
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
}
.card-header { font-weight: 700; margin-bottom: 0.4em; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(23, 21, 35, 0.12);
}
th { font-weight: 700; }
td { min-width: 0; }
tr:last-child td { border-bottom: none; }

/* FAQ */
details {
  border: var(--card-border);
  border-radius: 16px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}
summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  font-size: 1.2em;
  transition: transform 0.2s ease;
}
details[open] summary::after { transform: rotate(45deg); }
details[open] summary { border-bottom: 1px solid rgba(23, 21, 35, 0.1); }
.details-content { padding: 16px 20px; line-height: 1.7; }

/* 页头与页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(214, 212, 237, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(23, 21, 35, 0.08);
}
.bg-dark .site-header { background-color: rgba(19, 16, 45, 0.9); border-bottom-color: rgba(214, 212, 237, 0.1); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-list {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-link {
  text-decoration: none;
  font-weight: 600;
  padding: 8px 0;
  position: relative;
}
.nav-link[aria-current="page"],
.nav-link:hover { color: var(--color-brand); }
.bg-dark .nav-link[aria-current="page"],
.bg-dark .nav-link:hover { color: var(--color-accent); }
.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.25s ease;
}
.nav-link:hover::after,
.nav-link[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

.footer {
  padding-block: 48px;
  border-top: 1px solid rgba(23, 21, 35, 0.1);
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.85;
}
.bg-dark .footer { border-top-color: rgba(214, 212, 237, 0.1); }

/* SVG 容器与动效 */
.svg-container { width: 100%; height: auto; }
.grid-node {
  fill: rgba(255,255,255,0.15);
  transition: fill 0.3s ease, transform 0.3s ease;
}
.grid-node.active { fill: var(--color-accent); }
.draw-line {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  stroke: rgba(255,255,255,0.3);
  stroke-width: 2;
  fill: none;
}
.bubble-pop {
  transform: translateY(0);
  opacity: 1;
}

/* 关键帧定义 */
@keyframes nodePulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); fill: var(--color-accent); }
}
@keyframes drawStroke {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}
@keyframes floatShift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 动效类应用 */
.node-1 { animation: nodePulse 4s ease-in-out infinite 0.0s; }
.node-2 { animation: nodePulse 4s ease-in-out infinite 0.4s; }
.node-3 { animation: nodePulse 4s ease-in-out infinite 0.8s; }
.node-4 { animation: nodePulse 4s ease-in-out infinite 1.2s; }
.node-5 { animation: nodePulse 4s ease-in-out infinite 1.6s; }
.node-6 { animation: nodePulse 4s ease-in-out infinite 2.0s; }

.line-flow { animation: drawStroke 3s ease-in-out infinite; }
.float-panel { animation: floatShift 6s ease-in-out infinite; }
.input-breathe { animation: breathe 2.5s ease-in-out infinite; }

/* 响应式与无障碍 */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; height: auto; padding: 12px 0; }
  .nav-list { gap: 16px; margin-top: 8px; }
  .card-grid { grid-template-columns: 1fr; }
  .steps-row { flex-direction: column; }
  h1 br { 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;
  }
  .grid-node { opacity: 0.6; fill: rgba(255,255,255,0.25); }
  .draw-line { stroke-dashoffset: 0; }
}
