/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 颜色系统 */
  --color-dark: #1B1231;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;

  /* 面层次微调 */
  --color-dark-surface: #1B1231;
  --color-paper-surface: #DBD4ED;
  --color-paper-light: #EAE6F5;
  --color-dark-light: #2A1F4A;
  --color-dark-accent-subtle: rgba(153, 119, 238, 0.12);

  /* 结构令牌 */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;

  /* 排版基础 */
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --lh-body: 1.75;
  --lh-title: 1.15;
}

/* --- 重置与基础 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  font-size: 17px;
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-paper-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: opacity 0.2s ease; }
ul, ol { list-style: none; }

/* --- 容器与区块 --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
section {
  padding-block: var(--section-y);
  position: relative;
}
.section-inner {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* --- 面色控制 --- */
.bg-dark { background-color: var(--color-dark); color: var(--color-paper); }
.bg-dark .hl { color: var(--color-accent); }
.bg-dark .brand { color: var(--color-accent); }
.bg-dark .text-muted { color: rgba(219, 212, 237, 0.7); }
.bg-dark .btn-outline { border-color: var(--color-paper); color: var(--color-paper); }
.bg-dark .btn-outline:hover { background-color: rgba(219, 212, 237, 0.1); }

.bg-paper { background-color: var(--color-paper-surface); color: var(--color-text); }
.bg-paper .hl { color: var(--color-brand); }
.bg-paper .brand { color: var(--color-brand); }
.bg-paper .text-muted { color: rgba(25, 21, 35, 0.65); }
.bg-paper .btn-outline { border-color: var(--color-text); color: var(--color-text); }
.bg-paper .btn-outline:hover { background-color: rgba(25, 21, 35, 0.06); }

/* 浅色卡片在深色面上恢复纸面取色 */
.card-light {
  background-color: var(--color-paper-light);
  color: var(--color-text);
  border: var(--card-border) transparent;
  box-shadow: var(--card-shadow);
}
.card-light .hl { color: var(--color-brand); }
.card-light .brand { color: var(--color-brand); }

/* --- 标题与文本 --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5em;
}
.badge::before {
  content: "";
  display: block;
  width: 12px;
  height: 2px;
  border-radius: 2px;
}
.bg-dark .badge { color: var(--color-accent); }
.bg-dark .badge::before { background-color: var(--color-accent); }
.bg-paper .badge { color: var(--color-brand); }
.bg-paper .badge::before { background-color: var(--color-brand); }

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  font-weight: 500;
  line-height: var(--lh-title);
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 1em;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 500;
  line-height: var(--lh-title);
  margin-bottom: 0.6em;
}
h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 500;
  line-height: var(--lh-title);
  margin-bottom: 0.5em;
}
p { margin-bottom: 1em; max-width: 38em; }
.hl { font-weight: 600; }
.text-muted { font-size: 0.95em; }

/* --- 按钮 --- */
.btn-group { display: flex; flex-wrap: wrap; gap: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  border: 1px solid transparent;
}
.btn:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background-color: #8A65E8; }

/* 确保浅色背景按钮上的文字对比度 */
.bg-paper .btn-primary,
.card .btn-primary {
  color: #0f0a1c;
}

/* 深色背景按钮上的文字对比度 */
.bg-dark .btn-primary {
  color: #ffffff;
}
.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-text);
}
.bg-dark .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
.bg-dark .btn-secondary:hover { background-color: rgba(219, 212, 237, 0.1); }

/* --- 卡片与网格 --- */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--gap);
}
.card {
  background-color: var(--color-paper-light);
  border: var(--card-border) transparent;
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bg-dark .card { background-color: var(--color-dark-light); color: var(--color-paper); }
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background-color: rgba(82, 20, 235, 0.1);
  display: grid;
  place-items: center;
  color: var(--color-brand);
}
.bg-dark .card-icon { background-color: var(--color-dark-accent-subtle); color: var(--color-accent); }

/* --- 表格 --- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-card); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background-color: var(--color-paper-light);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.bg-dark table { background-color: var(--color-dark-light); color: var(--color-paper); }
th, td { padding: 16px 20px; text-align: left; border-bottom: 1px solid rgba(128,128,128,0.15); }
th { font-weight: 600; background-color: rgba(128,128,128,0.08); }
tr:last-child td { border-bottom: none; }
td strong { font-weight: 600; }

/* --- FAQ --- */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
details {
  background-color: var(--color-paper-light);
  border-radius: 16px;
  padding: 16px 20px;
  transition: background-color 0.2s ease;
}
.bg-dark details { background-color: var(--color-dark-light); color: var(--color-paper); }
details[open] { background-color: rgba(128,128,128,0.06); }
summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  font-size: 1.2em;
  font-weight: 400;
  transition: transform 0.2s ease;
}
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: 12px; font-size: 0.95em; line-height: 1.7; }

/* --- 页头页脚 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(219, 212, 237, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
.bg-dark .site-header { background-color: rgba(27, 18, 49, 0.9); border-bottom-color: rgba(219, 212, 237, 0.1); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.logo img { height: auto; max-height: 40px; width: auto; object-fit: contain; }
.nav-list { display: flex; gap: 24px; align-items: center; }
.nav-link { font-weight: 500; font-size: 0.95rem; position: relative; }
.nav-link:hover { opacity: 0.8; }
.nav-link[aria-current="page"] { font-weight: 700; }
.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  border-radius: 2px;
}
.site-footer {
  padding-block: 48px;
  border-top: 1px solid rgba(128,128,128,0.2);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted, rgba(25,21,35,0.6));
}
.bg-dark .site-footer { color: rgba(219,212,237,0.6); }

/* --- SVG 动效 --- */
.svg-panel { width: 100%; height: auto; }
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 4s ease-in-out infinite alternate;
}
.anim-grid-node {
  animation: gridPulse 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.anim-grid-node:nth-child(odd) { animation-delay: 0.8s; }
.anim-grid-node:nth-child(3n) { animation-delay: 1.6s; }
.anim-float { animation: floatUp 6s ease-in-out infinite; }
.anim-float-delay { animation: floatUp 6s ease-in-out infinite; animation-delay: 1.5s; }
.anim-slide-in { animation: slideIn 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes drawLine { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes gridPulse {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
@keyframes floatUp {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@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;
  }
}
