/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计变量 */
:root {
  /* 颜色系统 */
  --color-dark: #231334;
  --color-paper: #F5F3F7;
  --color-text: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;

  /* 结构变量 */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  --line-height-base: 1.55;

  /* 字体 */
  --font-main: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-main);
  color: var(--color-text);
  background: var(--color-paper);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* 容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

/* 页面主题层 */
.dark-surface {
  background: var(--color-dark);
  color: var(--color-paper);
}
.dark-surface .hl { color: var(--color-accent); }
.paper-surface {
  background: var(--color-paper);
  color: var(--color-text);
}
.paper-surface .hl { color: var(--color-brand); }

/* 眉标 */
.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--gap);
}
.paper-surface .eyebrow { color: var(--color-brand); }
.dark-surface .eyebrow { color: var(--color-accent); }

/* 标题 */
h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: var(--gap);
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  margin-bottom: var(--gap);
  margin-top: calc(var(--section-y) * 0.8);
}
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: var(--gap);
}

/* 正文 */
p { margin-bottom: var(--gap); max-width: 38em; }
.text-muted { opacity: 0.85; font-size: 0.95rem; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-height: 52px;
  padding: 0 1.5em;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  border: none;
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn:hover { transform: translateY(-2px); filter: brightness(0.95); }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.btn-secondary {
  background: transparent;
  border: 2px solid var(--color-text);
  color: var(--color-text);
}
.dark-surface .btn-secondary {
  border-color: var(--color-paper);
  color: var(--color-paper);
}

/* 卡片 */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  transition: transform 0.2s ease;
}
.card:hover { transform: translateX(2px); }
.dark-surface .card { background: var(--color-dark); border-color: var(--color-paper); box-shadow: 4px 4px 0 var(--color-paper); }

/* 网格布局 */
.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); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--gap) 0;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 0.75em 1em;
  border-bottom: 1px solid currentColor;
  text-align: left;
}
.data-table th { font-weight: 700; width: 40%; }
.paper-surface .data-table th { color: var(--color-text); }
.dark-surface .data-table th { color: var(--color-paper); }

/* 步骤条 */
.steps-list {
  display: flex;
  gap: var(--gap);
  counter-reset: step;
}
.step-item {
  flex: 1;
  min-width: 0;
  position: relative;
  padding-top: 2.5em;
}
.step-item::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  top: 0;
  left: 0;
  width: 2em;
  height: 2em;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 800;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
}
.dark-surface .step-item::before { background: var(--color-accent); color: var(--color-dark); }

/* FAQ */
details {
  border: 1px solid currentColor;
  border-radius: 12px;
  padding: 1em;
  margin-bottom: var(--gap);
  transition: background 0.2s;
}
summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5em;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}
details[open] summary { margin-bottom: 0.5em; }
.dark-surface details { border-color: rgba(245,243,247,0.3); }

/* 页头页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 243, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(28, 21, 35, 0.1);
}
.dark-surface .site-header { background: rgba(35, 19, 52, 0.95); border-bottom-color: rgba(245, 243, 247, 0.1); }
.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand img { height: 32px; width: auto; }
.nav-links { display: flex; gap: 1.5em; align-items: center; }
.nav-links a { font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { opacity: 0.8; }
.nav-links a[aria-current="page"] { font-weight: 700; border-bottom: 2px solid currentColor; }
.footer {
  padding: var(--section-y) 0;
  border-top: 1px solid currentColor;
  margin-top: var(--section-y);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}
.footer-col h4 { font-weight: 700; margin-bottom: 0.5em; }
.footer-col ul li { margin-bottom: 0.4em; }
.footer-col a { opacity: 0.8; }
.footer-col a:hover { opacity: 1; text-decoration: underline; }

/* SVG 动效基础 */
.svg-panel {
  width: 100%;
  height: auto;
  max-width: 100%;
}
.geo-shape {
  transform-box: fill-box;
  transform-origin: center;
}
.draw-line {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

/* 动画关键帧 */
@keyframes rotate-slow {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
}
@keyframes rotate-reverse {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-150deg); }
}
@keyframes float-up {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-8px); opacity: 1; }
}
@keyframes dash-flow {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* 动效类 */
.anim-rotate { animation: rotate-slow 12s linear infinite; }
.anim-rotate-rev { animation: rotate-reverse 15s linear infinite; }
.anim-float { animation: float-up 4s ease-in-out infinite; }
.anim-draw { animation: dash-flow 3s ease-in-out infinite; }
.anim-pulse { animation: pulse-dot 2s ease-in-out infinite; }

/* 响应式与无障碍 */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .steps-list { flex-direction: column; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 1em 0; }
  .nav-links { order: 3; width: 100%; justify-content: center; margin-top: 0.5em; }
  
  /* 修复横向溢出：确保所有块级元素不超出容器宽度 */
  h1, h2, h3, p, ul, ol, table, svg { max-width: 100%; }
  .flex-row > * { min-width: 0; }
}

@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;
  }
  .svg-panel { display: block; }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
