/* =========================================
   SafeW 全站共享样式
   Design Token & Reset
   ========================================= */
:root {
  /* 色板 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;

  /* 结构 Token */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: none;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;

  /* 字体与排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --text-base: 16px;
  --line-height-body: 1.65;
  --line-height-heading: 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: var(--text-base);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* =========================================
   布局容器
   ========================================= */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.section {
  padding-block: var(--section-y);
  position: relative;
}

.section-divider {
  border-top: 1px solid rgba(25, 21, 35, 0.08);
}

/* =========================================
   取色上下文类
   ========================================= */
.surface-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.surface-dark .hl {
  color: var(--color-accent);
}

.surface-dark a:not(.btn) {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.surface-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}

.surface-paper .hl {
  color: var(--color-brand);
}

.surface-paper a:not(.btn) {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 卡片内嵌于深色面时恢复纸面取色 */
.card-light-on-dark {
  background-color: var(--color-paper);
  color: var(--color-text);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

.card-light-on-dark .hl {
  color: var(--color-brand);
}

/* =========================================
   排版组件
   ========================================= */
.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: 12px;
}

.surface-dark .badge {
  color: var(--color-accent);
}

.surface-paper .badge {
  color: var(--color-brand);
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--line-height-heading);
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  margin-bottom: 16px;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 24px;
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  margin-bottom: 12px;
}

p {
  margin-bottom: 1em;
  max-width: 38em;
}

.hl {
  font-weight: 600;
}

/* =========================================
   按钮系统
   ========================================= */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.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:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(0.95);
}

.btn-secondary {
  background-color: transparent;
}

.surface-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.surface-paper .btn-secondary {
  color: var(--color-text);
  border-color: var(--color-text);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  filter: brightness(0.9);
}

/* =========================================
   表格系统
   ========================================= */
.table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: var(--radius-card);
  border: 1px solid rgba(25, 21, 35, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}

th {
  font-weight: 600;
  background-color: rgba(25, 21, 35, 0.03);
}

tr:last-child td {
  border-bottom: none;
}

/* =========================================
   FAQ (<details>)
   ========================================= */
.faq-list details {
  border: 1px solid rgba(25, 21, 35, 0.1);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-list summary {
  padding: 16px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  font-weight: 400;
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.faq-list details[open] summary::after {
  transform: rotate(45deg);
}

.faq-list details[open] summary {
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
}

.faq-list .faq-answer {
  padding: 16px;
  color: var(--color-text);
  line-height: 1.7;
}

.surface-dark .faq-list details {
  border-color: rgba(252, 252, 253, 0.15);
}

.surface-dark .faq-list summary {
  color: var(--color-paper);
}

.surface-dark .faq-list summary::after {
  color: var(--color-paper);
}

.surface-dark .faq-list details[open] summary {
  border-bottom-color: rgba(252, 252, 253, 0.15);
}

.surface-dark .faq-list .faq-answer {
  color: rgba(252, 252, 253, 0.9);
}

/* =========================================
   页头与导航
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(252, 252, 253, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
}

.site-header.scrolled {
  border-bottom-color: rgba(25, 21, 35, 0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
}

.logo-group img {
  height: 28px;
  width: auto;
}

.main-nav ul {
  display: flex;
  gap: 24px;
  align-items: center;
}

.main-nav a {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 6px 0;
  position: relative;
}

.main-nav a:hover {
  color: var(--color-brand);
}

.main-nav a[aria-current="page"] {
  color: var(--color-brand);
  font-weight: 600;
}

.main-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-brand);
}

/* =========================================
   页脚
   ========================================= */
.site-footer {
  padding-block: 48px;
  border-top: 1px solid rgba(25, 21, 35, 0.08);
  font-size: 0.9rem;
  color: rgba(25, 21, 35, 0.7);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links a:hover {
  color: var(--color-brand);
}

/* =========================================
   SVG 动效 Keyframes
   ========================================= */
@keyframes drawLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes breathDraw {
  0%, 100% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: 1; }
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes bubbleIn {
  0%, 100% { opacity: 0; transform: translateY(8px); }
  15%, 85% { opacity: 1; transform: translateY(0); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes flowDash {
  to { stroke-dashoffset: -8; }
}

/* =========================================
   SVG 动效 Class 绑定
   ========================================= */
.svg-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 4s ease-in-out infinite alternate;
}

.svg-breath {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: breathDraw 6s ease-in-out infinite;
}

.svg-float {
  animation: floatSlow 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.svg-bubble {
  opacity: 0;
  animation: bubbleIn 4s ease-in-out infinite;
}

.svg-bubble.delay-1 { animation-delay: 0.8s; }
.svg-bubble.delay-2 { animation-delay: 1.6s; }

.svg-pulse {
  animation: pulseDot 2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.svg-flow {
  stroke-dasharray: 4 4;
  animation: flowDash 1.5s linear infinite;
}

/* =========================================
   响应式与无障碍
   ========================================= */
@media (max-width: 768px) {
  .main-nav { display: none; }
  h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); }
  h2 { font-size: clamp(1.4rem, 4vw, 2rem); }
  .grid-alt { grid-template-columns: 1fr !important; }
  .magazine-layout { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .svg-draw, .svg-breath, .svg-float, .svg-bubble, .svg-pulse, .svg-flow {
    animation: none !important;
  }
  html { scroll-behavior: auto; }
}
