/* =========================================
   SafeW 全站共享样式
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-body: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;

  /* 结构 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

/* 面取色变量 */
.paper-face {
  --text-primary: var(--color-body);
  --text-secondary: #5a5c6b;
  --accent-color: var(--color-brand);
  --brand-color: var(--color-brand);
  --bg-base: var(--color-paper);
  --bg-surface: #ffffff;
  --border-color: rgba(21, 23, 35, 0.1);
}

.dark-face {
  --text-primary: var(--color-paper);
  --text-secondary: rgba(247, 245, 243, 0.75);
  --accent-color: var(--color-accent);
  --brand-color: var(--color-accent);
  --bg-base: var(--color-dark);
  --bg-surface: rgba(255, 255, 255, 0.05);
  --border-color: rgba(247, 245, 243, 0.15);
}

.dark-face .card-light {
  --text-primary: var(--color-body);
  --text-secondary: #5a5c6b;
  --accent-color: var(--color-brand);
  --brand-color: var(--color-brand);
  --bg-base: var(--color-paper);
  --bg-surface: #ffffff;
  --border-color: rgba(21, 23, 35, 0.08);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

/* 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-primary);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, p, ul, ol, blockquote { margin: 0; }
ul, ol { padding-left: 1.2em; list-style: none; }
a { color: var(--accent-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
a:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; border-radius: 2px; }

/* 布局容器 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.section {
  padding-block: var(--section-y);
  border-bottom: 1px solid var(--border-color);
}
.section:last-child { border-bottom: none; }
.dark-face .section { border-bottom-color: var(--border-color); }

/* 标题系统 */
.subtitle-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-color);
  margin-bottom: 0.5em;
  text-transform: uppercase;
}
h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1em;
  text-wrap: balance;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 0.8em;
  text-wrap: balance;
}
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}
.hl { color: var(--accent-color); }

/* 正文与段落 */
p { margin-bottom: 1em; color: var(--text-secondary); max-width: 38em; }
.hero-intro { font-size: 1.125rem; line-height: 1.6; color: var(--text-secondary); margin-bottom: 1.5em; }
.hero-fact { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.5em; opacity: 0.8; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  border: none;
}
.btn-primary {
  background-color: var(--accent-color);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-1px); background-color: #5d9fd9; }
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
}
.btn-secondary:hover { background: rgba(128,128,128,0.1); }
.dark-face .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.dark-face .btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* 胶囊与徽章 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 99px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-color);
  color: var(--color-dark);
  font-weight: 700;
  border-radius: 6px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* 网格与交错布局 */
.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); }
.alt-layout { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 768px) {
  .alt-layout.reverse-mobile { direction: rtl; }
  .alt-layout.reverse-mobile > * { direction: ltr; }
  .alt-layout.reverse-mobile .text-side { order: 2; }
  .alt-layout.reverse-mobile .visual-side { order: 1; }
}

/* 卡片与面板 */
.card {
  background: var(--bg-surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  height: 100%;
}
.visual-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--gap);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 列表与细节 */
dl dt { font-weight: 600; margin-bottom: 0.25em; color: var(--text-primary); }
dl dd { margin-left: 1.2em; margin-bottom: 0.8em; color: var(--text-secondary); }
details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 0.8em;
  padding: 0.8em 1em;
  background: var(--bg-surface);
}
summary { cursor: pointer; font-weight: 600; color: var(--text-primary); outline: none; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }
details[open] summary { margin-bottom: 0.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5em; }
details p { margin-top: 0.5em; }

/* 表格 */
.table-wrapper { overflow-x: auto; margin: 1em 0; border: 1px solid var(--border-color); border-radius: var(--radius-card); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8em 1em; text-align: left; border-bottom: 1px solid var(--border-color); }
th { background: var(--bg-surface); font-weight: 600; color: var(--text-primary); }
td { color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }

/* 页头页脚 */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text-primary); text-decoration: none; }
.brand img { width: 28px; height: 28px; object-fit: contain; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { font-size: 0.95rem; color: var(--text-secondary); font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--accent-color); }
.footer { padding: var(--section-y) 0; border-top: 1px solid var(--border-color); font-size: 0.9rem; color: var(--text-secondary); }
.footer-inner { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; }
.footer-col h4 { color: var(--text-primary); font-weight: 600; margin-bottom: 0.8em; }
.footer-col a { display: block; margin-bottom: 0.4em; }

/* 杂志式长文布局 */
.magazine-layout { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 900px) {
  .magazine-layout { grid-template-columns: 240px 1fr; }
  .toc-nav { position: sticky; top: 80px; align-self: start; }
  .toc-nav ul { padding-left: 0; border-left: 2px solid var(--border-color); }
  .toc-nav li { margin-bottom: 0.6em; }
  .toc-nav a { display: block; padding: 4px 0 4px 12px; font-size: 0.9rem; color: var(--text-secondary); }
  .toc-nav a:hover, .toc-nav a.active { color: var(--accent-color); border-left: 2px solid var(--accent-color); margin-left: -2px; }
}

/* SVG 响应式控制 */
.svg-responsive { width: 100%; height: auto; max-width: 100%; display: block; }

/* SVG 动效 Keyframes */
@keyframes drawLine {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes floatSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes pulseOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes slideInRight {
  0% { opacity: 0; transform: translateX(12px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes orbitBreathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.06); opacity: 1; }
}
@keyframes dashFlow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.anim-draw { animation: drawLine 3s ease-out forwards; }
.anim-float { animation: floatSoft 4s ease-in-out infinite; }
.anim-pulse { animation: pulseOpacity 2.5s ease-in-out infinite; }
.anim-slide { animation: slideInRight 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.anim-orbit { animation: orbitBreathe 5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-dash-flow { animation: dashFlow 2s linear infinite; }

/* 减少动态效果适配 */
@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-float, .anim-pulse, .anim-slide, .anim-orbit, .anim-dash-flow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
