/* ==========================================================================
   <project-map> — interactive projects map (see project-map.js)
   ========================================================================== */

project-map {
  /* Map colours (read by project-map.js) */
  --map-low: var(--color-mint);
  --map-high: var(--color-navy);
  --map-empty: #dde3e8;
  --map-selected: var(--color-orange);
  --map-line: rgb(210 151 89 / 0.35); /* same sand outline as the filters */

  display: block;
  margin-top: clamp(1.25rem, 2.5vw, 2rem);
}

/* Once the script has loaded: map on the left, project list on the right */
project-map:defined {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
  gap: 1.25rem;
}

project-map [hidden] {
  display: none !important;
}

/* ---------- Map ---------- */

.project-map__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--map-line);
  border-radius: var(--radius);
  background: var(--color-white);
}

.project-map__canvas {
  flex: 1;
  display: grid;
  align-content: center;
}

.project-map__status {
  display: grid;
  place-items: center;
  aspect-ratio: 2.25; /* same shape as the map, so nothing jumps when it loads */
  color: var(--color-ink);
  font-size: 0.875rem;
}

.project-map__svg {
  width: 100%;
  height: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  touch-action: none;
}

.project-map__country {
  fill: var(--map-empty);
  stroke: var(--color-white);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
}

.project-map__country.has-projects {
  cursor: pointer;
}

.project-map__country.is-hover,
.project-map__country.is-selected {
  stroke: var(--color-ink);
  stroke-width: 1.4;
}

.project-map__fallback {
  padding: 1rem;
}

/* ---------- Legend + zoom buttons (below the map) ---------- */

.project-map__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-grey);
  font-size: 0.8125rem;
}

/* The legend's parts wrap individually, so on small screens the zoom
   buttons share the second row instead of getting a row of their own */
.project-map__legend {
  display: contents;
}

.project-map__legend-title {
  font-weight: 700;
}

.project-map__scale,
.project-map__legend-none {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.project-map__scale-bar {
  width: 7rem;
  height: 0.625rem;
  border-radius: 999px;
}

.project-map__swatch {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 3px;
  background: var(--map-empty);
}

.project-map__controls {
  display: flex;
  gap: 0.375rem;
  margin-left: auto;
}

.project-map__controls button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--map-line);
  border-radius: 8px;
  background: var(--color-white);
  color: var(--color-navy);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.project-map__controls button:hover:not(:disabled) {
  background: var(--color-grey);
}

.project-map__controls button:disabled {
  color: rgb(60 62 64 / 0.35);
  cursor: default;
}

.project-map__controls svg {
  width: 1rem;
  height: 1rem;
}

/* ---------- Tooltip ---------- */

.project-map__tooltip {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: var(--color-navy);
  box-shadow: var(--shadow-soft);
  color: var(--color-white);
  font-size: 0.8125rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
}

.project-map__tooltip.is-below {
  transform: translate(-50%, 20px);
}

.project-map__tooltip strong {
  display: block;
}

/* ---------- Side panel ---------- */

.project-map__panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--map-line);
  border-radius: var(--radius);
  background: var(--color-white);
}

/* Absolutely positioned so the panel is exactly as tall as the map and scrolls */
.project-map__panel-body {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
}

.project-map__panel-title {
  color: var(--color-navy);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  line-height: 1.25;
}

.project-map__panel-title:focus {
  outline: none;
}

.project-map__panel-text {
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.project-map__back {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 0.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-navy);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.project-map__back .icon {
  transform: scaleX(-1);
}

.project-map__back:hover {
  text-decoration: underline;
}

/* List of countries */

.project-map__country-list {
  display: grid;
  gap: 0.125rem;
  margin-top: 1rem;
}

.project-map__country-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
}

.project-map__country-button:hover,
.project-map__country-button.is-hover {
  background: var(--color-grey);
}

.project-map__count {
  min-width: 1.75rem;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: var(--color-mint);
  color: var(--color-black);
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: center;
}

/* Projects in the selected country */

.project-map__projects {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.project-map__project {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-grey);
  font-size: 0.8125rem;
}

.project-map__project-title {
  color: var(--color-black);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.35;
}

.project-map__project-title a:hover {
  text-decoration: underline;
}

.project-map__project-meta {
  margin-top: 0.3rem;
}

.project-map__project-programme {
  margin-top: 0.15rem;
  color: var(--color-navy);
  font-weight: 700;
}

.project-map__theme {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.15em 0.75em;
  border-radius: 999px;
  background: var(--color-mint);
  color: var(--color-black);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Small screens: list below the map ---------- */

@media (max-width: 900px) {
  project-map:defined {
    grid-template-columns: 1fr;
  }

  .project-map__panel-body {
    position: static;
    max-height: 26rem;
  }
}
