/* ══════════════════════════════════════════════════════════════
   MAP PAGE v4 — Interactive map of Kazakhstan
   Navy/gold brand palette, sidebar-first UX, premium polish
   ══════════════════════════════════════════════════════════════ */

/* ── Override page-level elements ────────────────────────────── */
body:has(.map-page) .social-float {
  display: none !important;
}
body:has(.map-page) .site-footer {
  display: none;
}
body:has(.map-page) .main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── Map page container ─────────────────────────────────────── */
.map-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Compact header ─────────────────────────────────────────── */
.map-header {
  background: linear-gradient(
    135deg,
    var(--navy-deep, #0e1740),
    var(--navy, #152259)
  );
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--gold, #c8a84b);
}
.map-header__left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.map-header__bc {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.35);
}
.map-header__bc a {
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
}
.map-header__bc a:hover {
  color: rgba(255, 255, 255, 0.75);
}
.map-header__title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}
.map-header__stats {
  display: flex;
  gap: 16px;
  align-items: center;
}
.map-header__stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.map-header__stat-val {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gold, #c8a84b);
  font-variant-numeric: tabular-nums;
}
.map-header__stat-label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
}

/* ── Map container ──────────────────────────────────────────── */
.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
#region-map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   LAYER CONTROLS — bigger, polished, gold active state
   ══════════════════════════════════════════════════════════════ */
.map-layers {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-layer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(14, 23, 64, 0.88);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.01em;
}
.map-layer-btn:hover {
  background: rgba(28, 48, 112, 0.95);
  color: #fff;
  border-color: rgba(200, 168, 75, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.map-layer-btn.active {
  background: linear-gradient(135deg, var(--gold, #c8a84b), #d4b85c);
  color: var(--navy-deep, #0e1740);
  border-color: var(--gold, #c8a84b);
  box-shadow: 0 4px 16px rgba(200, 168, 75, 0.35);
}
.map-layer-btn.active:hover {
  background: linear-gradient(135deg, #d4b85c, var(--gold, #c8a84b));
  box-shadow: 0 6px 20px rgba(200, 168, 75, 0.45);
}
.layer-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════
   LEGEND — brand-styled with real values
   ══════════════════════════════════════════════════════════════ */
.map-legend {
  position: absolute;
  bottom: 28px;
  left: 14px;
  z-index: 5;
  background: rgba(14, 23, 64, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 180px;
  border: 1px solid rgba(200, 168, 75, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* v4 legend inner structure (generated by JS) */
.lg-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold, #c8a84b);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.lg-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.lg-sw {
  flex: 1;
}
.lg-sw--population-0 {
  background: #c8d6f0;
}
.lg-sw--population-1 {
  background: #9cb3e0;
}
.lg-sw--population-2 {
  background: #7090d0;
}
.lg-sw--population-3 {
  background: #4a6fc0;
}
.lg-sw--population-4 {
  background: #2c50a8;
}
.lg-sw--population-5 {
  background: #1c3882;
}
.lg-sw--population-6 {
  background: #152868;
}
.lg-sw--population-7 {
  background: #0e1a4a;
}
.lg-sw--news-0 {
  background: #fdf6e3;
}
.lg-sw--news-1 {
  background: #f5e6b0;
}
.lg-sw--news-2 {
  background: #ecd47d;
}
.lg-sw--news-3 {
  background: #c8a84b;
}
.lg-sw--news-4 {
  background: #a88a30;
}
.lg-sw--news-5 {
  background: #886c1c;
}
.lg-sw--news-6 {
  background: #6a5010;
}
.lg-sw--news-7 {
  background: #4a3808;
}
.lg-sw--urbanization-0 {
  background: #e8f5ee;
}
.lg-sw--urbanization-1 {
  background: #bde4cb;
}
.lg-sw--urbanization-2 {
  background: #86cfa0;
}
.lg-sw--urbanization-3 {
  background: #52b87a;
}
.lg-sw--urbanization-4 {
  background: #2e9e5a;
}
.lg-sw--urbanization-5 {
  background: #1a8040;
}
.lg-sw--urbanization-6 {
  background: #0f6030;
}
.lg-sw--urbanization-7 {
  background: #084020;
}
.lg-vals {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* v3 legend classes (fallback) */
.legend-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold, #c8a84b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.legend-bar {
  display: flex;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
}
.legend-swatch {
  flex: 1;
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 3px;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — open by default, premium feel
   ══════════════════════════════════════════════════════════════ */
.map-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: #fff;
  box-shadow: -6px 0 32px rgba(0, 0, 0, 0.28);
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(21, 34, 89, 0.2) transparent;
}
.map-sidebar.open {
  transform: translateX(0);
}

.sidebar-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}
.sidebar-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 1px;
}

.sidebar-empty {
  padding: 40px 18px;
  text-align: center;
  color: #8a8fa3;
  font-size: 0.82rem;
}
.sidebar-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 18px;
  color: #8a8fa3;
  font-size: 0.82rem;
}
.sidebar-loading::after {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid #e2e5f0;
  border-top-color: var(--navy, #152259);
  border-radius: 50%;
  animation: map-spin 0.7s linear infinite;
  margin-left: 8px;
}
@keyframes map-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ══════════════════════════════════════════════════════════════
   PANEL OVERVIEW — default country overview (v4)
   ══════════════════════════════════════════════════════════════ */
.panel-overview {
  padding: 0;
}

/* Hero block at top */
.panel-hero {
  background: linear-gradient(
    135deg,
    var(--navy, #152259) 0%,
    var(--navy-deep, #0e1740) 100%
  );
  padding: 28px 22px 22px;
  position: relative;
  overflow: hidden;
}
.panel-hero::before {
  content: "";
  position: absolute;
  top: -30%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(
    circle,
    rgba(200, 168, 75, 0.08) 0%,
    transparent 70%
  );
  border-radius: 50%;
  pointer-events: none;
}
.panel-hero-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 4px;
  line-height: 1.25;
  position: relative;
}
.panel-hero-sub {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
  position: relative;
}

/* KPI cards grid */
.panel-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 18px 12px;
}
.kpi-card {
  background: #f7f8fc;
  border-radius: 12px;
  padding: 14px 14px 12px;
  text-align: center;
  border: 1px solid #eef0f5;
  transition: all 0.2s;
}
.kpi-card:hover {
  border-color: rgba(200, 168, 75, 0.3);
  box-shadow: 0 2px 12px rgba(200, 168, 75, 0.1);
}
.kpi-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}
.kpi-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy, #152259);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-label {
  font-size: 0.65rem;
  color: #8a8fa3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Instruction hint */
.panel-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 6px 18px 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fdf8ed, #fef9f0);
  border-radius: 12px;
  border: 1px solid rgba(200, 168, 75, 0.2);
}
.panel-hint-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}
.panel-hint-text {
  font-size: 0.78rem;
  color: #5a5a6a;
  line-height: 1.45;
}

/* Section title */
.panel-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #8a8fa3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 18px;
  margin: 8px 0 10px;
}

/* Mini-list (top regions) */
.panel-mini-list {
  padding: 0 18px 18px;
}
.panel-mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}
.panel-mini-row:hover {
  background: #f0f2f9;
}
.panel-mini-row:active {
  background: #e4e7f2;
}
.panel-mini-rank {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--navy, #152259);
  color: var(--gold, #c8a84b);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel-mini-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy, #152259);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-mini-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-dark, #9a7a2e);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   REGION PANEL — header, kpis, tabs, contacts, news
   ══════════════════════════════════════════════════════════════ */

/* Region header */
.region-header {
  background: linear-gradient(
    135deg,
    var(--navy, #152259) 0%,
    var(--navy-deep, #0e1740) 100%
  );
  padding: 18px 22px 16px;
  position: relative;
}
.region-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.2s;
}
.region-back:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.region-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 12px;
  line-height: 1.25;
  padding-right: 36px;
}
.region-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.region-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.region-kpi-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold, #c8a84b);
  font-variant-numeric: tabular-nums;
}
.region-kpi-lbl {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Sidebar tabs (v4 slim) */
.stabs {
  display: flex;
  border-bottom: 2px solid #eef0f4;
  padding: 0 18px;
  background: #fafbfd;
}
.stab {
  flex: 1;
  padding: 11px 0;
  border: none;
  background: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8a8fa3;
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.stab:hover {
  color: var(--navy, #152259);
}
.stab.active {
  color: var(--navy, #152259);
  border-bottom-color: var(--gold, #c8a84b);
}

/* Tab pane */
.stab-pane {
  padding: 14px 18px;
}
.stab-pane.is-hidden {
  display: none;
}

/* Contact cards (v4) */
.ccard {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #f7f8fc;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  margin-bottom: 10px;
  border: 1px solid #eef0f5;
}
.ccard:hover {
  background: #eef0f7;
  border-color: rgba(200, 168, 75, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.ccard-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--navy, #152259);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.ccard-icon--gold {
  background: var(--gold, #c8a84b);
  color: var(--navy-deep, #0e1740);
}
.ccard-body {
  flex: 1;
  min-width: 0;
}
.ccard-type {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a8fa3;
  margin-bottom: 3px;
}
.ccard-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy, #152259);
  line-height: 1.35;
}
.ccard-url {
  font-size: 0.72rem;
  color: var(--gold, #c8a84b);
  word-break: break-all;
  margin-top: 2px;
}

/* News cards (v4) */
.ncard {
  display: flex;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 10px 0;
  border-bottom: 1px solid #f0f1f5;
  transition: opacity 0.15s;
}
.ncard:last-of-type {
  border-bottom: none;
}
.ncard:hover {
  opacity: 0.75;
}
.ncard-img {
  width: 64px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #eef0f4;
}
.ncard-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ncard-body {
  flex: 1;
  min-width: 0;
}
.ncard-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 3px;
  color: var(--navy, #152259);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ncard-body time {
  font-size: 0.65rem;
  color: #8a8fa3;
}

/* Panel link (bottom CTA) */
.panel-link {
  display: block;
  text-align: center;
  padding: 12px;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy, #152259);
  text-decoration: none;
  background: linear-gradient(135deg, #f0f3ff, #eef1fc);
  border-radius: 10px;
  transition: all 0.2s;
  border: 1px solid #e2e6f2;
}
.panel-link:hover {
  background: linear-gradient(135deg, #e2e8ff, #dde3fa);
  border-color: rgba(200, 168, 75, 0.3);
}

/* ══════════════════════════════════════════════════════════════
   POPUP — rich hover tooltip
   ══════════════════════════════════════════════════════════════ */
.ortcom-popup .maplibregl-popup-content {
  background: var(--navy, #152259);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: inherit;
  border: 1px solid rgba(200, 168, 75, 0.2);
}
.ortcom-popup .maplibregl-popup-tip {
  border-top-color: var(--navy, #152259);
}
.popup-inner {
}
.popup-name {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.2;
}
.popup-stats {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}
.popup-stats span {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   MapLibre overrides
   ══════════════════════════════════════════════════════════════ */
.maplibregl-ctrl-attrib {
  font-size: 10px !important;
}
.maplibregl-ctrl-group button {
  width: 34px !important;
  height: 34px !important;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .map-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 14px;
  }
  .map-header__stats {
    flex-wrap: wrap;
    gap: 10px;
  }
  .map-header__title {
    font-size: 0.9rem;
  }

  .map-layers {
    top: auto;
    bottom: 50px;
    left: 8px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .map-layer-btn {
    padding: 7px 10px;
    font-size: 0.72rem;
  }
  .map-legend {
    bottom: 8px;
    left: 8px;
    right: 8px;
    min-width: auto;
  }

  .map-sidebar {
    width: 100%;
    max-width: 100%;
    top: auto;
    bottom: 0;
    height: 65vh;
    transform: translateY(100%);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.2);
  }
  .map-sidebar.open {
    transform: translateY(0);
  }

  .panel-kpis {
    gap: 8px;
    padding: 12px 14px 10px;
  }
  .kpi-card {
    padding: 10px 10px 8px;
  }
  .kpi-val {
    font-size: 1rem;
  }

  .panel-hint {
    margin: 4px 14px 10px;
    padding: 10px 12px;
  }
  .panel-mini-row {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .panel-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .kpi-card {
    padding: 8px 8px 6px;
  }
  .kpi-val {
    font-size: 0.9rem;
  }
  .kpi-label {
    font-size: 0.6rem;
  }
}
