/* SafeW 全站共享样式 */

/* === 设计变量 === */
:root {
  /* 颜色系统 */
  --color-bg-dark: #21163C;
  --color-bg-paper: #E9E8EA;
  --color-text-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED926E;
  
  /* 派生颜色（用于边框、次要文字等，不用于正文） */
  --color-border-light: rgba(25, 21, 35, 0.16);
  --color-border-dark: rgba(233, 232, 234, 0.16);

  /* 圆角 */
  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-sm: 8px;

  /* 间距与节奏 */
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --container-max: 960px;
  --header-height: 72px;

  /* 字体 */
  --font-sans: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, monospace;
}

/* === 基础重置 === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text-body);
  background-color: var(--color-bg-paper);
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s ease;
}

ul, ol {
  list-style: none;
}

/* === 布局容器 === */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gap);
  overflow-x: hidden;
}

.section {
  padding: var(--section-y) 0;
  position: relative;
}

/* 面色切换 */
.bg-dark {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
}

.bg-paper {
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
}

/* 取色覆盖：深色面上的浅色卡片 */
.card-light-on-dark {
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
  border: 1px solid var(--color-border-light);
}

/* === 排版 === */
h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: var(--gap);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

.hl {
  color: var(--color-brand);
}

.bg-dark .hl {
  color: var(--color-accent);
}

.subtitle {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--gap);
  display: inline-block;
}

.paper-theme .subtitle {
  color: var(--color-brand);
}

.dark-theme .subtitle {
  color: var(--color-accent);
}

/* === 按钮 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
  gap: 8px;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--color-text-body);
  color: var(--color-text-body);
}

.bg-dark .btn-secondary {
  border-color: var(--color-bg-paper);
  color: var(--color-bg-paper);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  opacity: 0.8;
}

.btn-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* === 卡片 === */
.card {
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
}

.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-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

th {
  font-weight: 600;
  background-color: rgba(25, 21, 35, 0.05);
}

tr:last-child td {
  border-bottom: none;
}

/* === FAQ === */
details {
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--gap) 0;
}

summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 24px;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2em;
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: translateY(-50%) rotate(45deg);
}

details p {
  margin-top: var(--gap);
  margin-bottom: 0;
  color: currentColor;
  opacity: 0.9;
}

/* === 导航 === */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: rgba(233, 232, 234, 0.8);
  backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.scrolled .header {
  border-bottom-color: var(--color-border-light);
  background-color: rgba(233, 232, 234, 0.95);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-link {
  font-weight: 500;
  position: relative;
}

.nav-link[aria-current="page"] {
  color: var(--color-brand);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-brand);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.nav-link:hover::after,
.nav-link[aria-current="page"]::after {
  transform: scaleX(1);
}

/* === 页脚 === */
.footer {
  padding: var(--section-y) 0;
  border-top: 1px solid var(--color-border-light);
  margin-top: var(--section-y);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}

.footer-col h4 {
  font-size: 0.9rem;
  margin-bottom: var(--gap);
  opacity: 0.7;
}

.footer-col a {
  display: block;
  margin-bottom: 8px;
  opacity: 0.8;
}

.footer-col a:hover {
  opacity: 1;
  color: var(--color-brand);
}

/* === SVG 动效 Keyframes === */
/* 描边绘制 */
@keyframes draw-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* 数据点流动 */
@keyframes flow-dot {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* 浮动 */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* 呼吸 */
@keyframes pulse-opacity {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* 淡入上浮 */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 动效类 */
.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-line 2s ease forwards;
}

.flow-dot {
  animation: flow-dot 3s linear infinite;
}

.float-element {
  animation: float 4s ease-in-out infinite;
}

.pulse-element {
  animation: pulse-opacity 2s ease-in-out infinite;
}

.fade-up-element {
  animation: fade-up 0.8s ease-out forwards;
}

.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }

/* SVG 基础样式 */
.svg-panel {
  width: 100%;
  height: auto;
  overflow: visible;
}

/* 减少动态效果偏好 */
@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;
  }
  .flow-dot, .float-element, .pulse-element, .fade-up-element, .draw-path {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
    transform: none !important;
  }
}
