/* =========================================
   SafeW 全局样式 / Design Tokens / Reset
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;
  
  /* 结构 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1280px;
  
  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --lh-body: 1.65;
  --lh-tight: 1.15;
  
  /* 分割线 */
  --divider: rgba(25, 21, 35, 0.08);
  --divider-dark: rgba(252, 252, 253, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: var(--lh-body);
  -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: min(100% - 32px, var(--content-max));
  margin-inline: auto;
  overflow-x: hidden;
}

/* 页头 */
.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(--divider);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { font-size: 0.95rem; font-weight: 500; transition: color 0.2s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--color-brand); }
.btn-nav {
  background: var(--color-accent); color: var(--color-dark);
  padding: 8px 16px; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 0.9rem; transition: transform 0.2s, filter 0.2s;
}
.btn-nav:hover { transform: translateY(-1px); filter: brightness(0.95); }

/* 按钮系统 */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 24px; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, background 0.2s;
}
.btn:focus-visible { outline: 3px solid var(--color-brand); outline-offset: 2px; }
.btn-primary {
  background: var(--color-accent); color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(0.96); }
.btn-secondary {
  background: transparent; border: 1px solid var(--color-text); color: var(--color-text);
}
.btn-secondary:hover { background: rgba(25, 21, 35, 0.04); }
.dark-surface .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.dark-surface .btn-secondary:hover { background: rgba(252, 252, 253, 0.1); }

/* 眉标与标题 */
.breadcrumb { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 12px; }
.paper-surface .breadcrumb { color: var(--color-brand); }
.dark-surface .breadcrumb { color: var(--color-accent); }

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 500; line-height: var(--lh-tight);
  margin-bottom: var(--gap); letter-spacing: -0.02em;
}
.hl { font-weight: 700; }
.paper-surface .hl { color: var(--color-brand); }
.dark-surface .hl { color: var(--color-accent); }

/* 区块通用 */
.section { padding-block: var(--section-y); border-bottom: 1px solid var(--divider); }
.dark-surface { background: var(--color-dark); color: var(--color-paper); border-bottom: none; }
.dark-surface .section-title { color: var(--color-paper); }
.dark-surface .breadcrumb { color: var(--color-accent); }
.dark-surface .hl { color: var(--color-accent); }
.dark-surface p, .dark-surface li { color: rgba(252, 252, 253, 0.85); }
.dark-surface .paper-card { background: var(--color-paper); color: var(--color-text); border-radius: var(--radius-card); padding: var(--gap); }
.dark-surface .paper-card p, .dark-surface .paper-card li { color: var(--color-text); }

/* 网格与布局 */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--gap); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }

/* 定义列表 */
.def-list { display: grid; gap: 24px; counter-reset: item; }
.def-item { counter-increment: item; display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.def-num {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--color-accent); color: var(--color-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}
.dark-surface .def-num { background: var(--color-brand); color: var(--color-paper); }
.def-content h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.def-content p { font-size: 0.95rem; opacity: 0.85; }

/* 场景对照 */
.scenario-row { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 48px; }
.scenario-row:last-child { margin-bottom: 0; }
.scenario-ctx { padding: 24px; background: rgba(25, 21, 35, 0.03); border-radius: var(--radius-card); border-left: 4px solid var(--color-brand); }
.dark-surface .scenario-ctx { background: rgba(252, 252, 253, 0.05); border-left-color: var(--color-accent); }
.scenario-steps { padding: 24px; }
.step-list { display: grid; gap: 16px; }
.step-item { display: flex; gap: 12px; align-items: flex-start; }
.step-badge { min-width: 24px; height: 24px; border-radius: 6px; background: var(--color-accent); color: var(--color-dark); display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; }
.dark-surface .step-badge { background: var(--color-brand); color: var(--color-paper); }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider); }
.data-table th { font-weight: 600; opacity: 0.7; }
.dark-surface .data-table th, .dark-surface .data-table td { border-bottom-color: rgba(252,252,253,0.1); }

/* FAQ */
.faq-list { display: grid; gap: 16px; }
.faq-item { border: 1px solid var(--divider); border-radius: var(--radius-card); overflow: hidden; }
.faq-item summary {
  padding: 16px 20px; cursor: pointer; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; transition: transform 0.2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .answer { padding: 0 20px 16px; font-size: 0.95rem; opacity: 0.85; line-height: 1.7; }
.dark-surface .faq-item { border-color: rgba(252,252,253,0.15); }

/* 卡片 */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }
.news-date { font-size: 0.8rem; color: var(--color-brand); font-weight: 600; margin-bottom: 8px; display: block; }
.dark-surface .news-date { color: var(--color-accent); }

/* 杂志长文侧栏 */
.mag-layout { display: grid; grid-template-columns: 240px 1fr; gap: 48px; align-items: start; }
.mag-toc { position: sticky; top: 80px; padding-right: 16px; border-right: 1px solid var(--divider); }
.mag-toc li { margin-bottom: 12px; }
.mag-toc a { font-size: 0.9rem; color: var(--color-text); opacity: 0.7; transition: opacity 0.2s; }
.mag-toc a:hover, .mag-toc a.active { opacity: 1; color: var(--color-brand); }
.dark-surface .mag-toc { border-right-color: var(--divider-dark); }
.dark-surface .mag-toc a { color: var(--color-paper); }
.dark-surface .mag-toc a:hover { color: var(--color-accent); }
.mag-body h3 { font-size: 1.3rem; margin-top: 32px; margin-bottom: 12px; font-weight: 600; }
.mag-body p { margin-bottom: 16px; }

/* SVG 基础与动效 */
.svg-panel { width: 100%; height: auto; }
svg { overflow: visible; }
svg [class*="anim-"] { transition: all 0.3s; }
.anim-float { animation: floatY 4s ease-in-out infinite; }
.anim-breathe { animation: breathe 3s ease-in-out infinite; }
.anim-slideIn { animation: slideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.anim-flow { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: flowDash 4s linear infinite; }
.anim-dot-flow { animation: dotMove 3s linear infinite; }

@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes flowDash { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dotMove {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* 减少动态效果 */
@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;
  }
}

/* 响应式 */
@media (max-width: 900px) {
  .mag-layout { grid-template-columns: 1fr; }
  .mag-toc { position: static; border-right: none; border-bottom: 1px solid var(--divider); padding-bottom: 16px; margin-bottom: 24px; display: flex; gap: 16px; flex-wrap: wrap; }
  .scenario-row { grid-template-columns: 1fr; }
  .nav { gap: 16px; }
  .btn-nav span { display: none; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .header-inner { height: 56px; }
}
