/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计变量与 Token */
:root {
  /* 配色 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-body: #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: 1120px;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --title-weight: 800;
  --title-ls: -0.02em;
  --title-lh: 1.1;
  --body-lh: 1.65;
  --body-size: 18px;

  /* 语义化变量（默认纸面） */
  --bg-page: var(--color-paper);
  --bg-section: var(--color-paper);
  --bg-card: #F4F3F7;
  --text-main: var(--color-body);
  --text-muted: #4A465A;
  --highlight: var(--color-brand);
  --link: var(--color-brand);
  --border-subtle: #E8E6EE;
}

/* 重置与基础 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--body-size);
  line-height: var(--body-lh);
  color: var(--text-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* 布局容器 */
.container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
.section { padding-top: var(--section-y); padding-bottom: var(--section-y); background: var(--bg-section); position: relative; }
.section + .section { border-top: 1px solid var(--border-subtle); }

/* 主题覆盖：深色面 */
.theme-dark {
  --bg-section: var(--color-dark);
  --bg-card: #231B3D;
  --text-main: var(--color-paper);
  --text-muted: #B0A8C9;
  --highlight: var(--color-accent);
  --link: var(--color-accent);
  --border-subtle: #2A2244;
}
/* 主题覆盖：卡片（用于深色区内的浅色面板） */
.theme-card {
  --bg-section: transparent;
  --bg-card: var(--color-paper);
  --text-main: var(--color-body);
  --text-muted: #4A465A;
  --highlight: var(--color-brand);
  --link: var(--color-brand);
  --border-subtle: #E8E6EE;
}

/* 排版组件 */
.label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--highlight);
  margin-bottom: 0.75rem;
}
.hl { color: var(--highlight); font-weight: 700; }
h1, h2, h3 { font-weight: var(--title-weight); letter-spacing: var(--title-ls); line-height: var(--title-lh); color: var(--text-main); }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
p { margin-bottom: 1rem; max-width: 38em; }
strong { font-weight: 700; }

/* 页头 */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(252, 252, 253, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.site-header.scrolled { border-bottom-color: var(--border-subtle); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--text-main); }
.brand img { height: 32px; width: auto; }
.nav { display: flex; gap: 1.5rem; align-items: center; }
.nav a { text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--text-muted); }
.nav a:hover { color: var(--text-main); }
.nav a[aria-current="page"] { color: var(--highlight); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0 1.25rem; height: 48px; min-width: 120px;
  font-weight: 700; font-size: 1rem; border-radius: var(--radius-btn);
  text-decoration: none; cursor: pointer; border: none;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.btn-primary { background: var(--highlight); color: #ffffff; }
.btn-primary:hover { background: color-mix(in srgb, var(--highlight) 85%, black); transform: translateY(-1px); }
.btn-secondary { background: transparent; border: 1px solid var(--text-main); color: var(--text-main); }
.btn-secondary:hover { background: rgba(0,0,0,0.04); transform: translateY(-1px); }
.theme-dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.theme-dark .btn-secondary:hover { background: rgba(255,255,255,0.08); }

/* 卡片与网格 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.card {
  background: var(--bg-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }
.card h3 { margin-top: 0; }
.card p { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0; }
.card time { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* 表格 */
.data-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; min-width: 320px; }
.data-table th, .data-table td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.data-table th { font-weight: 700; color: var(--text-muted); font-size: 0.9rem; }
.data-table td:first-child { font-weight: 600; color: var(--text-main); width: 40%; }

/* 步骤与编号徽标 */
.step-list { counter-reset: step; }
.step-item { position: relative; padding-left: 3.5rem; margin-bottom: 1.5rem; }
.step-item::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 0;
  width: 2.5rem; height: 2.5rem;
  background: var(--highlight); color: var(--color-dark);
  font-weight: 800; font-size: 0.9rem;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.step-item h3 { display: inline; margin-bottom: 0.25rem; }

/* FAQ */
.faq-item { border-bottom: 1px solid var(--border-subtle); margin-bottom: 0; }
.faq-item summary {
  padding: 1.25rem 0; 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.25rem; color: var(--highlight); transition: transform 0.2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding-bottom: 1.25rem; color: var(--text-muted); }

/* 杂志式长文布局 */
.magazine-layout { display: grid; grid-template-columns: 1fr 220px; gap: 2rem; }
.toc-nav { position: sticky; top: 80px; align-self: start; }
.toc-nav ul { border-left: 2px solid var(--border-subtle); padding-left: 1rem; }
.toc-nav li { margin-bottom: 0.75rem; }
.toc-nav a { text-decoration: none; color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.toc-nav a:hover, .toc-nav a.active { color: var(--highlight); }

/* SVG 基础与动效 */
.svg-visual { width: 100%; height: auto; max-width: 100%; overflow: visible; }
.svg-visual path, .svg-visual rect, .svg-visual circle { transition: transform 0.3s ease; }
.anim-draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw-path 2.5s ease forwards; }
.anim-float { animation: float-shape 4s ease-in-out infinite; }
.anim-breathe { animation: breathe-opacity 3s ease-in-out infinite; }
.anim-rotate { animation: rotate-geo 12s linear infinite; transform-box: fill-box; transform-origin: center; }
.anim-rotate-reverse { animation: rotate-geo-rev 14s linear infinite; transform-box: fill-box; transform-origin: center; }

@keyframes draw-path { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes float-shape { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes breathe-opacity { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes rotate-geo { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes rotate-geo-rev { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }

/* 减少动态效果 */
@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-breathe, .anim-rotate, .anim-rotate-reverse { animation: none !important; }
}

/* 响应式适配 */
@media (max-width: 900px) {
  .magazine-layout { grid-template-columns: 1fr; }
  .toc-nav { display: none; }
  .nav { gap: 1rem; }
}
@media (max-width: 600px) {
  .header-inner { height: 56px; }
  .nav a:not(.btn) { display: none; }
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .card-grid { grid-template-columns: 1fr; }
}

/* 兜底：裁掉横向溢出 */
div.container,
div.magazine-layout {
  overflow-x: clip;
}
