/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* 1. 设计变量与基础重置 */
:root {
  /* 色板 */
  --color-dark: #19102D;
  --color-paper: #F4F3F7;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;

  /* 结构性约束 */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;

  /* 字体与排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --lh-body: 1.55;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
}

/* 2. 布局容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section {
  padding: var(--section-y) 0;
  position: relative;
}

.section-divider {
  height: 1px;
  background-color: rgba(0, 0, 0, 0.12);
  margin: 0;
}

/* 3. 主题覆盖（纸面/深色面） */
.bg-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}
.bg-paper a { color: var(--color-brand); }
.bg-paper .hl { color: var(--color-brand); }

.bg-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.bg-dark a { color: var(--color-accent); }
.bg-dark .hl { color: var(--color-accent); }

/* 深色区块内的浅色卡片恢复纸面取色 */
.bg-dark .card {
  background-color: var(--color-paper);
  color: var(--color-text);
  border-color: var(--color-text);
  box-shadow: var(--card-shadow);
}
.bg-dark .card a { color: var(--color-brand); }
.bg-dark .card .hl { color: var(--color-brand); }

/* 4. 排版系统 */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.bg-paper .badge { color: var(--color-brand); }
.bg-dark .badge { color: var(--color-accent); }

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 500;
  line-height: 1.25;
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

.text-muted {
  opacity: 0.8;
  font-size: 0.95rem;
}

/* 5. 组件：按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 52px;
  padding: 0 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border-radius: var(--radius-btn);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border: 2px solid var(--color-dark);
  box-shadow: 3px 3px 0 var(--color-dark);
}
.btn-primary:hover {
  transform: translateY(-2px);
  background-color: #c95de0;
}
.btn-primary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-text);
}
.bg-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.btn-secondary:hover {
  background-color: rgba(0,0,0,0.05);
  transform: translateY(-1px);
}
.bg-dark .btn-secondary:hover {
  background-color: rgba(255,255,255,0.08);
}
.btn-secondary:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* 6. 组件：卡片 */
.card {
  background-color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  border-radius: var(--radius-card);
}

/* 7. 组件：表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.data-table th {
  font-weight: 600;
  background-color: rgba(0,0,0,0.03);
}
.bg-dark .data-table th {
  background-color: rgba(255,255,255,0.06);
  border-bottom-color: rgba(255,255,255,0.1);
}

/* 8. 组件：FAQ / Details */
details {
  border: var(--card-border);
  margin-bottom: 0.75rem;
  background-color: var(--color-paper);
  border-radius: var(--radius-card);
}
summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  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;
  font-weight: 400;
}
details[open] summary::after { content: "-"; }
details .answer {
  padding: 0 1.25rem 1rem;
  line-height: var(--lh-body);
}

/* 9. 页头与页脚 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-paper);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding: 0.75rem 0;
  transition: box-shadow 0.2s ease;
}
.site-header.scrolled {
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.logo-area img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
nav ul {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
nav a {
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  position: relative;
}
nav a:hover, nav a[aria-current="page"] {
  color: var(--color-brand);
}
.bg-dark nav a { color: var(--color-paper); }
.bg-dark nav a:hover, nav a[aria-current="page"] { color: var(--color-accent); }
nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: currentColor;
}

.site-footer {
  background-color: var(--color-dark);
  color: var(--color-paper);
  padding: 3rem 0;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}
.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--color-accent);
}
.footer-col a {
  display: block;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  opacity: 0.85;
}
.footer-col a:hover { opacity: 1; text-decoration: underline; }
.copyright {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  opacity: 0.7;
  text-align: center;
}

/* 10. SVG 动效体系 */
.svg-container {
  width: 100%;
  height: auto;
  max-width: 100%;
}
.svg-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* 星点明灭 */
@keyframes star-blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.star {
  animation: star-blink 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.star:nth-child(even) { animation-delay: 1.5s; }
.star:nth-child(3n) { animation-delay: 3s; }

/* 连线绘制 */
@keyframes draw-line {
  0%, 100% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
}
.line-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-line 8s ease-in-out infinite;
}

/* 气泡漂浮 */
@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.float-group {
  animation: float-bubble 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.float-group.delay-1 { animation-delay: 1s; }
.float-group.delay-2 { animation-delay: 2.5s; }

/* 通知滑入 */
@keyframes slide-in {
  0%, 100% { transform: translateX(0); opacity: 1; }
  10% { transform: translateX(-12px); opacity: 0; }
  20% { transform: translateX(0); opacity: 1; }
}
.slide-in-el {
  animation: slide-in 10s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* 输入呼吸点 */
@keyframes breathe-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}
.breathe {
  animation: breathe-dot 3s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.breathe:nth-child(2) { animation-delay: 0.6s; }
.breathe:nth-child(3) { animation-delay: 1.2s; }

/* 11. 无障碍：减少动态效果 */
@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;
  }
}

/* 12. 响应式微调 */
@media (max-width: 768px) {
  .header-inner nav ul { gap: 1rem; }
  .btn { width: 100%; justify-content: center; }
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
