/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计变量 */
:root {
  --color-dark: #251943;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED6E89;
  --color-surface-light: #F8F6FA;
  
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;
  
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 基础重置与排版 */
*, *::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: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* 容器与布局 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.section {
  padding: var(--section-y) 0;
}
.section--dark {
  background-color: var(--color-dark);
  color: var(--color-surface-light);
}
.section--paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}
.grid {
  display: grid;
  gap: var(--gap);
}
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }

/* 标题系统 */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: calc(var(--gap) * 0.75);
}
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-top: calc(var(--gap) * 1.5); }
h3 { font-size: clamp(1.2rem, 2vw, 1.6rem); margin-top: calc(var(--gap)); }
p { margin-bottom: calc(var(--gap) * 0.75); max-width: 38em; }
.text-accent { color: var(--color-accent); }
.text-brand { color: var(--color-brand); }
.text-surface { color: var(--color-surface-light); }

/* 眉标 */
.label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  position: relative;
  padding-left: 1.2em;
}
.label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0.6em;
  height: 2px;
  background-color: currentColor;
}
.paper-section .label { color: var(--color-brand); }
.dark-section .label { color: var(--color-accent); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  height: 52px;
  padding: 0 1.5em;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn--secondary {
  background: transparent;
  border: 1px solid currentColor;
}
.paper-section .btn--secondary { color: var(--color-text); border-color: var(--color-text); }
.dark-section .btn--secondary { color: var(--color-surface-light); border-color: var(--color-surface-light); }

/* 卡片与面板 */
.card {
  background-color: var(--color-surface-light);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  transition: box-shadow 0.2s ease;
}
.dark-section .card { background-color: var(--color-paper); color: var(--color-text); }
.card:hover { box-shadow: 0 14px 32px -12px rgba(25, 21, 35, 0.35); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.15);
}
.dark-section th, .dark-section td { border-bottom-color: rgba(248, 246, 250, 0.15); }
th { font-weight: 700; }

/* 定义列表 */
.dl { display: grid; gap: var(--gap); }
.dl dt { font-weight: 700; margin-bottom: 0.3em; }
.dl dd { margin-left: 0; padding-left: 1em; border-left: 3px solid var(--color-brand); }
.dark-section .dl dd { border-left-color: var(--color-accent); }

/* 步骤时间线 */
.timeline { position: relative; padding-left: 2em; }
.timeline::before {
  content: "";
  position: absolute;
  left: 0.5em;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(25, 21, 35, 0.2);
}
.dark-section .timeline::before { background: rgba(248, 246, 250, 0.2); }
.step { position: relative; margin-bottom: var(--gap); }
.step::before {
  content: attr(data-num);
  position: absolute;
  left: -2.4em;
  top: 0;
  width: 1.6em;
  height: 1.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-accent);
  color: var(--color-dark);
  font-weight: 800;
  font-size: 0.85rem;
}

/* FAQ */
details {
  border-bottom: 1px solid rgba(25, 21, 35, 0.15);
  padding: 1em 0;
}
.dark-section details { border-bottom-color: rgba(248, 246, 250, 0.15); }
summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5em;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  margin-left: auto;
  font-weight: 400;
  opacity: 0.6;
}
details[open] summary::after { content: "−"; }
details p { margin-top: 0.6em; margin-left: 1.2em; }

/* 页头与页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(219, 212, 237, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}
.dark-section .site-header { background-color: rgba(37, 25, 67, 0.95); border-bottom-color: rgba(248, 246, 250, 0.15); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav { display: flex; gap: var(--gap); }
.nav a { font-weight: 600; padding: 0.5em 0; position: relative; }
.nav a[aria-current="page"] { color: var(--color-accent); }
.dark-section .nav a[aria-current="page"] { color: var(--color-accent); }
.footer {
  background-color: var(--color-dark);
  color: var(--color-surface-light);
  padding: var(--section-y) 0;
  margin-top: var(--section-y);
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.footer a { display: block; padding: 0.4em 0; opacity: 0.85; }
.footer a:hover { opacity: 1; text-decoration: underline; }

/* SVG 动效基础 */
svg { width: 100%; height: auto; overflow: visible; }
.anim-star { animation: twinkle 4s ease-in-out infinite alternate; }
.anim-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawLine 6s ease-in-out infinite; }
.anim-float { animation: float 5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.anim-bubble { animation: popIn 3s ease-out infinite alternate; }
.anim-pulse { animation: breathe 4s ease-in-out infinite; }
.anim-glow { animation: glowPulse 7s ease-in-out infinite; }

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes drawLine {
  0%, 100% { stroke-dashoffset: 1; }
  30%, 70% { stroke-dashoffset: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes popIn {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}
@keyframes glowPulse {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(237, 110, 137, 0.3)); }
  50% { filter: drop-shadow(0 0 8px rgba(237, 110, 137, 0.7)); }
}

/* 减少动态效果 */
@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;
  }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; height: auto; padding: 1em 0; gap: 1em; }
  .nav { flex-wrap: wrap; justify-content: center; }
  h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
}

/* 对比度修复：浅色背景上的深色文字 */
.toc-list a { color: var(--color-text) !important; opacity: 1 !important; }
