/* =========================================
   SafeW 全局样式与动效系统
   ========================================= */

/* --- 设计变量 (Design Tokens) --- */
:root {
  /* 颜色系统 */
  --color-bg-dark: #231334;
  --color-bg-paper: #F5F3F7;
  --color-text-main: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* 派生色 (用于卡片背景、分割线等) */
  --color-bg-dark-surface: #2A1840; /* 深色面上稍浅的层级 */
  --color-bg-paper-card: #EBE8EF;  /* 纸面上稍深的层级 */
  --color-border-light: rgba(28, 21, 35, 0.08);
  --color-border-dark: rgba(245, 243, 247, 0.1);

  /* 尺寸与间距 */
  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-sm: 8px;
  
  --card-border: 0;
  --card-shadow: none;
  
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1120px;
  
  /* 字体栈 */
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

/* --- 基础重置与排版 --- */
*, *::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: 1.75;
  color: var(--color-text-main);
  background-color: var(--color-bg-paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

ul, ol {
  list-style: none;
}

/* --- 布局容器 --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  position: relative;
}

.section-divider {
  width: 100%;
  height: 1px;
  background-color: var(--color-border-light);
  border: none;
}

/* --- 标题系统 --- */
.epigraph {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  color: var(--color-brand);
}

.dark-mode .epigraph {
  color: var(--color-accent);
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--color-text-main);
}

.dark-mode h1, 
.dark-mode h2, 
.dark-mode h3, 
.dark-mode h4 {
  color: var(--color-bg-paper);
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.highlight {
  color: var(--color-brand);
}

.dark-mode .highlight {
  color: var(--color-accent);
}

.text-center {
  text-align: center;
}

.max-w-prose {
  max-width: 38em;
  margin-left: auto;
  margin-right: auto;
}

/* --- 按钮组件 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 24px;
  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;
  border: none;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text-main);
  border: 1px solid var(--color-text-main);
}

.dark-mode .btn-secondary {
  color: var(--color-bg-paper);
  border-color: var(--color-bg-paper);
}

.btn-secondary:hover {
  background-color: rgba(0,0,0,0.05);
}

.dark-mode .btn-secondary:hover {
  background-color: rgba(255,255,255,0.1);
}

/* --- 棋盘式交错布局 (Chessboard Layout) --- */
.chess-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: center;
}

.chess-row.reverse {
  direction: rtl; /* 快速交换左右视觉位置 */
}

.chess-row.reverse > * {
  direction: ltr; /* 恢复文字方向 */
}

.chess-panel {
  background-color: var(--color-bg-paper-card);
  border-radius: var(--radius-card);
  padding: var(--gap);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: var(--card-border);
  box-shadow: var(--card-shadow);
}

.dark-mode .chess-panel {
  background-color: var(--color-bg-dark-surface);
}

/* --- 卡片网格 (新闻等) --- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}

.card {
  background-color: var(--color-bg-paper-card);
  border-radius: var(--radius-card);
  padding: var(--gap);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
}

.card-meta {
  font-size: 0.85rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.dark-mode .card-meta {
  color: var(--color-accent);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.card-excerpt {
  font-size: 0.95rem;
  color: var(--color-text-main);
  opacity: 0.9;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.dark-mode .card-excerpt {
  color: var(--color-bg-paper);
}

/* --- 表格 --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  background-color: var(--color-bg-paper-card);
  border: var(--card-border);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table-wrapper th, 
.table-wrapper td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-light);
}

.dark-mode .table-wrapper th,
.dark-mode .table-wrapper td {
  border-bottom-color: var(--color-border-dark);
}

.table-wrapper th {
  font-weight: 700;
  background-color: rgba(0,0,0,0.02);
}

.dark-mode .table-wrapper th {
  background-color: rgba(255,255,255,0.05);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

/* --- FAQ (Details/Summary) --- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

details {
  background-color: var(--color-bg-paper-card);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  border: var(--card-border);
  transition: background-color 0.2s ease;
}

summary {
  font-weight: 700;
  font-size: 1.1rem;
  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.5rem;
  font-weight: 300;
  transition: transform 0.3s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details p {
  margin-top: 1rem;
  opacity: 0.9;
}

/* --- 核心功能 Tab (纯 CSS 实现) --- */
.tabs-nav {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: 1rem;
}

.dark-mode .tabs-nav {
  border-bottom-color: var(--color-border-dark);
}

.tab-radio {
  display: none;
}

.tab-label {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-main);
  opacity: 0.6;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
}

.dark-mode .tab-label {
  color: var(--color-bg-paper);
}

.tab-label:hover {
  opacity: 0.8;
}

.tab-radio:checked + .tab-label {
  opacity: 1;
  color: var(--color-brand);
  background-color: rgba(125, 20, 235, 0.05);
}

.dark-mode .tab-radio:checked + .tab-label {
  color: var(--color-accent);
  background-color: rgba(237, 210, 110, 0.1);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-radio:checked + .tab-label + .tab-content {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 步骤列表 --- */
.steps-list {
  counter-reset: step-counter;
}

.step-item {
  position: relative;
  padding-left: 3.5rem;
  margin-bottom: 2rem;
}

.step-item::before {
  counter-increment: step-counter;
  content: counter(step-counter, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  font-weight: 800;
  font-size: 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- 页头与页脚 --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(245, 243, 247, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border-light);
  padding: 1rem 0;
}

.dark-mode.header {
  background-color: rgba(35, 19, 52, 0.9);
  border-bottom-color: var(--color-border-dark);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-link[aria-current="page"] {
  color: var(--color-brand);
  font-weight: 700;
}

.dark-mode .nav-link[aria-current="page"] {
  color: var(--color-accent);
}

.footer {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
  padding: 4rem 0 2rem;
  margin-top: var(--section-y);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--gap);
  margin-bottom: 3rem;
}

.footer-col h4 {
  color: var(--color-bg-paper);
  margin-bottom: 1rem;
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col a {
  opacity: 0.7;
}

.footer-col a:hover {
  opacity: 1;
  color: var(--color-accent);
}

.footer-bottom {
  border-top: 1px solid var(--color-border-dark);
  padding-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* --- SVG 动效系统 --- */
/* 默认状态：元素可见，动画围绕默认状态循环 */
.svg-orbit {
  transform-origin: center;
  transform-box: fill-box;
}

.anim-float {
  animation: float 6s ease-in-out infinite;
}

.anim-bubble-delay-1 {
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, float 4s ease-in-out infinite 0.5s;
}

.anim-bubble-delay-2 {
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, float 4s ease-in-out infinite 1s;
}

.anim-bubble-delay-3 {
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, float 4s ease-in-out infinite 1.5s;
}

.anim-typing {
  animation: typing 2s steps(3) infinite alternate;
}

.anim-pulse {
  animation: pulse 3s ease-in-out infinite;
}

.anim-slide-in {
  animation: slideIn 0.8s ease-out forwards;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes typing {
  0% { stroke-dashoffset: 3; }
  100% { stroke-dashoffset: 0; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 减少动态效果支持 */
@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;
  }
}

/* --- 响应式适配 --- */
@media (max-width: 768px) {
  .chess-row, 
  .chess-row.reverse {
    grid-template-columns: 1fr;
    direction: ltr;
  }
  
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .nav-links {
    display: none; /* 简化版：移动端隐藏导航，仅保留主按钮逻辑需JS，此处为静态页暂略复杂菜单 */
  }
  
  /* 移动端显示简单的下载按钮或汉堡菜单占位 */
  .header .btn {
    display: inline-flex;
  }
  
  .tabs-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .tab-label {
    width: 100%;
    text-align: left;
  }
}

