/* Project Map front end.
   Colours come from --pm-* custom properties so themes can override them on .pmap. */

.pmap {
  --pm-side: 340px;
  --pm-radius-panel: 6px;
  --pm-radius-control: 3px;
  --pm-radius-chip: 2px;
  --pm-plate: #23272a;

  --pm-bg: #eef0f1;
  --pm-surface: #ffffff;
  --pm-ink: #23272a;
  --pm-muted: #687076;
  --pm-line: #d5dadd;
  --pm-hover: #eceff1;
  --pm-focus: #2d7db5;
  --pm-shadow: 0 14px 44px rgba(22, 26, 30, 0.26);
}

.pmap[data-theme="dark"] {
  --pm-bg: #16191c;
  --pm-surface: #1f2326;
  --pm-ink: #eef1f2;
  --pm-muted: #9aa3a9;
  --pm-line: #353b40;
  --pm-hover: #2a2f33;
  --pm-focus: #7fb8e0;
  --pm-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
}


.pmap {
  position: relative;
  display: grid;
  grid-template-columns: var(--pm-side) minmax(0, 1fr);
  height: var(--pm-height, 720px);
  overflow: hidden;
  background: var(--pm-bg);
  color: var(--pm-ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.pmap *, .pmap *::before, .pmap *::after { box-sizing: border-box; }
/* Neutralise theme element styles (uppercase headings, floated nav items, padded sections, list bullets).
   ".pmap :where(...)" weighs exactly one class: it beats theme element selectors such as "nav li" or "section",
   while the component classes below (also one class, declared later) still win. */
.pmap :where(h1, h2, h3, p, ul, ol, li, dl, dt, dd, figure, figcaption, section, nav, aside, header, article) {
  float: none; width: auto; min-height: 0;
  margin: 0; padding: 0; border: 0;
  font: inherit; color: inherit; text-transform: none; letter-spacing: normal; line-height: inherit;
  list-style: none; background: none; overflow: visible;
}
.pmap :where(button, input, select) {
  font: inherit; color: inherit; text-transform: none; letter-spacing: normal;
  box-shadow: none; min-height: 0; margin: 0; float: none;
}
.pmap :where(img) { max-width: none; height: auto; border: 0; box-shadow: none; }
.pmap :where(a) { text-decoration: none; }
.pmap :focus-visible { outline: 2px solid var(--pm-focus); outline-offset: 2px; }

.pm-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- sidebar */

.pmap-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pm-surface);
  border-right: 1px solid var(--pm-line);
  position: relative;
  z-index: 2;
}

.pm-sheet-handle { display: none; }

.pmap-head { padding: 24px 20px 14px; }
.pmap-title { margin: 0; font-size: 23px; line-height: 1.15; font-weight: 800; letter-spacing: -0.015em; }
.pmap-count { margin: 4px 0 0; color: var(--pm-muted); font-variant-numeric: tabular-nums; }

.pmap-search { padding: 0 20px 14px; }
.pmap-search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--pm-line);
  border-radius: var(--pm-radius-control);
  background: var(--pm-bg) no-repeat 12px 50% / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23879096' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
}
.pmap-search input::placeholder { color: var(--pm-muted); }

.pmap-systems { padding: 0 20px 14px; border-bottom: 1px solid var(--pm-line); }
.pm-systems-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; color: var(--pm-muted); font-size: 12.5px; font-weight: 700; }
.pm-link { border: 0; background: none; padding: 0; color: var(--pm-ink); font-size: 12.5px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.pm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-chip {
  padding: 5px 8px;
  border: 1px solid var(--pm-line);
  border-radius: var(--pm-radius-chip);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.pm-chip:hover { border-color: var(--pm-muted); }
.pm-chip[aria-pressed="true"] { background: var(--pm-ink); border-color: var(--pm-ink); color: var(--pm-surface); }
.pm-chip-more { border-style: dashed; color: var(--pm-muted); }

.pmap-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0 24px; overscroll-behavior: contain; }

.pm-group + .pm-group { margin-top: 4px; }
.pm-group-head {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 20px 6px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.pm-group-count { color: var(--pm-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.pm-group-head[aria-pressed="false"] { color: var(--pm-muted); }
.pm-group-head[aria-pressed="false"] .pm-swatch { opacity: 0.3; }
.pm-group-head[aria-pressed="false"] .pm-group-count::after { content: ' (gizli)'; }

.pm-swatch { display: inline-block; width: 4px; height: 16px; border-radius: 1px; background: var(--c); flex: none; }

.pm-items { list-style: none; margin: 0; padding: 0; }
.pm-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 8px 20px 8px 34px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}
.pm-item small { display: block; margin-top: 2px; color: var(--pm-muted); font-size: 12px; font-weight: 400; }
.pm-item:hover, .pm-item.is-hover { background: var(--pm-hover); }
.pm-item[aria-current="true"] { background: var(--pm-hover); }
.pm-item[aria-current="true"]::before {
  content: '';
  position: absolute;
  left: 20px; top: 8px; bottom: 8px;
  width: 4px;
  border-radius: 1px;
  background: var(--c);
}

.pm-empty { padding: 22px 20px; color: var(--pm-muted); }
.pm-empty p { margin: 0 0 10px; }

/* ---------------------------------------------------------------- map */

.pmap-stage { position: relative; min-width: 0; overflow: hidden; }
.pmap-map { position: absolute; inset: 0; background: var(--pm-bg); }
.pmap .leaflet-container { font-family: inherit; background: var(--pm-bg); }
.pmap .leaflet-control-attribution { font-size: 11px; background: color-mix(in srgb, var(--pm-surface) 82%, transparent); color: var(--pm-muted); }
.pmap .leaflet-control-attribution a { color: var(--pm-ink); }

.pmap .leaflet-bar { border: 0; border-radius: var(--pm-radius-control); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); overflow: hidden; }
.pmap .leaflet-bar a, .pm-map-btn {
  width: 36px; height: 36px; line-height: 36px;
  background: var(--pm-surface); color: var(--pm-ink); border-color: var(--pm-line);
}
.pmap .leaflet-bar a:hover { background: var(--pm-hover); color: var(--pm-ink); }
.pm-fit-control .pm-map-btn {
  display: block; width: auto; padding: 0 12px;
  border: 0; font-size: 13px; font-weight: 700; cursor: pointer;
}

.pm-tiles-soft { filter: grayscale(1) contrast(0.92) brightness(1.04); }
.pm-tiles-dark { filter: grayscale(1) invert(1) contrast(0.86) brightness(0.92); }

/* Marker: a slim vertical column that grows and shows its name when selected */
.pm-marker { background: none; border: 0; }
.pm-pin { position: absolute; inset: 0; }
.pm-col {
  position: absolute;
  left: 3px; bottom: 5px;
  width: 8px; height: 22px;
  background: var(--c);
  border: 1.5px solid #fff;
  border-radius: 1.5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: height 0.18s ease, width 0.18s ease, left 0.18s ease;
}
.pm-col::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -6px;
  width: 2px; height: 5px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.pm-label {
  position: absolute;
  left: 15px; bottom: 14px;
  padding: 6px 9px 6px 8px;
  border-left: 3px solid var(--c);
  background: var(--pm-plate);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.pm-marker:hover .pm-label, .pm-marker:focus-visible .pm-label,
.pm-marker.is-hover .pm-label, .pm-marker.is-active .pm-label { opacity: 1; transform: none; }
.pm-marker.is-hover .pm-col, .pm-marker:hover .pm-col { height: 28px; }
.pm-marker.is-active .pm-col { left: 2px; width: 10px; height: 42px; }
.pm-marker.is-active .pm-label { bottom: 30px; }

/* Cluster: the bottom strip shows the share of each region inside */
.pm-cluster-wrap { background: none; border: 0; }
.pm-cluster {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%; height: 100%;
  padding-bottom: 5px;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 3px;
  background: var(--pm-plate);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.32);
  transition: transform 0.15s ease;
}
.pm-cluster-wrap:hover .pm-cluster { transform: scale(1.06); }
.pm-cluster-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; display: flex; }
.pm-cluster-bar i { display: block; height: 100%; }

/* ---------------------------------------------------------------- detail panel */

.pmap-detail {
  position: absolute;
  top: 14px; right: 14px; bottom: 14px;
  z-index: 1000;
  width: 400px;
  max-width: calc(100% - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--pm-radius-panel);
  background: var(--pm-surface);
  box-shadow: var(--pm-shadow);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease, visibility 0s linear 0s;
}
.pmap-detail:not(.is-open) {
  visibility: hidden;
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0s linear 0.2s;
}

.pm-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: var(--pm-radius-control);
  background: rgba(22, 25, 28, 0.72); color: #fff;
  cursor: pointer;
}
.pm-close svg, .pm-hero-nav svg, .pm-lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pm-hero { position: relative; margin: 0; aspect-ratio: 4 / 3; background: #2a2e32; }
.pm-hero-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.pm-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pm-hero-nav {
  position: absolute; top: 50%; z-index: 2;
  display: grid; place-items: center;
  width: 36px; height: 36px; margin-top: -18px;
  border: 0; border-radius: var(--pm-radius-control);
  background: rgba(22, 25, 28, 0.62); color: #fff;
  cursor: pointer;
}
.pm-hero-prev { left: 10px; }
.pm-hero-next { right: 10px; }
.pm-hero-counter {
  position: absolute; left: 10px; bottom: 10px;
  margin: 0; padding: 4px 8px;
  border-radius: var(--pm-radius-chip);
  background: rgba(22, 25, 28, 0.72); color: #fff;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pm-hero.is-empty {
  display: flex; align-items: flex-end;
  padding: 18px 20px;
  background:
    linear-gradient(90deg, transparent 0 55%, rgba(255, 255, 255, 0.09) 55% calc(55% + 2px), transparent 0),
    linear-gradient(90deg, transparent 0 63%, rgba(255, 255, 255, 0.09) 63% calc(63% + 2px), transparent 0),
    linear-gradient(180deg, transparent 0 22%, rgba(255, 255, 255, 0.09) 22% calc(22% + 2px), transparent 0),
    #2a2e32;
  color: #c5ccd1;
  font-size: 13px;
}

.pm-thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 20px 2px; scrollbar-width: thin; }
.pm-thumb { flex: none; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: var(--pm-radius-chip); background: #2a2e32; cursor: pointer; overflow: hidden; }
.pm-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0.72; }
.pm-thumb[aria-current="true"] { border-color: var(--pm-ink); }
.pm-thumb[aria-current="true"] img, .pm-thumb:hover img { opacity: 1; }

.pm-body { padding: 16px 20px 24px; }
.pm-region { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--pm-muted); font-size: 13px; font-weight: 700; }
.pm-name { margin: 6px 0 18px; font-size: 21px; line-height: 1.22; font-weight: 800; letter-spacing: -0.005em; outline: none; }

.pm-facts { margin: 0 0 20px; }
.pm-facts dt { color: var(--pm-muted); font-size: 12.5px; font-weight: 700; }
.pm-facts dd { margin: 6px 0 0; }
.pm-facts dd .pm-chips { gap: 6px; }
.pm-facts dd + dt { margin-top: 12px; }
.pm-desc { margin: 0 0 20px; color: var(--pm-ink); }
.pm-desc p + p { margin-top: 10px; }

.pm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pm-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--pm-line);
  border-radius: var(--pm-radius-control);
  background: transparent;
  color: var(--pm-ink);
  font-size: 13px; font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.pm-btn:hover { border-color: var(--pm-muted); }
.pm-btn-primary { background: var(--pm-ink); border-color: var(--pm-ink); color: var(--pm-surface); }
.pm-btn-primary:hover { background: color-mix(in srgb, var(--pm-ink) 86%, var(--pm-surface)); }

.pm-toast {
  position: absolute; left: 50%; bottom: 24px; z-index: 1200;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: var(--pm-radius-control);
  background: var(--pm-ink); color: var(--pm-surface);
  font-weight: 700;
  box-shadow: var(--pm-shadow);
}

/* ---------------------------------------------------------------- consent */

.pmap-consent {
  position: absolute; inset: 0; z-index: 1100;
  display: grid; place-items: center;
  padding: 20px;
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, color-mix(in srgb, var(--pm-line) 70%, transparent) 79px 80px),
    repeating-linear-gradient(180deg, transparent 0 79px, color-mix(in srgb, var(--pm-line) 70%, transparent) 79px 80px),
    var(--pm-bg);
}
.pmap-consent[hidden] { display: none; }
.pm-consent-card { max-width: 380px; padding: 24px; border-radius: var(--pm-radius-panel); background: var(--pm-surface); box-shadow: var(--pm-shadow); }
.pm-consent-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.pm-consent-card p { margin: 0 0 18px; color: var(--pm-muted); }
.pm-check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; cursor: pointer; }

/* ---------------------------------------------------------------- lightbox */

.pm-lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(14, 16, 18, 0.96); color: #fff;
  font-family: inherit;
}
.pm-lightbox::backdrop { background: rgba(14, 16, 18, 0.6); }
.pm-lightbox[open] { display: grid; place-items: center; }
.pm-lightbox img { max-width: 92vw; max-height: 84dvh; object-fit: contain; }
.pm-lb-btn {
  position: absolute; display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08); color: #fff;
  cursor: pointer;
}
.pm-lb-btn:hover { background: rgba(255, 255, 255, 0.16); }
.pm-lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pm-lb-close { top: 16px; right: 16px; }
.pm-lb-prev { left: 16px; top: 50%; margin-top: -22px; }
.pm-lb-next { right: 16px; top: 50%; margin-top: -22px; }
.pm-lb-caption { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: #c5ccd1; }

/* ---------------------------------------------------------------- mobile */

@media (max-width: 859px) {
  .pmap { display: block; height: max(var(--pm-height, 720px), 560px); }
  .pmap-stage { position: absolute; inset: 0; }

  .pmap-side {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 900;
    height: 42%;
    border-right: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    transition: height 0.26s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .pmap-side.is-expanded { height: 88%; }

  .pm-sheet-handle {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 100%; padding: 8px 0 0;
    border: 0; background: none; cursor: pointer;
  }
  .pm-sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--pm-line); }
  .pm-sheet-label { color: var(--pm-muted); font-size: 12px; font-weight: 700; }

  .pmap-head { display: flex; align-items: baseline; gap: 10px; padding: 6px 16px 10px; }
  .pmap-title { font-size: 19px; }
  .pmap-count { margin: 0; }
  .pmap-search, .pmap-systems { padding-left: 16px; padding-right: 16px; }
  .pmap-systems .pm-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .pmap-systems .pm-chips::-webkit-scrollbar { display: none; }
  .pm-group-head { padding-left: 16px; padding-right: 16px; }
  .pm-item { padding-left: 30px; padding-right: 16px; }
  .pm-item[aria-current="true"]::before { left: 16px; }

  .pmap-detail {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-width: none; height: 64%;
    border-radius: 12px 12px 0 0;
  }
  .pmap-detail:not(.is-open) { transform: translateY(40px); }

  .pm-toast { bottom: calc(42% + 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .pmap *, .pmap *::before, .pmap *::after { transition: none !important; animation: none !important; }
}

.pmap-notice { padding: 12px 16px; border-left: 4px solid #d39a12; background: #fff8e6; }
