/* =========================================
   SafeW 全局样式与设计 Token
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #231334;
  --color-paper: #F5F3F7;
  --color-text: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;

  /* 结构 Token */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 960px;

  /* 排版 Token */
  --font-sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --leading-body: 1.75;
  --leading-title: 1.25;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--leading-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* =========================================
   布局与容器
   ========================================= */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-block: var(--section-y);
  position: relative;
}

.section-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.section-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}

/* 取色覆盖规则 */
.section-dark .hl,
.section-dark .badge,
.section-dark a:not(.btn) {
  color: var(--color-accent);
}

.section-paper .hl,
.section-paper .badge,
.section-paper a:not(.btn) {
  color: var(--color-brand);
}

.card {
  background-color: rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
}

.section-dark .card {
  background-color: rgba(245, 243, 247, 0.08);
}

.grid-split {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid-split {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

/* =========================================
   排版组件
   ========================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.badge::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 2px;
  background-color: currentColor;
  border-radius: 1px;
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  font-weight: 600;
  line-height: var(--leading-title);
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 600;
  line-height: var(--leading-title);
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: var(--leading-title);
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

p:last-child {
  margin-bottom: 0;
}

code {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.hl {
  font-weight: 700;
}

.lead {
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  line-height: 1.8;
  opacity: 0.9;
  margin-bottom: 2rem;
}

/* =========================================
   按钮组件
   ========================================= */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  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(-2px);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: transparent;
  border-color: currentColor;
  color: inherit;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  opacity: 0.85;
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.section-paper .btn:focus-visible {
  outline-color: var(--color-brand);
}

/* =========================================
   表格组件
   ========================================= */
.data-table {
  display: block;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-top: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.data-table th {
  font-weight: 700;
  width: 40%;
}

.section-dark .data-table th,
.section-dark .data-table td {
  border-bottom-color: rgba(245, 243, 247, 0.15);
}

/* =========================================
   FAQ / Details
   ========================================= */
details {
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  padding: 16px 20px;
  transition: background-color 0.2s ease;
}

.section-dark details {
  background-color: rgba(245, 243, 247, 0.08);
}

summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

details[open] summary::before {
  transform: rotate(45deg);
}

details > div {
  margin-top: 12px;
  line-height: 1.7;
  opacity: 0.9;
}

/* =========================================
   SVG 动效系统
   ========================================= */
svg.animated-svg {
  width: 100%;
  height: auto;
}

svg.animated-svg path,
svg.animated-svg circle,
svg.animated-svg rect {
  transition: all 0.3s ease;
}

/* 网格节点依次点亮 */
@keyframes node-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.grid-node {
  animation: node-pulse 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.grid-node:nth-child(1) { animation-delay: 0s; }
.grid-node:nth-child(2) { animation-delay: 0.8s; }
.grid-node:nth-child(3) { animation-delay: 1.6s; }
.grid-node:nth-child(4) { animation-delay: 2.4s; }
.grid-node:nth-child(5) { animation-delay: 3.2s; }
.grid-node:nth-child(6) { animation-delay: 4.0s; }

/* 气泡轻微漂浮 */
@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.bubble-float {
  animation: float-bubble 4.5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.bubble-float:nth-child(even) {
  animation-duration: 5.2s;
  animation-direction: reverse;
}

/* 输入框三点呼吸 */
@keyframes breathe-dot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.dot-breathe {
  animation: breathe-dot 2.4s ease-in-out infinite;
}

.dot-breathe:nth-child(2) { animation-delay: 0.2s; }
.dot-breathe:nth-child(3) { animation-delay: 0.4s; }

/* 连接线流动描边 */
@keyframes draw-line {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.line-flow {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-line 3s linear infinite;
}

/* 通知卡片滑入循环 */
@keyframes slide-in-card {
  0%, 100% { transform: translateX(0); opacity: 1; }
  10% { transform: translateX(8px); opacity: 0.85; }
  90% { transform: translateX(8px); opacity: 0.85; }
}

.notification-slide {
  animation: slide-in-card 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  .grid-node,
  .bubble-float,
  .dot-breathe,
  .line-flow,
  .notification-slide {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* =========================================
   响应式辅助
   ========================================= */
@media (max-width: 600px) {
  .btn-group {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}

/* 焦点可见性增强 */
:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

.section-dark :focus-visible {
  outline-color: var(--color-accent);
}
