/* =========================================
   SafeW 全站共享样式 (style.css)
   ========================================= */

/* --- 1. 设计变量 (Design Tokens) --- */
:root {
  /* 色板 */
  --color-bg-dark: #140E25;
  --color-bg-paper: #F7F5F3;
  --color-text-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  
  /* 取色变量：纸面环境 */
  --paper-text: var(--color-text-body);
  --paper-brand: var(--color-brand);
  --paper-accent: var(--color-brand); /* 纸面上强调通常用品牌色，除非特殊说明 */

  /* 取色变量：深色环境 */
  --dark-text: var(--color-bg-paper);
  --dark-accent: var(--color-accent);
  --dark-brand: var(--color-accent);

  /* 圆角与边界 */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;

  /* 节奏与间距 */
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;
  --line-height-base: 1.55;

  /* 字体 */
  --font-sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* --- 2. 基础重置与排版 --- */
*, *::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: var(--line-height-base);
  color: var(--paper-text);
  background-color: var(--color-bg-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--paper-brand);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--paper-brand);
  outline-offset: 2px;
  border-radius: 2px;
}

strong, b {
  font-weight: 700;
}

ul, ol {
  list-style: none;
}

/* --- 3. 布局容器 --- */
.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);
}

.section--dark {
  background-color: var(--color-bg-dark);
  color: var(--dark-text);
}

.section--dark a:not(.btn) {
  color: var(--dark-accent);
}

.section--dark .hl {
  color: var(--dark-accent);
}

/* 标题系统 */
.masthead {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  color: var(--paper-brand);
}

.section--dark .masthead {
  color: var(--dark-accent);
}

h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--paper-text);
}

.section--dark h1, .section--dark h2, .section--dark h3 {
  color: var(--dark-text);
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

.hl {
  color: var(--paper-brand);
}

.section--dark .hl {
  color: var(--dark-accent);
}

/* --- 4. 组件：按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  text-decoration: none !important;
}

.btn:focus-visible {
  outline: 3px solid var(--dark-accent);
  outline-offset: 2px;
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  border: none;
}

.btn--primary:hover {
  filter: brightness(1.1);
}

.btn--secondary {
  background-color: transparent;
  color: var(--paper-text);
  border: 1px solid var(--paper-text);
}

.section--dark .btn--secondary {
  color: var(--dark-text);
  border-color: var(--dark-text);
}

.btn--secondary:hover {
  background-color: rgba(25, 21, 35, 0.05);
}

.section--dark .btn--secondary:hover {
  background-color: rgba(247, 245, 243, 0.1);
}

/* --- 5. 组件：卡片 --- */
.card {
  background-color: #fff;
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.section--dark .card {
  background-color: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.section--dark .card:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* --- 6. 组件：表格 --- */
.table-wrapper {
  overflow-x: auto;
  border: var(--card-border);
  border-radius: var(--radius-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}

th {
  font-weight: 700;
  background-color: rgba(25, 21, 35, 0.03);
  width: 30%;
}

tr:last-child th, tr:last-child td {
  border-bottom: none;
}

.section--dark table th {
  background-color: rgba(255, 255, 255, 0.05);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.section--dark table td {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* --- 7. 组件：FAQ (Details/Summary) --- */
details {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  overflow: hidden;
}

summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(25, 21, 35, 0.02);
  transition: background-color 0.2s;
}

summary:hover {
  background-color: rgba(25, 21, 35, 0.05);
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-left: 1rem;
}

details[open] summary::after {
  transform: rotate(-135deg);
}

details[open] summary {
  background-color: rgba(25, 21, 35, 0.05);
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}

details p {
  padding: 1rem 1.25rem;
  margin-bottom: 0;
  color: inherit;
}

.section--dark details {
  border-color: rgba(255, 255, 255, 0.15);
}

.section--dark summary {
  background-color: rgba(255, 255, 255, 0.03);
}

.section--dark summary:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.section--dark details[open] summary {
  background-color: rgba(255, 255, 255, 0.06);
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

/* --- 8. 组件：导航与页头 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(247, 245, 243, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
  padding: 0.75rem 0;
}

.section--dark .site-header {
  background-color: rgba(20, 14, 37, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--paper-text);
}

.section--dark .nav-links a {
  color: var(--dark-text);
}

.nav-links a:hover {
  color: var(--paper-brand);
}

.section--dark .nav-links a:hover {
  color: var(--dark-accent);
}

.nav-links a[aria-current="page"] {
  color: var(--paper-brand);
  font-weight: 700;
}

.section--dark .nav-links a[aria-current="page"] {
  color: var(--dark-accent);
}

/* --- 9. 页脚 --- */
.site-footer {
  padding: 3rem 0;
  border-top: 1px solid rgba(25, 21, 35, 0.1);
  font-size: 0.9rem;
  color: rgba(25, 21, 35, 0.6);
}

.section--dark .site-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: rgba(247, 245, 243, 0.5);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: inherit;
}

.footer-links a:hover {
  color: var(--paper-brand);
}

.section--dark .footer-links a:hover {
  color: var(--dark-accent);
}

/* --- 10. SVG 动效系统 --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes dashFlow {
  to { stroke-dashoffset: -24; }
}

@keyframes rotateIn {
  from { transform: rotate(-10deg) scale(0.9); opacity: 0; }
  to { transform: rotate(0deg) scale(1); opacity: 1; }
}

.svg-el-float {
  animation: float 6s ease-in-out infinite;
}

.svg-el-slide {
  animation: slideInRight 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.svg-el-breathe {
  animation: breathe 3s ease-in-out infinite;
}

.svg-el-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dashFlow 2s linear infinite;
}

.svg-el-rotate {
  transform-box: fill-box;
  transform-origin: center;
  animation: rotateIn 4s 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;
  }
}

/* --- 11. 响应式适配 --- */
@media (max-width: 768px) {
  .nav-links {
    display: none; /* 移动端简化：隐藏导航，仅留主按钮或折叠菜单（此处简化为仅保留主按钮逻辑，实际项目可加汉堡菜单） */
  }
  
  .header-inner {
    justify-content: space-between;
  }

  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .section {
    padding-top: calc(var(--section-y) * 0.75);
    padding-bottom: calc(var(--section-y) * 0.75);
  }
}

/* 核心功能 Tab 样式 (Radio Hack) */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.tab-nav input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tab-nav label {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-btn);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.tab-nav input[type="radio"]:checked + label {
  background: var(--color-accent);
  color: var(--color-bg-dark);
  border-color: var(--color-accent);
}

.tab-content {
  display: none;
}

.tab-nav input[type="radio"]:checked + label + .tab-content {
  display: block;
  animation: slideInRight 0.4s ease-out;
}

/* 窄屏下 Tab 内容默认全部显示，保证无 JS 可读性 */
@media (max-width: 768px) {
  .tab-nav {
    display: none; /* 移动端隐藏 Tab 切换栏 */
  }
  .tab-content {
    display: block !important;
    margin-bottom: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1.5rem;
  }
}
