/* ========== 文物关联知识图谱 ========== */

.kg-section {
  position: relative;
  margin-bottom: var(--spacing-lg);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  border-radius: 20px;
  border: 1px solid rgba(200, 155, 69, 0.45);
  background: linear-gradient(145deg, #fbf7ef 0%, #f8f1e6 48%, #f3ebe0 100%);
  box-shadow:
    0 12px 40px rgba(58, 36, 24, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  overflow: hidden;
}

.kg-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(79, 111, 82, 0.07) 0%, transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(139, 47, 28, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(200, 155, 69, 0.05) 0%, transparent 55%);
  pointer-events: none;
}

.kg-section::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 55%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(200, 155, 69, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.kg-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.kg-header-icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #c89b45 0%, #a67c32 100%);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 4px 14px rgba(200, 155, 69, 0.35);
}

.kg-title {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 600;
  color: #3a2418;
  margin: 0 0 0.25rem;
  letter-spacing: 0.04em;
}

.kg-subtitle {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(58, 36, 24, 0.62);
}

.kg-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 320px);
  gap: 1.25rem;
  align-items: stretch;
}

.kg-canvas-wrap {
  position: relative;
  min-height: 420px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(200, 155, 69, 0.22);
  backdrop-filter: blur(4px);
  overflow: hidden;
}

.kg-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.kg-line {
  stroke: rgba(58, 36, 24, 0.14);
  stroke-width: 0.35;
  stroke-dasharray: 1.2 0.8;
  transition: stroke 0.25s ease, stroke-width 0.25s ease, opacity 0.25s ease;
}

.kg-line--active {
  stroke: #c89b45;
  stroke-width: 0.55;
  stroke-dasharray: none;
  opacity: 1;
  filter: drop-shadow(0 0 2px rgba(200, 155, 69, 0.6));
}

.kg-center-node {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  min-width: 140px;
  max-width: 200px;
  padding: 1rem 1.15rem;
  text-align: center;
  border-radius: 999px;
  background: linear-gradient(145deg, #5c3a22 0%, #3a2418 55%, #2a1810 100%);
  border: 2px solid rgba(200, 155, 69, 0.75);
  box-shadow:
    0 10px 28px rgba(58, 36, 24, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 6px rgba(200, 155, 69, 0.08);
  color: #f8f1e6;
}

.kg-center-badge {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(200, 155, 69, 0.95);
  margin-bottom: 0.35rem;
}

.kg-center-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.kg-center-sub {
  display: block;
  font-size: 0.72rem;
  opacity: 0.82;
  line-height: 1.4;
}

.kg-node {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  width: min(168px, 28vw);
  padding: 0.65rem 0.75rem;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition:
    transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.28s ease,
    border-color 0.25s ease;
  backdrop-filter: blur(6px);
}

.kg-node:hover,
.kg-node:focus-visible,
.kg-node--active {
  transform: translate(-50%, calc(-50% - 4px));
  box-shadow: 0 12px 24px rgba(58, 36, 24, 0.14);
  outline: none;
}

.kg-node-type {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;
  background: rgba(255, 255, 255, 0.55);
}

.kg-node-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 600;
  color: #3a2418;
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.kg-node-desc {
  display: block;
  font-size: 0.68rem;
  line-height: 1.45;
  color: rgba(58, 36, 24, 0.68);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kg-node--green {
  background: linear-gradient(135deg, rgba(79, 111, 82, 0.14) 0%, rgba(255, 255, 255, 0.75) 100%);
  border-color: rgba(79, 111, 82, 0.35);
}
.kg-node--green .kg-node-type {
  color: #4f6f52;
}

.kg-node--blue {
  background: linear-gradient(135deg, rgba(44, 74, 110, 0.12) 0%, rgba(255, 255, 255, 0.75) 100%);
  border-color: rgba(44, 74, 110, 0.32);
}
.kg-node--blue .kg-node-type {
  color: #2c4a6e;
}

.kg-node--purple {
  background: linear-gradient(135deg, rgba(118, 85, 138, 0.12) 0%, rgba(255, 255, 255, 0.75) 100%);
  border-color: rgba(118, 85, 138, 0.32);
}
.kg-node--purple .kg-node-type {
  color: #76558a;
}

.kg-node--gold {
  background: linear-gradient(135deg, rgba(200, 155, 69, 0.16) 0%, rgba(255, 255, 255, 0.78) 100%);
  border-color: rgba(200, 155, 69, 0.4);
}
.kg-node--gold .kg-node-type {
  color: #9a7228;
}

.kg-node--brown {
  background: linear-gradient(135deg, rgba(107, 68, 35, 0.12) 0%, rgba(255, 255, 255, 0.75) 100%);
  border-color: rgba(107, 68, 35, 0.3);
}
.kg-node--brown .kg-node-type {
  color: #6b4423;
}

.kg-node--cyan {
  background: linear-gradient(135deg, rgba(85, 124, 139, 0.12) 0%, rgba(255, 255, 255, 0.75) 100%);
  border-color: rgba(85, 124, 139, 0.32);
}
.kg-node--cyan .kg-node-type {
  color: #557c8b;
}

.kg-node--active.kg-node--green {
  border-color: #4f6f52;
}
.kg-node--active.kg-node--blue {
  border-color: #2c4a6e;
}
.kg-node--active.kg-node--purple {
  border-color: #76558a;
}
.kg-node--active.kg-node--gold {
  border-color: #c89b45;
}
.kg-node--active.kg-node--brown {
  border-color: #6b4423;
}
.kg-node--active.kg-node--cyan {
  border-color: #557c8b;
}

.kg-detail {
  border-radius: 16px;
  padding: 1.15rem 1.25rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(200, 155, 69, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.kg-detail-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: rgba(58, 36, 24, 0.45);
  text-align: center;
  font-size: 0.88rem;
}

.kg-detail-placeholder i {
  font-size: 1.5rem;
  color: rgba(200, 155, 69, 0.65);
}

.kg-detail-head {
  margin-bottom: 0.75rem;
}

.kg-detail-type {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.45rem;
  background: rgba(58, 36, 24, 0.06);
  color: #3a2418;
}

.kg-detail-type--green {
  color: #4f6f52;
  background: rgba(79, 111, 82, 0.12);
}
.kg-detail-type--blue {
  color: #2c4a6e;
  background: rgba(44, 74, 110, 0.1);
}
.kg-detail-type--purple {
  color: #76558a;
  background: rgba(118, 85, 138, 0.1);
}
.kg-detail-type--gold {
  color: #9a7228;
  background: rgba(200, 155, 69, 0.14);
}
.kg-detail-type--brown {
  color: #6b4423;
  background: rgba(107, 68, 35, 0.1);
}
.kg-detail-type--cyan {
  color: #557c8b;
  background: rgba(85, 124, 139, 0.1);
}

.kg-detail-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: #3a2418;
  margin: 0;
  line-height: 1.4;
}

.kg-detail-text {
  flex: 1;
  font-size: 0.86rem;
  line-height: 1.65;
  color: rgba(58, 36, 24, 0.78);
  margin: 0 0 1rem;
}

.kg-detail-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(135deg, #8b2f1c 0%, #6b2315 100%);
  box-shadow: 0 4px 14px rgba(139, 47, 28, 0.28);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kg-detail-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 47, 28, 0.35);
}

/* ========== 知识详情弹窗 ========== */
.kg-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: kg-modal-fade-in 0.22s ease;
}

.kg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58, 36, 24, 0.45);
  backdrop-filter: blur(4px);
}

.kg-modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(85vh, 640px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid rgba(200, 155, 69, 0.45);
  background: linear-gradient(160deg, #fbf7ef 0%, #f8f1e6 100%);
  box-shadow:
    0 24px 60px rgba(58, 36, 24, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: kg-modal-slide-up 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.kg-modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(58, 36, 24, 0.08);
  color: #3a2418;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.kg-modal-close:hover {
  background: rgba(139, 47, 28, 0.12);
  transform: scale(1.05);
}

.kg-modal-header {
  padding: 1.35rem 1.5rem 0.85rem;
  border-bottom: 1px solid rgba(200, 155, 69, 0.22);
}

.kg-modal-type {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.kg-modal-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: #3a2418;
  margin: 0 0 0.45rem;
  padding-right: 2rem;
  line-height: 1.4;
}

.kg-modal-meta {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(58, 36, 24, 0.62);
}

.kg-modal-meta strong {
  color: #8b2f1c;
  font-weight: 600;
}

.kg-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.kg-modal-section-title {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: #8b2f1c;
  margin: 0 0 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.kg-modal-section-title:not(:first-child) {
  margin-top: 1rem;
}

.kg-modal-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.7;
  color: rgba(58, 36, 24, 0.82);
}

.kg-modal-text--muted {
  color: rgba(58, 36, 24, 0.65);
  font-size: 0.82rem;
}

.kg-modal-footer {
  padding: 0.85rem 1.5rem 1.15rem;
  border-top: 1px solid rgba(200, 155, 69, 0.18);
  display: flex;
  justify-content: flex-end;
}

.kg-modal-btn-secondary {
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(200, 155, 69, 0.45);
  background: rgba(255, 255, 255, 0.7);
  color: #3a2418;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.kg-modal-btn-secondary:hover {
  background: #fff;
  border-color: #c89b45;
}

@keyframes kg-modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes kg-modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 移动端：上下布局，节点纵向排列 */
@media (max-width: 768px) {
  .kg-body,
  .kg-body--compact {
    grid-template-columns: 1fr;
  }

  .kg-canvas-wrap {
    min-height: auto;
    padding: 1rem 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
  }

  .kg-lines {
    display: none;
  }

  .kg-center-node {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    margin-bottom: 0.5rem;
    max-width: 100%;
  }

  .kg-node {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100%;
    max-width: 100%;
  }

  .kg-node:hover,
  .kg-node:focus-visible,
  .kg-node--active {
    transform: translateY(-2px) !important;
  }

  .kg-detail {
    min-height: 160px;
  }
}

@media (max-width: 480px) {
  .kg-section {
    padding: 1rem;
    border-radius: 16px;
  }

  .kg-header-icon {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1rem;
  }
}
