/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 配色 */
  --color-dark: #271231;
  --color-paper: #F5F0E5;
  --color-body: #1F1523;
  --color-brand: #9B12D8;
  --color-accent: #ED6EC0;
  --color-body-light: #F5F0E5;
  --color-brand-light: #ED6EC0;

  /* 结构约束 */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 1px solid rgba(31, 21, 35, 0.16);
  --card-shadow: none;

  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --lh-body: 1.55;
}

/* --- 重置与基础 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  line-height: var(--lh-body);
  color: var(--color-body);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* --- 容器与网格 --- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
/* 防止网格子元素溢出容器 */
.grid-2 > *, .grid-3 > * { min-width: 0; }

/* --- 面与上下文 --- */
.paper-bg { background-color: var(--color-paper); color: var(--color-body); }
.dark-bg { background-color: var(--color-dark); color: var(--color-body-light); }
.dark-bg .hl, .dark-bg a { color: var(--color-accent); }
.paper-bg .hl, .paper-bg a { color: var(--color-brand); }
.paper-bg a:hover { text-decoration: underline; }
.dark-bg a:hover { text-decoration: underline; }

/* --- 排版 --- */
.tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.paper-bg .tag { color: var(--color-brand); }
.dark-bg .tag { color: var(--color-accent); }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; letter-spacing: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin-bottom: 0.8rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.6rem; }
p { margin-bottom: 1rem; max-width: 38em; }
.highlight-text { font-weight: 600; }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border: 1px solid var(--color-accent);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-body);
  color: var(--color-body);
}
.btn-secondary:hover { transform: translateY(-1px); background-color: rgba(31, 21, 35, 0.05); }
.dark-bg .btn-secondary { border-color: var(--color-body-light); color: var(--color-body-light); }
.dark-bg .btn-secondary:hover { background-color: rgba(245, 240, 229, 0.08); }
.btn-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* --- 卡片 --- */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  border-radius: var(--radius-card);
}
.dark-bg .card { background: rgba(255, 255, 255, 0.04); border-color: rgba(245, 240, 229, 0.12); }

/* --- 表格 --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid rgba(31, 21, 35, 0.12); }
th { font-weight: 600; background: rgba(0,0,0,0.02); }
.dark-bg th { background: rgba(255,255,255,0.05); border-bottom-color: rgba(245,240,229,0.15); }
.dark-bg td { border-bottom-color: rgba(245,240,229,0.1); }

/* --- FAQ --- */
details {
  border: var(--card-border);
  margin-bottom: 12px;
  border-radius: var(--radius-card);
  background: var(--color-paper);
}
.dark-bg details { background: rgba(255,255,255,0.03); border-color: rgba(245,240,229,0.1); }
summary {
  padding: 16px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 1.2rem; font-weight: 400; }
details[open] summary::after { content: "−"; }
details > div { padding: 0 16px 16px; line-height: var(--lh-body); }

/* --- 分隔线 --- */
.section-divider {
  height: 1px;
  background: currentColor;
  opacity: 0.15;
  margin: var(--section-y) 0;
  transform: scaleX(1.05) rotate(-0.5deg);
}

/* --- 导航与页脚 --- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-paper);
  border-bottom: 1px solid rgba(31, 21, 35, 0.1);
  backdrop-filter: blur(8px);
}
.dark-bg .site-header { background: var(--color-dark); border-bottom-color: rgba(245,240,229,0.1); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 28px; width: auto; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { font-size: 0.95rem; font-weight: 500; opacity: 0.85; color: var(--color-body); }
.nav-links a:hover, .nav-links a[aria-current="page"] { opacity: 1; color: var(--color-brand); }
.dark-bg .nav-links a[aria-current="page"], .dark-bg .nav-links a:hover { color: var(--color-accent); }
.dark-bg .nav-links a { color: var(--color-body-light); }

.site-footer {
  background: var(--color-dark); color: var(--color-body-light);
  padding: 48px 0 32px; border-top: 1px solid rgba(245,240,229,0.1);
}
.footer-inner { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px; margin-bottom: 32px; }
.footer-col h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 12px; color: var(--color-accent); }
.footer-col ul li { margin-bottom: 8px; }
.footer-col a { opacity: 0.8; font-size: 0.9rem; }
.footer-col a:hover { opacity: 1; }
.footer-bottom { border-top: 1px solid rgba(245,240,229,0.1); padding-top: 24px; font-size: 0.85rem; opacity: 0.7; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* --- SVG 动效 --- */
.svg-container { width: 100%; height: auto; max-width: 100%; display: block; }
.svg-container svg { width: 100%; height: 100%; }
.anim-flow { animation: flow-line 4s linear infinite; }
.anim-float { animation: float-dot 6s ease-in-out infinite; }
.anim-slide { animation: slide-in 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.anim-pulse { animation: pulse-opacity 3s ease-in-out infinite; }

@keyframes flow-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes float-dot {
  0%, 100% { transform: translate(0, 0); opacity: 0.4; }
  50% { transform: translate(12px, -6px); opacity: 1; }
}
@keyframes slide-in {
  from { transform: translateX(-16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes pulse-opacity {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.9; }
}

/* SVG 子元素变换中心 */
svg g, svg path, svg circle, svg rect {
  transform-box: fill-box;
  transform-origin: center;
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  .nav-links { display: none; } /* 简化处理，移动端隐藏导航链接，保留主按钮 */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
  .header-inner { height: 56px; }
  .btn { height: 48px; font-size: 0.95rem; }
}

/* --- 减少动态效果 --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
