/* =========================================
   SafeW 全站共享样式
   ========================================= */

:root {
  /* 色板 */
  --color-deep: #19102D;
  --color-paper: #F4F3F7;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;

  /* 结构 Token */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 2px solid var(--color-body);
  --card-shadow: 4px 4px 0 var(--color-body);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  --line-height-body: 1.55;

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--color-body);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; height: auto; }

/* 容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

/* 排版 */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--color-body);
}
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: calc(var(--gap) * 0.5); }
p { margin-bottom: var(--gap); max-width: 38em; }

.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: calc(var(--gap) * 0.5);
  color: var(--color-brand);
}
.dark-surface .badge { color: var(--color-accent); }

.hl { color: var(--color-brand); }
.dark-surface .hl { color: var(--color-accent); }

/* 布局：宽屏左侧索引 + 右侧正文 */
.layout-index {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--gap);
  align-items: start;
}
.sidebar-nav {
  position: sticky;
  top: calc(var(--gap) * 2);
  padding: var(--gap);
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}
.sidebar-nav ul { list-style: none; }
.sidebar-nav li { margin-bottom: calc(var(--gap) * 0.5); }
.sidebar-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a[aria-current="page"] {
  border-left-color: var(--color-brand);
  background: rgba(82, 20, 235, 0.05);
}
.dark-surface .sidebar-nav { background: var(--color-deep); border-color: #fff; }
.dark-surface .sidebar-nav a { color: var(--color-paper); }
.dark-surface .sidebar-nav a:hover, .dark-surface .sidebar-nav a[aria-current="page"] {
  border-left-color: var(--color-accent);
  background: rgba(214, 110, 237, 0.1);
}

@media (max-width: 900px) {
  .layout-index { grid-template-columns: 1fr; }
  .sidebar-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.75rem;
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .sidebar-nav ul { display: flex; gap: 0.5rem; }
  .sidebar-nav a { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar-nav a:hover, .sidebar-nav a[aria-current="page"] { border-bottom-color: var(--color-brand); }
  .dark-surface .sidebar-nav a:hover, .dark-surface .sidebar-nav a[aria-current="page"] { border-bottom-color: var(--color-accent); }
}

/* 头部与页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-paper);
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 800; font-size: 1.1rem; }
.brand img { width: 28px; height: 28px; object-fit: contain; }
.main-nav { display: flex; gap: var(--gap); align-items: center; }
.main-nav a { font-weight: 600; font-size: 0.95rem; padding: 0.5rem 0; }
.main-nav a:hover { color: var(--color-brand); }
.dark-surface .site-header { background: var(--color-deep); border-bottom-color: rgba(255,255,255,0.1); }
.dark-surface .main-nav a { color: var(--color-paper); }
.dark-surface .main-nav a:hover { color: var(--color-accent); }

.site-footer {
  margin-top: auto;
  background: var(--color-deep);
  color: var(--color-paper);
  padding: var(--section-y) 0;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}
.footer-grid h4 { color: var(--color-paper); margin-bottom: var(--gap); }
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: 0.5rem; }
.footer-grid a { color: rgba(244, 243, 247, 0.8); transition: color 0.2s; }
.footer-grid a:hover { color: var(--color-accent); }
.footer-bottom {
  margin-top: var(--gap);
  padding-top: var(--gap);
  border-top: 1px solid rgba(244, 243, 247, 0.15);
  text-align: center;
  font-size: 0.85rem;
  color: rgba(244, 243, 247, 0.6);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 52px;
  padding: 0 24px;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-deep);
  border: 2px solid var(--color-accent);
}
.btn-secondary {
  background: transparent;
  color: var(--color-body);
  border: 2px solid var(--color-body);
}
.dark-surface .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

/* 卡片与面板 */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
}
.panel {
  background: var(--color-deep);
  color: var(--color-paper);
  padding: var(--gap);
  border-radius: var(--radius-card);
}
.dark-card {
  background: var(--color-deep);
  color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}
.paper-card {
  background: var(--color-paper);
  color: var(--color-body);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--gap) 0;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.15);
}
.data-table th { font-weight: 700; background: rgba(82, 20, 235, 0.05); }
.dark-surface .data-table th { background: rgba(214, 110, 237, 0.1); }
.data-table tr:last-child td { border-bottom: none; }

/* 列表与步骤 */
.step-list { counter-reset: step; list-style: none; }
.step-list li {
  position: relative;
  padding-left: 3rem;
  margin-bottom: var(--gap);
}
.step-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 2rem; height: 2rem;
  background: var(--color-accent);
  color: var(--color-deep);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
}
.timeline-line {
  position: absolute;
  left: 1rem; top: 2rem; bottom: 0;
  width: 2px;
  background: rgba(25, 21, 35, 0.15);
}

/* FAQ */
.faq-item { margin-bottom: var(--gap); border: var(--card-border); box-shadow: var(--card-shadow); }
.faq-item summary {
  padding: 1rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; font-weight: 400; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { padding: 0 1rem 1rem; margin: 0; }

/* SVG 基础 */
.svg-icon { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.svg-panel { width: 100%; height: auto; max-width: 600px; margin: 0 auto; }
svg { shape-rendering: geometricPrecision; }
svg path { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; }

/* 动效 Keyframes */
@keyframes orbitBreath {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.08); opacity: 0.8; }
}
@keyframes drawPath {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes slideIn {
  0% { transform: translateX(20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes inputDots {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* 动效类 */
.anim-orbit { animation: orbitBreath 4s infinite alternate ease-in-out; }
.anim-draw { animation: drawPath 2s forwards ease-out; }
.anim-float { animation: float 5s infinite ease-in-out; }
.anim-slide-in { animation: slideIn 0.6s ease-out both; }
.anim-float:nth-child(2) { animation-delay: 0.5s; }
.anim-float:nth-child(3) { animation-delay: 1s; }
.anim-input-dots circle { animation: inputDots 1.5s infinite ease-in-out; }
.anim-input-dots circle:nth-child(1) { animation-delay: 0s; }
.anim-input-dots circle:nth-child(2) { animation-delay: 0.2s; }
.anim-input-dots circle:nth-child(3) { animation-delay: 0.4s; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .anim-orbit, .anim-draw, .anim-float, .anim-slide-in, .anim-input-dots {
    animation: none !important;
  }
}
