/**
 * Sitemap (/sitemap, contrib module "sitemap"): horizontal tree of blue boxes.
 * Markup: .sitemap-item--menu-* > div > ul > li > (a|span) + ul
 * Connectors: li::after = vertical line, li::before = horizontal tick.
 */
.sitemap .sitemap-plugin--menu {
  --sm-w: 300px;          /* box width */
  --sm-gap: 20px;         /* indent between levels */
  --sm-space: 10px;       /* vertical space between boxes */
  --sm-pad: 10px;         /* box padding */
  --sm-tick: calc(var(--sm-pad) + 0.7em); /* y of the box's first text line centre */
  --sm-line: #ccc;
  --sm-bg: var(--bs-primary, #3974ba);
  --sm-bg-hover: #2b5a92;
  --sm-bg-active: #1f4373;
  font-family: 'Onest', sans-serif;
  margin-bottom: 2rem;
}

.sitemap .sitemap-plugin--menu ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--sm-gap);
}

.sitemap .sitemap-plugin--menu li {
  position: relative;
  display: flex;
  align-items: flex-start;
  margin: 0 0 var(--sm-space);
  padding: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.sitemap .sitemap-plugin--menu li > a,
.sitemap .sitemap-plugin--menu li > span {
  display: block;
  flex: 0 0 var(--sm-w);
  width: var(--sm-w);
  box-sizing: border-box;
  padding: var(--sm-pad);
  border-radius: 3px;
  background: var(--sm-bg);
  color: #fff;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.sitemap .sitemap-plugin--menu li > a:hover {
  background: var(--sm-bg-hover);
  color: #fff;
  text-decoration: underline;
}

.sitemap .sitemap-plugin--menu li > a:focus-visible {
  outline: 3px solid #0b2545;
  outline-offset: 2px;
  color: #fff;
}

.sitemap .sitemap-plugin--menu li > a.is-active {
  background: var(--sm-bg-active);
  text-decoration: underline;
}

/* Child list sits to the right of the parent box. */
.sitemap .sitemap-plugin--menu li > ul {
  flex: 1 1 auto;
  min-width: 0;
}

/* Connector lines. */
.sitemap .sitemap-plugin--menu li::before,
.sitemap .sitemap-plugin--menu li::after {
  content: "";
  position: absolute;
  background: var(--sm-line);
}

/* Tick into the box. */
.sitemap .sitemap-plugin--menu li::before {
  top: var(--sm-tick);
  left: calc(var(--sm-gap) / -2);
  width: calc(var(--sm-gap) / 2);
  height: 1px;
}

/* First child: the tick also bridges the gap from the parent box. */
.sitemap .sitemap-plugin--menu ul ul > li:first-child::before {
  left: calc(var(--sm-gap) * -1);
  width: var(--sm-gap);
}

/* Vertical line: through the item and the space below it. */
.sitemap .sitemap-plugin--menu li::after {
  top: 0;
  bottom: calc(var(--sm-space) * -1);
  left: calc(var(--sm-gap) / -2);
  width: 1px;
}

.sitemap .sitemap-plugin--menu li:first-child::after {
  top: var(--sm-tick);
}

/* Last child: stop the line at its tick. */
.sitemap .sitemap-plugin--menu li:last-child::after {
  bottom: auto;
  height: var(--sm-tick);
}

.sitemap .sitemap-plugin--menu li:first-child:last-child::after {
  display: none;
}

/* Tablet: shrink boxes so three levels fit without overflow. */
@media (max-width: 1199.98px) {
  .sitemap .sitemap-plugin--menu {
    --sm-w: 250px;
  }
}

@media (max-width: 991.98px) {
  .sitemap .sitemap-plugin--menu {
    --sm-w: 205px;
    --sm-gap: 16px;
  }

  .sitemap .sitemap-plugin--menu li {
    font-size: 0.9375rem;
  }
}

/* Mobile: vertical indented tree, full-width boxes. */
@media (max-width: 767.98px) {
  .sitemap .sitemap-plugin--menu {
    --sm-gap: 16px;
  }

  .sitemap .sitemap-plugin--menu li {
    display: block;
  }

  .sitemap .sitemap-plugin--menu li > a,
  .sitemap .sitemap-plugin--menu li > span {
    width: auto;
  }

  .sitemap .sitemap-plugin--menu li > ul {
    margin-top: var(--sm-space);
  }

  /* Children hang below the parent box: plain ticks, line starts at the box bottom. */
  .sitemap .sitemap-plugin--menu ul ul > li:first-child::before {
    left: calc(var(--sm-gap) / -2);
    width: calc(var(--sm-gap) / 2);
  }

  .sitemap .sitemap-plugin--menu ul ul > li:first-child::after {
    top: calc(var(--sm-space) * -1);
  }

  .sitemap .sitemap-plugin--menu ul ul > li:first-child:last-child::after {
    display: block;
    height: calc(var(--sm-tick) + var(--sm-space));
  }

  /* Last child: line stops at its own tick (top is 0, or -space for a first child). */
  .sitemap .sitemap-plugin--menu ul ul > li:first-child:last-child::after,
  .sitemap .sitemap-plugin--menu li:last-child::after {
    bottom: auto;
  }
}
