/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 色板 */
  --c-dark: #251943;
  --c-paper: #DBD4ED;
  --c-text: #191523;
  --c-brand: #5214EB;
  --c-accent: #ED6E89;
  
  /* 结构令牌 */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;
  --sidebar-w: 240px;
  
  /* 排版 */
  --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 { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--c-text);
  background-color: var(--c-paper);
  line-height: 1.75;
  -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);
}

/* 区块节奏 */
.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}
.section-inner {
  display: grid;
  gap: var(--gap);
}

/* 标题系统 */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-bottom: 0.6em; }
p { margin-bottom: 1em; max-width: 38em; }
.text-muted { color: rgba(25, 21, 35, 0.7); }
.hl { color: var(--c-brand); }
.section-dark .hl { color: var(--c-accent); }

/* 眉标 */
.breadcrumb {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.8em;
  text-transform: uppercase;
}
.section-dark .breadcrumb { color: var(--c-accent); }
.section-paper .breadcrumb { color: var(--c-brand); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  height: 48px;
  padding: 0 1.5em;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.btn-primary {
  background-color: var(--c-accent);
  color: var(--c-dark);
  border: none;
}
.btn-primary:hover { transform: translateY(-1px); background-color: #d95f7a; }
.btn-secondary {
  background: transparent;
  color: var(--c-text);
  border: 1px solid var(--c-text);
}
.section-dark .btn-secondary { color: var(--c-paper); border-color: var(--c-paper); }
.btn-secondary:hover { background-color: rgba(25, 21, 35, 0.05); }
.section-dark .btn-secondary:hover { background-color: rgba(219, 212, 237, 0.1); }
.btn-icon { width: 20px; height: 20px; }

/* 卡片与面板 */
.card {
  background: #fff;
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  position: relative;
}
.panel {
  background-color: var(--c-dark);
  border-radius: var(--radius-card);
  padding: var(--gap);
  color: var(--c-paper);
}
.panel .hl { color: var(--c-accent); }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.8em 1em;
  border-bottom: var(--card-border);
  text-align: left;
}
th { font-weight: 600; background: rgba(25, 21, 35, 0.03); }
td a { color: var(--c-brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.section-dark td a { color: var(--c-accent); }

/* 列表与要点 */
.list-check li {
  position: relative;
  padding-left: 1.5em;
  margin-bottom: 0.6em;
}
.list-check li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 0.5em;
  height: 0.5em;
  background: var(--c-brand);
  border-radius: 0;
}
.section-dark .list-check li::before { background: var(--c-accent); }

/* 导航与页头 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(219, 212, 237, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 0.8em; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 32px; width: auto; }
.nav-links { display: flex; gap: 1.5em; align-items: center; }
.nav-links a { font-weight: 500; font-size: 0.95rem; position: relative; }
.nav-links a[aria-current="page"], .nav-links a:hover { color: var(--c-brand); }
.section-dark .nav-links a[aria-current="page"], .section-dark .nav-links a:hover { color: var(--c-accent); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; }
.nav-toggle svg { width: 24px; height: 24px; stroke: currentColor; }

/* 侧边索引 */
.sidebar-index {
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 0.5em;
}
.sidebar-index ul { display: flex; flex-direction: column; gap: 0.4em; }
.sidebar-index a {
  display: block;
  padding: 0.5em 0.8em;
  font-size: 0.9rem;
  color: rgba(25, 21, 35, 0.6);
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.sidebar-index a:hover, .sidebar-index a.active {
  color: var(--c-brand);
  border-left-color: var(--c-brand);
}
.section-dark .sidebar-index a:hover, .section-dark .sidebar-index a.active {
  color: var(--c-accent);
  border-left-color: var(--c-accent);
}

/* 页脚 */
.site-footer {
  background: var(--c-dark);
  color: var(--c-paper);
  padding: var(--gap) 0;
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1em;
}
.footer-links { display: flex; gap: 1.5em; }
.footer-links a { opacity: 0.8; transition: opacity 0.2s; }
.footer-links a:hover { opacity: 1; }

/* 响应式布局 */
@media (max-width: 900px) {
  .layout-grid { grid-template-columns: 1fr !important; }
  .sidebar-index {
    position: static;
    height: auto;
    border-bottom: 1px solid rgba(25, 21, 35, 0.1);
    margin-bottom: var(--gap);
  }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--c-paper);
    flex-direction: column;
    padding: 1.5em;
    border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  }
  .nav-links.open { display: flex; }
  .hero-layout { grid-template-columns: 1fr !important; }
  .hero-visual { order: -1; margin-bottom: var(--gap); }
}

/* =========================================
   SVG 动效系统
   ========================================= */
svg.anim-target { width: 100%; height: auto; }
svg.anim-target path, svg.anim-target rect, svg.anim-target circle, svg.anim-target line, svg.anim-target polyline, svg.anim-target polygon {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 描边绘制 */
.stroke-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
@keyframes draw-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
.anim-draw { animation: draw-line 3s ease forwards; }

/* 呼吸点 */
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}
.anim-breathe {
  transform-box: fill-box;
  transform-origin: center;
  animation: breathe 4s ease-in-out infinite;
}

/* 卡片漂浮 */
@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.anim-float {
  animation: float-y 6s ease-in-out infinite;
}
.anim-float-delay { animation-delay: -2s; }
.anim-float-slow { animation-duration: 8s; }

/* 滑入通知 */
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.anim-slide-in {
  transform-box: fill-box;
  transform-origin: center;
  animation: slide-in 5s ease-out infinite alternate;
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}
