/* ═══════════════════════════════════════════════════
   长江诗文地图 — style.css
   ═══════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%; margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: #13100d;
}

/* ── Header ──────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: rgba(13,10,7,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(201,168,76,0.18);
  z-index: 9999;
  box-shadow: 0 1px 24px rgba(0,0,0,0.28);
}

.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  color: rgba(201,168,76,0.8); text-decoration: none; font-size: 17px;
  transition: all .15s; flex-shrink: 0;
  border: 1px solid rgba(201,168,76,0.22);
}
.back-btn:hover {
  background: rgba(201,168,76,0.12);
  color: #e8c97a;
  border-color: rgba(201,168,76,0.45);
}

.site-title {
  font-weight: 600; font-size: 15.5px;
  letter-spacing: .16em; color: #f0ead8;
}

.header-legend {
  margin-left: auto;
  display: flex; gap: 14px; align-items: center;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: rgba(240,234,216,0.6); cursor: pointer;
  transition: color .15s; letter-spacing: 0.05em;
}
.legend-item:hover { color: rgba(240,234,216,0.95); }
.legend-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; box-shadow: 0 0 6px currentColor;
}

/* ── Layout ──────────────────────────────────────── */
.layout {
  position: absolute;
  top: 52px; bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr 360px;
}

#map { width: 100%; height: 100%; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  border-left: 1px solid rgba(201,168,76,0.14);
  background: #0f0c09;
  display: flex; flex-direction: column;
  min-width: 320px;
  overflow: hidden;
}

/* ── Controls ────────────────────────────────────── */
.controls {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(255,255,255,0.02);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: rgba(255,255,255,0.05);
  color: #f0ead8;
}
.input::placeholder { color: rgba(240,234,216,0.35); }
.input:focus {
  border-color: rgba(201,168,76,0.55);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.10);
  background: rgba(255,255,255,0.07);
}

.filter-row {
  display: flex; gap: 6px;
}

.section-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: rgba(240,234,216,0.55);
  transition: all .15s;
  letter-spacing: 0.04em;
}
.section-btn:hover { background: rgba(255,255,255,0.08); color: #f0ead8; }
.section-btn.active {
  background: rgba(201,168,76,0.18);
  color: #e8c97a;
  border-color: rgba(201,168,76,0.45);
}
.section-btn.upper.active  { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.45); }
.section-btn.middle.active { background: rgba(34,197,94,0.16);  color: #4ade80; border-color: rgba(34,197,94,0.40); }
.section-btn.lower.active  { background: rgba(59,130,246,0.18); color: #60a5fa; border-color: rgba(59,130,246,0.45); }

.filter-row2 { display: flex; gap: 6px; }

.select-sm {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.05);
  color: rgba(240,234,216,0.75);
  outline: none;
  cursor: pointer;
}
.select-sm:focus { border-color: rgba(201,168,76,0.5); }
.select-sm option { background: #1a1510; color: #f0ead8; }

.hint {
  font-size: 11.5px; color: rgba(240,234,216,0.30);
  line-height: 1.5;
}

/* ── Result info ─────────────────────────────────── */
.result-info {
  padding: 7px 14px;
  font-size: 11.5px; color: rgba(240,234,216,0.38);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.15);
  letter-spacing: 0.04em;
}

/* ── Detail panel ────────────────────────────────── */
.detail {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,168,76,0.2) transparent;
}
.detail::-webkit-scrollbar { width: 4px; }
.detail::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 2px; }

.detail-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
  color: rgba(240,234,216,0.28); font-size: 13.5px; gap: 6px;
  text-align: center;
  padding: 40px 20px;
  letter-spacing: 0.05em;
}
.detail-empty-icon {
  font-size: 34px; margin-bottom: 8px; opacity: .35;
  color: #c9a84c;
}

/* ── Place header ────────────────────────────────── */
.place-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(201,168,76,0.14);
  background: rgba(201,168,76,0.04);
  position: sticky; top: 0; z-index: 2;
}

.place-name {
  font-size: 15.5px; font-weight: 700; color: #f0ead8;
  margin-bottom: 6px; line-height: 1.4;
}

.place-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.section-tag {
  display: inline-block;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  border: 1px solid;
  letter-spacing: 0.06em;
}

.poem-count {
  font-size: 11.5px; color: rgba(240,234,216,0.40);
  letter-spacing: 0.04em;
}

/* ── Poems list ──────────────────────────────────── */
.poems-list {
  padding: 10px 12px 20px;
  display: flex; flex-direction: column; gap: 8px;
}

.poem-card {
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  transition: all .18s;
  cursor: default;
}
.poem-card:hover {
  border-color: rgba(201,168,76,0.28);
  background: rgba(201,168,76,0.05);
  box-shadow: 0 2px 16px rgba(0,0,0,0.24);
}

.poem-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.poem-title {
  font-size: 13.5px; font-weight: 700; color: #e8dfc8;
}
.poem-badge {
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: rgba(201,168,76,0.15);
  color: rgba(201,168,76,0.85);
  border: 1px solid rgba(201,168,76,0.22);
}
.poem-author {
  font-size: 11.5px; color: rgba(240,234,216,0.42); margin-bottom: 8px;
}
.poem-text {
  font-size: 13px; line-height: 2.0; color: rgba(240,234,216,0.72);
  white-space: pre-wrap; word-break: break-word;
  font-family: "STKaiti", "KaiTi", "仿宋", serif;
}

.no-results {
  text-align: center; color: rgba(240,234,216,0.25);
  font-size: 13px; padding: 24px 0;
}

/* ── Search highlight styles ─────────────────────── */

/* Summary line in place-header */
.match-summary {
  margin-top: 6px;
  font-size: 11px;
  color: #c9a84c;
  letter-spacing: 0.06em;
  background: rgba(201,168,76,0.10);
  border: 1px solid rgba(201,168,76,0.22);
  border-radius: 6px;
  padding: 3px 10px;
  display: inline-block;
}

/* Matched poem card */
.poem-card--match {
  border-color: rgba(201,168,76,0.50) !important;
  background: rgba(201,168,76,0.07) !important;
  box-shadow: 0 0 0 1px rgba(201,168,76,0.18),
              0 4px 20px rgba(0,0,0,0.28) !important;
  position: relative;
  overflow: hidden;
}

/* Left accent bar on matched card */
.match-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #e8c97a, #c9a84c);
  border-radius: 3px 0 0 3px;
}

/* "匹配" tag badge */
.match-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(201,168,76,0.20);
  color: #e8c97a;
  border: 1px solid rgba(201,168,76,0.40);
  letter-spacing: 0.08em;
  margin-left: auto;
  flex-shrink: 0;
}

/* Dimmed non-matching card */
.poem-card--dim {
  opacity: 0.38;
}
.poem-card--dim:hover {
  opacity: 0.70;
}

/* Keyword highlight <mark> inside cards */
mark.hl {
  background: rgba(232,201,122,0.30);
  color: #f5e090;
  border-radius: 3px;
  padding: 0 2px;
  font-style: normal;
  font-weight: 600;
  border-bottom: 1px solid rgba(232,201,122,0.55);
}

/* ── Pulse ring animation for matched markers ────── */
/* Rings are concentric circleMarkers; their opacity is animated via JS */
.pulse-ring-a path { animation: breatheA 2.0s ease-in-out infinite alternate; }
.pulse-ring-b path { animation: breatheB 2.0s ease-in-out infinite alternate; }
.pulse-ring-c path { animation: breatheC 2.0s ease-in-out infinite alternate; }

@keyframes breatheA {
  from { stroke-opacity: 0.70; stroke-width: 2px; }
  to   { stroke-opacity: 0.08; stroke-width: 1px; }
}
@keyframes breatheB {
  from { stroke-opacity: 0.40; stroke-width: 1.5px; }
  to   { stroke-opacity: 0.05; stroke-width: 0.5px; }
}
@keyframes breatheC {
  from { stroke-opacity: 0.20; stroke-width: 1px; }
  to   { stroke-opacity: 0.02; stroke-width: 0.5px; }
}

/* ── Leaflet overrides ───────────────────────────── */
.leaflet-control-layers {
  background: rgba(13,10,7,0.90) !important;
  border: 1px solid rgba(201,168,76,0.20) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35) !important;
  color: #f0ead8 !important;
}
.leaflet-control-layers label {
  color: rgba(240,234,216,0.80) !important;
  font-size: 12.5px;
}
.leaflet-control-layers-separator {
  border-color: rgba(255,255,255,0.10) !important;
}
.leaflet-control-zoom a {
  background: rgba(13,10,7,0.88) !important;
  border-color: rgba(201,168,76,0.22) !important;
  color: rgba(240,234,216,0.80) !important;
}
.leaflet-control-zoom a:hover {
  background: rgba(201,168,76,0.15) !important;
  color: #e8c97a !important;
}

.place-tooltip {
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(201,168,76,0.25) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.40);
  background: rgba(10,7,4,0.92) !important;
  color: #f0ead8 !important;
}
.place-tooltip::before { display: none !important; }
.leaflet-tooltip.place-tooltip.leaflet-tooltip-top::before {
  display: block !important;
  border-top-color: rgba(10,7,4,0.92) !important;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 55% 45%;
  }
  .sidebar {
    position: relative; min-width: 0;
    border-left: none; border-top: 1px solid rgba(201,168,76,0.14);
  }
  #map { height: 100%; }
  .header-legend { display: none; }
  .site-title { font-size: 14px; }
}
