/* =========================================
   SafeW 全站共享样式
   ========================================= */

/* --- 设计变量 --- */
:root {
  /* 配色 */
  --color-dark: #271334;
  --color-paper: #E9E8EA;
  --color-text: #1D1523;
  --color-brand: #8A13DD;
  --color-accent: #9EED6E;

  /* 圆角 */
  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-badge: 6px;

  /* 卡片边界与阴影 */
  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);

  /* 节奏与密度 */
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1280px;
  --line-height-body: 1.65;

  /* 字体 */
  --font-main: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", 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%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- 排版系统 --- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
  overflow-x: hidden;
}

.section-divider {
  height: 1px;
  background-color: rgba(var(--color-text), 0.15);
  margin: 0 calc(var(--gap) * -1);
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

.hl {
  font-weight: 700;
}

/* --- 主题层 --- */
.theme-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}
.theme-dark .hl,
.theme-dark .badge,
.theme-dark a:not(.btn) {
  color: var(--color-accent);
}
.theme-dark .badge {
  color: var(--color-accent);
}

.theme-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}
.theme-paper .hl,
.theme-paper .badge,
.theme-paper a:not(.btn) {
  color: var(--color-brand);
}

/* 卡片内部恢复纸面取色 */
.card-light {
  background-color: var(--color-paper);
  color: var(--color-text);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
}
.card-light .hl,
.card-light .badge,
.card-light a:not(.btn) {
  color: var(--color-brand);
}

/* --- 导航与页脚 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(233, 232, 234, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(29, 21, 35, 0.1);
  padding: 1rem 0;
}
.theme-dark .site-header {
  background-color: rgba(39, 19, 52, 0.9);
  border-bottom-color: rgba(233, 232, 234, 0.1);
}

.nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
}
.brand img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.nav-links a {
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  position: relative;
  transition: opacity 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  opacity: 0.8;
}
.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: currentColor;
}

.site-footer {
  padding: 3rem 0;
  border-top: 1px solid rgba(29, 21, 35, 0.15);
  margin-top: 2rem;
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-links {
  display: flex;
  gap: 1.5rem;
}

/* --- 按钮组件 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  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-dark);
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
}
.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-text);
}
.theme-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.btn-secondary:hover {
  background-color: rgba(29, 21, 35, 0.05);
}
.theme-dark .btn-secondary:hover {
  background-color: rgba(233, 232, 234, 0.1);
}

/* --- 卡片网格 --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

/* --- 表格 --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.data-table th,
.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(29, 21, 35, 0.15);
  text-align: left;
}
.data-table th {
  font-weight: 700;
  background-color: rgba(29, 21, 35, 0.04);
}
.theme-dark .data-table th {
  background-color: rgba(233, 232, 234, 0.1);
}

/* --- FAQ (Details/Summary) --- */
details.faq-item {
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1rem;
  background-color: var(--color-paper);
  color: var(--color-text);
  transition: transform 0.2s;
}
details.faq-item[open] {
  transform: translateY(-2px);
}
summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
summary::-webkit-details-marker {
  display: none;
}
summary::marker {
  display: none;
  content: "";
}
summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--color-brand);
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: transform 0.2s;
}
details.faq-item[open] summary::before {
  transform: rotate(45deg);
  background-color: var(--color-dark);
}
.faq-answer {
  margin-top: 1rem;
  padding-left: 2.5rem;
  line-height: 1.7;
}

/* --- SVG 通用 --- */
.svg-visual {
  width: 100%;
  height: auto;
  max-width: 100%;
  overflow: visible;
}
.svg-visual path,
.svg-visual circle,
.svg-visual rect,
.svg-visual line {
  shape-rendering: geometricPrecision;
}

/* --- SVG 动效关键帧 --- */
@keyframes drawLine {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes popIn {
  0%, 100% { opacity: 0.85; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.02); }
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes slideInRight {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 0.9; transform: scale(1.1); }
}

/* 动效类绑定 */
.anim-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 4s ease-in-out infinite alternate;
}
.anim-pop {
  animation: popIn 5s ease-in-out infinite alternate;
  transform-origin: center;
  transform-box: fill-box;
}
.anim-float {
  animation: floatY 6s ease-in-out infinite alternate;
  transform-origin: center;
  transform-box: fill-box;
}
.anim-breathe {
  animation: breathe 4s ease-in-out infinite;
}
.anim-slide {
  animation: slideInRight 5s ease-out forwards;
}
.anim-twinkle {
  animation: twinkle 3.5s ease-in-out infinite alternate;
  transform-origin: center;
  transform-box: fill-box;
}

/* 减少动态效果适配 */
@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-pop, .anim-float, .anim-breathe, .anim-slide, .anim-twinkle {
    animation: none !important;
  }
}
