/* =========================================
   SafeW 全站共享样式
   设计系统 · 排版 · 组件 · SVG 动效
   ========================================= */

:root {
  /* 色板 */
  --color-bg-dark: #141838;
  --color-bg-paper: #FCFCFD;
  --color-text-body: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  
  /* 表面层覆盖色 */
  --color-text-on-dark: #FCFCFD;
  --color-border-paper: rgba(0, 0, 0, 0.06);
  --color-border-dark: rgba(255, 255, 255, 0.08);

  /* 结构 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;
  
  /* 字体 Token */
  --font-weight-title: 500;
  --line-height-title: 1.15;
  --h1-size: clamp(2.6rem, 6.4vw, 5rem);
  --h2-size: clamp(1.6rem, 3vw, 2.4rem);
  --h3-size: clamp(1.2rem, 2vw, 1.5rem);
  --body-size: 16px;
  --body-line-height: 1.75;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  font-size: var(--body-size);
  line-height: var(--body-line-height);
  color: var(--color-text-body);
  background: var(--color-bg-paper);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* 布局容器 */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.section + .section { border-top: 1px solid var(--color-border-paper); }
.surface-dark + .surface-dark { border-top: none; }

/* 表面层取色规则 */
.surface-dark { background: var(--color-bg-dark); color: var(--color-text-on-dark); }
.surface-dark .hl, .surface-dark .subtitle, .surface-dark .tag { color: var(--color-accent); }
.surface-dark .btn-primary { background: var(--color-accent); color: var(--color-bg-dark); }
.surface-dark .btn-secondary { border-color: var(--color-text-on-dark); color: var(--color-text-on-dark); }
.surface-dark .card-light { background: var(--color-bg-paper); color: var(--color-text-body); border-radius: var(--radius-card); padding: 1.5rem; }
.surface-dark .card-light .hl { color: var(--color-brand); }
.surface-dark .card-light .tag { color: var(--color-brand); }

.surface-paper { background: var(--color-bg-paper); color: var(--color-text-body); }
.surface-paper .hl { color: var(--color-brand); }
.surface-paper .subtitle { color: var(--color-brand); }
.surface-paper .btn-primary { background: var(--color-brand); color: #fff; }
.surface-paper .btn-secondary { border-color: var(--color-text-body); color: var(--color-text-body); }

/* 排版 */
.mt-small { margin-top: 1rem; }
.mt-medium { margin-top: 2rem; }
.mt-large { margin-top: 3rem; }
.text-center { text-align: center; }
.max-w-prose { max-width: 38em; margin-inline: auto; }

h1, h2, h3, h4 { font-weight: var(--font-weight-title); line-height: var(--line-height-title); text-wrap: balance; margin: 0 0 0.8em; }
h1 { font-size: var(--h1-size); letter-spacing: -0.02em; }
h2 { font-size: var(--h2-size); letter-spacing: -0.01em; }
h3 { font-size: var(--h3-size); }
p { margin: 0 0 1em; }

/* 眉标 */
.subtitle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}
.subtitle::before { content: ""; width: 1.5ch; height: 2px; background: currentColor; border-radius: 1px; }

/* 按钮 */
.btn-group { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 50px;
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* 卡片 */
.card {
  background: rgba(0, 0, 0, 0.02);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-2px); }
.surface-dark .card { background: rgba(255, 255, 255, 0.04); }
.card-light .card { background: rgba(0, 0, 0, 0.02); }

/* 网格 */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; table-layout: auto; }
.data-table th, .data-table td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border-paper); min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.surface-dark .data-table th, .surface-dark .data-table td { border-bottom: 1px solid var(--color-border-dark); }
.data-table th { font-weight: 600; }
.data-table td a { color: var(--color-brand); text-decoration: underline; text-underline-offset: 2px; }
.surface-dark .data-table td a { color: var(--color-accent); }

/* 步骤条 */
.steps-row { display: flex; flex-wrap: wrap; gap: var(--gap); counter-reset: step; }
.step-item { flex: 1 1 200px; position: relative; padding-left: 2.5rem; }
.step-item::before {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem;
  background: var(--color-accent); color: var(--color-bg-dark);
  font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.surface-dark .step-item::before { background: var(--color-accent); }

/* 场景标签 */
.scenario-block { display: flex; flex-direction: column; gap: 1rem; }
.tag {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem; border-radius: 4px;
  background: rgba(0,0,0,0.05); color: var(--color-text-body);
}
.surface-dark .tag { background: rgba(255,255,255,0.1); color: var(--color-text-on-dark); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.problem { color: var(--color-brand); }
.surface-dark .tag.problem { color: var(--color-accent); }
.tag.action { color: var(--color-brand); }
.tag.result { color: var(--color-brand); }

/* FAQ */
details {
  border: 1px solid var(--color-border-paper);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: background 0.2s ease;
}
.surface-dark details { border-color: var(--color-border-dark); }
details[open] { background: rgba(0,0,0,0.02); }
.surface-dark details[open] { background: rgba(255,255,255,0.03); }
summary {
  font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-weight: 400; font-size: 1.2rem; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: 0.75rem; margin-bottom: 0; }

/* 页头页脚 */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(252, 252, 253, 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border-paper);
}
.surface-dark .site-header { background: rgba(20, 24, 56, 0.9); border-bottom-color: var(--color-border-dark); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.nav-list { display: flex; gap: 1.5rem; }
.nav-link { font-size: 0.95rem; font-weight: 500; opacity: 0.8; transition: opacity 0.2s; }
.nav-link:hover, .nav-link[aria-current="page"] { opacity: 1; }
.nav-link[aria-current="page"] { font-weight: 700; }
.footer {
  padding: 2rem 0; border-top: 1px solid var(--color-border-paper);
  font-size: 0.85rem; opacity: 0.8;
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }

/* SVG 基础 */
.svg-animated { width: 100%; height: auto; display: block; }
.svg-animated rect, .svg-animated circle, .svg-animated path {
  fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
/* 描边绘制 */
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-cycle 6s ease-in-out infinite;
}
/* 几何旋转 */
.anim-rotate {
  transform-box: fill-box;
  transform-origin: center;
  animation: rotate-sync 12s linear infinite;
}
/* 气泡漂浮 */
.anim-float {
  transform-box: fill-box;
  transform-origin: center;
  animation: float-bubble 5s ease-in-out infinite;
}

@keyframes draw-cycle {
  0%, 100% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
}
@keyframes rotate-sync {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 减少动态效果 */
@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;
  }
  .anim-draw, .anim-rotate, .anim-float { animation: none !important; }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .steps-row { flex-direction: column; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 1rem 0; }
  .nav-list { order: 3; width: 100%; justify-content: center; padding-top: 0.5rem; }
}

/* 兜底：裁掉横向溢出 */
div.container {
  overflow-x: clip;
}
