/* =========================================
   SafeW 共享样式表 (style.css)
   ========================================= */

/* --- 设计变量 (Design Tokens) --- */
:root {
  /* 颜色体系 */
  --color-dark-bg: #140E25;
  --color-paper: #F5F0E5;
  --color-body-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  
  /* 语义化变量 (纸面环境) */
  --text-primary: var(--color-body-text);
  --text-secondary: #3D3A47;
  --link-color: var(--color-brand);
  --highlight-color: var(--color-brand);
  --bg-surface: var(--color-paper);
  --border-color: rgba(25, 21, 35, 0.12);
  
  /* 尺寸与间距 */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;
  
  /* 排版 */
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --title-weight: 500;
  --title-lineheight: 1.15;
  --body-lineheight: 1.55;
}

/* 深色环境覆盖 (Hero / Footer) */
[data-theme="dark"] {
  --text-primary: var(--color-paper);
  --text-secondary: rgba(245, 240, 229, 0.8);
  --link-color: var(--color-accent);
  --highlight-color: var(--color-accent);
  --bg-surface: var(--color-dark-bg);
  --border-color: rgba(245, 240, 229, 0.15);
  --card-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.5);
}

/* 基础重置与全局 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--body-lineheight);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: opacity 0.2s ease;
}
a:hover { opacity: 0.85; }

/* 布局容器 */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section {
  padding-block: var(--section-y);
}

/* 排版系统 */
h1, h2, h3, h4 {
  font-weight: var(--title-weight);
  line-height: var(--title-lineheight);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: calc(var(--gap) * 1.5);
}

h3 {
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: var(--gap);
  max-width: 65ch;
}

strong {
  font-weight: 600;
}

.highlight {
  color: var(--highlight-color);
}

/* 眉标 (Eyebrow) */
.eyebrow {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: calc(var(--gap) * 0.5);
  color: var(--link-color);
}

/* 按钮组件 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--highlight-color);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
  border: none;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 237, 110, 0.4);
  opacity: 1;
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: rgba(25, 21, 35, 0.05);
  opacity: 1;
}
[data-theme="dark"] .btn-secondary {
  color: var(--color-paper);
  border-color: rgba(245, 240, 229, 0.3);
}
[data-theme="dark"] .btn-secondary:hover {
  background-color: rgba(245, 240, 229, 0.1);
}

/* 页头 Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(245, 240, 229, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
}
[data-theme="dark"] .site-header {
  background-color: rgba(20, 14, 37, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  text-decoration: none;
}
.logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}
.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.nav-links a:hover, .nav-links [aria-current="page"] {
  color: var(--highlight-color);
}
.nav-links [aria-current="page"] {
  font-weight: 700;
}

@media (max-width: 768px) {
  .nav-links { display: none; } /* 简化移动端，仅保留主按钮或汉堡菜单逻辑可由JS补充，此处保持静态简洁 */
}

/* 卡片组件 */
.card {
  background-color: var(--bg-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: calc(var(--gap) * 1.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -12px rgba(25, 21, 35, 0.35);
}

/* 表格组件 */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
th {
  background-color: rgba(25, 21, 35, 0.04);
  font-weight: 600;
  color: var(--text-primary);
}
td {
  color: var(--text-secondary);
}
tr:last-child th, tr:last-child td {
  border-bottom: none;
}
[data-theme="dark"] th {
  background-color: rgba(245, 240, 229, 0.05);
}

/* FAQ Details/Summary */
details {
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}
details[open] summary {
  margin-bottom: 12px;
}
summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
  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;
  color: var(--link-color);
}
details[open] summary::after {
  content: "−";
}
details p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 8px;
}

/* 标签页 Tabs (CSS Radio Hack) */
.tabs-container {
  margin-top: calc(var(--gap) * 2);
}
.tab-radio {
  display: none;
}
.tab-labels {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tab-label {
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.tab-label:hover {
  color: var(--text-primary);
  background-color: rgba(25, 21, 35, 0.04);
}
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}
.tab-radio:checked + .tab-label {
  background-color: var(--highlight-color);
  color: var(--color-dark-bg);
  font-weight: 700;
}
.tab-radio:nth-of-type(1):checked ~ .tab-panels .tab-panel:nth-of-type(1),
.tab-radio:nth-of-type(2):checked ~ .tab-panels .tab-panel:nth-of-type(2),
.tab-radio:nth-of-type(3):checked ~ .tab-panels .tab-panel:nth-of-type(3),
.tab-radio:nth-of-type(4):checked ~ .tab-panels .tab-panel:nth-of-type(4),
.tab-radio:nth-of-type(5):checked ~ .tab-panels .tab-panel:nth-of-type(5) {
  display: block;
}

/* 步骤条 Steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--gap);
  counter-reset: step-counter;
}
.step-item {
  position: relative;
  padding-left: 48px;
}
.step-item::before {
  counter-increment: step-counter;
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 流程箭头 Flow */
.flow-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: var(--gap) 0;
}
.flow-node {
  flex: 1;
  min-width: 150px;
  text-align: center;
  padding: 16px;
  background-color: rgba(25, 21, 35, 0.03);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-color);
}
.flow-arrow {
  flex-shrink: 0;
  color: var(--link-color);
}

/* 新闻卡片 Grid */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}

/* 页脚 Footer */
.site-footer {
  background-color: var(--color-dark-bg);
  color: var(--color-paper);
  padding: calc(var(--section-y) * 1.5) 0;
  border-top: 1px solid rgba(245, 240, 229, 0.1);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 32px;
}
.footer-col h4 {
  color: var(--color-paper);
  font-size: 1rem;
  margin-bottom: 16px;
}
.footer-col ul {
  list-style: none;
}
.footer-col li {
  margin-bottom: 10px;
}
.footer-col a {
  color: rgba(245, 240, 229, 0.7);
  font-size: 0.9rem;
}
.footer-col a:hover {
  color: var(--color-accent);
}
.copyright {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid rgba(245, 240, 229, 0.1);
  text-align: center;
  font-size: 0.85rem;
  color: rgba(245, 240, 229, 0.5);
}

/* SVG 动效 Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes orbitBreathe {
  0%, 100% { 
    transform: scale(0.95); 
    opacity: 0.6; 
    stroke-dashoffset: 0;
  }
  50% { 
    transform: scale(1.05); 
    opacity: 1; 
    stroke-dashoffset: -4;
  }
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* SVG 元素类 */
.svg-orbit {
  transform-origin: center;
  transform-box: fill-box;
  animation: orbitBreathe 6s ease-in-out infinite;
}
.svg-orbit:nth-child(2) { animation-delay: -1.5s; animation-duration: 7s; }
.svg-orbit:nth-child(3) { animation-delay: -3s; animation-duration: 8s; }

.svg-bubble {
  animation: floatBubble 4s ease-in-out infinite;
}
.svg-bubble:nth-child(odd) { animation-delay: -1s; }

.svg-dot {
  transform-origin: center;
  transform-box: fill-box;
  animation: pulseDot 2s ease-in-out infinite;
}

.svg-slide {
  animation: slideInRight 1.5s ease-out forwards;
}

/* 减少动态效果适配 */
@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;
  }
  .svg-orbit, .svg-bubble, .svg-dot, .svg-slide {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 响应式微调 */
@media (max-width: 600px) {
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .container { padding: 0 16px; }
  .steps-grid { grid-template-columns: 1fr; }
  .flow-row { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); margin: 8px 0; }
}
