/* ========================================
   SafeW 全站共享样式
   ======================================== */

/* --- 设计变量 --- */
:root {
  /* 色板 */
  --color-dark: #140E25;
  --color-paper: #FCFCFD;
  --color-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #6EEDD2;

  /* 派生色 */
  --color-dark-surface: #1A1330;
  --color-paper-surface: #F3F3F6;
  --color-brand-muted: rgba(82, 20, 235, 0.12);
  --color-accent-muted: rgba(110, 237, 210, 0.12);

  /* 圆角 */
  --radius-card: 8px;
  --radius-btn: 6px;

  /* 卡片边界 */
  --card-border: 0;
  --card-shadow: none;

  /* 间距与节奏 */
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --container-x: 1.5rem;

  /* 内容宽度 */
  --content-max: 1120px;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", "Source Code Pro", monospace;

  /* 行高 */
  --line-height-body: 1.65;
  --line-height-heading: 1.25;

  /* 过渡 */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-body);
  color: var(--color-body);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- 容器 --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--container-x);
}

/* --- 页面区块 --- */
.section {
  padding-block: var(--section-y);
}

.section--dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.section--paper {
  background-color: var(--color-paper);
  color: var(--color-body);
}

/* --- 眉标 --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 2px;
  border-radius: 1px;
}

.paper .badge::before {
  background-color: var(--color-brand);
}

.dark .badge::before {
  background-color: var(--color-accent);
}

/* --- 标题系统 --- */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: 0;
  line-height: var(--line-height-heading);
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: calc(var(--gap) * 0.75);
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  margin-bottom: calc(var(--gap) * 0.5);
}

.hl {
  font-weight: 700;
}

.paper .hl {
  color: var(--color-brand);
}

.dark .hl {
  color: var(--color-accent);
}

/* --- 正文排版 --- */
.text-body {
  font-size: 1rem;
  line-height: var(--line-height-body);
  max-width: 38em;
}

.text-body p {
  margin-bottom: 1em;
}

.text-body p:last-child {
  margin-bottom: 0;
}

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding-inline: 1.5em;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  border-radius: var(--radius-btn);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent), 0 0 0 5px var(--color-brand);
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border-color: var(--color-accent);
}

.btn--primary:hover {
  transform: translateY(-1px);
  background-color: #5ddcc0;
  border-color: #5ddcc0;
}

.btn--secondary {
  background-color: transparent;
}

.paper .btn--secondary {
  color: var(--color-body);
  border-color: var(--color-body);
}

.paper .btn--secondary:hover {
  transform: translateY(-1px);
  background-color: rgba(25, 21, 35, 0.06);
}

.dark .btn--secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.dark .btn--secondary:hover {
  transform: translateY(-1px);
  background-color: rgba(252, 252, 253, 0.08);
}

.btn__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* --- 面板 / 卡片 --- */
.panel {
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card {
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  transition: background-color var(--transition-base);
}

.paper .card {
  background-color: var(--color-paper-surface);
}

.dark .card {
  background-color: var(--color-dark-surface);
}

/* --- 网格 --- */
.grid {
  display: grid;
  gap: var(--gap);
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* --- 图文交错 --- */
.split-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  align-items: center;
}

.split-row--reverse {
  direction: rtl;
}

.split-row--reverse > * {
  direction: ltr;
}

@media (min-width: 768px) {
  .split-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- 表格 --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 0.75em 1em;
  text-align: left;
  border-bottom: 1px solid rgba(128, 128, 128, 0.15);
}

th {
  font-weight: 600;
}

.paper th, .paper td {
  border-color: rgba(25, 21, 35, 0.1);
}

.dark th, .dark td {
  border-color: rgba(252, 252, 253, 0.1);
}

/* --- FAQ --- */
.faq-item {
  border-bottom: 1px solid rgba(128, 128, 128, 0.15);
}

.paper .faq-item {
  border-color: rgba(25, 21, 35, 0.08);
}

.dark .faq-item {
  border-color: rgba(252, 252, 253, 0.08);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 1em 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  list-style: none;
  transition: color var(--transition-fast);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::marker {
  display: none;
  content: "";
}

.faq-item summary:hover {
  color: var(--color-brand);
}

.dark .faq-item summary:hover {
  color: var(--color-accent);
}

.faq-item summary::after {
  content: "";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--transition-fast);
}

.faq-item[open] summary::after {
  transform: rotate(180deg);
}

.faq-item .faq-answer {
  padding-bottom: 1em;
  font-size: 0.95rem;
  line-height: var(--line-height-body);
}

/* --- 提示框 --- */
.callout {
  border-left: 3px solid var(--color-brand);
  padding: 1em 1.25em;
  margin-block: 1em;
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  font-size: 0.95rem;
}

.dark .callout {
  border-left-color: var(--color-accent);
}

.callout p {
  margin: 0;
}

/* --- 编号徽标 --- */
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.paper .step-number {
  background-color: var(--color-brand);
  color: var(--color-paper);
}

.dark .step-number {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

/* --- 列表标记 --- */
.marked-list {
  counter-reset: item;
  padding-left: 0;
}

.marked-list li {
  position: relative;
  padding-left: 2em;
  margin-bottom: 0.5em;
}

.marked-list li::before {
  counter-increment: item;
  content: counter(item);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5em;
  height: 1.5em;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.paper .marked-list li::before {
  background-color: var(--color-brand-muted);
  color: var(--color-brand);
}

.dark .marked-list li::before {
  background-color: var(--color-accent-muted);
  color: var(--color-accent);
}

/* --- 页头 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-paper);
  border-bottom: 1px solid rgba(25, 21, 35, 0.08);
  transition: background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

.site-header.scrolled {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-weight: 700;
  font-size: 1.1rem;
}

.header-logo img {
  width: 28px;
  height: 28px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5em;
}

.header-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25em 0;
  position: relative;
  transition: color var(--transition-fast);
}

.header-nav a:hover {
  color: var(--color-brand);
}

.header-nav a[aria-current="page"] {
  color: var(--color-brand);
}

.header-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--color-brand);
  border-radius: 1px;
}

.dark .header-nav a:hover {
  color: var(--color-accent);
}

.dark .header-nav a[aria-current="page"] {
  color: var(--color-accent);
}

.dark .header-nav a[aria-current="page"]::after {
  background-color: var(--color-accent);
}

/* --- 页脚 --- */
.site-footer {
  padding-block: 3rem;
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-weight: 700;
  font-size: 1rem;
}

.footer-brand img {
  width: 24px;
  height: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5em;
}

.footer-links a {
  font-size: 0.9rem;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.footer-links a:hover {
  opacity: 1;
}

.footer-copy {
  font-size: 0.8rem;
  opacity: 0.5;
}

/* --- 新闻卡片 --- */
.news-card {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.news-card time {
  font-size: 0.8rem;
  opacity: 0.6;
}

.news-card h3 {
  font-size: 1.05rem;
  line-height: 1.4;
}

.news-card p {
  font-size: 0.9rem;
  line-height: var(--line-height-body);
  opacity: 0.85;
}

/* --- 场景卡片 --- */
.scene-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

@media (min-width: 768px) {
  .scene-card {
    grid-template-columns: 1fr 1fr;
  }
}

.scene-context {
  padding: 1.5em;
  border-radius: var(--radius-card);
}

.paper .scene-context {
  background-color: var(--color-paper-surface);
}

.dark .scene-context {
  background-color: var(--color-dark-surface);
}

.scene-steps {
  counter-reset: step;
  padding: 0;
}

.scene-steps li {
  position: relative;
  padding-left: 2.2em;
  margin-bottom: 0.75em;
  font-size: 0.95rem;
  line-height: var(--line-height-body);
}

.scene-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 1.6em;
  height: 1.6em;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.paper .scene-steps li::before {
  background-color: var(--color-brand);
  color: var(--color-paper);
}

.dark .scene-steps li::before {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

/* --- 功能定义列表 --- */
.feature-list {
  display: grid;
  gap: 1.5em;
}

.feature-item dt {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.3em;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.feature-item dd {
  font-size: 0.95rem;
  line-height: var(--line-height-body);
  opacity: 0.85;
}

/* --- 专题长文目录 --- */
.toc {
  position: sticky;
  top: 80px;
  padding: 1.5em;
  border-radius: var(--radius-card);
  font-size: 0.9rem;
}

.paper .toc {
  background-color: var(--color-paper-surface);
}

.dark .toc {
  background-color: var(--color-dark-surface);
}

.toc h4 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.75em;
  opacity: 0.6;
}

.toc ol {
  padding-left: 0;
  counter-reset: toc-item;
}

.toc li {
  counter-increment: toc-item;
  margin-bottom: 0.5em;
}

.toc li::before {
  display: none;
}

.toc a {
  display: block;
  padding: 0.25em 0;
  font-size: 0.9rem;
  opacity: 0.75;
  transition: opacity var(--transition-fast);
}

.toc a:hover {
  opacity: 1;
}

.paper .toc a:hover {
  color: var(--color-brand);
}

.dark .toc a:hover {
  color: var(--color-accent);
}

@media (max-width: 1024px) {
  .toc {
    position: static;
  }
}

/* --- SVG 通用 --- */
.svg-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-panel {
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* --- SVG 动效 Keyframes --- */

/* 同心轨道呼吸 */
@keyframes orbit-breathe-1 {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.06); opacity: 0.5; }
}

@keyframes orbit-breathe-2 {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.08); opacity: 0.4; }
}

@keyframes orbit-breathe-3 {
  0%, 100% { transform: scale(1); opacity: 0.15; }
  50% { transform: scale(1.1); opacity: 0.35; }
}

.orbit-ring {
  transform-box: fill-box;
  transform-origin: center;
}

.orbit-ring--1 { animation: orbit-breathe-1 6s ease-in-out infinite; }
.orbit-ring--2 { animation: orbit-breathe-2 8s ease-in-out infinite; }
.orbit-ring--3 { animation: orbit-breathe-3 10s ease-in-out infinite; }

/* 气泡浮现 */
@keyframes bubble-fade-in {
  0%, 10% { opacity: 0; transform: translateY(8px); }
  15%, 85% { opacity: 1; transform: translateY(0); }
  90%, 100% { opacity: 0; transform: translateY(-4px); }
}

.bubble {
  transform-box: fill-box;
  transform-origin: center;
}

.bubble--1 { animation: bubble-fade-in 8s ease-in-out infinite; animation-delay: 0s; }
.bubble--2 { animation: bubble-fade-in 8s ease-in-out infinite; animation-delay: 2s; }
.bubble--3 { animation: bubble-fade-in 8s ease-in-out infinite; animation-delay: 4s; }

/* 输入三点呼吸 */
@keyframes dot-breathe {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.dot-input {
  animation: dot-breathe 1.5s ease-in-out infinite;
}

.dot-input--1 { animation-delay: 0s; }
.dot-input--2 { animation-delay: 0.25s; }
.dot-input--3 { animation-delay: 0.5s; }

/* 通知卡片滑入 */
@keyframes notif-slide-in {
  0%, 5% { opacity: 0; transform: translateX(16px); }
  10%, 80% { opacity: 1; transform: translateX(0); }
  85%, 100% { opacity: 0; transform: translateX(-8px); }
}

.notif-card {
  transform-box: fill-box;
  transform-origin: center;
  animation: notif-slide-in 10s ease-in-out infinite;
  animation-delay: 3s;
}

/* 连接线流动 */
@keyframes dash-flow {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.flow-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dash-flow 3s linear infinite;
}

/* 消息浮动 */
@keyframes float-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.float-gentle {
  transform-box: fill-box;
  transform-origin: center;
  animation: float-gentle 4s ease-in-out infinite;
}

/* 脉冲点 */
@keyframes pulse-dot {
  0%, 100% { r: 3; opacity: 0.8; }
  50% { r: 4.5; opacity: 0.4; }
}

.pulse-dot {
  animation: pulse-dot 2.5s ease-in-out infinite;
}

/* 设置面板图标旋转 */
@keyframes icon-spin-slow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spin-slow {
  transform-box: fill-box;
  transform-origin: center;
  animation: icon-spin-slow 12s linear infinite;
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  .header-nav {
    display: none;
  }

  .split-row--reverse {
    direction: ltr;
  }

  .grid--3 {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    gap: 1.5rem;
  }
}

/* --- 减少动态效果 --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .orbit-ring,
  .bubble,
  .dot-input,
  .notif-card,
  .flow-line,
  .float-gentle,
  .pulse-dot,
  .spin-slow {
    animation: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* --- 焦点可见 --- */
*:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.dark *:focus-visible {
  outline-color: var(--color-accent);
}

/* --- 辅助类 --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center {
  text-align: center;
}

.mt-lg {
  margin-top: var(--section-y);
}
