/* ====================
   SafeW 全站共享样式
   ==================== */

/* --- 设计变量 --- */
:root {
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-body: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  --color-accent-hover: #5A9AD6;
  --color-divider: rgba(21, 23, 35, 0.08);
  --color-muted: rgba(21, 23, 35, 0.6);

  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;

  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;

  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --line-height-base: 1.55;
}

/* --- 基础重置与排版 --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--color-paper);
  color: var(--color-body);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* 标题系统 */
.section-number {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.section-dark .section-number { color: var(--color-accent); }

h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: var(--gap);
  text-wrap: balance;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 600;
  line-height: 1.25;
  margin-top: var(--gap);
  margin-bottom: calc(var(--gap) * 1.5);
  text-wrap: balance;
}
h3 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--gap);
}
p { margin-bottom: var(--gap); max-width: 38em; }
.text-muted { color: var(--color-muted); }

/* 强调词 */
.hl { color: var(--color-brand); }
.section-dark .hl { color: var(--color-accent); }

/* 区块背景与分割 */
section { padding: var(--section-y) 0; border-bottom: 1px solid var(--color-divider); }
section:last-of-type { border-bottom: none; }
.section-dark { background: var(--color-dark); color: var(--color-paper); border-bottom: none; }
.section-dark p, .section-dark li { color: var(--color-paper); }
.section-dark .text-muted { color: rgba(247, 245, 243, 0.7); }
.card-light {
  background: var(--color-paper);
  color: var(--color-body);
  padding: var(--gap);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}
.card-light .hl { color: var(--color-brand); }
.card-light p { color: var(--color-body); }

/* 页头 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 243, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-divider);
}
.section-dark .site-header { background: rgba(20, 24, 56, 0.95); border-bottom-color: rgba(247, 245, 243, 0.1); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.logo img { height: 32px; width: auto; }
.nav-list { display: flex; gap: calc(var(--gap) * 2); }
.nav-link { font-size: 0.95rem; font-weight: 500; padding: 4px 0; position: relative; }
.nav-link:hover { color: var(--color-brand); }
.section-dark .nav-link:hover { color: var(--color-accent); }
.nav-link[aria-current="page"] { color: var(--color-brand); font-weight: 600; }
.section-dark .nav-link[aria-current="page"] { color: var(--color-accent); }
.header-actions { display: flex; align-items: center; gap: var(--gap); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background: var(--color-accent-hover); transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-body);
  color: var(--color-body);
}
.section-dark .btn-secondary { border-color: var(--color-paper); color: var(--color-paper); }
.btn-secondary:hover { background: rgba(0,0,0,0.05); }
.section-dark .btn-secondary:hover { background: rgba(255,255,255,0.1); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.section-dark .btn:focus-visible { outline-color: var(--color-accent); }
.btn svg { width: 18px; height: 18px; stroke-width: 2; }

/* 卡片与网格 */
.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); }
.card {
  background: var(--color-paper);
  padding: var(--gap);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}
.card h3 { margin-top: 0; }
.card p { flex-grow: 1; }
.time-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(20, 44, 235, 0.08);
  color: var(--color-brand);
  margin-bottom: 8px;
}
.section-dark .time-tag { background: rgba(110, 175, 237, 0.15); color: var(--color-accent); }

/* 表格 */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: var(--gap); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--color-divider); }
th { font-weight: 600; background: rgba(0,0,0,0.02); }
td { word-break: break-all; }
a.link-accent { color: var(--color-brand); text-decoration: underline; text-underline-offset: 2px; }
.section-dark .link-accent { color: var(--color-accent); }

/* FAQ */
.faq-item { border-bottom: 1px solid var(--color-divider); }
.faq-item details { padding: var(--gap) 0; }
.faq-item summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::marker { content: ""; }
.faq-item summary::before {
  content: "+";
  font-weight: 700;
  color: var(--color-brand);
  width: 20px;
  text-align: center;
}
.faq-item[open] summary::before { content: "-"; color: var(--color-accent); }
.faq-item p { margin-top: var(--gap); margin-bottom: 0; }

/* 步骤条 */
.step-row { display: flex; gap: var(--gap); flex-wrap: wrap; }
.step-item { flex: 1 1 200px; position: relative; padding-left: 32px; }
.step-num {
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px;
  background: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.step-item:not(:last-child)::after {
  content: ""; position: absolute; top: 12px; left: 24px; right: -20px;
  height: 1px; background: var(--color-divider);
}

/* 杂志长文布局 */
.magazine-layout { display: grid; grid-template-columns: 1fr 240px; gap: calc(var(--gap) * 3); }
.toc { position: sticky; top: 80px; align-self: start; }
.toc ul { border-left: 2px solid var(--color-divider); padding-left: 12px; }
.toc li { margin-bottom: 12px; font-size: 0.9rem; }
.toc a { color: var(--color-muted); transition: color 0.2s; }
.toc a:hover, .toc a.active { color: var(--color-brand); }
.section-dark .toc a:hover, .section-dark .toc a.active { color: var(--color-accent); }

/* 场景卡片 */
.scenario-block { margin-bottom: var(--gap); }
.scenario-tag {
  display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  padding: 4px 10px; border-radius: 4px; margin-bottom: 8px;
}
.tag-problem { background: rgba(244, 67, 54, 0.1); color: #D32F2F; }
.tag-action { background: rgba(20, 44, 235, 0.1); color: var(--color-brand); }
.tag-result { background: rgba(67, 160, 71, 0.1); color: #388E3C; }

/* SVG 基础与动效 */
.svg-panel { width: 100%; height: auto; max-width: 100%; }
.anim-flow-line { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: flowDash 4s linear infinite; }
.anim-bubble { animation: floatBubble 6s ease-in-out infinite alternate; }
.anim-slide-up { animation: slideUp 5s ease-in-out infinite; }
.anim-draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawPath 3s ease forwards; }

@keyframes flowDash {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes floatBubble {
  0% { transform: translateY(0); opacity: 0.8; }
  100% { transform: translateY(-8px); opacity: 1; }
}
@keyframes slideUp {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-4px); opacity: 1; }
}
@keyframes drawPath {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

/* 焦点与无障碍 */
:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.section-dark :focus-visible { outline-color: var(--color-accent); }

@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;
  }
  .anim-flow-line, .anim-bubble, .anim-slide-up, .anim-draw {
    animation: none !important;
  }
}

/* 响应式适配 */
@media (max-width: 768px) {
  .magazine-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .step-row { flex-direction: column; }
  .step-item:not(:last-child)::after { display: none; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; }
  .nav-list { order: 3; width: 100%; justify-content: center; margin-top: 8px; }
}
