/* 可视化速查 · 算法可视化图谱（原创样式；:root 变量体系与 site.css 保持一致） */

:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #fff;
  --ink: #17201e;
  --muted: #65716d;
  --line: #d7dfdb;
  --dark: #15211f;
  --dark-2: #1d2d29;
  --teal: #0d8490;
  --amber: #c7811d;
  --coral: #c95649;
  --green: #3b8c63;
  --violet: #725ca8;
  --shadow: 0 10px 28px rgba(20, 35, 31, 0.08);
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Consolas, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Cascadia Code", "JetBrains Mono", "Fira Code", ui-monospace, Consolas, "SF Mono", Menlo, "Microsoft YaHei", monospace;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- 页头 ---------- */

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 max(24px, calc((100% - 1240px) / 2));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border: 1px solid var(--teal);
  border-radius: 5px;
  color: var(--teal);
  font: 600 11px/1 var(--mono);
}

.brand-text b {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.brand-text small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font: 500 9px/1.2 var(--mono);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.site-header nav a:hover {
  color: var(--teal);
}

svg {
  width: 16px;
  height: 16px;
}

/* ---------- 页头区（深色 hero） ---------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 90px;
}

.hero {
  padding: 44px 0 34px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--teal);
  font: 600 11px/1.4 var(--mono);
  letter-spacing: 0.08em;
}

.hero h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.15;
}

.hero-sub {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.85;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 14px;
  margin-top: 22px;
}

.stat {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 128px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat b {
  color: var(--ink);
  font: 600 23px/1 var(--mono);
}

.stat small {
  color: var(--muted);
  font-size: 12px;
}

.stat-legend {
  gap: 8px;
}

.legend-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.legend-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-num {
  color: var(--ink);
  font: 600 13px/1 var(--mono);
}

i.dot.diff-1,
.dot.diff-1 {
  background: var(--green);
}

.dot.diff-2 {
  background: var(--amber);
}

.dot.diff-3 {
  background: var(--coral);
}

/* ---------- 功能说明卡片 ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.feature-card {
  padding: 20px 20px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--dark);
  color: #f2f7f5;
}

.feature-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.feature-num {
  color: #63c7d0;
  font: 600 21px/1 var(--mono);
  letter-spacing: 0.04em;
}

.feature-head svg {
  width: 20px;
  height: 20px;
  color: #8fb3ac;
}

.feature-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
}

.feature-card p {
  margin: 0;
  color: #b9c8c4;
  font-size: 13.5px;
  line-height: 1.8;
}

/* ---------- 筛选工具条 ---------- */

.toolbar {
  position: sticky;
  z-index: 20;
  top: 64px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 26px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.search-box {
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--teal);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(13, 132, 144, 0.14);
}

.search-box svg {
  flex: none;
  width: 15px;
  height: 15px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.search-box input::placeholder {
  color: #78847f;
}

.diff-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.diff-btn {
  min-height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.diff-btn:hover {
  color: var(--ink);
}

.diff-btn[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}

.result-count {
  margin: 0;
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.result-count b {
  color: var(--teal);
  font: 600 14px/1 var(--mono);
}

/* ---------- 空态 ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 54px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 26px;
  height: 26px;
  color: #9db0aa;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ---------- 分类速查区 ---------- */

.group {
  margin-bottom: 30px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.group-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.group-head::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.group-count {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 600 12px/1 var(--mono);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.topic-card:hover {
  border-color: rgba(13, 132, 144, 0.45);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.card-name {
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-summary {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
}

.diff-chip {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.diff-chip.diff-1 {
  color: var(--green);
  border-color: rgba(59, 140, 99, 0.4);
  background: rgba(59, 140, 99, 0.08);
}

.diff-chip.diff-2 {
  color: var(--amber);
  border-color: rgba(199, 129, 29, 0.4);
  background: rgba(199, 129, 29, 0.08);
}

.diff-chip.diff-3 {
  color: var(--coral);
  border-color: rgba(201, 86, 73, 0.4);
  background: rgba(201, 86, 73, 0.08);
}

.stage-tag {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font: 600 11px/1.6 var(--mono);
}

.card-actions {
  display: flex;
  gap: 7px;
  margin-top: auto;
  padding-top: 3px;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.card-btn svg {
  width: 13px;
  height: 13px;
}

.card-btn:hover {
  color: var(--teal);
  border-color: var(--teal);
}

.card-btn.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.card-btn.primary:hover {
  background: #096e78;
  border-color: #096e78;
  color: #fff;
}

/* ---------- 预览抽屉 ---------- */

body.drawer-lock {
  overflow: hidden;
}

.drawer-backdrop {
  position: fixed;
  z-index: 55;
  inset: 0;
  background: rgba(21, 33, 31, 0.44);
}

.preview-drawer {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  width: min(760px, 94vw);
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(20, 35, 31, 0.18);
}

.preview-drawer.open {
  display: flex;
  animation: preview-in 0.26s ease;
}

@keyframes preview-in {
  from {
    transform: translateX(105%);
  }
  to {
    transform: none;
  }
}

.preview-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--dark);
  color: #f2f7f5;
}

.preview-kicker {
  margin: 0 0 3px;
  color: #63c7d0;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.08em;
}

.preview-head h2 {
  overflow: hidden;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  color: #d7e3df;
  font-size: 13px;
  white-space: nowrap;
}

.ghost-btn:hover {
  border-color: #63c7d0;
  color: #fff;
}

.ghost-btn svg {
  width: 13px;
  height: 13px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  background: transparent;
  color: #d7e3df;
}

.icon-btn:hover {
  border-color: #63c7d0;
  color: #fff;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.preview-body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.preview-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--surface);
}

.preview-loading {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}

.preview-loading[hidden] {
  display: none;
}

.preview-loading p {
  margin: 0;
  font-size: 13px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1288px) {
  .page {
    padding: 0 20px 80px;
  }

  .hero h1 {
    font-size: 30px;
  }
}

@media (max-width: 980px) {
  .features {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 34px;
  }
}

@media (max-width: 760px) {
  .site-header nav {
    gap: 16px;
  }

  .site-header nav .nav-label {
    display: none;
  }

  .hero h1 {
    font-size: 26px;
  }

  .toolbar {
    top: 63px;
  }

  .preview-drawer {
    width: 100vw;
    border-left: none;
  }
}

@media (max-width: 440px) {
  .page {
    padding: 0 14px 64px;
  }

  .site-header {
    padding: 0 14px;
  }

  .hero {
    padding-top: 26px;
  }

  .hero-stats {
    gap: 10px;
  }

  .stat {
    flex: 1 1 100px;
    min-width: 0;
  }

  .stat-legend {
    flex: 1 1 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    flex-basis: auto;
  }

  .diff-group {
    justify-content: space-between;
  }

  .diff-btn {
    flex: 1;
    padding: 0 6px;
  }

  .result-count {
    text-align: center;
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
