/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计 Token / 变量 */
:root {
  /* 颜色系统 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;
  
  /* 默认取色（纸面模式） */
  --bg-surface: var(--color-paper);
  --text-primary: var(--color-text);
  --text-secondary: #4A4558;
  --accent-target: var(--color-brand);
  --border-color: #E5E3EA;
  --card-bg: #FFFFFF;

  /* 尺寸与间距 */
  --radius-card: 8px;
  --radius-btn: 6px;
  --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, "Noto Sans SC", sans-serif;
}

/* 深色面覆盖 */
.surface-dark {
  --bg-surface: var(--color-dark);
  --text-primary: var(--color-paper);
  --text-secondary: #B8B3C9;
  --accent-target: var(--color-accent);
  --border-color: rgba(255, 255, 255, 0.12);
  --card-bg: rgba(255, 255, 255, 0.06);
}

/* 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
ul, ol { padding-left: 0; list-style: none; }

/* 容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* 眉标 */
.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-target);
  margin-bottom: 0.75rem;
}

/* 标题 */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 0.75rem;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); line-height: 1.15; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.25; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; line-height: 1.3; margin-bottom: 0.5rem; }
p { margin-bottom: 1.25rem; max-width: 38em; }

/* 高亮词 */
.hl { color: var(--accent-target); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  border: none;
  text-decoration: none;
}
.btn:focus-visible { outline: 3px solid var(--accent-target); outline-offset: 2px; }
.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background-color: #5CE0C4; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--text-primary);
  color: var(--text-primary);
}
.btn-outline:hover { background-color: rgba(0,0,0,0.04); }
.surface-dark .btn-outline { border-color: var(--color-paper); color: var(--color-paper); }
.surface-dark .btn-outline:hover { background-color: rgba(255,255,255,0.08); }

/* 页头 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.brand img { width: 28px; height: 28px; object-fit: contain; }
nav ul { display: flex; gap: 1.5rem; align-items: center; }
nav a { font-size: 0.95rem; font-weight: 500; opacity: 0.85; }
nav a:hover, nav [aria-current="page"] { opacity: 1; color: var(--accent-target); }
.surface-dark nav a { color: var(--color-paper); }
.nav-actions { display: flex; gap: 0.75rem; align-items: center; }

/* 页脚 */
.site-footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}
.footer-col h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text-primary); }
.footer-col a { display: block; padding: 0.25rem 0; opacity: 0.8; }
.footer-col a:hover { opacity: 1; color: var(--accent-target); }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }

/* 卡片与面板 */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}
.panel {
  background-color: var(--bg-surface);
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}
.surface-dark .panel { background-color: rgba(255,255,255,0.04); }

/* 表格 */
.table-wrapper { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--border-color); border-radius: var(--radius-card); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { background-color: rgba(0,0,0,0.03); font-weight: 600; }
.surface-dark th { background-color: rgba(255,255,255,0.05); }
tr:last-child td { border-bottom: none; }

/* FAQ details */
details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 0.75rem;
  background-color: var(--card-bg);
  transition: background-color 0.2s ease;
}
details[open] { background-color: rgba(0,0,0,0.02); }
.surface-dark details[open] { background-color: rgba(255,255,255,0.04); }
summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 1.2rem; font-weight: 400; transition: transform 0.2s ease; }
details[open] summary::after { transform: rotate(45deg); }
details p { padding: 0 1.25rem 1rem; margin: 0; font-size: 0.95rem; color: var(--text-secondary); }

/* 网格布局辅助 */
.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); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }

/* 分割线与视觉引导 */
.divider-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: var(--section-y) 0;
  border: none;
}

/* SVG 动效基类 */
svg.animated { width: 100%; height: auto; }
svg.animated path, svg.animated circle, svg.animated rect, svg.animated line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s ease;
}

/* 动效定义 */
@keyframes draw-in {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}
@keyframes float-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes dash-flow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

.anim-draw { animation: draw-in 3s ease forwards; }
.anim-breathe { animation: breathe 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-float { animation: float-up 5s ease-in-out infinite; }
.anim-dash-flow { animation: dash-flow 2.5s ease forwards; }
.anim-pulse { animation: pulse-dot 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.5s; }
.delay-3 { animation-delay: 0.8s; }

/* 响应式调整 */
@media (max-width: 768px) {
  .header-inner { height: 56px; }
  nav ul { display: none; } /* 简化移动端处理，实际项目可加汉堡菜单 */
  h1 { font-size: clamp(1.8rem, 6vw, 2.5rem); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .magazine-layout { grid-template-columns: 1fr !important; }
  .magazine-toc { display: none; }
}

/* 减少动态效果 */
@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-breathe, .anim-float, .anim-dash-flow, .anim-pulse {
    animation: none !important;
    stroke-dashoffset: 0 !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
