/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 基础变量与色板 */
:root {
  --color-dark: #140E25;
  --color-paper: #F5F0E5;
  --color-text: #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(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --line-height-base: 1.65;
}

/* 面层级取色覆盖 */
.surface-paper {
  --bg: var(--color-paper);
  --fg: var(--color-text);
  --fg-muted: rgba(25, 21, 35, 0.65);
  --accent: var(--color-brand);
  --link: var(--color-brand);
  --border: rgba(25, 21, 35, 0.12);
}

.surface-dark {
  --bg: var(--color-dark);
  --fg: var(--color-paper);
  --fg-muted: rgba(245, 240, 229, 0.7);
  --accent: var(--color-accent);
  --link: var(--color-accent);
  --border: rgba(245, 240, 229, 0.15);
}

/* 卡片内恢复纸面取色 */
.card-light {
  --bg: var(--color-paper);
  --fg: var(--color-text);
  --fg-muted: rgba(25, 21, 35, 0.65);
  --accent: var(--color-brand);
  --link: var(--color-brand);
  --border: rgba(25, 21, 35, 0.1);
}

/* 重置与基础排版 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; transition: opacity 0.2s; }
a:hover { opacity: 0.85; }
ul, ol { list-style: none; }

/* 容器与区块 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.section {
  padding-block: var(--section-y);
  background: var(--bg);
  position: relative;
}

.section + .section {
  border-top: 1px solid var(--border);
}

/* 排版层次 */
.masthead {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: inline-block;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-wrap: balance;
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
  margin-bottom: calc(var(--gap) * 0.75);
  text-wrap: balance;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
  margin-bottom: var(--gap);
}

p { margin-bottom: var(--gap); max-width: 38em; }
.hl { color: var(--accent); font-weight: 600; }

/* 按钮系统 */
.btn-group { display: flex; gap: 12px; flex-wrap: wrap; margin-block: var(--gap); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--accent);
  color: var(--color-dark);
  border: none;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 237, 110, 0.25);
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1.5px solid var(--fg);
}
.btn-secondary:hover {
  background: rgba(25, 21, 35, 0.06);
  transform: translateY(-1px);
}

/* 卡片与网格 */
.card {
  background: var(--bg);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 12px 32px -12px rgba(25, 21, 35, 0.35); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }

/* 表格 */
.table-wrap { overflow-x: auto; margin-block: var(--gap); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th { font-weight: 600; color: var(--fg); }
td { color: var(--fg-muted); }
tr:last-child td { border-bottom: none; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  transition: box-shadow 0.2s;
}
details[open] { box-shadow: var(--card-shadow); }
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--fg);
  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;
  color: var(--accent);
  transition: transform 0.2s;
}
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: 12px; font-size: 0.95rem; color: var(--fg-muted); line-height: 1.6; }

/* 页头与页脚 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand img { height: 32px; width: auto; }
.brand span { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a {
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav a:hover, .nav a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.footer {
  padding-block: var(--section-y);
  background: var(--bg);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; }
.footer-links a { color: var(--fg-muted); text-decoration: none; }
.footer-links a:hover { color: var(--fg); }

/* SVG 视觉面板 */
.viz-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--gap);
  position: relative;
  overflow: hidden;
}
.svg-viz {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08));
}

/* 动效关键帧 */
@keyframes flow-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes slide-in {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.9; }
}

/* 动效应用类 */
.anim-flow {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flow-line 3s ease-in-out infinite alternate;
}
.anim-float {
  animation: float-y 4s ease-in-out infinite;
}
.anim-breathe {
  animation: breathe 3.5s ease-in-out infinite;
}
.anim-slide {
  animation: slide-in 2.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.anim-twinkle {
  animation: twinkle 2s ease-in-out infinite;
}
.rot-center {
  transform-box: fill-box;
  transform-origin: center;
}

/* 响应式适配 */
@media (max-width: 768px) {
  .nav { display: none; }
  h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  [class*="anim-"] { animation: none !important; }
}
