/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 色板 */
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-text: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;

  /* 结构性 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;

  /* 排版 */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-body: 1.65;
}

/* --- 基础重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background-color: var(--color-paper);
  color: var(--color-text);
  line-height: var(--line-height-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; }

/* --- 面与容器 --- */
.bg-dark {
  --color-bg: var(--color-dark);
  --color-fg: var(--color-paper);
  --color-highlight: var(--color-accent);
  background-color: var(--color-bg);
  color: var(--color-fg);
  overflow-x: hidden;
}
.bg-paper {
  --color-bg: var(--color-paper);
  --color-fg: var(--color-text);
  --color-highlight: var(--color-brand);
  background-color: var(--color-bg);
  color: var(--color-fg);
  overflow-x: hidden;
}
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
  overflow-x: hidden;
}
.section {
  padding-block: var(--section-y);
  position: relative;
  overflow-x: hidden;
}

/* --- 排版 --- */
h1, h2, h3, h4 { line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); margin-bottom: var(--gap); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: calc(var(--gap) * 0.75); text-wrap: balance; }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); margin-bottom: calc(var(--gap) * 0.5); }
p { margin-bottom: var(--gap); max-width: 38em; }
.lead { font-size: clamp(1.1rem, 1.5vw, 1.25rem); opacity: 0.9; margin-bottom: calc(var(--gap) * 1.5); }
.hl { color: var(--color-highlight); }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: calc(var(--gap) * 0.5);
  color: var(--color-highlight);
}
.text-muted { opacity: 0.75; font-size: 0.9rem; }

/* --- 页头与导航 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-paper);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  transition: background 0.2s, box-shadow 0.2s;
}
.site-header.scrolled {
  background: rgba(247, 245, 243, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.logo img { height: 32px; width: auto; }
.nav-list { display: flex; gap: calc(var(--gap) * 1.5); }
.nav-link { font-weight: 500; font-size: 0.95rem; padding: 4px 0; position: relative; }
.nav-link[aria-current="page"] { color: var(--color-highlight); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; bottom: -2px; left: 0; width: 100%; height: 2px; background: var(--color-highlight);
}
.header-actions { display: flex; align-items: center; gap: 12px; }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  border: none;
}
.btn:focus-visible { outline: 2px solid var(--color-highlight); outline-offset: 3px; }
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background-color: #5a9bd6; }
.btn-secondary {
  background: transparent;
  border: 2px solid var(--color-text);
  color: var(--color-text);
}
.bg-dark .btn-secondary {
  border-color: var(--color-paper);
  color: var(--color-paper);
}
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* --- 卡片与面板 --- */
.card {
  background: var(--color-bg);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: calc(var(--gap) * 1.5);
  position: relative;
  overflow: hidden;
}
.card-light-on-dark {
  --color-bg: var(--color-paper);
  --color-fg: var(--color-text);
  --color-highlight: var(--color-brand);
  background-color: var(--color-paper);
  color: var(--color-text);
  border-color: var(--color-text);
}
.panel-deep {
  background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, transparent 100%), var(--color-bg);
  border-radius: var(--radius-card);
  padding: calc(var(--gap) * 2);
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- 表格 --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-top: var(--gap);
}
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.data-table th { font-weight: 600; }
.bg-dark .data-table th, .bg-dark .data-table td { border-color: rgba(255,255,255,0.15); }

/* --- 列表与定义 --- */
.def-list dt { font-weight: 600; margin-top: calc(var(--gap) * 0.75); margin-bottom: 4px; }
.def-list dd { margin-left: 0; margin-bottom: var(--gap); opacity: 0.9; }
.step-list { counter-reset: step; }
.step-item {
  display: flex;
  gap: 16px;
  margin-bottom: var(--gap);
  counter-increment: step;
}
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  border-radius: 6px;
}

/* --- FAQ --- */
.faq-item { border-bottom: 1px solid rgba(0,0,0,0.1); padding: 16px 0; }
.bg-dark .faq-item { border-color: rgba(255,255,255,0.15); }
.faq-summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.faq-summary::-webkit-details-marker { display: none; }
.faq-summary::after { content: "+"; font-size: 1.2rem; transition: transform 0.2s; }
.faq-item[open] .faq-summary::after { transform: rotate(45deg); }
.faq-answer { margin-top: 8px; opacity: 0.9; }

/* --- 网格布局 --- */
.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); }
.grid-magazine { display: grid; grid-template-columns: 1fr 280px; gap: calc(var(--gap) * 2); }
@media (max-width: 900px) {
  .grid-magazine { grid-template-columns: 1fr; }
  .nav-list { display: none; } /* 移动端简化，实际项目可加汉堡菜单 */
}

/* --- SVG 容器与响应式 --- */
.svg-container { width: 100%; height: auto; }
.svg-container svg { width: 100%; height: auto; display: block; }

/* --- SVG 动效 Keyframes --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes slideIn {
  0%, 100% { transform: translateX(0); opacity: 1; }
  10% { transform: translateX(-12px); opacity: 0; }
  20% { transform: translateX(0); opacity: 1; }
}
@keyframes drawLine {
  0%, 100% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
}
@keyframes spinMerge {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
}

.anim-float { animation: float 6s ease-in-out infinite; }
.anim-breathe { animation: breathe 3s ease-in-out infinite; }
.anim-slide-in { animation: slideIn 5s ease-in-out infinite; }
.anim-flow { animation: drawLine 4s ease-in-out infinite; }
.anim-rotate { 
  animation: spinMerge 8s linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* --- 减少动态效果 --- */
@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-container svg { display: block; }
}
