/* ============================================
   SafeW 全站共享样式
   ============================================ */

/* --- 设计变量 --- */
:root {
  /* 色板 */
  --color-dark: #21163C;
  --color-paper: #E9E8EA;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED926E;
  --color-text-on-dark: #E9E8EA;
  --color-accent-on-dark: #ED926E;

  /* 尺寸与节奏 */
  --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: 1120px;

  /* 排版 */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --lh-body: 1.55;
  --lh-h1: 1.25;
  --lh-h2: 1.25;
  --fw-title: 600;
  --tracking-title: 0;
}

/* --- 基础重置 --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- 布局容器 --- */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.dark-surface { background: var(--color-dark); color: var(--color-text-on-dark); }
.paper-surface { background: var(--color-paper); color: var(--color-text); }

/* 深色面上的浅色卡片恢复纸面取色 */
.dark-surface .card {
  background: var(--color-paper);
  color: var(--color-text);
  border-color: var(--card-border);
}
.dark-surface .card h3, .dark-surface .card p { color: var(--color-text); }
.dark-surface .card .hl { color: var(--color-brand); }

/* 下载页：深色背景上的说明文字需保持可读性 */
.dark-surface .download-grid div.dl-card p { color: var(--color-text-on-dark) !important; opacity: 1 !important; }

/* --- 排版 --- */
h1, h2, h3, h4 { font-weight: var(--fw-title); letter-spacing: var(--tracking-title); line-height: var(--lh-h1); margin-top: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: 1.5em; text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1.2em; text-wrap: balance; }
h3 { font-size: 1.25rem; margin-bottom: 0.8em; }
p { margin-bottom: 1em; max-width: 38em; }
mark, .hl { font-weight: 700; }
.paper-surface .hl { color: var(--color-brand); }
.dark-surface .hl { color: var(--color-accent); }

/* 眉标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.8em;
}
.paper-surface .badge { color: var(--color-brand); }
.dark-surface .badge { color: var(--color-accent); }
.badge::before {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  height: 48px;
  padding: 0 1.4em;
  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, opacity 0.2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-primary:hover { background: #d9825f; }
.btn-secondary { background: transparent; border: 1px solid var(--color-text); color: var(--color-text); }
.dark-surface .btn-secondary { border-color: var(--color-text-on-dark); color: var(--color-text-on-dark); }
.dark-surface .btn-secondary:hover { background: rgba(233, 232, 234, 0.08); }

/* --- 卡片与面板 --- */
.card {
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: var(--gap);
  background: var(--color-paper);
  box-shadow: var(--card-shadow);
}
.panel {
  border-radius: var(--radius-card);
  padding: 1.5em;
  background: var(--color-dark);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.dark-surface .panel { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(233, 232, 234, 0.1); }

/* --- 表格 --- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}
.dark-surface th, .dark-surface td { border-bottom-color: rgba(233, 232, 234, 0.1); }
th { font-weight: 600; }
td:first-child { font-weight: 600; }
a.link-underline { text-decoration: underline; text-underline-offset: 3px; }
.paper-surface .link-underline { color: var(--color-brand); }
.dark-surface .link-underline { color: var(--color-accent); }

/* --- 详情/FAQ --- */
details {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  padding: 1em;
  background: var(--color-paper);
}
.dark-surface details {
  background: rgba(233, 232, 234, 0.06);
  border-color: rgba(233, 232, 234, 0.1);
}
summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6em;
}
summary::-webkit-details-marker { display: none; }
summary::marker { display: none; }
summary::after {
  content: "+";
  margin-left: auto;
  font-weight: 400;
  opacity: 0.6;
}
details[open] summary::after { content: "−"; }
details p { margin-top: 0.8em; margin-bottom: 0; }

/* --- 时间轴 --- */
.timeline { position: relative; padding-left: 1.5em; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: currentColor;
  opacity: 0.2;
}
.timeline-item { position: relative; margin-bottom: 2em; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.5em;
  top: 0.5em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-paper);
}
.dark-surface .timeline-item::before { border-color: var(--color-dark); }
.timeline-time { font-size: 0.85rem; font-weight: 700; opacity: 0.8; margin-bottom: 0.3em; }

/* --- 步骤条 --- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.step { counter-increment: step-counter; position: relative; padding: 1em; border-radius: var(--radius-card); background: rgba(25, 21, 35, 0.03); }
.dark-surface .step { background: rgba(233, 232, 234, 0.05); }
.step::before {
  content: counter(step-counter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.6em;
}

/* --- 页头与页脚 --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(233, 232, 234, 0.85);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
.dark-surface .header { background: rgba(33, 22, 60, 0.9); border-bottom-color: rgba(233, 232, 234, 0.1); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 0.6em; font-weight: 700; font-size: 1.1rem; }
.logo img { width: 28px; height: 28px; object-fit: contain; }
nav { display: flex; gap: 1.5em; }
nav a { font-weight: 500; font-size: 0.95rem; opacity: 0.8; transition: opacity 0.2s; }
nav a:hover, nav a[aria-current="page"] { opacity: 1; }
.footer {
  padding: 2em 0;
  border-top: 1px solid rgba(25, 21, 35, 0.1);
  font-size: 0.9rem;
  opacity: 0.8;
}
.dark-surface .footer { border-top-color: rgba(233, 232, 234, 0.1); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1em; }
.footer-links { display: flex; gap: 1.2em; }

/* --- SVG 动效 --- */
.svg-panel { width: 100%; height: auto; }
svg { width: 100%; height: auto; }
svg path, svg line, svg polyline, svg circle {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.draw-line { animation: drawLine 4s ease-in-out infinite alternate; }
.float-bubble { animation: floatBubble 6s ease-in-out infinite alternate; }
.pulse-dot { animation: pulseDot 3s ease-in-out infinite; }
.rotate-shape { animation: rotateShape 12s linear infinite; transform-box: fill-box; transform-origin: center; }
.slide-in { animation: slideIn 5s ease-out infinite alternate; }
.stroke-accent { stroke: var(--color-accent); }
.stroke-brand { stroke: var(--color-brand); }
.stroke-text { stroke: var(--color-text); }
.dark-surface .stroke-text { stroke: var(--color-text-on-dark); }
.fill-text { fill: var(--color-text); }
.dark-surface .fill-text { fill: var(--color-text-on-dark); }
.fill-accent { fill: var(--color-accent); }
.fill-brand { fill: var(--color-brand); }
.fill-dark { fill: var(--color-dark); }
.fill-paper { fill: var(--color-paper); }

@keyframes drawLine {
  0% { stroke-dashoffset: 1; }
  50%, 100% { stroke-dashoffset: 0; }
}
@keyframes floatBubble {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}
@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}
@keyframes rotateShape {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes slideIn {
  0% { transform: translateX(-8px); opacity: 0.7; }
  100% { transform: translateX(0); opacity: 1; }
}

/* --- 响应式与无障碍 --- */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; height: auto; padding: 0.8em 0; }
  nav { margin-top: 0.5em; }
  .hero-grid { grid-template-columns: 1fr !important; }
  .steps { grid-template-columns: 1fr; }
  .timeline { padding-left: 1.2em; }
}
@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;
  }
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
