/* =========================================
   SafeW 全站共享样式 (style.css)
   ========================================= */

/* 1. 设计变量与基础重置 */
:root {
  /* 色板 */
  --color-dark: #17203F;
  --color-paper: #FCFCFD;
  --color-body: #151823;
  --color-brand: #1441EB;
  --color-accent: #6EEDBD;
  
  /* 结构性 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(21, 24, 35, 0.3);
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;
  
  /* 排版 */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-base: 1.75;
}

*, *::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: 16px;
  line-height: var(--line-height-base);
  color: var(--color-body);
  background-color: var(--color-paper);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* 2. 容器与版式节奏 */
.container {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

section {
  padding-block: var(--section-y);
}

/* 3. 背景上下文切换 (严格遵循取色规则) */
.bg-paper {
  background-color: var(--color-paper);
  --text-primary: var(--color-body);
  --text-secondary: #4B5063;
  --accent: var(--color-brand);
  --link: var(--color-brand);
}

.bg-dark {
  background-color: var(--color-dark);
  --text-primary: var(--color-paper);
  --text-secondary: #A0A8C4;
  --accent: var(--color-accent);
  --link: var(--color-accent);
}

.light-card {
  background-color: var(--color-paper);
  --text-primary: var(--color-body);
  --text-secondary: #4B5063;
  --accent: var(--color-brand);
  --link: var(--color-brand);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
}

/* 4. 排版层级 */
.section-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  max-width: 38em;
}

.hl {
  color: var(--accent);
}

/* 5. 组件：按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--color-dark);
}

/* 深色背景上的按钮需要浅色文字以符合对比度要求 */
.bg-dark .btn-primary {
  background-color: var(--color-brand);
  color: var(--color-paper);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(110, 237, 189, 0.25);
}

/* 深色背景上悬停时保持高对比度 */
.bg-dark .btn-primary:hover {
  box-shadow: 0 4px 12px rgba(20, 65, 235, 0.4);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--text-primary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(128,128,128,0.08);
  transform: translateY(-1px);
}

/* 6. 组件：卡片与网格 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
  align-items: center;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--color-paper);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 12px 32px -12px rgba(21, 24, 35, 0.35);
  transform: translateY(-2px);
}

/* 7. 组件：表格 */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid rgba(128,128,128,0.15);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(128,128,128,0.12);
  vertical-align: top;
}

th {
  font-weight: 600;
  background: rgba(128,128,128,0.05);
  color: var(--text-primary);
}

td {
  color: var(--text-secondary);
}

tr:last-child td {
  border-bottom: none;
}

/* 8. 组件：FAQ (Details/Summary) */
details {
  border: 1px solid rgba(128,128,128,0.15);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  background: var(--color-paper);
  overflow: hidden;
}

summary {
  padding: 16px 20px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  font-weight: 400;
  color: var(--accent);
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details p {
  padding: 0 20px 16px;
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* 9. 组件：页头页脚 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(252, 252, 253, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 12px 0;
}

.bg-dark .header {
  background: rgba(23, 32, 63, 0.95);
  border-bottom-color: rgba(255,255,255,0.08);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.logo img {
  height: 28px;
  width: auto;
}

.nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav a {
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav a:hover, .nav a[aria-current="page"] {
  color: var(--accent);
}

/* 导航中的按钮默认使用浅色背景深色文字，确保在任何背景下可读 */
.header .btn-primary {
  background-color: var(--color-paper);
  color: var(--color-brand);
}

.footer {
  background: var(--color-dark);
  color: #A0A8C4;
  padding: 48px 0 32px;
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links a {
  color: #A0A8C4;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--color-accent);
}

/* 10. SVG 动效系统 */
.svg-container {
  width: 100%;
  height: auto;
  max-width: 100%;
}

svg {
  width: 100%;
  height: auto;
}

/* 线条自绘 */
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-path 6s ease-in-out infinite alternate;
}

@keyframes draw-path {
  0% { stroke-dashoffset: 1; }
  40%, 100% { stroke-dashoffset: 0; }
}

/* 轻微漂浮 */
.anim-float {
  animation: float-move 5s ease-in-out infinite alternate;
}

@keyframes float-move {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

/* 呼吸点 */
.anim-breathe {
  animation: breathe-pulse 3s ease-in-out infinite;
}

@keyframes breathe-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 滑入 */
.anim-slide-in {
  animation: slide-enter 4s ease-out infinite alternate;
}

@keyframes slide-enter {
  0% { transform: translateX(-12px); opacity: 0.7; }
  30%, 100% { transform: translateX(0); opacity: 1; }
}

/* 旋转/缩放原点修正 */
.rot-center {
  transform-box: fill-box;
  transform-origin: center;
}

/* 11. 响应式适配 */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > :first-child { order: -1; }
  .nav { display: none; }
  h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); }
}

/* 12. 减少动态效果偏好 */
@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;
  }
  .anim-draw, .anim-float, .anim-breathe, .anim-slide-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
