/* =========================================
   SafeW 全站共享样式与动效
   ========================================= */

/* --- 设计变量 --- */
:root {
  --color-dark: #140E25;
  --color-paper: #F5F0E5;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  --color-accent-text: #140E25;

  --radius-card: 8px;
  --radius-btn: 6px;
  --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: 1120px;

  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

/* --- 基础重置与排版 --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--color-paper);
  color: var(--color-text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* 标题系统 */
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); font-weight: 800; margin-bottom: 0.5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 800; line-height: 1.25; margin-bottom: 1.5em; }
h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75em; }
p { max-width: 38em; margin: 0 0 1em; }
small { font-size: 0.875rem; opacity: 0.85; }

/* 眉标 */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-btn);
}
section.paper .badge { color: var(--color-brand); background: rgba(82, 20, 235, 0.08); }
section.dark .badge { color: var(--color-accent); background: rgba(200, 237, 110, 0.15); }

/* 高亮词 */
.hl { font-weight: 800; }
section.paper .hl { color: var(--color-brand); }
section.dark .hl { color: var(--color-accent); }

/* --- 布局容器 --- */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); overflow-x: hidden; }
.section-inner { padding: var(--section-y) 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); }
.flex-row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }

/* 区块背景切换 */
section.paper { background: var(--color-paper); color: var(--color-text); }
section.dark { background: var(--color-dark); color: var(--color-paper); }
section.dark .card { background: rgba(245, 240, 229, 0.06); border-color: rgba(245, 240, 229, 0.12); }
section.dark .table-wrapper { background: rgba(245, 240, 229, 0.06); border-radius: var(--radius-card); overflow-x: auto; }

/* --- 组件：按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0 1.25rem; height: 52px; 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, color 0.2s ease;
}
.btn-primary { background: var(--color-accent); color: var(--color-accent-text); }
.btn-primary:hover { background: #d9f58a; transform: translateY(-2px); }
.btn-secondary { background: transparent; border: 1px solid var(--color-text); color: var(--color-text); }
section.dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn-secondary:hover { background: rgba(25, 21, 35, 0.08); transform: translateY(-2px); }
section.dark .btn-secondary:hover { background: rgba(245, 240, 229, 0.1); }
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* --- 组件：卡片 --- */
.card {
  background: var(--color-paper);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-2px); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: var(--gap); }

/* --- 组件：表格 --- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid currentColor; opacity: 0.9; }
th { font-weight: 700; opacity: 1; }
td:first-child { font-weight: 600; white-space: nowrap; }

/* --- 组件：FAQ (details/summary) --- */
details {
  border: var(--card-border); border-radius: var(--radius-card);
  padding: 1rem 1.25rem; margin-bottom: 0.75rem; background: var(--color-paper);
}
section.dark details { background: rgba(245, 240, 229, 0.06); }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 0.2s; }
details[open] summary::before { transform: rotate(-45deg) translateY(-2px); }
details p { margin-top: 0.75rem; margin-bottom: 0; font-size: 0.95rem; }

/* --- 组件：步骤条 --- */
.steps { display: flex; flex-wrap: wrap; gap: 1rem; counter-reset: step; }
.step { flex: 1 1 200px; position: relative; padding-left: 2.5rem; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem; border-radius: 4px;
  background: var(--color-accent); color: var(--color-dark);
  font-weight: 800; font-size: 0.9rem; display: grid; place-items: center;
}
.step-title { font-weight: 700; margin-bottom: 0.25rem; }

/* --- 组件：流程箭头 --- */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-weight: 600; }
.flow-node { padding: 0.5rem 1rem; border: 1px solid currentColor; border-radius: var(--radius-btn); background: rgba(255,255,255,0.05); }
.flow-arrow { opacity: 0.4; font-size: 1.2rem; }

/* --- 页头与页脚 --- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245, 240, 229, 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}
section.dark .header { background: rgba(20, 14, 37, 0.9); border-bottom-color: rgba(245, 240, 229, 0.1); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.1rem; }
.logo img { width: 32px; height: 32px; object-fit: contain; }
.nav { display: flex; gap: 1.5rem; align-items: center; }
.nav a { font-weight: 500; opacity: 0.8; transition: opacity 0.2s; }
.nav a:hover, .nav a[aria-current="page"] { opacity: 1; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.mobile-menu-btn { display: none; background: none; border: none; color: inherit; cursor: pointer; }

.footer {
  padding: 3rem 0; border-top: 1px solid rgba(25, 21, 35, 0.1);
  font-size: 0.9rem; opacity: 0.85;
}
section.dark .footer { border-top-color: rgba(245, 240, 229, 0.1); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2rem; }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a:hover { text-decoration: underline; }

/* --- SVG 动效 --- */
.svg-scene { width: 100%; height: auto; max-width: 100%; margin: 0 auto; display: block; }
.anim-float-slow { animation: floatSlow 8s ease-in-out infinite; }
.anim-float-mid { animation: floatMid 6s ease-in-out infinite; }
.anim-float-fast { animation: floatFast 5s ease-in-out infinite; }
.anim-draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawPath 4s ease forwards; }
.anim-pulse { animation: pulseOp 3.5s ease-in-out infinite; }
.anim-slide-in { animation: slideIn 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes floatSlow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes floatMid { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes floatFast { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes drawPath { 0% { stroke-dashoffset: 1; } 100% { stroke-dashoffset: 0; } }
@keyframes pulseOp { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes slideIn { 0% { transform: translateX(20px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

/* 旋转/缩放子元素中心修正 */
svg .rotator, svg .scaler { transform-box: fill-box; transform-origin: center; }

/* 减少动态效果支持 */
@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) {
  .nav { display: none; }
  .mobile-menu-btn { display: block; }
  .grid-2, .card-grid { grid-template-columns: 1fr; }
  .flow { flex-direction: column; align-items: stretch; }
  .flow-arrow { transform: rotate(90deg); margin: 0.25rem 0; }
  h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
}
