/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 1. 设计变量与语义取色 */
:root {
  /* 色板 */
  --color-dark: #271334;
  --color-paper: #E9E8EA;
  --color-body: #1D1523;
  --color-brand: #8A13DD;
  --color-accent: #9EED6E;
  --color-paper-light: #F4F3F5;
  --color-dark-overlay: #1A0C24;

  /* 结构 Token */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;

  /* 纸面默认语义 */
  --c-bg: var(--color-paper);
  --c-bg-alt: #FFFFFF;
  --c-text: var(--color-body);
  --c-text-muted: rgba(29, 21, 35, 0.72);
  --c-highlight: var(--color-brand);
  --c-link: var(--color-brand);
  --c-btn-primary-bg: var(--color-brand);
  --c-btn-primary-text: var(--color-paper);
  --c-btn-secondary-border: var(--color-body);
  --c-btn-secondary-text: var(--color-body);
}

.dark-face {
  --c-bg: var(--color-dark);
  --c-bg-alt: var(--color-dark-overlay);
  --c-text: var(--color-paper);
  --c-text-muted: rgba(233, 232, 234, 0.72);
  --c-highlight: var(--color-accent);
  --c-link: var(--color-accent);
  --c-btn-primary-bg: var(--color-accent);
  --c-btn-primary-text: var(--color-dark);
  --c-btn-secondary-border: var(--color-paper);
  --c-btn-secondary-text: var(--color-paper);
}

/* 2. 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--c-link); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }

/* 3. 布局容器 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  background: var(--c-bg);
  color: var(--c-text);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

/* 4. 标题与眉标 */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-highlight);
  margin-bottom: 0.6rem;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  margin-bottom: 1.2rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  margin-bottom: 0.8rem;
}

p { margin-bottom: 1rem; max-width: 38em; }
p:last-child { margin-bottom: 0; }

.hl { color: var(--c-highlight); }

/* 5. 组件：按钮 */
.btn-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--c-highlight);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--c-btn-primary-bg);
  color: var(--c-btn-primary-text);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.05); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--c-btn-secondary-border);
  color: var(--c-btn-secondary-text);
}
.btn-secondary:hover { transform: translateY(-2px); opacity: 0.9; }

.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* 6. 组件：卡片 */
.card {
  background: var(--c-bg-alt);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  position: relative;
}
.card.dark-card { background: var(--c-bg-alt); color: var(--color-body); }
.card.light-card { background: var(--color-paper-light); color: var(--color-body); }

/* 7. 组件：表格 */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  background: var(--c-bg-alt);
  padding: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 400px;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.dark-face th, .dark-face td { border-bottom-color: rgba(255,255,255,0.1); }
th { font-weight: 600; }
td:first-child { font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* 8. 组件：FAQ */
details {
  background: var(--c-bg-alt);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  overflow: hidden;
}
summary {
  padding: 18px 20px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 48px;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: var(--c-highlight);
}
details[open] summary::after { content: "-"; }
.details-content {
  padding: 0 20px 18px;
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* 9. 页头页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background 0.3s;
}
.site-header.scrolled {
  background: var(--c-bg);
  border-bottom-color: rgba(0,0,0,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--c-text); }
.brand img { height: 32px; width: auto; }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { font-size: 0.95rem; font-weight: 500; color: var(--c-text-muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--c-text); }
.nav a[aria-current="page"] { font-weight: 600; }

.site-footer {
  padding: 48px 0;
  background: var(--c-bg);
  color: var(--c-text-muted);
  font-size: 0.9rem;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  text-align: center;
}
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--c-text-muted); }
.footer-links a:hover { color: var(--c-text); }

/* 10. SVG 动效体系 */
.svg-panel {
  width: 100%;
  height: auto;
  max-width: 100%;
}
.svg-panel g, .svg-panel path, .svg-panel rect, .svg-panel circle {
  transform-box: fill-box;
  transform-origin: center;
}

/* 网格节点依次点亮 */
@keyframes grid-light {
  0%, 100% { stroke-dashoffset: 1; opacity: 0.3; }
  50% { stroke-dashoffset: 0; opacity: 1; }
}
.anim-grid-node {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: grid-light 6s ease-in-out infinite;
}
.anim-grid-node:nth-child(odd) { animation-delay: -1.5s; }
.anim-grid-node:nth-child(even) { animation-delay: -3s; }
.anim-grid-node:nth-child(3n) { animation-delay: -4.5s; }

/* 气泡轻微漂浮 */
@keyframes float-subtle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.anim-float { animation: float-subtle 7s ease-in-out infinite; }
.anim-float.delay-1 { animation-delay: -2s; }
.anim-float.delay-2 { animation-delay: -4s; }

/* 描边流动 */
@keyframes draw-flow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
.anim-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-flow 4s ease-in-out infinite alternate;
}

/* 输入点呼吸 */
@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}
.anim-pulse { animation: pulse-dot 3s ease-in-out infinite; }
.anim-pulse:nth-child(2) { animation-delay: -1s; }
.anim-pulse:nth-child(3) { animation-delay: -2s; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  .anim-grid-node, .anim-float, .anim-draw, .anim-pulse {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
    transform: none !important;
  }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .header-nav-desktop { display: none; }
  h1 { font-size: clamp(1.8rem, 8vw, 2.6rem); }
  .hero-layout { grid-template-columns: 1fr !important; }
  .hero-visual { order: -1; margin-bottom: 16px; }
}
