/* 地图页专用样式 */

/* ── Hero 区 ─────────────────────────────────── */
.map-hero {
  background: linear-gradient(160deg, var(--bg-paper) 0%, var(--bg-card) 100%);
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 5vw, 4rem) 0;
  border-bottom: 1px solid rgba(26, 26, 26, 0.06);
}

.map-hero-body {
  max-width: 54rem;
  margin: 0 auto 2rem;
  animation: fade-up 0.8s var(--ease-out) both;
}

.map-eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
}

.map-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.map-lead {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-muted);
  line-height: 1.65;
  max-width: 36rem;
}

.map-source-note {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
  line-height: 1.65;
  max-width: 48rem;
}

.map-source-note a {
  color: var(--c-gov);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.map-source-note a:hover {
  color: var(--c-palace);
}

/* ── 分类筛选栏 ──────────────────────────────── */
.map-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 54rem;
  margin: 0 auto;
  padding: 1rem 0;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--bg-paper);
  border: 1px solid rgba(26, 26, 26, 0.1);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.filter-btn:hover {
  background: var(--bg-card);
  border-color: rgba(26, 26, 26, 0.18);
}

.filter-btn.active {
  background: var(--ink);
  color: var(--bg-paper);
  border-color: var(--ink);
}

.filter-btn[data-cat]:not(.active) {
  color: var(--f-color, var(--ink));
  border-color: rgba(26, 26, 26, 0.12);
}

.filter-btn[data-cat]:not(.active):hover {
  background: rgba(26, 26, 26, 0.05);
}

.filter-count {
  font-size: 0.72rem;
  background: rgba(26, 26, 26, 0.08);
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
}

.filter-btn.active .filter-count {
  background: rgba(247, 245, 240, 0.2);
}

/* ── 地图区 ─────────────────────────────────── */
.map-section {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem);
}

.map-container {
  max-width: 74rem;
  margin: 0 auto;
}

.map-wrapper {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid rgba(26, 26, 26, 0.07);
  box-shadow: 0 8px 32px rgba(26, 26, 26, 0.08);
}

/* Leaflet 交互地图容器 */
.map-wrapper-leaflet {
  padding: 0;
}

.china-map {
  width: 100%;
  height: min(72vh, 640px);
  min-height: 420px;
  z-index: 1;
}

.leaflet-container {
  font-family: var(--font-sans);
  border-radius: 16px;
  background: var(--bg-card);
}

.leaflet-control-attribution {
  font-size: 0.65rem;
  max-width: 100%;
  white-space: normal;
  line-height: 1.35;
}

/* ── 图例 ─────────────────────────────────── */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: center;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid rgba(26, 26, 26, 0.05);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--l-color, var(--c-gov));
  flex-shrink: 0;
}

/* ── 弹窗 ─────────────────────────────────── */
.map-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(90vw, 340px);
}

.map-popup[hidden] {
  display: none;
}

.popup-card {
  background: var(--bg-paper);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(26, 26, 26, 0.2);
  animation: popup-in 0.3s var(--ease-out) both;
}

.popup-img-wrap {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: var(--bg-card);
}

.popup-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: rgba(26, 26, 26, 0.5);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.popup-close:hover {
  background: rgba(26, 26, 26, 0.75);
}

.popup-body {
  padding: 1.1rem 1.25rem 1.25rem;
}

.popup-cat-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--m-color, var(--c-gov));
  margin-bottom: 0.35rem;
}

.popup-body h3 {
  margin: 0 0 0.3rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}

.popup-region {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin: 0 0 0.65rem;
}

.popup-intro {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.65;
  margin: 0 0 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.popup-link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--m-color, var(--c-gov));
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.1rem;
  transition: opacity 0.2s;
}

.popup-link:hover {
  opacity: 0.75;
}

.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.35);
  z-index: 19;
  backdrop-filter: blur(3px);
}

.popup-backdrop[hidden] {
  display: none;
}

/* ── 收藏列表 ─────────────────────────────────── */
.map-favorites {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.5rem);
}

.fav-head {
  text-align: center;
  margin-bottom: 1.5rem;
}

.fav-head h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.5vw, 1.65rem);
  letter-spacing: 0.05em;
}

.fav-head p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.fav-list {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

.fav-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid rgba(26, 26, 26, 0.06);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  animation: fade-up 0.5s var(--ease-out) both;
}

.fav-item:hover {
  background: var(--bg-paper);
  border-color: rgba(26, 26, 26, 0.14);
  transform: translateX(4px);
}

.fav-img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-paper);
}

.fav-info {
  flex: 1;
  min-width: 0;
}

.fav-name {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

.fav-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  margin-right: 0.35rem;
}

.fav-remove {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
  flex-shrink: 0;
}

.fav-remove:hover {
  opacity: 1;
  color: var(--c-palace);
}

.fav-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-muted);
}

.fav-empty[hidden] {
  display: none;
}

.fav-empty span {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}

.fav-empty p {
  font-size: 0.9rem;
  margin: 0;
}

/* ── 动画 ─────────────────────────────────── */
@keyframes popup-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ── 响应式 ─────────────────────────────────── */
@media (min-width: 640px) {
  .fav-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .site-nav {
    display: flex;
  }

  .nav-toggle {
    display: none;
  }

  .mobile-nav {
    display: none !important;
  }
}

@media (min-width: 1100px) {
  .fav-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-hero-body,
  .fav-item,
  .popup-card {
    animation: none !important;
    transition: none !important;
  }

  .fav-item:hover {
    transform: none;
  }
}
