/* =========================================
   SafeW 全站共享样式 (style.css)
   ========================================= */

/* --- 设计变量与基础重置 --- */
:root {
  /* 色板 */
  --color-dark: #21163C;
  --color-paper: #E9E8EA;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED926E;

  /* 结构 Token */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;

  /* 排版 Token */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title-weight: 600;
  --line-height-body: 1.55;
}

*, *::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-body);
  font-size: 1rem;
  background-color: var(--color-paper);
  color: var(--color-body);
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- 表面层取色覆盖规则 --- */
.surface-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.surface-dark .hl { color: var(--color-accent); }
.surface-dark .badge { color: var(--color-accent); }
.surface-dark a:not(.btn) { color: var(--color-accent); }
.surface-dark .icon { stroke: var(--color-accent); }

.surface-paper {
  background-color: var(--color-paper);
  color: var(--color-body);
}
.surface-paper .hl { color: var(--color-brand); }
.surface-paper .badge { color: var(--color-brand); }
.surface-paper a:not(.btn) { color: var(--color-brand); }
.surface-paper .icon { stroke: var(--color-brand); }

/* 深色面上的浅色卡片恢复纸面取色 */
.surface-dark .card-light {
  background-color: var(--color-paper);
  color: var(--color-body);
  border: var(--card-border);
}
.surface-dark .card-light .hl { color: var(--color-brand); }
.surface-dark .card-light .badge { color: var(--color-brand); }
.surface-dark .card-light a:not(.btn) { color: var(--color-brand); }
.surface-dark .card-light .icon { stroke: var(--color-brand); }

/* --- 布局容器 --- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding: var(--section-y) 0;
}

.grid-layout {
  display: grid;
  gap: var(--gap);
}

/* --- 排版系统 --- */
h1, h2, h3, h4 {
  font-weight: var(--font-title-weight);
  line-height: 1.25;
  letter-spacing: 0;
  margin-bottom: 0.5em;
}

h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-top: 1.5em; }
h3 { font-size: 1.25rem; margin-top: 1.2em; }

p { margin-bottom: 1em; max-width: 38em; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.6em;
  text-transform: uppercase;
}
.hl { font-weight: 700; }

/* --- 组件：按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); background-color: #e08560; }
.btn-secondary {
  background: transparent;
  border: 2px solid currentColor;
  color: inherit;
}
.btn-secondary:hover { background-color: rgba(128,128,128,0.1); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.icon-btn {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* --- 组件：卡片与面板 --- */
.card {
  border-radius: var(--radius-card);
  border: var(--card-border);
  background: var(--color-paper);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
}
.panel {
  border-radius: var(--radius-card);
  background: var(--color-dark);
  padding: var(--gap);
  overflow: hidden;
}

/* --- 组件：表格 --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1em 0;
}
.data-table th, .data-table td {
  padding: 0.75em 1em;
  border-bottom: 1px solid rgba(128,128,128,0.2);
  text-align: left;
}
.data-table th { font-weight: 600; }
.surface-dark .data-table th, .surface-dark .data-table td { border-color: rgba(233,232,234,0.15); }

/* --- 组件：FAQ (Details/Summary) --- */
details {
  border-radius: var(--radius-card);
  border: var(--card-border);
  background: var(--color-paper);
  margin-bottom: var(--gap);
  overflow: hidden;
}
summary {
  padding: 1rem var(--gap);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 2.5rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: var(--color-brand);
}
details[open] summary::after { content: "-"; }
details .answer {
  padding: 0 var(--gap) 1rem;
  line-height: 1.6;
}

/* --- 组件：时间轴 --- */
.timeline {
  position: relative;
  padding-left: 2rem;
  border-left: 2px solid rgba(128,128,128,0.3);
}
.timeline-item {
  position: relative;
  margin-bottom: 2rem;
  padding-left: 1rem;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -2.35rem;
  top: 0.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-dark);
}
.timeline-time {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 0.3em;
  display: block;
}

/* --- 组件：步骤条 --- */
.steps-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  counter-reset: step-counter;
}
.step-card {
  flex: 1 1 250px;
  counter-increment: step-counter;
  position: relative;
  padding-top: 2.5rem;
}
.step-card::before {
  content: "0" counter(step-counter);
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 48px;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- 组件：定义列表 --- */
.def-list dt {
  font-weight: 700;
  margin-bottom: 0.25em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.def-list dd {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
  color: currentColor;
  opacity: 0.9;
}

/* --- 页头与页脚 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(233, 232, 234, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-links {
  display: flex;
  gap: 1.5rem;
}
.nav-links a {
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  color: var(--color-brand);
}
.site-footer {
  background: var(--color-dark);
  color: var(--color-paper);
  padding: 3rem 0;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}
.footer-col h4 {
  color: var(--color-accent);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.footer-col ul li { margin-bottom: 0.6rem; }
.footer-col a:hover { text-decoration: underline; }
.copyright {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(233,232,234,0.15);
  font-size: 0.85rem;
  opacity: 0.8;
}

/* --- SVG 动效系统 --- */
.ui-svg {
  width: 100%;
  height: auto;
}
.ui-svg .node {
  fill: var(--color-body);
  opacity: 0.2;
  transition: fill 0.4s ease, opacity 0.4s ease;
}
.surface-dark .ui-svg .node { fill: var(--color-paper); }
.animate-grid .ui-svg .node:nth-child(1) { animation: gridPulse 5s infinite alternate ease-in-out 0.2s; }
.animate-grid .ui-svg .node:nth-child(2) { animation: gridPulse 5s infinite alternate ease-in-out 0.4s; }
.animate-grid .ui-svg .node:nth-child(3) { animation: gridPulse 5s infinite alternate ease-in-out 0.6s; }
.animate-grid .ui-svg .node:nth-child(4) { animation: gridPulse 5s infinite alternate ease-in-out 0.8s; }
.animate-grid .ui-svg .node:nth-child(5) { animation: gridPulse 5s infinite alternate ease-in-out 1.0s; }
.animate-grid .ui-svg .node:nth-child(6) { animation: gridPulse 5s infinite alternate ease-in-out 1.2s; }
.animate-grid .ui-svg .node:nth-child(7) { animation: gridPulse 5s infinite alternate ease-in-out 1.4s; }
.animate-grid .ui-svg .node:nth-child(8) { animation: gridPulse 5s infinite alternate ease-in-out 1.6s; }

@keyframes gridPulse {
  0%, 100% { opacity: 0.2; fill: var(--color-body); }
  50% { opacity: 1; fill: var(--color-accent); }
}
.surface-dark .animate-grid .ui-svg .node { fill: var(--color-paper); }
.surface-dark .animate-grid .ui-svg .node:nth-child(odd),
.surface-dark .animate-grid .ui-svg .node:nth-child(even) {
  animation-name: gridPulseDark;
}
@keyframes gridPulseDark {
  0%, 100% { opacity: 0.2; fill: var(--color-paper); }
  50% { opacity: 1; fill: var(--color-accent); }
}

.bubble-float {
  animation: floatY 4s infinite alternate ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes floatY {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

.input-breathe circle {
  animation: breathe 2.4s infinite alternate ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}
.input-breathe circle:nth-child(2) { animation-delay: 0.2s; }
.input-breathe circle:nth-child(3) { animation-delay: 0.4s; }
@keyframes breathe {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

.slide-in {
  animation: slideInRight 6s infinite alternate ease-in-out;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes slideInRight {
  0%, 100% { transform: translateX(0); opacity: 0.85; }
  50% { transform: translateX(8px); opacity: 1; }
}

.draw-line {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawDash 8s infinite linear;
}
@keyframes drawDash {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}

/* --- 减少动态效果 --- */
@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;
  }
  .bubble-float, .input-breathe circle, .slide-in, .draw-line, .node {
    animation: none !important;
    opacity: 1 !important;
    fill: currentColor !important;
  }
}

/* --- 响应式适配 --- */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .header-inner { flex-direction: column; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
  .nav-links { gap: 1rem; flex-wrap: wrap; justify-content: center; }
  .hero-layout { grid-template-columns: 1fr !important; }
  .steps-row { flex-direction: column; }
  .timeline { padding-left: 1.5rem; }
  .timeline-item::before { left: -1.85rem; }
}

@media (min-width: 769px) {
  .hero-layout { grid-template-columns: 1fr 1fr; align-items: center; }
  .news-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .feature-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
