/* =========================================
   SafeW 共享样式 (style.css)
   ========================================= */

/* --- 1. 设计 Token 与变量 --- */
:root {
  /* 颜色体系 */
  --color-bg-dark: #271231;
  --color-bg-paper: #F5F0E5;
  --color-text-body: #1F1523;
  --color-brand: #9B12D8;
  --color-accent: #ED6EC0;

  /* 语义化颜色映射 */
  --bg-base: var(--color-bg-paper);
  --text-primary: var(--color-text-body);
  --text-secondary: color-mix(in srgb, var(--color-text-body) 70%, transparent);
  --brand-color: var(--color-brand);
  --accent-color: var(--color-accent);
  --border-color: color-mix(in srgb, var(--color-text-body) 16%, transparent);

  /* 布局与间距 */
  --content-max: 960px;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  
  /* 组件形态 */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 1px solid var(--border-color);
  --card-shadow: none;

  /* 字体比例 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 深色面覆盖变量 */
.dark-surface {
  --bg-base: var(--color-bg-dark);
  --text-primary: var(--color-bg-paper);
  --text-secondary: color-mix(in srgb, var(--color-bg-paper) 70%, transparent);
  --brand-color: var(--color-accent);
  --accent-color: var(--color-accent);
  --border-color: color-mix(in srgb, var(--color-bg-paper) 20%, transparent);
}

/* --- 2. 基础重置与排版 --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.55;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-color);
  text-decoration: none;
  transition: opacity 0.2s;
}
a:hover {
  opacity: 0.85;
  text-decoration: underline;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* --- 3. 通用布局容器 --- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section {
  padding: var(--section-y) 0;
  position: relative;
}

/* 细线分节：纸面上用边框，深色面用透明或浅色线 */
.section-divider {
  border-top: 1px solid var(--border-color);
  width: 100%;
}

/* --- 4. 标题与眉标 --- */
.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--brand-color);
  margin-bottom: calc(var(--gap) / 2);
  text-transform: uppercase;
}

h1, h2, h3, h4 {
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: var(--gap);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: calc(var(--gap) / 2);
}

/* 关键词高亮 */
.hl {
  color: var(--brand-color);
}
.dark-surface .hl {
  color: var(--accent-color);
}

/* --- 5. 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent-color);
  color: var(--color-bg-dark);
}
.btn-primary:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--text-primary);
  color: var(--text-primary);
}
.dark-surface .btn-outline {
  border-color: var(--color-bg-paper);
  color: var(--color-bg-paper);
}
.btn-outline:hover {
  background-color: color-mix(in srgb, var(--text-primary) 10%, transparent);
}
.dark-surface .btn-outline:hover {
  background-color: color-mix(in srgb, var(--color-bg-paper) 10%, transparent);
}

/* --- 6. 卡片与网格 --- */
.card {
  background-color: var(--bg-base);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  border-radius: var(--radius-card);
}

.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);
}

/* --- 7. 表格 --- */
.table-wrapper {
  overflow-x: auto;
  border: var(--card-border);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
th {
  font-weight: 700;
  background-color: color-mix(in srgb, var(--text-primary) 5%, transparent);
}
tr:last-child td {
  border-bottom: none;
}

/* --- 8. 表单与细节 (FAQ/Tabs) --- */
details {
  border: var(--card-border);
  margin-bottom: 8px;
  background-color: var(--bg-base);
  border-radius: var(--radius-card);
}
details summary {
  padding: 16px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 40px;
}
details summary::-webkit-details-marker {
  display: none;
}
details summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  color: var(--brand-color);
}
details[open] summary::after {
  content: "-";
}
details p {
  padding: 0 16px 16px 16px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 0;
}

/* --- 9. 页头与页脚 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-base);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-primary);
  text-decoration: none;
}
.brand-logo img {
  width: 28px;
  height: 28px;
}
nav ul {
  display: flex;
  list-style: none;
  gap: 24px;
}
nav a {
  font-weight: 500;
  color: var(--text-secondary);
}
nav a:hover, nav a[aria-current="page"] {
  color: var(--brand-color);
  text-decoration: none;
}

.site-footer {
  padding: 48px 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
  list-style: none;
}
.footer-links a {
  color: var(--text-secondary);
}

/* --- 10. SVG 动效系统 --- */
.svg-anim-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

svg {
  width: 100%;
  height: auto;
  display: block;
}

/* 描边绘制动画 (Stroke Draw) */
.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.anim-draw {
  animation: drawLine 4s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
@keyframes drawLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 呼吸闪烁 (Opacity Pulse) */
.anim-pulse {
  animation: pulse 3s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* 卡片层叠漂浮 (Float Stack) */
.float-layer-1 { animation: floatY 6s ease-in-out infinite; }
.float-layer-2 { animation: floatY 6s ease-in-out infinite 1s; }
.float-layer-3 { animation: floatY 6s ease-in-out infinite 2s; }
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* 消息气泡滑入 */
.bubble-enter {
  animation: slideInUp 5s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes slideInUp {
  0%, 10% { transform: translateY(20px); opacity: 0; }
  20%, 80% { transform: translateY(0); opacity: 1; }
  90%, 100% { transform: translateY(-10px); opacity: 0; }
}

/* 连接线路由流动 */
.route-flow {
  stroke-dasharray: 4 4;
  animation: dashFlow 2s linear infinite;
}
@keyframes dashFlow {
  to { stroke-dashoffset: -8; }
}

/* 减少动态效果适配 */
@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;
  }
  .draw-path {
    stroke-dashoffset: 0;
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 12px; }
  nav ul { gap: 16px; }
  h1 { font-size: 2.2rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
