/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 设计变量 */
:root {
  --color-dark: #141838;
  --color-paper: #F7F5F3;
  --color-text: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  
  --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: 1120px;
  
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
}

/* 基础重置与排版 */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { padding-left: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
p { margin: 0; }

/* 容器与布局 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}
.section {
  padding-block: var(--section-y);
  position: relative;
}
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.grid-3 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 表面层配色覆盖 */
.surface-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.surface-dark .hl { color: var(--color-accent); }
.surface-dark .brand-link { color: var(--color-accent); }
.surface-light-on-dark {
  background-color: var(--color-paper);
  color: var(--color-text);
  border-radius: var(--radius-card);
  padding: var(--gap);
}
.surface-light-on-dark .hl { color: var(--color-brand); }

/* 标题与眉标 */
.breadcrumb {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  color: var(--color-brand);
}
.surface-dark .breadcrumb { color: var(--color-accent); }
h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: var(--gap); }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.text-body { font-size: 1rem; line-height: 1.55; max-width: 38em; }
.hl { color: var(--color-brand); }
.surface-dark .hl { color: var(--color-accent); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 52px;
  padding-inline: 1.5rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
}
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { transform: translateY(-1px); background-color: #5a9ddc; }
.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-text);
}
.surface-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* 卡片与面板 */
.card {
  background-color: color-mix(in srgb, var(--color-paper) 90%, white);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
}
.surface-dark .card {
  background-color: color-mix(in srgb, var(--color-dark) 85%, black);
}
.visual-panel {
  background-color: var(--color-dark);
  border-radius: var(--radius-card);
  padding: var(--gap);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.surface-dark .visual-panel { background-color: color-mix(in srgb, var(--color-dark) 95%, white); }

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}
.data-table th { font-weight: 700; }
.data-table tr:last-child td { border-bottom: none; }

/* 折叠面板 (FAQ) */
details {
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: var(--radius-card);
  padding: var(--gap);
  margin-bottom: var(--gap);
  background-color: color-mix(in srgb, currentColor 3%, transparent);
}
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: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s;
}
details[open] summary::before { transform: rotate(45deg); }
details p { margin-top: 0.5rem; line-height: 1.6; }

/* 导航与页头 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(247, 245, 243, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}
.surface-dark .site-header { background-color: rgba(20, 24, 56, 0.9); }
.site-header.scrolled { border-bottom-color: color-mix(in srgb, currentColor 10%, transparent); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { text-decoration: underline; }
.nav-links a[aria-current="page"] { color: var(--color-brand); font-weight: 700; }
.surface-dark .nav-links a[aria-current="page"] { color: var(--color-accent); }

/* 页脚 */
.site-footer {
  padding-block: var(--section-y);
  border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  font-size: 0.9rem;
  color: color-mix(in srgb, currentColor 70%, transparent);
}
.footer-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.footer-col h4 { color: currentColor; margin-bottom: 0.5rem; }
.footer-col ul li { margin-bottom: 0.4rem; }
.footer-col a:hover { text-decoration: underline; }

/* SVG 动效基础 */
.svg-container { width: 100%; height: auto; }
svg { width: 100%; height: auto; }
svg path, svg circle, svg rect, svg line, svg polyline, svg polygon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg .fill-solid { fill: currentColor; stroke: none; }
svg .stroke-accent { stroke: var(--color-accent); }
svg .stroke-brand { stroke: var(--color-brand); }
svg .stroke-paper { stroke: var(--color-paper); }
svg .stroke-dark { stroke: var(--color-dark); }

/* 关键帧定义 */
@keyframes draw-path {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.98); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes slide-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes flow-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 动效类应用 */
.draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw-path 3s ease-out forwards; }
.breathe { animation: breathe 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.float { animation: float 5s ease-in-out infinite; }
.slide-in { animation: slide-in-up 0.8s ease-out both; }
.flow { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 1; animation: flow-line 2.5s linear infinite; }
.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.5s; }
.delay-3 { animation-delay: 0.8s; }
.delay-4 { animation-delay: 1.1s; }

/* 减少动态效果 */
@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, .flow { stroke-dashoffset: 0 !important; }
  .float, .breathe, .slide-in { animation: none !important; transform: none !important; opacity: 1 !important; }
}

/* 响应式微调 */
@media (max-width: 767px) {
  .header-inner { flex-direction: column; height: auto; padding-block: 0.5rem; }
  .nav-links { gap: 1rem; margin-block: 0.5rem; }
  .hero-layout { grid-template-columns: 1fr !important; }
  .hero-float-card { position: static; margin-top: var(--gap); }
  .deep-dive-layout { grid-template-columns: 1fr !important; }
}
@media (min-width: 768px) {
  .hero-layout { grid-template-columns: 1.2fr 1fr; align-items: center; }
  .deep-dive-layout { grid-template-columns: 2fr 1fr; align-items: start; }
  .hero-float-card {
    position: absolute;
    bottom: -24px;
    left: 5%;
    right: 5%;
    z-index: 10;
  }
}
/* 防止横向溢出 */
html, body { overflow-x: hidden; max-width: 100vw; }
.flex-col { display: flex; flex-direction: column; min-width: 0; }
.long-text { overflow-wrap: anywhere; word-break: break-word; }
.whitespace-nowrap { white-space: nowrap; }
