/*
 * Layout and responsive presentation for the dedicated interactive map page.
 * Enhanced UX, accessible controls, smooth mobile handling, and Leaflet polish.
 */

.map-page {
  background: var(--bg);
}

.map-hero {
  padding: 2.5rem 0 1.5rem;
}

.map-hero .lead {
  max-width: 860px;
}

.map-shell {
  width: min(1440px, 96vw);
  margin: 0 auto 3rem;
  display: grid;
  grid-template-columns: minmax(280px, 350px) 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.map-sidebar {
  padding: 1.5rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
  max-height: 78vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.map-sidebar::-webkit-scrollbar {
  width: 6px;
}
.map-sidebar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.map-sidebar h2 {
  font-size: 1.35rem;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.map-sidebar h3 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.65rem;
  color: var(--yellow);
  font-weight: 700;
}

.map-intro {
  font-size: 0.92rem;
  color: var(--ink-secondary);
  margin: 0;
  line-height: 1.5;
}

.map-mobile-jump {
  display: none;
}
@media (max-width: 820px) {
  .map-mobile-jump {
    display: block;
    background: var(--yellow);
    color: #000 !important;
    text-align: center;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: background var(--transition-fast);
  }
  .map-mobile-jump:hover {
    background: var(--red);
    color: #fff !important;
  }
}

.map-search {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.map-search input {
  min-width: 0;
  width: 100%;
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.map-search input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(255, 204, 0, 0.2);
  outline: none;
}

.map-search button,
.map-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--ink);
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.map-search button {
  background: var(--yellow);
  color: #000;
  border-color: var(--yellow);
}

.map-search button:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.map-tool:hover,
.map-tool:focus {
  border-color: var(--yellow);
  color: var(--yellow);
  background: var(--surface-hover);
}

.map-status {
  min-height: 1.5rem;
  margin: 0;
  color: var(--yellow);
  font-size: 0.84rem;
  line-height: 1.4;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 204, 0, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 204, 0, 0.15);
  display: none;
}

.map-status:not(:empty) {
  display: block;
}

.map-sidebar-controls {
  display: grid;
  gap: 1.25rem;
}

.map-control-list {
  display: grid;
  gap: 0.65rem;
}

.map-switch {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.92rem;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.map-switch:hover {
  color: #fff;
}

.map-switch input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--red);
  cursor: pointer;
}

.map-switch select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.8rem;
}

/* Range slider styling */
.opacity-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.opacity-row output {
  font-weight: 700;
  color: var(--yellow);
}

.opacity-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--red);
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
}

.map-tools {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.map-tools .map-tool {
  flex: 1 1 auto;
  min-width: 80px;
}

.map-key {
  display: grid;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: var(--ink-secondary);
  background: var(--bg);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-subtle);
}

.key-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.key-line {
  width: 28px;
  height: 0;
  border-top: 3px solid var(--red);
}

.key-line.admin {
  border-top: 2px dashed #f6f2df;
}

.key-dot {
  width: 13px;
  height: 13px;
  background: var(--yellow);
  border: 2px solid #111;
  border-radius: 50%;
}

.map-caution {
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin: 0;
  line-height: 1.5;
}

.map-caution strong {
  color: var(--red-light);
}

#country-map {
  height: 78vh;
  min-height: 590px;
  background: #151e18;
}

/* Leaflet Container & Popup Polish */
.leaflet-container {
  font-family: inherit;
}

.leaflet-popup-content-wrapper {
  background: #141715;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
}

.leaflet-popup-tip {
  background: #141715;
}

.leaflet-popup-content {
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0.8rem 1rem;
}

.leaflet-popup-content a {
  color: var(--yellow);
  font-weight: 600;
}

.leaflet-popup-content a:hover {
  color: var(--red-light);
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(12, 14, 13, 0.85) !important;
  color: #aaa !important;
}

.leaflet-control-attribution a {
  color: #ccc !important;
}

.leaflet-control-zoom a {
  background: #141715 !important;
  color: var(--yellow) !important;
  border-color: var(--line) !important;
  transition: all var(--transition-fast);
}

.leaflet-control-zoom a:hover {
  background: var(--surface-hover) !important;
  color: #fff !important;
}

.place-result {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin: 0.5rem 0;
  background: var(--bg);
  transition: border-color var(--transition-fast);
}

.place-result strong {
  display: block;
  color: #fff;
}

.place-result span {
  font-size: 0.8rem;
  color: var(--muted);
}

.map-noscript {
  padding: 2.5rem;
  background: var(--surface);
  color: #fff;
  text-align: center;
}

.map-content-note {
  width: min(1080px, 92vw);
  margin: 0 auto 3rem;
}

/* History Markers & Popups */
.history-marker-wrap {
  background: transparent;
  border: 0;
  overflow: visible;
}

.history-marker {
  display: block;
  width: 24px;
  height: 30px;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.8));
  transition: transform var(--transition-fast);
}

.history-marker-wrap:hover .history-marker {
  transform: scale(1.15);
}

.key-history {
  width: 14px;
  height: 14px;
  background: var(--red);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  margin: 0 3px;
}

.history-popup {
  line-height: 1.5;
}

.history-popup p {
  margin: 0.6rem 0;
}

.poi-kicker {
  color: var(--red-light);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.35rem !important;
}

.poi-title {
  display: block;
  font-size: 1.1rem;
  line-height: 1.25;
  color: #fff;
  margin-bottom: 0.5rem;
}

.history-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.65rem;
  margin: 0.65rem 0;
  font-size: 0.82rem;
  background: var(--bg);
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-subtle);
}

.history-popup dt {
  color: var(--muted);
  font-weight: 700;
}

.history-popup dd {
  margin: 0;
  color: var(--ink-secondary);
}

.poi-location-note {
  display: block;
  border-left: 3px solid var(--yellow);
  padding: 0.4rem 0.6rem;
  background: rgba(255, 204, 0, 0.08);
  color: #fff;
  font-size: 0.78rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.5rem 0;
}

.poi-citation {
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.poi-citation cite {
  font-style: normal;
  color: #fff;
}

.leaflet-marker-icon:focus .history-marker {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

/* Mobile Responsiveness for Map */
@media (max-width: 820px) {
  .map-shell {
    grid-template-columns: 1fr;
    width: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .map-sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 1.2rem;
  }
  .map-sidebar-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
  }
  #country-map {
    height: 65vh;
    min-height: 480px;
  }
}

@media (max-width: 540px) {
  .map-sidebar-controls {
    grid-template-columns: 1fr;
  }
  #country-map {
    height: 60vh;
    min-height: 400px;
  }
  .map-hero {
    padding-top: 1.75rem;
  }
}
