/* =========================================
   SafeW 全局样式与动效系统
   ========================================= */

:root {
  /* 色板 */
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-light-paper: #EDEBE9;
  --color-text: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  --color-white: #FFFFFF;

  /* 设计 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 960px;
  --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;
}

body {
  font-family: var(--font-sans);
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

/* 容器与分节 */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section {
  padding: var(--section-y) 0;
}

.bg-dark {
  background: var(--color-dark);
  color: var(--color-paper);
}

.bg-light-paper {
  background: var(--color-light-paper);
  color: var(--color-text);
}

/* 排版 */
.text-center { text-align: center; }
.mt-sm { margin-top: var(--gap); }
.mb-md { margin-bottom: calc(var(--gap) * 1.5); }

h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  text-wrap: balance;
}

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) / 2);
}

p {
  margin-bottom: 1em;
  max-width: 38em;
}

.hl {
  color: var(--color-brand);
}

.bg-dark .hl {
  color: var(--color-accent);
}

/* 眉标 */
.section-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.5em;
  color: var(--color-brand);
}

.bg-dark .section-eyebrow {
  color: var(--color-accent);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85em 1.6em;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--color-text);
  color: var(--color-text);
}

.bg-dark .btn-secondary {
  border-color: var(--color-paper);
  color: var(--color-paper);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* 卡片系统 */
.card {
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  background: var(--color-paper);
  padding: var(--gap);
}

.card-on-dark {
  border-color: var(--color-accent);
  box-shadow: 4px 4px 0 var(--color-accent);
  background: var(--color-paper);
  color: var(--color-text);
}

.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 {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--gap);
  font-size: 0.95rem;
}

th, td {
  padding: 0.8em 1em;
  border-bottom: 1px solid var(--color-text);
  text-align: left;
}

th {
  font-weight: 700;
}

.bg-dark th,
.bg-dark td {
  border-color: rgba(255, 255, 255, 0.2);
}

/* FAQ */
details {
  margin-bottom: var(--gap);
  border: var(--card-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

summary {
  padding: 1em;
  font-weight: 700;
  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.2em;
  font-weight: 400;
}

details[open] summary::after {
  content: "-";
}

details > div {
  padding: 0 1em 1em;
  line-height: 1.7;
}

/* 导航与页脚 */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-paper);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 1em 0;
}

.bg-dark header {
  background: var(--color-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-weight: 800;
  font-size: 1.1rem;
}

.brand img {
  width: 32px;
  height: 32px;
}

nav {
  display: flex;
  gap: var(--gap);
  align-items: center;
}

nav a {
  font-weight: 500;
  padding: 0.4em 0;
}

nav a:hover {
  text-decoration: underline;
}

nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid var(--color-brand);
}

.bg-dark nav a[aria-current="page"] {
  border-color: var(--color-accent);
}

footer {
  padding: var(--section-y) 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.9rem;
}

.bg-dark footer {
  border-color: rgba(255, 255, 255, 0.08);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.footer-links a {
  display: block;
  padding: 0.3em 0;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* 布局辅助 */
.magazine-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--gap);
}

.steps-row {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
}

.step-item {
  flex: 1 1 200px;
}

.tag {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.5em;
}

.tag-problem { background: #FFE4E4; color: #D32F2F; }
.tag-action { background: #E3F2FD; color: #1565C0; }
.tag-result { background: #E8F5E9; color: #2E7D32; }

.bg-dark .tag-problem { background: rgba(255,255,255,0.15); color: #FFCDD2; }
.bg-dark .tag-action { background: rgba(255,255,255,0.15); color: #BBDEFB; }
.bg-dark .tag-result { background: rgba(255,255,255,0.15); color: #C8E6C9; }

/* SVG 响应式 */
.svg-responsive {
  width: 100%;
  height: auto;
}

/* SVG 动效 Keyframes */
@keyframes interlock-rotate {
  0%, 100% { transform: rotate(0deg) translate(0, 0); }
  50% { transform: rotate(180deg) translate(6px, -6px); }
}

@keyframes float-bubble {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-10px); opacity: 1; }
}

@keyframes dash-draw {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}

.geo-shape {
  animation: interlock-rotate 14s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.msg-bubble {
  animation: float-bubble 5s ease-in-out infinite;
}

.draw-line {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dash-draw 6s ease-in-out infinite;
}

/* 减少动态效果 */
@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;
  }
}

/* 窄屏适配 */
@media (max-width: 768px) {
  .magazine-layout {
    grid-template-columns: 1fr;
  }
  .steps-row {
    flex-direction: column;
  }
  nav {
    gap: 0.8rem;
  }
  h1 {
    line-height: 1.15;
  }
}
