/* =========================================
   SafeW 全局样式与 SVG 动效
   ========================================= */

/* 重置与基础 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-body);
  background: 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 { list-style: none; }

/* 设计 Token 与色板 */
:root {
  --color-dark: #19102D;
  --color-paper: #FCFCFD;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;
  
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: none;
  
  --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, sans-serif;
}

/* 表面上下文：控制取色变量继承 */
.surface-dark {
  background: var(--color-dark);
  color: var(--color-paper);
  --text-primary: var(--color-paper);
  --text-secondary: rgba(252, 252, 253, 0.85);
  --link-color: var(--color-accent);
}
.surface-paper {
  background: var(--color-paper);
  color: var(--color-body);
  --text-primary: var(--color-body);
  --text-secondary: rgba(25, 21, 35, 0.75);
  --link-color: var(--color-brand);
}
.surface-light-card {
  background: #F4F4F5;
  color: var(--color-body);
  --text-primary: var(--color-body);
  --text-secondary: rgba(25, 21, 35, 0.75);
  --link-color: var(--color-brand);
}

/* 布局与排版 */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gap); }
section { padding: var(--section-y) 0; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.flex-row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.flex-col { display: flex; flex-direction: column; gap: var(--gap); }
.main-content { max-width: 38em; }

h1, h2, h3, h4, h5, h6 { font-weight: 500; line-height: 1.15; color: var(--text-primary); text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); letter-spacing: -0.02em; margin-bottom: var(--gap); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin-bottom: calc(var(--gap) * 1.5); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-top: calc(var(--gap) * 1.5); margin-bottom: calc(var(--gap) * 0.5); }
p { margin-bottom: var(--gap); max-width: 38em; }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.5rem; display: block; }
.surface-paper .eyebrow { color: var(--color-brand); }
.surface-dark .eyebrow { color: var(--color-accent); }
.hl { color: var(--link-color); }

/* 组件：按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0 1.5rem; height: 52px; font-size: 1rem; font-weight: 500;
  border-radius: var(--radius-btn); cursor: pointer; transition: transform 0.2s ease, opacity 0.2s ease;
  text-decoration: none; white-space: nowrap; border: none;
}
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--color-accent); color: var(--color-dark); }
.btn-primary:hover { background: #c95de6; }
.btn-secondary { border: 1px solid var(--text-primary); background: transparent; color: var(--text-primary); }
.btn-secondary:hover { background: rgba(128,128,128,0.1); }

/* 组件：卡片 */
.card {
  background: var(--card-bg, var(--color-paper));
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  border-radius: var(--radius-card);
}
.surface-dark .card { background: rgba(255,255,255,0.05); }
.surface-paper .card { background: #F4F4F5; }

/* 组件：表格 */
table { width: 100%; border-collapse: collapse; margin: var(--gap) 0; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid rgba(128,128,128,0.2); }
th { font-weight: 600; }
.surface-dark td { border-color: rgba(255,255,255,0.1); }

/* 组件：FAQ */
details { border-bottom: 1px solid rgba(128,128,128,0.2); padding: 1rem 0; }
summary { cursor: pointer; font-weight: 500; 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; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: 0.75rem; color: var(--text-secondary); }

/* 页头与页脚 */
header { position: sticky; top: 0; z-index: 100; background: var(--color-paper); border-bottom: 1px solid rgba(0,0,0,0.05); backdrop-filter: blur(8px); }
.surface-dark header { background: rgba(25, 16, 45, 0.9); border-color: rgba(255,255,255,0.1); }
.nav-inner { display: flex; justify-content: space-between; align-items: center; height: 64px; }
.logo { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.logo img { height: 28px; width: auto; }
nav ul { display: flex; gap: 1.5rem; }
nav a { font-size: 0.9rem; font-weight: 500; opacity: 0.8; transition: opacity 0.2s; }
nav a:hover, nav a[aria-current="page"] { opacity: 1; color: var(--link-color); }
footer { padding: calc(var(--section-y) * 1.5) 0; border-top: 1px solid rgba(128,128,128,0.2); margin-top: var(--section-y); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.footer-links a { display: block; padding: 0.4rem 0; opacity: 0.7; }
.footer-links a:hover { opacity: 1; }
.copyright { margin-top: var(--gap); font-size: 0.85rem; opacity: 0.6; }

/* SVG 容器与尺寸控制 */
.svg-container { width: 100%; height: auto; max-width: 600px; margin: 0 auto; }
.svg-container svg { width: 100%; height: auto; }

/* SVG 动效类与关键帧 */
.draw { pathLength: 1; stroke-dasharray: 1; stroke-dashoffset: 0; animation: drawLine 4s ease-in-out infinite alternate; }
.breathe { animation: breathe 3s ease-in-out infinite alternate; }
.float { animation: float 5s ease-in-out infinite alternate; }
.slide-in { animation: slideIn 4s ease-out forwards; }

@keyframes drawLine { 0% { stroke-dashoffset: 1; } 100% { stroke-dashoffset: 0; } }
@keyframes breathe { 0% { opacity: 0.6; transform: scale(0.98); } 100% { opacity: 1; transform: scale(1.02); } }
@keyframes float { 0% { transform: translateY(0); } 100% { transform: translateY(-8px); } }
@keyframes slideIn { 0% { transform: translateX(-20px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

.anim-el { transform-box: fill-box; transform-origin: center; }

/* 响应式适配 */
@media (max-width: 768px) {
  .hero-layout, .feature-list, .case-split { grid-template-columns: 1fr; }
  .flex-row { flex-direction: column; align-items: flex-start; }
  .btn { width: 100%; }
}

/* 尊重系统减少动态效果偏好 */
@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, .breathe, .float, .slide-in { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
