/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计 Token --- */
:root {
  /* 颜色系统 */
  --color-dark: #140E25;
  --color-paper: #F7F5F3;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  
  /* 圆角与阴影 */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  
  /* 节奏与密度 */
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  
  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-base: 1.65;
}

/* --- 基础重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  line-height: var(--line-height-base);
  color: var(--color-body);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
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);
}
.section {
  padding-block: var(--section-y);
}
.grid { display: grid; gap: var(--gap); }
.flex { display: flex; gap: var(--gap); align-items: center; }
.flex-col { flex-direction: column; align-items: flex-start; }
.text-center { text-align: center; }

/* --- 面版取色变量 --- */
.dark-surface {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.dark-surface .hl { color: var(--color-accent); }
.light-paper {
  background-color: var(--color-paper);
  color: var(--color-body);
}
.light-paper .hl { color: var(--color-brand); }

/* --- 排版 --- */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: 0.02em; line-height: 1.2; }
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: 1.5rem; margin-bottom: 0.75rem; }
p { margin-bottom: 1rem; max-width: 38em; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.light-paper .badge { color: var(--color-brand); }
.dark-surface .badge { color: var(--color-accent); }
.hl { font-weight: 800; }

/* --- 组件：按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  height: 52px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(200, 237, 110, 0.3); }
.btn-secondary {
  background: transparent;
  border: 2px solid currentColor;
  color: inherit;
}
.light-paper .btn-secondary { border-color: var(--color-body); color: var(--color-body); }
.dark-surface .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn-secondary:hover { transform: translateY(-2px); opacity: 0.85; }

/* --- 组件：卡片 --- */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dark-surface .card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); }
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px -12px rgba(25, 21, 35, 0.4); }

/* --- 组件：表格 --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 0; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid rgba(25,21,35,0.1); }
.light-paper th { font-weight: 600; }
.dark-surface th { border-bottom-color: rgba(255,255,255,0.15); }
.dark-surface td { border-bottom-color: rgba(255,255,255,0.1); }

/* --- 组件：FAQ --- */
details {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(25,21,35,0.08);
  border-radius: var(--radius-card);
  margin-bottom: 0.75rem;
  padding: 1rem 1.25rem;
  transition: background 0.2s ease;
}
.dark-surface details { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
details[open] { background: rgba(255,255,255,0.06); }
summary { cursor: pointer; font-weight: 600; list-style: none; position: relative; padding-right: 1.5rem; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 0; font-weight: 400; }
details[open] summary::after { content: "-"; }
details p { margin-top: 0.75rem; margin-bottom: 0; font-size: 0.95rem; line-height: 1.7; }

/* --- 组件：步骤编号 --- */
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

/* --- 页头与侧边栏 --- */
.sidebar-nav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  background: var(--color-dark);
  color: var(--color-paper);
  padding: 2rem 1.5rem;
  display: none; /* Mobile first hidden */
  flex-direction: column;
  gap: 1rem;
  z-index: 200;
}
.sidebar-nav .logo { color: var(--color-paper); margin-bottom: 2rem; font-weight: 700; font-size: 1.2rem; display: flex; align-items: center; gap: 0.75rem; }
.sidebar-nav .logo img { height: 32px; width: auto; }
.sidebar-nav nav ul { flex-direction: column; gap: 0.5rem; }
.sidebar-nav nav a { color: rgba(255,255,255,0.7); padding: 0.5rem 0; border-left: 2px solid transparent; transition: color 0.2s, border-color 0.2s; }
.sidebar-nav nav a:hover, .sidebar-nav nav a[aria-current="page"] { color: var(--color-accent); border-left-color: var(--color-accent); }

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 243, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25,21,35,0.08);
}
.dark-surface .mobile-header { background: rgba(20, 14, 37, 0.92); border-bottom-color: rgba(255,255,255,0.1); }
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.header-inner .logo { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.header-inner .logo img { height: 32px; width: auto; }
.nav-actions { display: flex; gap: 0.75rem; align-items: center; }
.nav-links { display: none; } /* Hidden on mobile, shown on desktop via sidebar */

.main-content { margin-left: 0; width: 100%; }

/* --- SVG 面板 --- */
.svg-panel {
  width: 100%;
  height: auto;
  max-width: 100%;
  overflow: hidden;
}
svg { width: 100%; height: auto; display: block; }

/* --- SVG 动效关键帧 --- */
@keyframes drawLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* 动效类 */
.anim-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 3.5s ease forwards;
}
.anim-float {
  animation: float 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.anim-breathe {
  animation: breathe 4s ease-in-out infinite;
}
.anim-slide {
  animation: slideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.anim-pulse {
  animation: pulseDot 2.5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* --- 响应式布局 --- */
@media (min-width: 1024px) {
  .sidebar-nav { display: flex; }
  .main-content { margin-left: 240px; width: calc(100% - 240px); }
  .mobile-header { display: none; }
  .hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; }
  .feature-row:nth-child(even) { flex-direction: row-reverse; }
  .feature-row { display: flex; gap: var(--gap); align-items: center; }
  .feature-text, .feature-visual { flex: 1; }
  .feature-visual { order: 2; }
  .feature-text { order: 1; }
}

@media (max-width: 1023px) {
  .hero-grid { flex-direction: column; }
  .hero-text { order: 1; }
  .hero-visual { order: 2; height: 320px; }
  .nav-links { display: flex; gap: 1rem; }
}

/* --- 减少动态效果 --- */
@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, .anim-pulse {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
