/* QEA Local Stories — component styles.
   ---------------------------------------------------------------
   Every colour, radius and font lives in the custom properties
   below. To match the QEA site exactly, retune this one block; no
   rule further down hardcodes a brand colour. */

.qea-root {
  /* --- brand palette ---
     Sampled from the QEA Local Stories page so the component sits on
     that page without a seam. Retune here; nothing below hardcodes a
     brand colour. */
  --qea-page: #1e1e7f;        /* page behind the component */
  --qea-ink: #ffffff;         /* titles */
  --qea-ink-soft: #9698dd;    /* body copy, labels, counts */
  --qea-accent: #ff527e;      /* markers, active chip, type pill, CTA */
  --qea-accent-dark: #eaecff; /* text on the tinted surface, links */
  --qea-accent-tint: #3c3c90; /* technology pill, selected card */
  --qea-surface: #262784;     /* cards, popup */
  --qea-surface-alt: #2f2e8a; /* map backdrop, popup sections */
  --qea-chip: #2f2e8a;        /* unselected filter chip */
  --qea-border: #343593;
  --qea-divider: #4446ad;      /* map / sidebar split, and rule lines */
  --qea-label: #b8bbf1;       /* EXPLORE / TYPE / TECHNOLOGY */
  --qea-popup: #2b2bad;       /* popup panel, brighter than the cards */
  --qea-scrim: rgba(10, 10, 60, 0.55);
  --qea-focus: #a0b4ff;       /* also the water colour on the basemap */

  /* --- type --- */
  --qea-font: inherit;
  --qea-size-base: 15px;
  --qea-size-small: 13px;

  /* --- shape & rhythm --- */
  --qea-radius: 8px;
  --qea-gap: 20px;
  /* Breathing room inside the story column. The map stays edge to edge,
     as on the QEA page; it is the panel beside it that needs the room. */
  --qea-pad: 28px;
  --qea-pad-mobile: 18px;

  /* --- layout ---
     The component fills whatever box it is given: set the height on the
     Embed (or its parent) in Webflow and everything below follows. No
     code change needed to resize it.

     --qea-min-height is only a floor for the case where NO ancestor
     declares a height — `height: 100%` resolves to `auto` there, which
     would otherwise collapse the map to nothing. Set it to 0 if you
     want a short container to win outright. */
  /* The story column is the sized one and the map takes what's left.
     26% of a wide screen, but never below --qea-sidebar-min — a flat
     percentage on a small screen would give the cards less width than
     their own images. The max() means the sidebar holds its proportion
     on a large monitor and quietly claims a bigger share as the screen
     shrinks, with no breakpoint to maintain. */
  --qea-sidebar: max(26%, var(--qea-sidebar-min));
  --qea-sidebar-min: 320px;
  --qea-min-height: 560px;
  --qea-map-height-mobile: 340px;

  font-family: var(--qea-font);
  font-size: var(--qea-size-base);
  color: var(--qea-ink);
  line-height: 1.5;
  box-sizing: border-box;

  /* Fill the host box in both axes. See --qea-min-height above for the
     auto-height fallback. */
  width: 100%;
  height: 100%;
  min-height: var(--qea-min-height);
  display: flex;
  flex-direction: column;
  background: var(--qea-page);
}
.qea-root *,
.qea-root *::before,
.qea-root *::after { box-sizing: inherit; }

/* ============================= layout ============================= */

.qea-layout {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  /* Takes the root's full height. min-height:0 lets the flex children
     shrink below their content, which is what allows the list to scroll
     internally rather than pushing the component taller than its box. */
  flex: 1 1 auto;
  min-height: 0;
  /* Prevents the flex children from forcing the page wider than the
     viewport when a long story title can't wrap. */
  max-width: 100%;
  overflow: hidden;
}

.qea-mapcol {
  /* Takes whatever the story column leaves. */
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  border-radius: var(--qea-radius);
  overflow: hidden;
  background: var(--qea-surface-alt);
}

.qea-map { width: 100%; height: 100%; }



.qea-listcol {
  flex: 0 0 var(--qea-sidebar);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--qea-pad) var(--qea-pad) 0;
  border-left: 1px solid var(--qea-divider);
}

/* ============================ filters ============================= */

.qea-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--qea-divider);
}

.qea-filters__row { display: flex; flex-direction: column; gap: 7px; }

.qea-filters__label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--qea-label);
}

.qea-filters__group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qea-chip {
  font: inherit;
  font-size: var(--qea-size-small);
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--qea-chip);
  color: #e4e7ff;
  cursor: pointer;
}
.qea-chip:hover { border-color: var(--qea-accent); }

/* Selected filter carries weight + fill, not colour alone. */
.qea-chip[aria-pressed="true"] {
  background: var(--qea-accent);
  border-color: var(--qea-accent);
  color: #fff;
  font-weight: 600;
}

/* "EXPLORE / 31 of 31 stories" — the count of what the filters leave
   in view, against the size of the whole collection. */
.qea-count {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.qea-count__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--qea-label);
}
.qea-count__value {
  font-size: 26px;
  line-height: 1.15;
  color: var(--qea-ink-soft);
}
.qea-count__value strong {
  font-weight: 700;
  color: var(--qea-ink);
}

/* ========================== the story list ======================== */

.qea-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  /* flex-basis 0, not auto: the cards must not contribute their own
     height to the layout. With `auto` the list reports its full content
     height, which in a container that has no height of its own pushes
     the whole component (and the map beside it) to the height of every
     card stacked up — 1769px for six stories. At 0 the list takes the
     space left over and scrolls, and an auto-height host settles at
     --qea-min-height instead. */
  flex: 1 1 0;
  min-height: 0;
  /* Keeps momentum scrolling inside the list on touch instead of
     dragging the whole page. */
  -webkit-overflow-scrolling: touch;
}
.qea-list > li { margin: 0 0 12px; }
.qea-list > li:last-child { margin-bottom: var(--qea-pad); }

.qea-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0;
  cursor: pointer;
  background: var(--qea-surface);
  border: 1px solid var(--qea-border);
  /* The left edge is the non-colour selection cue — transparent here,
     solid when selected, so the card visibly shifts even in greyscale
     or for a colour-blind visitor. */
  border-left: 4px solid transparent;
  border-radius: var(--qea-radius);
  overflow: hidden;
}
.qea-card:hover { border-color: var(--qea-accent); }

.qea-card.is-selected {
  border-color: var(--qea-accent);
  border-left-color: var(--qea-accent);
  background: var(--qea-accent-tint);
}
.qea-card.is-selected .qea-card__title { font-weight: 700; }

.qea-card__img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: var(--qea-surface-alt);
}

.qea-card__body { padding: 12px 14px; }

.qea-card__title {
  margin: 0 0 2px;
  font-size: var(--qea-size-base);
  font-weight: 600;
  color: var(--qea-ink);
}

.qea-card__loc,
.qea-popup__loc {
  margin: 0 0 8px;
  font-size: var(--qea-size-small);
  color: var(--qea-ink-soft);
}

.qea-card__summary {
  margin: 8px 0 0;
  font-size: var(--qea-size-small);
  color: var(--qea-ink-soft);
}

.qea-card__pills { display: flex; flex-wrap: wrap; gap: 4px; }

.qea-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.qea-pill--type { background: var(--qea-accent); color: #fff; }
.qea-pill--tech {
  background: var(--qea-accent-tint);
  color: var(--qea-accent-dark);
}

.qea-empty {
  font-size: var(--qea-size-small);
  color: var(--qea-ink-soft);
  padding: 8px 0;
}

/* ============================= markers ============================
   NOTE: .qea-marker must never be given `position` of its own —
   MapLibre applies an inline transform to this element and its own
   positioning has to win. (Learned the hard way in the sibling
   rewiring-nz maps.) */

.qea-marker {
  display: block;
  width: 26px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
}
.qea-marker.is-hidden { display: none; }

.qea-marker__pin {
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto;
  background: var(--qea-accent);
  border: 0;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  position: relative;
}
/* The white centre, as on the old map. */
.qea-marker__pin::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: #fff;
}
.qea-marker.is-selected .qea-marker__pin::after { width: 10px; height: 10px; margin: -5px 0 0 -5px; }

/* Selected marker changes SIZE as well as colour, so the cue survives
   greyscale. */
.qea-marker.is-selected { width: 34px; height: 44px; z-index: 2; }
.qea-marker.is-selected .qea-marker__pin {
  width: 28px;
  height: 28px;
  background: var(--qea-accent);
  border-width: 3px;
}

/* ============================== popup ============================= */

.qea-popup .maplibregl-popup-content {
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  background: var(--qea-popup);
}
.qea-popup .maplibregl-popup-tip { border-top-color: var(--qea-popup); }

.qea-popup__inner { position: relative; outline: none; }

/* The popup is sized in JS, but it must never be wider than the map
   that clips it — on a narrow map the fixed width would hang off both
   sides. */
.qea-popup .maplibregl-popup-content { max-width: 100%; }
.qea-popup__inner:focus-visible { outline: 3px solid var(--qea-focus); }

/* Sized against the map container, not the viewport — see the
   popupMaxHeight() note in stories.js. */
.qea-popup__scroll {
  max-height: var(--qea-popup-max, 320px);
  overflow-y: auto;
}

.qea-popup__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  border: 0;
  border-radius: 50%;
  /* Dark disc on the hero image, where a white one disappeared against
     a bright photo. */
  background: rgba(12, 12, 48, 0.62);
  color: #fff;
  cursor: pointer;
}
.qea-popup__close:hover { background: rgba(12, 12, 48, 0.85); }

.qea-popup__img {
  display: block;
  width: 100%;
  height: 290px;
  object-fit: cover;
  background: var(--qea-surface-alt);
}

.qea-popup__body { padding: 22px 24px 26px; }
.qea-popup__body .qea-card__pills { gap: 6px; margin-bottom: 4px; }

/* The popup is the focus while it is open, so the rest is dimmed — the
   same treatment as the old map. */
.qea-root.has-popup .qea-listcol { opacity: 0.55; transition: opacity 0.15s; }

.qea-popup__title {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--qea-ink);
}
/* When there is a location line it sits between the two, so the title's
   own gap would double up. */
.qea-popup__title + .qea-popup__loc { margin-top: -6px; }

.qea-popup__summary {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.6;
  color: #ccd0f5;
}

.qea-detail__section {
  margin-top: 18px;
  padding-top: 0;
  border-top: 0;
}

.qea-detail__heading {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--qea-accent);
}

.qea-detail__rich {
  font-size: 15px;
  line-height: 1.6;
  color: #eef0ff;
}
.qea-detail__rich p { margin: 0 0 10px; }
.qea-detail__rich ul, .qea-detail__rich ol { margin: 0 0 10px; padding-left: 20px; }
.qea-detail__rich li { margin: 0 0 6px; }
.qea-detail__rich p:last-child { margin-bottom: 0; }
.qea-detail__rich img { max-width: 100%; height: auto; border-radius: 4px; }
.qea-detail__rich a { color: var(--qea-accent-dark); }

/* ========================= focus visibility =======================
   A single consistent focus ring across every interactive element,
   strong enough to see against both the white list and the map. */

.qea-root :focus-visible,
.qea-marker:focus-visible {
  outline: 3px solid var(--qea-focus);
  outline-offset: 2px;
}

/* ============================== mobile ============================ */

@media (max-width: 800px) {
  /* Stacked, the component stops filling its container and grows with
     its content instead. This is deliberate, and it is the one place the
     host's height is treated as a minimum rather than the box to fit.

     The filter chips are why. At 375px they wrap to roughly 280px of
     rows; with a 340px map above them, a 720px container leaves the
     story list a 48px window — three cards' worth of content in a slot
     too short for one. Every height a phone actually has is too short
     for a fixed layout here, so the list runs down the page and the
     page scrolls, which is what a phone is good at. */
  .qea-root {
    height: auto;
    min-height: 0;
  }

  .qea-layout {
    flex-direction: column;
    gap: 0;
    overflow: visible;
  }

  .qea-listcol {
    padding: var(--qea-pad-mobile) var(--qea-pad-mobile) 0;
    border-left: 0;
    border-top: 1px solid var(--qea-divider);
  }

  .qea-mapcol {
    /* The map takes a fixed slice off the top and the list takes the
       rest of the container, rather than the map being sized and the
       list running on down the page. Accepts a percentage too, if you
       would rather the split scaled with the container. */
    flex: 0 0 var(--qea-map-height-mobile);
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .qea-listcol {
    /* Grows with its content rather than scrolling inside a fixed
       share — two nested scroll regions on a phone is miserable. The
       sidebar width doesn't apply once the columns stack. */
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
  }

  .qea-list {
    flex: 0 0 auto;
    overflow-y: visible;
  }

  .qea-filters__row { flex-direction: column; gap: 5px; }
  .qea-filters__label { width: auto; }

}

@media (prefers-reduced-motion: reduce) {
  .qea-root * { animation: none !important; transition: none !important; }
}
