/*
  The impact map (/impact-map). Loaded only on that page.

  The look follows the pattern people already know from booking and property
  maps: a bright map, white cards with soft shadows floating over it, round
  white markers that turn dark when chosen. Every text colour below is checked
  against white for WCAG AA contrast.

  Layout in one line: on a wide screen the map fills the window and the list
  and the project card float over it; on a phone the map sits on top and the
  card and the list follow underneath in the normal page flow.
*/
.public-map {
  /* The open-sea blue of the pictures, shown while they load and at the edges. */
  --ocean: #124a80;
  --text: #1f2a28;
  --text-muted: #5b6663;
  --hairline: #e2e5e3;
  --wash: #f3f5f4;
  --shadow: 0 6px 24px rgba(8, 24, 40, 0.28), 0 1px 3px rgba(8, 24, 40, 0.18);
  /* One colour per pillar. Each also has its own icon, so colour is never
     the only thing telling them apart. */
  --education: #07539d;
  --basic-needs: #0a6c7e;
  --job-creation: #087a38;
}

.imap {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--text);
}
.imap a {
  color: inherit;
}
.public-map .imap :focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* Icons are line drawings; the colour comes from whatever they sit in. */
.imap-icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.imap-pillar-education { --pillar: var(--education); }
.imap-pillar-basic-needs { --pillar: var(--basic-needs); }
.imap-pillar-job-creation { --pillar: var(--job-creation); }

/* ------------------------------------------------------------ the map */
.imap-stage {
  position: relative;
  height: 68svh;
  min-height: 22rem;
  overflow: hidden;
  background: var(--ocean);
}
.imap-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.imap-js .imap-svg {
  cursor: grab;
}
.imap-js .imap-svg.is-dragging {
  cursor: grabbing;
}
/* A close-up fades in over the wider picture when it has finished loading. */
.imap-detail {
  opacity: 0;
  transition: opacity 0.6s ease;
}
.imap-detail.is-loaded {
  opacity: 1;
}

/* A slight darkening along the bottom edge only, so the picture credit
   stays readable over a bright sea. */
.imap-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 20, 26, 0.4), transparent 10%);
}

/* ------------------------------------------------------------ labels */
.imap-label {
  fill: #fff;
  font: 600 13px "Montserrat", Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  paint-order: stroke;
  stroke: rgba(6, 30, 52, 0.8);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.imap-label-town {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  display: none; /* town names only make sense zoomed in, which needs the script */
}
.imap-label.is-hidden {
  display: none;
}
.imap-js .imap-label-town:not(.is-hidden) {
  display: inline;
}

/* ------------------------------------------------------------ markers */
.imap-hit {
  fill: transparent;
}
/* A white disc with the pillar's icon. The chosen one turns dark. */
.imap-pin-disc {
  fill: #fff;
  stroke: rgba(8, 24, 40, 0.18);
  stroke-width: 1px;
  filter: drop-shadow(0 2px 3px rgba(8, 24, 40, 0.45));
  transition: fill 0.15s ease;
}
.imap-pin .imap-icon {
  color: var(--pillar, var(--text));
  stroke-width: 2;
}
.imap-pin:hover .imap-pin-disc {
  fill: var(--wash);
  stroke: var(--text);
  stroke-width: 2px;
}
.imap-pin[aria-current="true"] .imap-pin-disc {
  fill: var(--text);
  stroke: #fff;
  stroke-width: 2px;
}
.imap-pin[aria-current="true"] .imap-icon {
  color: #fff;
}
/* Only the chosen marker pulses, so the eye goes to it. */
.imap-pulse {
  display: none;
  fill: none;
  stroke: #fff;
  stroke-width: 3px;
  transform-box: fill-box;
  transform-origin: center;
  animation: imap-pulse 2s ease-out infinite;
}
.imap-pin[aria-current="true"] .imap-pulse {
  display: inline;
}
@keyframes imap-pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  75%, 100% { transform: scale(2.1); opacity: 0; }
}
.imap-pin-name {
  fill: #fff;
  font: 700 14px "Montserrat", Arial, sans-serif;
  paint-order: stroke;
  stroke: rgba(6, 30, 52, 0.9);
  stroke-width: 4px;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.imap-pin:hover .imap-pin-name,
.imap-pin:focus-visible .imap-pin-name,
.imap-pin[aria-current="true"] .imap-pin-name {
  opacity: 1;
}
/* SVG links get no focus ring from the page's own rule in every browser. */
.imap-pin:focus-visible,
.imap-cluster:focus-visible {
  outline: none;
}
.imap-pin:focus-visible .imap-hit,
.imap-cluster:focus-visible .imap-hit {
  stroke: var(--yellow);
  stroke-width: 4px;
}

/* Several projects too close together to show apart. Only the script can
   zoom in to separate them, so without it the separate markers show instead. */
.imap-cluster {
  display: none;
}
.imap-js .imap-cluster {
  display: inline;
}
.imap-cluster-count {
  fill: var(--text);
  font: 700 16px "Montserrat", Arial, sans-serif;
  pointer-events: none;
}
.imap-cluster:hover .imap-pin-disc {
  fill: var(--text);
}
.imap-cluster:hover .imap-cluster-count {
  fill: #fff;
}
.imap-pin.is-far,
.imap-pin.is-filtered,
.imap-cluster.is-split,
.imap-cluster.is-filtered {
  display: none;
}

/* ------------------------------------------------------------ controls on the map */
.imap-zoom {
  position: absolute;
  right: var(--gutter);
  bottom: 2.75rem;
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}
.imap-zoom[hidden],
.imap-tabs[hidden] {
  display: none;
}
.imap-zoom button {
  border: 0;
  background: #fff;
  color: var(--text);
  font: 700 0.9rem "Montserrat", Arial, sans-serif;
  cursor: pointer;
}
.imap-zoom button:hover {
  background: var(--wash);
}
.imap-zoom-home {
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
/* Plus above minus in one rounded block, as on most maps. */
.imap-zoom-pair {
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.imap-zoom-pair button {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.4rem;
  line-height: 1;
}
.imap-zoom-pair button + button {
  border-top: 1px solid var(--hairline);
}
.imap-zoom-pair button:focus-visible {
  outline-offset: -3px;
}
.imap-credit {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 0.6rem;
  margin: 0;
  font-size: 0.72rem;
  color: #fff;
  text-shadow: 0 0 4px #04141a, 0 0 2px #04141a;
}
.imap-credit a {
  color: #fff;
}

/* ------------------------------------------------------------ title, tabs, list */
.imap-intro {
  order: 2;
  padding: 1.5rem var(--gutter);
}
.imap-intro h1 {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.imap-lead {
  margin: 0 0 1rem;
  max-width: 34rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
/* A row of icon-over-word tabs with a line under the chosen one. */
.imap-tabs {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.25rem;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
}
.imap-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0 0.6rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font: 600 0.78rem "Montserrat", Arial, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}
.imap-tab:hover {
  color: var(--text);
  border-bottom-color: var(--hairline);
}
.imap-tab[aria-pressed="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}
.imap-list ul,
.imap-photos {
  margin: 0;
  padding: 0;
  list-style: none;
}
.imap-list a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.5rem;
  border-radius: 0.75rem;
  text-decoration: none;
}
.imap-list li + li a {
  box-shadow: 0 -1px 0 var(--hairline);
}
.imap-list a:hover,
.imap-list a[aria-current="true"] {
  background: var(--wash);
}
.imap-chip {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--wash);
  color: var(--pillar, var(--text));
}
.imap-list a[aria-current="true"] .imap-chip {
  background: var(--text);
  color: #fff;
}
.imap-list strong,
.imap-list small {
  display: block;
}
.imap-list strong {
  font-size: 0.95rem;
}
.imap-list small {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.imap-list li.is-filtered {
  display: none;
}

/* ------------------------------------------------------------ the project card */
.imap-panel {
  order: 1; /* on a phone the card comes straight after the map, before the list */
  scroll-margin-top: 1rem;
  border-bottom: 1px solid var(--hairline);
}
.imap:not(.has-card) .imap-panel {
  display: none;
}
/* The photo sits edge to edge at the top, with the round buttons over it. */
.imap-top {
  position: relative;
  background: var(--wash);
}
.imap-photos {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.imap-photos::-webkit-scrollbar {
  display: none;
}
.imap-photos li {
  flex: 0 0 100%;
  scroll-snap-align: start;
}
/* The photo is the main thing on the card: large, edge to edge, with the
   details underneath for anyone who scrolls on. */
.imap-photos img {
  display: block;
  width: 100%;
  height: auto;
  /* Square, because SR&C's photos are a mix of upright and sideways shots
     and a square crops either kind about equally. */
  aspect-ratio: 1;
  max-height: 62svh;
  object-fit: cover;
}
.public-map .imap .imap-photos:focus-visible {
  outline-offset: -3px;
}
.imap-no-photo {
  display: grid;
  place-items: center;
  height: 7.5rem;
  color: var(--pillar, var(--text-muted));
  background: color-mix(in srgb, var(--pillar, #888) 12%, #fff);
}
.imap-round {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: 400 1.5rem/1 "Montserrat", Arial, sans-serif;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(8, 24, 40, 0.35);
  cursor: pointer;
}
.imap-round[hidden] {
  display: none;
}
.imap-round:hover {
  background: #fff;
  transform: scale(1.06);
}
.imap-close {
  top: 0.75rem;
  right: 0.75rem;
}
.imap-photo-prev,
.imap-photo-next {
  top: calc(50% - 1.125rem);
}
.imap-photo-prev {
  left: 0.75rem;
}
.imap-photo-next {
  right: 0.75rem;
}
.imap-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.6rem;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  pointer-events: none;
}
.imap-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}
.imap-dots .is-on {
  background: #fff;
}
.imap-body {
  padding: 1rem var(--gutter) 1.25rem;
}
.imap-kicker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pillar, var(--text-muted));
}
.imap-card h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.imap-place {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}
.imap-summary {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}
/* The results: a big figure with its label beside it, one per line. */
.imap-facts {
  margin: 1rem 0 0;
  border-top: 1px solid var(--hairline);
}
.imap-facts div {
  display: flex;
  flex-direction: row-reverse; /* the figure reads first, its label after */
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--hairline);
}
.imap-facts dd {
  margin: 0;
  min-width: 3.2rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.imap-facts dt {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.imap-source {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.imap-source strong {
  color: var(--text);
}
.imap-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  margin: 1rem 0 0;
}
.imap-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1.4rem;
  border-radius: 0.6rem;
  background: var(--green);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
}
.imap-button:hover {
  background: #066a30;
}
.imap-text-link {
  font-size: 0.9rem;
  font-weight: 600;
}
.imap-walk {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.85rem;
}
.imap-walk a {
  padding: 0.4rem 0;
  color: var(--text-muted);
  text-decoration: none;
}
.imap-walk a:hover {
  color: var(--text);
  text-decoration: underline;
}
.imap-walk a:last-child {
  text-align: right;
}

/* ------------------------------------------------------------ wide screens: everything floats over the map */
@media (min-width: 900px) {
  /* The site header floats over the top of the map, as it does over the home page's picture. */
  .public-map .header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    background: rgba(8, 20, 22, 0.55); /* the same see-through bar as the home page */
  }
  .imap {
    display: block;
    height: 100svh;
    min-height: 44rem;
    overflow: hidden;
  }
  .imap-stage {
    position: absolute;
    inset: 0;
    height: auto;
  }
  /* The card may run a little taller than the list, to give the photo room. */
  .imap-panel {
    max-height: calc(100% - 8.25rem) !important;
  }
  .imap-intro,
  .imap-panel {
    position: absolute;
    top: 6.75rem;
    max-height: calc(100% - 9.75rem);
    overflow-y: auto;
    border: 0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .imap-intro {
    left: var(--gutter);
    width: min(23.5rem, 32vw);
    padding: 1.25rem 1.25rem 0.75rem;
  }
  .imap-panel {
    right: var(--gutter);
    width: min(25rem, 33vw);
    transition: transform 0.5s cubic-bezier(0.2, 0.65, 0.3, 1), opacity 0.35s ease;
  }
  .imap-body {
    padding: 1rem 1.25rem 1.1rem;
  }
  /* With no project chosen the card waits off the right-hand edge. */
  .imap:not(.has-card) .imap-panel {
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateX(120%);
  }
  .imap-zoom {
    bottom: 3rem;
    transition: right 0.5s cubic-bezier(0.2, 0.65, 0.3, 1);
  }
  /* Step aside so the open card does not cover the zoom buttons. */
  .imap.has-card .imap-zoom {
    right: calc(var(--gutter) + min(25rem, 33vw) + 1rem);
  }
}

/* People who have asked their device for less motion get a still map:
   no pulsing, no sliding card. The script also checks this
   and moves the camera in one step instead of flying. */
@media (prefers-reduced-motion: reduce) {
  .imap-pulse,
  .imap-panel,
  .imap-zoom,
  .imap-detail,
  .imap-pin-name,
  .imap-round {
    animation: none !important;
    transition: none !important;
  }
  .imap-pulse {
    display: none !important;
  }
  .imap-photos {
    scroll-behavior: auto;
  }
}
