/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计 Token & 变量 --- */
:root {
  /* 色板 */
  --color-dark: #1B1231;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;
  
  /* 结构 & 间距 */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;
  
  /* 排版 */
  --font-main: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --lh-body: 1.55;
  --lh-heading: 1.25;
  --fw-heading: 600;
}

/* --- 基础重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; word-break: break-all; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- 容器与区块 --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.bg-dark { background-color: var(--color-dark); color: var(--color-paper); }
.bg-paper { background-color: var(--color-paper); color: var(--color-text); }

/* 深色面上的文字与强调色覆盖 */
.bg-dark .hl, .bg-dark .badge, .bg-dark a:not(.btn):not(.nav-link) { color: var(--color-accent); }
.bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark p, .bg-dark li { color: var(--color-paper); }
.bg-dark .table-wrap { background: var(--color-paper); color: var(--color-text); }

/* 纸面上的品牌色覆盖 */
.bg-paper .hl { color: var(--color-brand); }
.bg-paper .badge { color: var(--color-brand); }

/* --- 排版组件 --- */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}
h1, h2, h3 {
  font-weight: var(--fw-heading);
  line-height: var(--lh-heading);
  letter-spacing: 0;
  margin-bottom: 0.75rem;
}
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-top: 1.5rem; }
h3 { font-size: clamp(1.1rem, 2vw, 1.35rem); margin-top: 1.25rem; }
p { margin-bottom: 1rem; max-width: 38em; }
.text-center { text-align: center; }
.grid-auto {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }
.flex-row { display: flex; flex-direction: row; gap: var(--gap); align-items: center; }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border-color: var(--color-accent);
}
.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);
}

/* --- 卡片 --- */
.card {
  background-color: var(--color-paper);
  color: var(--color-text);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-2px); }
.card-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

/* --- 表格 --- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  background: var(--color-paper);
  color: var(--color-text);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
  table-layout: fixed;
}
th, td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
th { font-weight: 600; background: rgba(25, 21, 35, 0.03); }
td:first-child { font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* --- FAQ (Details/Summary) --- */
details {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  background: var(--color-paper);
  color: var(--color-text);
  overflow: hidden;
}
summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 40px;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
}
details[open] summary::after { content: "-"; }
details > div { padding: 0 20px 16px; }
details > div p { margin-bottom: 0.5rem; }

/* --- 导航与页脚 --- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(219, 212, 237, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
.bg-dark header { background: rgba(27, 18, 49, 0.95); border-bottom-color: rgba(219, 212, 237, 0.1); }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.logo img { height: 32px; width: auto; }
nav ul { display: flex; gap: 24px; }
nav a { font-weight: 500; opacity: 0.85; transition: opacity 0.2s; }
nav a:hover, nav a[aria-current="page"] { opacity: 1; }
footer {
  background: var(--color-dark);
  color: var(--color-paper);
  padding-block: 48px;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.9;
}
footer a { color: var(--color-accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
footer a:hover { text-underline-offset: 5px; }

/* --- SVG 动效关键帧 --- */
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes drawLine {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes slideIn {
  0% { transform: translateX(12px); opacity: 0.6; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 动效类 */
.star { animation: twinkle 4s ease-in-out infinite alternate; }
.star-delay-1 { animation-delay: 1.2s; }
.star-delay-2 { animation-delay: 2.4s; }
.float-slow { animation: float 6s ease-in-out infinite; }
.float-fast { animation: float 4.5s ease-in-out infinite; }
.connect-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 3s ease-in-out infinite alternate;
}
.msg-bubble { animation: slideIn 2s ease-out forwards; }
.typing-dot { animation: breathe 1.5s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.3s; }
.typing-dot:nth-child(3) { animation-delay: 0.6s; }

/* 旋转/缩放中心修正 */
.animate-spin, .animate-scale {
  transform-box: fill-box;
  transform-origin: center;
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .connect-line { stroke-dasharray: none; stroke-dashoffset: 0; }
}

/* 响应式微调 */
@media (max-width: 768px) {
  .flex-row { flex-direction: column; }
  .grid-auto { grid-template-columns: 1fr; }
  h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
