/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  --color-deep: #13102D;
  --color-paper: #F7F5F3;
  --color-text: #171523;
  --color-brand: #2714EB;
  --color-accent: #89ED6E;

  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(23, 21, 35, 0.3);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  --body-lh: 1.65;
  --header-h: 64px;

  /* 取色变量（默认纸面） */
  --text-primary: var(--color-text);
  --text-secondary: rgba(23, 21, 35, 0.75);
  --link-color: var(--color-brand);
  --icon-color: var(--color-brand);
  --bg-base: var(--color-paper);
  --border-color: rgba(23, 21, 35, 0.12);
}

/* 深色面覆盖 */
.dark-panel {
  --text-primary: var(--color-paper);
  --text-secondary: rgba(247, 245, 243, 0.8);
  --link-color: var(--color-accent);
  --icon-color: var(--color-accent);
  --bg-base: var(--color-deep);
  --border-color: rgba(247, 245, 243, 0.15);
}

/* 卡片内恢复纸面取色 */
.light-card {
  --text-primary: var(--color-text);
  --text-secondary: var(--color-text);
  --link-color: var(--color-brand);
  --icon-color: var(--color-brand);
  --bg-base: var(--color-paper);
  --border-color: rgba(23, 21, 35, 0.1);
}

/* --- 基础重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  line-height: var(--body-lh);
  color: var(--text-primary);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--link-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- 布局容器 --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.section {
  padding-block: var(--section-y);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
.section:last-of-type { border-bottom: none; }
.section.dark-section { background-color: var(--color-deep); }

/* --- 排版 --- */
.madeleine {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--link-color);
  margin-bottom: 0.75rem;
}
.madeleine::before { content: ""; width: 1.5ch; height: 2px; background: currentColor; border-radius: 1px; }

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 500;
  line-height: 1.25;
  margin-bottom: 1.5rem;
}
h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}
p { margin-bottom: 1rem; max-width: 38em; }
.hl { color: var(--link-color); }

/* --- 页头 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 243, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-h);
}
.dark-section .site-header { background: rgba(19, 16, 45, 0.85); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 600; color: var(--text-primary); }
.brand img { width: 32px; height: 32px; object-fit: contain; }
nav ul { display: flex; gap: 1.5rem; }
nav a { font-size: 0.95rem; font-weight: 500; color: var(--text-secondary); }
nav a[aria-current="page"], nav a:hover { color: var(--text-primary); }
.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: var(--color-accent);
  color: var(--color-deep);
  font-weight: 600;
  border-radius: var(--radius-btn);
  transition: transform 0.2s, filter 0.2s;
}
.header-cta:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
  min-height: 48px;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--link-color); outline-offset: 2px; }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-deep);
  box-shadow: var(--card-shadow);
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--text-primary);
}
.btn-secondary:hover { background: rgba(23, 21, 35, 0.05); }
.dark-section .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.dark-section .btn-secondary:hover { background: rgba(247, 245, 243, 0.1); }

/* --- 网格与双栏 --- */
.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); }

/* --- 侧边索引 --- */
.layout-split {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--gap);
}
.side-nav {
  position: sticky;
  top: calc(var(--header-h) + var(--gap));
  align-self: start;
  padding: 1.25rem;
  background: var(--bg-base);
  border: var(--card-border) solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}
.side-nav ul { display: flex; flex-direction: column; gap: 0.5rem; }
.side-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}
.side-nav a:hover, .side-nav a.active { background: rgba(23, 21, 35, 0.06); color: var(--text-primary); }
.dark-section .side-nav a:hover, .dark-section .side-nav a.active { background: rgba(247, 245, 243, 0.1); }

/* --- 卡片与面板 --- */
.card {
  background: var(--bg-base);
  border: var(--card-border) solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -12px rgba(23, 21, 35, 0.35); }
.visual-panel {
  background: var(--color-deep);
  border-radius: var(--radius-card);
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  position: relative;
}
.panel-caption {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

/* --- Tab 导航（纯 CSS） --- */
.tab-group { display: flex; flex-direction: column; gap: 1.5rem; }
.tab-radio { display: none; }
.tab-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(23, 21, 35, 0.05);
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.tab-label:hover { background: rgba(23, 21, 35, 0.08); }
.tab-content { display: none; }
.tab-radio:checked + .tab-label { background: var(--link-color); color: #fff; }
.tab-radio:checked ~ .tab-content { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- FAQ --- */
details {
  border: var(--card-border) solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  background: var(--bg-base);
  overflow: hidden;
}
summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  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; font-weight: 400; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
.details-body { padding: 0 1.25rem 1rem; color: var(--text-secondary); line-height: 1.7; }

/* --- 表格 --- */
.table-wrap { overflow-x: auto; border: var(--card-border) solid var(--border-color); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { background: rgba(23, 21, 35, 0.04); font-weight: 600; }
.dark-section th { background: rgba(247, 245, 243, 0.08); }
tr:last-child th, tr:last-child td { border-bottom: none; }

/* --- 提示框 --- */
.callout {
  border-left: 4px solid var(--link-color);
  background: rgba(23, 21, 35, 0.03);
  padding: 1rem 1.25rem;
  border-radius: 0 12px 12px 0;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.dark-section .callout { background: rgba(247, 245, 243, 0.06); }

/* --- 页脚 --- */
.site-footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.footer-col h4 { font-weight: 600; margin-bottom: 0.75rem; color: var(--text-primary); }
.footer-col ul { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-col a { color: var(--text-secondary); }
.footer-col a:hover { color: var(--text-primary); }
.copyright { margin-top: 2rem; text-align: center; }

/* --- SVG 动效 --- */
svg.svg-anim { width: 100%; height: auto; }
svg.svg-anim path, svg.svg-anim circle, svg.svg-anim rect, svg.svg-anim line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.draw-line { animation: drawStroke 4s ease-in-out infinite alternate; }
.float-slow { animation: floatY 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.breathe-dot { animation: breathe 2.5s ease-in-out infinite; }
.slide-in { animation: slideRight 5s ease-in-out infinite alternate; }
.flow-line { animation: dashMove 3s linear infinite; stroke-dasharray: 0.5 0.5; }

@keyframes drawStroke { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes breathe { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes slideRight { from { transform: translateX(-15px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }
@keyframes dashMove { to { stroke-dashoffset: -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;
  }
  .draw-line, .float-slow, .breathe-dot, .slide-in, .flow-line {
    animation: none !important;
  }
}

/* --- 响应式 --- */
@media (max-width: 960px) {
  .layout-split { grid-template-columns: 1fr; }
  .side-nav { position: static; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem; }
  .side-nav ul { flex-direction: row; flex-wrap: wrap; }
  .visual-panel { aspect-ratio: 16 / 9; }
}
@media (max-width: 640px) {
  h1 { font-size: clamp(2rem, 8vw, 2.8rem); }
  .flex-row { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
}
