/* =========================================
   SafeW 全局样式表 (Global Stylesheet)
   ========================================= */

:root {
  /* 色板定义 */
  --color-deep: #13102D;
  --color-paper: #F7F5F3;
  --color-text: #171523;
  --color-brand: #2714EB;
  --color-accent: #89ED6E;
  
  /* 结构变量 */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 1px solid rgba(23, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 960px;
  
  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* 状态色 */
  --focus-ring: 2px solid var(--color-brand);
}

/* 深色面取色覆盖 */
.color-deep {
  --bg-color: var(--color-deep);
  --text-color: var(--color-paper);
  --accent-color: var(--color-accent);
  --brand-color: var(--color-accent);
  --border-color: rgba(247, 245, 243, 0.16);
  --card-bg: rgba(247, 245, 243, 0.05);
  --card-border: 1px solid rgba(247, 245, 243, 0.16);
}

/* 浅色面取色覆盖 (默认) */
.color-paper {
  --bg-color: var(--color-paper);
  --text-color: var(--color-text);
  --accent-color: var(--color-accent);
  --brand-color: var(--color-brand);
  --border-color: rgba(23, 21, 35, 0.16);
  --card-bg: #FFFFFF;
  --card-border: 1px solid rgba(23, 21, 35, 0.16);
}

/* 基础重置 */
*, *::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);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.55;
  font-size: 16px;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 容器与布局 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-block: var(--section-y);
}

.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));
}

/* 排版系统 */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: calc(var(--gap) * 2);
  text-wrap: balance;
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

a {
  color: var(--brand-color);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

a:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* 眉标 (Subtitle/Meta Label) */
.meta-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-color);
  margin-bottom: var(--gap);
}

.color-deep .meta-label {
  color: var(--accent-color);
}

/* 高亮词 */
.hl {
  color: var(--brand-color);
}

.color-deep .hl {
  color: var(--accent-color);
}

/* 按钮系统 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 28px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent-color);
  color: var(--color-deep);
  border: none;
}

.btn-primary:hover {
  background-color: #7de063;
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--text-color);
}

.color-deep .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.btn-secondary:hover {
  background-color: rgba(23, 21, 35, 0.05);
}

.color-deep .btn-secondary:hover {
  background-color: rgba(247, 245, 243, 0.1);
}

.btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}

/* 卡片系统 */
.card {
  background-color: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: var(--gap);
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

/* 表格系统 */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  border: var(--card-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

th, td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: rgba(23, 21, 35, 0.05);
  font-weight: 700;
  white-space: nowrap;
}

.color-deep th {
  background-color: rgba(247, 245, 243, 0.05);
}

tr:last-child td {
  border-bottom: none;
}

/* FAQ 系统 */
details {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  background-color: var(--card-bg);
  transition: all 0.2s ease;
}

summary {
  padding: 20px 24px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: 400;
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details[open] summary {
  border-bottom: 1px solid var(--border-color);
}

details > :not(summary) {
  padding: 20px 24px;
  line-height: 1.7;
}

/* 页头与页脚 */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-color);
  text-decoration: none;
}

.logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 24px;
  align-items: center;
}

nav a {
  color: var(--text-color);
  font-weight: 500;
  font-size: 0.95rem;
}

nav a[aria-current="page"] {
  color: var(--brand-color);
  font-weight: 700;
}

footer {
  border-top: 1px solid var(--border-color);
  padding: 48px 0;
  margin-top: var(--section-y);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 48px;
}

.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-color);
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 10px;
}

.footer-col a {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.9rem;
}

.footer-col a:hover {
  opacity: 1;
}

/* SVG 动效 Keyframes */
@keyframes drawLine {
  0% { stroke-dashoffset: 1; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1; }
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes rotateGeo {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes slideIn {
  0% { transform: translateX(-20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 动效类 */
.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 4s ease-in-out infinite;
}

.anim-float {
  animation: floatBubble 4s ease-in-out infinite;
}

.anim-float-delayed {
  animation: floatBubble 4s ease-in-out infinite 1.5s;
}

.anim-breathe {
  transform-origin: center;
  animation: breathe 3s ease-in-out infinite;
}

.anim-rotate {
  transform-origin: center;
  transform-box: fill-box;
  animation: rotateGeo 12s linear infinite;
}

.anim-slide {
  animation: slideIn 1s ease-out forwards;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  
  nav ul {
    display: none; /* 简化处理，实际项目需汉堡菜单，此处保持单页简洁 */
  }
  
  .header-inner {
    justify-content: center;
  }
  
  .logo {
    margin-right: auto;
  }
  
  .btn-nav {
    display: inline-flex;
  }
}

@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;
  }
  
  .anim-draw, .anim-float, .anim-breathe, .anim-rotate, .anim-slide {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
