/* ═══ NORMALIZE ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; height: 100%; }
img { display: block; max-width: 100%; }
button { font: inherit; }
[hidden] { display: none !important; }

/* ═══ VARIABLES ═══ */
:root {
  --cream: #f5edd6;
  --parchment: #ede0c4;
  --aged: #d9c9a8;
  --brown-light: #c8a96e;
  --brown-mid: #8b6635;
  --brown-dark: #5c3d1e;
  --brown-deep: #3a2210;
  --burgundy: #7a1f2e;
  --burgundy-light: #9e3547;
  --gold: #c9922a;
  --gold-light: #e0b060;
  --ink: #2a1a0e;
  --sepia-text: #4a3220;
  --sepia-muted: #7a6248;
  --shadow: rgba(58,34,16,0.18);
  --shadow-deep: rgba(58,34,16,0.35);

  --breakpoint-mobile: 900px;
  --sidebar-width: 280px;
  --font-serif: 'EB Garamond', Georgia, serif;
  --font-display: 'Playfair Display', serif;
  --font-italic: 'Cormorant Garamond', serif;
}

/* ═══ BASE ═══ */
body {
  font-family: var(--font-serif);
  font-size: 17px;
  background: var(--brown-deep);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ═══ SKIP LINK ═══ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 9999;
  background: var(--gold);
  color: var(--brown-deep);
  padding: 8px 16px;
  border-radius: 0 0 4px 4px;
  font-family: var(--font-display);
  font-size: 14px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ═══ HEADER ═══ */
.header {
  background: linear-gradient(135deg, var(--brown-deep) 0%, #2c1608 50%, var(--brown-dark) 100%);
  border-bottom: 2px solid var(--gold);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 40px,
    rgba(201,146,42,0.04) 40px,
    rgba(201,146,42,0.04) 41px
  );
  pointer-events: none;
}
.header-ornament {
  font-size: 22px;
  color: var(--gold);
  opacity: 0.7;
  letter-spacing: 8px;
}
.header-center { text-align: center; flex: 1; }
.header-title {
  font-family: var(--font-display);
  font-size: clamp(16px, 2.2vw, 26px);
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 2px;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.header-subtitle {
  font-family: var(--font-italic);
  font-size: clamp(11px, 1.2vw, 14px);
  color: var(--aged);
  letter-spacing: 4px;
  font-style: italic;
  margin-top: 2px;
}
.header-line {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 4px auto 0;
  opacity: 0.6;
}

/* ═══ SOUND SECTION (sidebar) ═══ */
.sound-section {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(139,102,53,0.2);
  background: rgba(0,0,0,0.08);
}
.sound-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--burgundy) 0%, #5a1520 100%);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--cream);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 1px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}
.sound-toggle-btn:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0,0,0,0.4); }
.sound-toggle-btn:active { transform: translateY(1px); }
.sound-waves { display: flex; align-items: flex-end; gap: 2.5px; width: 18px; height: 16px; flex-shrink: 0; }
.wave-bar { width: 3px; height: 4px; background: var(--gold-light); border-radius: 1px; transition: height 0.3s; }
.sound-toggle-btn.playing .wave-bar:nth-child(1) { animation: wavePulse 0.8s ease-in-out infinite alternate 0s; }
.sound-toggle-btn.playing .wave-bar:nth-child(2) { animation: wavePulse 0.8s ease-in-out infinite alternate 0.15s; }
.sound-toggle-btn.playing .wave-bar:nth-child(3) { animation: wavePulse 0.8s ease-in-out infinite alternate 0.3s; }
.sound-toggle-btn.playing .wave-bar:nth-child(4) { animation: wavePulse 0.8s ease-in-out infinite alternate 0.45s; }
@keyframes wavePulse { 0% { transform: scaleY(0.3); } 100% { transform: scaleY(2.5); } }

/* ═══ MAIN LAYOUT ═══ */
.main { display: flex; flex: 1; min-height: 0; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, #f0e4c8 0%, #e8d8b0 100%);
  border-right: 2px solid var(--brown-mid);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23a08040' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.5;
}
.sidebar-section {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(139,102,53,0.25);
  position: relative;
}
.sidebar-heading {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--brown-mid), transparent);
}

/* Filter buttons */
.filter-grid { display: flex; flex-direction: column; gap: 6px; }
.filter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid rgba(139,102,53,0.25);
  background: rgba(201,168,76,0.06);
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--sepia-text);
  text-align: left;
  position: relative;
  overflow: hidden;
  line-height: 1.4;
}
.filter-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
  transform: scaleY(0);
  transition: transform 0.25s ease;
}
.filter-btn:hover { background: rgba(255,255,255,0.55); border-color: var(--brown-mid); }
.filter-btn.active {
  background: rgba(201,146,42,0.14);
  color: var(--brown-dark);
  border-color: var(--gold);
  font-weight: 600;
}
.filter-btn.active::before { transform: scaleY(1); }
.filter-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.filter-icon { font-size: 15px; flex-shrink: 0; }
.filter-count {
  margin-left: auto;
  background: rgba(201,146,42,0.18);
  color: var(--brown-dark);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  flex-shrink: 0;
}
.filter-btn.active .filter-count {
  background: var(--gold);
  color: var(--brown-deep);
}

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(139,102,53,0.2);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--burgundy);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  color: var(--sepia-muted);
  margin-top: 4px;
  line-height: 1.3;
}

/* Legend */
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--sepia-text);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Quote block */
.sidebar-quote {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 15px;
  line-height: 1.65;
  color: var(--sepia-text);
  padding: 14px;
  background: rgba(255,255,255,0.35);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
  margin-top: 4px;
}
.sidebar-quote-author {
  font-style: normal;
  font-size: 13px;
  color: var(--sepia-muted);
  margin-top: 8px;
}

/* ═══ MAP ═══ */
.map-wrap { flex: 1; position: relative; overflow: hidden; height: 100%; z-index: 1; }
#map {
  width: 100%;
  height: 100%;
  filter: sepia(0.55) contrast(0.92) saturate(1.15) brightness(0.95);
  z-index: 1;
}
.map-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  box-shadow: inset 0 0 60px rgba(58,34,16,0.25);
}
.map-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid rgba(139,102,53,0.4);
  pointer-events: none;
}
.map-loading {
  position: absolute;
  inset: 0;
  background: var(--brown-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--gold-light);
  letter-spacing: 3px;
  transition: opacity 0.5s;
}

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,15,5,0.72);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 20px;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: linear-gradient(160deg, #f5edd6 0%, #ede0c4 60%, #e4d1b2 100%);
  border: 2px solid var(--brown-mid);
  border-radius: 4px;
  max-width: 700px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  background: linear-gradient(135deg, var(--brown-dark) 0%, var(--brown-deep) 100%);
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gold);
  position: relative;
}
.modal-category {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1.25;
}
.modal-meta {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.modal-meta-item {
  font-size: 14px;
  color: var(--aged);
  letter-spacing: 0.5px;
}
.modal-meta-item span { color: var(--gold-light); font-weight: 500; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: 1px solid rgba(201,146,42,0.4);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--gold-light);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}
.modal-close:hover { background: rgba(201,146,42,0.2); }
.modal-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.modal-body { padding: 24px 28px 28px; }

/* Image comparison */
.comparison-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.comparison-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--brown-mid), transparent);
}
.comparison-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.photo-box {
  border: 2px solid var(--brown-mid);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  background: var(--brown-dark);
  aspect-ratio: 4/3;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--brown-dark) 0%, #3a2210 100%);
}
.photo-placeholder .ph-icon { font-size: 32px; opacity: 0.4; }
.photo-placeholder .ph-year {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-light);
  opacity: 0.7;
}
.photo-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(30,15,5,0.75);
  color: var(--aged);
  font-size: 12px;
  letter-spacing: 1px;
  text-align: center;
  padding: 5px;
  font-style: italic;
}
.photo-box-then { filter: sepia(0.8) contrast(0.85) brightness(0.9); }

/* Facts */
.facts-section {
  margin-bottom: 20px;
  background: rgba(242, 236, 208, 0.4); /* --parchment with opacity */
  border-radius: 0 4px 4px 0;
  border-left: 3px solid var(--gold);
  padding: 16px 20px;
}
.facts-section p {
  font-size: 17px;
  line-height: 1.6; /* Reduced from 1.8 */
  color: var(--sepia-text);
  margin-bottom: 8px; /* Reduced from 14px */
  text-align: justify;
}
.facts-section p:last-child { margin-bottom: 0; }

/* Quote in modal */
.modal-quote {
  background: var(--brown-dark);
  border-radius: 3px;
  padding: 16px 20px;
  margin-top: 6px;
}
.modal-quote-text {
  font-family: var(--font-italic);
  font-size: 18px;
  font-style: italic;
  line-height: 1.7;
  color: var(--gold-light);
}
.modal-quote-text::before { content: '\00AB'; font-size: 24px; color: var(--gold); line-height: 0; vertical-align: -4px; margin-right: 3px; }
.modal-quote-text::after { content: '\00BB'; font-size: 24px; color: var(--gold); line-height: 0; vertical-align: -4px; margin-left: 3px; }
.modal-quote-author {
  margin-top: 12px;
  font-size: 13px;
  color: var(--aged);
  letter-spacing: 1px;
  text-align: right;
}

/* ═══ CUSTOM MARKERS ═══ */
.custom-marker {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}
.custom-marker:hover { transform: rotate(-45deg) scale(1.15); }
.custom-marker-inner { transform: rotate(45deg); font-size: 12px; color: white; }

/* Cluster override */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(90,50,20,0.7) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(139,102,53,0.9) !important;
  color: var(--cream) !important;
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-mid); border-radius: 3px; }

/* Decorative ornament in modal header */
.ornament-line { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
.ornament-line-hr { flex: 1; height: 1px; background: rgba(201,146,42,0.35); }
.ornament-line-symbol { color: var(--gold); font-size: 14px; opacity: 0.7; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; max-height: 200px; flex-direction: row; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; }
  .sidebar-section { min-width: 220px; border-bottom: none; border-right: 1px solid rgba(139,102,53,0.25); }
  .map-wrap { flex: 1; min-height: 400px; }
  body { overflow: auto; }
}

/* Single photo mode in modal */
#photoContainer.single-photo {
  display: flex;
  justify-content: center;
}
#photoContainer.single-photo .photo-box {
  width: 80%;
  max-width: 400px;
}

/* Full-size image viewer */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}
.image-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  border: 4px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.image-viewer::after {
  content: 'Нажмите чтобы закрыть';
  position: absolute;
  bottom: 20px;
  color: var(--cream);
  font-size: 14px;
  text-align: center;
  width: 100%;
}