/* =========================================
   SafeW 全站共享样式 (style.css)
   ========================================= */

/* 1. 设计变量与 Token */
:root {
  /* 色板 */
  --color-dark: #1B1231;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;
  --color-bg-light: #F2EEF8;
  --color-bg-dark-alt: #2A1F4A;
  --color-surface-light: rgba(255, 255, 255, 0.4);
  --color-surface-dark: rgba(0, 0, 0, 0.15);

  /* 结构 Token */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;

  /* 排版 Token */
  --font-main: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --h1-size: clamp(2.4rem, 6vw, 4.5rem);
  --h2-size: clamp(1.6rem, 3vw, 2.4rem);
  --h3-size: 1.25rem;
  --body-size: 18px;
  --lead-size: 1.125rem;
}

/* 2. 基础重置与全局 */
*, *::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: var(--body-size);
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* 3. 布局容器 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}
.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  position: relative;
}
.section--dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.section--paper { background-color: var(--color-paper); color: var(--color-text); }
.section--light { background-color: var(--color-bg-light); color: var(--color-text); }

/* 4. 排版组件 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.badge--brand { color: var(--color-brand); }
.badge--accent { color: var(--color-accent); }
.badge::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 2px;
  background: currentColor;
}

h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 24px;
}
h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); line-height: 1.25; margin-top: 0; }
h3 { font-size: var(--h3-size); margin-top: 0; }
p { margin-bottom: 1.2em; max-width: 38em; }
.small { font-size: 0.875rem; opacity: 0.8; }
.hl { color: var(--color-brand); }
.section--dark .hl { color: var(--color-accent); }

/* 5. 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 28px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.btn:hover { transform: translateY(-2px); }
.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn--primary:hover { background-color: #8A68E0; }
.btn--secondary {
  background: transparent;
  border: 2px solid var(--color-text);
  color: var(--color-text);
}
.section--dark .btn--secondary {
  border-color: var(--color-paper);
  color: var(--color-paper);
}
.section--dark .btn--secondary:hover { background-color: rgba(255,255,255,0.1); }
.btn svg { width: 20px; height: 20px; stroke-width: 2; }

/* 6. 卡片与面板 */
.card {
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  background: var(--color-surface-light);
  transition: background 0.3s ease;
}
.panel-dark {
  background: var(--color-bg-dark-alt);
  border-radius: var(--radius-card);
  padding: var(--gap);
  position: relative;
  overflow: hidden;
}
.panel-paper {
  background: var(--color-bg-light);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

/* 7. 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.section--dark .data-table th,
.section--dark .data-table td { border-bottom-color: rgba(255,255,255,0.1); }
.data-table th { font-weight: 700; opacity: 0.9; }
.data-table tr:last-child td { border-bottom: none; }

/* 8. FAQ */
details {
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--color-surface-light);
  padding: 16px 20px;
  transition: background 0.2s ease;
}
.section--dark details { background: rgba(255,255,255,0.08); }
details[open] { background: var(--color-bg-light); }
.summary {
  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;
  transition: transform 0.2s ease;
}
details[open] .summary::after { transform: rotate(45deg); }
.details-body { margin-top: 12px; line-height: 1.7; }

/* 9. 新闻卡片 */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}
.news-card {
  background: var(--color-bg-light);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section--dark .news-card { background: var(--color-bg-dark-alt); }
.news-date { font-size: 0.8rem; opacity: 0.7; }

/* 10. 网格与双栏 */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }

/* 11. 响应式布局 (左栏侧边导航) */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--color-dark);
  color: var(--color-paper);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  z-index: 100;
}
.nav-links { display: flex; flex-direction: column; gap: 16px; }
.nav-links a {
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 500;
  transition: background 0.2s;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  background: rgba(255,255,255,0.1);
  color: var(--color-accent);
}
.main-content {
  padding: 40px;
  background: var(--color-paper);
  overflow: hidden;
}

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; width: 100%; height: auto;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  .nav-links { flex-direction: row; gap: 8px; }
  .nav-links a { padding: 8px 12px; font-size: 0.9rem; }
  .main-content { padding: 80px 24px 40px; }
}

/* 12. SVG 动效系统 */
.svg-container { width: 100%; height: auto; }
.svg-container svg { width: 100%; height: auto; display: block; }

/* 呼吸效果 */
.anim-breathe { animation: safew-breathe 3s ease-in-out infinite; }
@keyframes safew-breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 浮动效果 */
.anim-float { animation: safew-float 6s ease-in-out infinite; }
@keyframes safew-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 滑入效果 */
.anim-slide { animation: safew-slide 4s ease-out forwards; }
@keyframes safew-slide {
  from { transform: translateX(-15px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 描边流动 */
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: safew-draw 3s ease-in-out infinite alternate;
}
@keyframes safew-draw {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 1; }
}

/* 缓慢旋转 */
.anim-spin {
  animation: safew-spin 18s linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes safew-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
