/* =========================================
   SafeW 全站共享样式
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #271231;
  --color-paper: #F5F0E5;
  --color-body: #1F1523;
  --color-brand: #9B12D8;
  --color-accent: #ED6EC0;
  --color-text-light: #F5F0E5;

  /* 结构 Token */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(31, 21, 35, 0.3);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  --line-height-body: 1.65;

  /* 语义化变量（默认纸面） */
  --surface-bg: var(--color-paper);
  --text-primary: var(--color-body);
  --text-secondary: var(--color-body);
  --link-color: var(--color-brand);
  --highlight-color: var(--color-brand);
  --border-color: rgba(31, 21, 35, 0.12);
}

/* 深色面覆盖 */
.surface-dark {
  --surface-bg: var(--color-dark);
  --text-primary: var(--color-text-light);
  --text-secondary: rgba(245, 240, 229, 0.85);
  --link-color: var(--color-accent);
  --highlight-color: var(--color-accent);
  --border-color: rgba(245, 240, 229, 0.15);
}

/* 深色面上的浅色卡片覆盖 */
.card-light-on-dark {
  --surface-bg: var(--color-paper);
  --text-primary: var(--color-body);
  --text-secondary: var(--color-body);
  --link-color: var(--color-brand);
  --highlight-color: var(--color-brand);
  --border-color: rgba(31, 21, 35, 0.12);
}

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--text-primary);
  background-color: var(--surface-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 容器 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* 排版 */
h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin-bottom: var(--gap); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); margin-bottom: calc(var(--gap) * 0.6); }
p { margin-bottom: 1em; max-width: 38em; }
a { color: var(--link-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.8; }
mark, .hl { color: var(--highlight-color); font-weight: 600; }

/* 眉标 */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--link-color);
  margin-bottom: 0.8em;
}
.section-label::before {
  content: "";
  display: block;
  width: 1.2em;
  height: 2px;
  background-color: currentColor;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  height: 52px;
  padding: 0 1.5em;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 3px solid var(--highlight-color);
  outline-offset: 2px;
}
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(237, 110, 192, 0.35);
}
.btn-secondary {
  background: transparent;
  border: 2px solid var(--text-primary);
  color: var(--text-primary);
}
.surface-dark .btn-secondary {
  border-color: var(--text-primary);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: rgba(31, 21, 35, 0.08);
}
.surface-dark .btn-secondary:hover {
  background-color: rgba(245, 240, 229, 0.08);
}
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* 布局网格 */
.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; align-items: center; gap: var(--gap); }
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }

/* 卡片 */
.card {
  background-color: var(--surface-bg);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5em;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -12px rgba(31, 21, 35, 0.35); }

/* 表格 */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  border-radius: var(--radius-card);
  overflow: hidden;
}
th, td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
th { font-weight: 600; background-color: rgba(31, 21, 35, 0.04); }
.surface-dark th { background-color: rgba(245, 240, 229, 0.06); }
td:first-child { font-weight: 600; white-space: nowrap; }

/* FAQ */
details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 0.8em;
  background-color: var(--surface-bg);
}
summary {
  padding: 1em;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 2.5em;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 1em;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: var(--link-color);
}
details[open] summary::after { content: "−"; }
details > :not(summary) { padding: 0 1em 1em; }

/* 页头页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--surface-bg);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 0.6em; font-weight: 700; font-size: 1.1rem; color: var(--text-primary); }
.logo img { height: 32px; width: auto; }
.nav-links { display: flex; gap: 1.5em; align-items: center; }
.nav-links a { font-size: 0.95rem; font-weight: 500; }
.nav-links a[aria-current="page"] { color: var(--highlight-color); }
.site-footer {
  padding: 3em 0;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2em; }
.footer-col h4 { margin-bottom: 0.8em; font-size: 0.9rem; font-weight: 600; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.5em; }
.footer-col a { font-size: 0.9rem; }
.copyright { margin-top: 2em; font-size: 0.85rem; opacity: 0.7; text-align: center; }

/* SVG 容器 */
.svg-panel {
  width: 100%;
  height: auto;
  max-width: 600px;
  aspect-ratio: 4 / 3;
  background-color: var(--surface-bg);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SVG 动效关键帧 */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes dash-flow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes spin-slow {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}
@keyframes slide-up {
  0% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* 动效类 */
.anim-float { animation: float 6s ease-in-out infinite; }
.anim-breathe { animation: breathe 4s ease-in-out infinite; }
.anim-draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: dash-flow 5s linear infinite; }
.anim-spin { animation: spin-slow 14s linear infinite; transform-box: fill-box; transform-origin: center; }
.anim-delay-1 { animation-delay: 1s; }
.anim-delay-2 { animation-delay: 2s; }
.anim-delay-3 { animation-delay: 3s; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 0.8em 0; }
  .nav-links { order: 3; width: 100%; justify-content: center; margin-top: 0.5em; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .svg-panel { max-width: 100%; }
}
