/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 1. 设计变量与 Token */
:root {
  /* 色板 */
  --color-dark: #251943;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED6E89;
  
  /* 结构 Token */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;
  
  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-base: 1.75;
  --line-height-heading: 1.25;
}

/* 2. 基础重置与全局 */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }

/* 3. 布局容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

/* 背景面控制 */
.bg-dark { background-color: var(--color-dark); color: var(--color-paper); }
.bg-dark a:not(.btn):not([class]) { color: var(--color-accent); }
.bg-dark .hl { color: var(--color-accent); }
.bg-dark .table-border { border-color: rgba(219, 212, 237, 0.2); }

.bg-paper { background-color: var(--color-paper); color: var(--color-text); }
.bg-paper a:not(.btn):not([class]) { color: var(--color-brand); }
.bg-paper .hl { color: var(--color-brand); }
.bg-paper .table-border { border-color: rgba(25, 21, 35, 0.16); }

/* 卡片在深色面上的取色修正 */
.card-in-dark {
  background-color: var(--color-paper);
  color: var(--color-text);
  border: var(--card-border);
}

/* 4. 排版层级 */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--line-height-heading);
  letter-spacing: 0;
  margin: 0 0 16px 0;
}
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); text-wrap: balance; margin-bottom: 32px; }
h3 { font-size: 1.25rem; margin-bottom: 12px; }
p { margin: 0 0 16px 0; max-width: 38em; }
.lead { font-size: clamp(1.1rem, 2vw, 1.35rem); line-height: 1.6; margin-bottom: 24px; }

/* 眉标 */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 24px;
  position: relative;
}
.section-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 2px;
  background-color: currentColor;
}
.bg-dark .section-label { color: var(--color-accent); }
.bg-paper .section-label { color: var(--color-brand); }

/* 5. 组件：按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  text-align: center;
}
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border: none;
}
.btn-primary:hover { transform: translateY(-2px); background-color: #d95a73; }
.btn-secondary {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
}
.bg-dark .btn-secondary { border-color: var(--color-paper); }
.bg-paper .btn-secondary { border-color: var(--color-text); }
.btn-secondary:hover { opacity: 0.85; transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* 6. 组件：卡片与面板 */
.card {
  background-color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 24px;
}
.visual-panel {
  background-color: var(--color-dark);
  border-radius: var(--radius-card);
  padding: 32px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.visual-panel svg { width: 100%; height: auto; max-width: 500px; }

/* 7. 组件：表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 12px 0;
  border-bottom: var(--card-border);
  text-align: left;
}
.data-table th { font-weight: 600; }
.table-border td, .table-border th { border-color: rgba(25, 21, 35, 0.16); }

/* 8. 组件：FAQ (Details) */
.faq-item {
  border-bottom: var(--card-border);
  margin-bottom: 16px;
}
.faq-item summary {
  padding: 16px 0;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 32px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: currentColor;
}
.faq-item[open] summary::after { content: "-"; }
.faq-item p { margin: 0; padding-bottom: 16px; line-height: 1.7; }

/* 9. SVG 动效基线 */
.svg-anim { width: 100%; height: auto; }
.node { fill: transparent; stroke-width: 2; transition: fill 0.4s ease; }
.line-draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }
.bubble { opacity: 0.8; }
.dot-input { opacity: 0.4; }

/* 10. 关键帧定义 */
@keyframes gridLightUp {
  0%, 100% { fill: transparent; opacity: 0.2; transform: scale(0.8); }
  50% { fill: var(--color-accent); opacity: 1; transform: scale(1.1); }
}
@keyframes dashFlow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes floatBubble {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-6px); opacity: 1; }
}
@keyframes breatheDot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes slideInCard {
  0% { transform: translateX(20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 11. 动效类绑定 */
.node-light { animation: gridLightUp 6s infinite ease-in-out; }
.node-light.d1 { animation-delay: 0s; }
.node-light.d2 { animation-delay: 1.2s; }
.node-light.d3 { animation-delay: 2.4s; }
.node-light.d4 { animation-delay: 3.6s; }
.node-light.d5 { animation-delay: 4.8s; }

.line-flow { animation: dashFlow 4s infinite linear; }
.bub-float { animation: floatBubble 5s infinite ease-in-out; }
.bub-float.delay-1 { animation-delay: 1.5s; }
.bub-float.delay-2 { animation-delay: 3s; }
.dot-breathe { animation: breatheDot 2.4s infinite ease-in-out; }
.dot-breathe.d1 { animation-delay: 0s; }
.dot-breathe.d2 { animation-delay: 0.4s; }
.dot-breathe.d3 { animation-delay: 0.8s; }
.card-slide { animation: slideInCard 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

/* 12. 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .node-light, .line-flow, .bub-float, .dot-breathe, .card-slide {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 13. 响应式调整 */
@media (max-width: 768px) {
  .grid-2col, .grid-3col { grid-template-columns: 1fr; }
  .flex-row { flex-direction: column; }
  .visual-panel { order: -1; }
}
.grid-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.flex-row { display: flex; gap: var(--gap); align-items: center; }
.flex-row.reverse { flex-direction: row-reverse; }
@media (min-width: 1024px) {
  .flex-row.reverse { flex-direction: row; }
}
