/**
 * @file
 * Primary, footer and inline menus.
 *
 * The old primary menu put ten uppercase links in a single row with a fixed
 * 32px right margin each — they wrapped and collided between 992px and 1200px.
 * Here the primary menu carries the five wayfinding links; the five external
 * council links move to the utility bar and footer, which is where visitors
 * expect them and where they stop competing with event navigation.
 */

.menu--main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3xs) var(--space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu--main .menu__link {
  position: relative;
  display: block;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: var(--step--1);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

/**
 * THE UNDERLINE IS ALWAYS THERE; IT JUST HAS NO WIDTH YET.
 *
 * A hover state that only changes colour tells you what you are pointing at
 * after you have already pointed at it. A rule that grows out from under the
 * word as the pointer arrives — and stays, at full width, on the page you are
 * on — says which item is which before and after the click, and it is the same
 * mark in both cases rather than two unrelated effects.
 *
 * Drawn on a pseudo-element and scaled rather than animated in width, so it
 * runs on the compositor and cannot reflow the menu.
 */
.menu--main .menu__link::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-xs);
  inset-block-end: 0.35rem;
  block-size: 2px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--me-magenta) 0%,
    var(--me-magenta-300) 100%
  );
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-fast) var(--ease-out);
}

/*
 * HOVER IS THE SAME MAGENTA AS THE CURRENT PAGE.
 *
 * It was --me-magenta-300, a lighter pink, so that "here" and "under the
 * pointer" were two different colours. One colour for both is the call here:
 * the menu now has a single accent, and the two states are still told apart by
 * the underline — hover's grows out from the left as the pointer arrives and
 * retracts when it leaves, the current page's is simply always there at full
 * width. Position, not hue, is doing that job.
 */
.menu--main .menu__link:hover {
  color: var(--nav-active-text);
  background: transparent;
}

.menu--main .menu__link:hover::after,
.menu--main .menu__link:focus-visible::after {
  transform: scaleX(1);
}

/*
 * THE CURRENT PAGE IS BRAND MAGENTA; HOVER IS THE LIGHTENED ACCENT.
 *
 * Both used to be --me-magenta-300, which meant pointing at any item made it
 * look exactly like the item you were already on. Now "here" is #ec008c, the
 * same colour as the solid underline below it, and "under the pointer" is the
 * lighter #ff63ba — two states, two colours, and the current item is the one
 * carrying the actual brand.
 *
 * --nav-active-text, not --me-magenta directly: #ec008c holds 4.52:1 on the
 * dark canvas but only 4.25:1 on white, so the token swaps itself for
 * --me-magenta-700 in light mode. See the note on it in base/tokens.css.
 */
.menu--main .menu__link.is-active,
.menu--main .menu__item--active-trail > .menu__link {
  color: var(--nav-active-text);
}

.menu--main .menu__link.is-active::after,
.menu--main .menu__item--active-trail > .menu__link::after {
  transform: scaleX(1);
}

/* The current page's mark is solid rather than a gradient, so "here" and
   "under the pointer" are not quite the same signal. */
.menu--main .menu__link.is-active::after,
.menu--main .menu__item--active-trail > .menu__link::after {
  background: var(--me-magenta);
}

@media (prefers-reduced-motion: reduce) {
  .menu--main .menu__link::after {
    transition: none;
  }
}

/* Second level — a plain disclosure, not a hover-only dropdown. */
.menu--main .menu {
  display: none;
}

@media (max-width: 63.999rem) {
  .menu--main {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .menu--main .menu__item + .menu__item {
    border-block-start: 1px solid var(--border-subtle);
  }

  .menu--main .menu__link {
    padding: var(--space-s) var(--space-2xs);
    border-radius: 0;
    font-size: var(--step-0);
    white-space: normal;
  }

  /* In the drawer the items are stacked rows, so the mark goes down the
     leading edge where it does not read as an underline of the row below. */
  .menu--main .menu__link::after {
    inset-inline: 0 auto;
    inset-block: 0.35rem;
    inline-size: 3px;
    block-size: auto;
    transform: scaleY(0);
    transform-origin: center top;
  }

  .menu--main .menu__link:hover::after,
  .menu--main .menu__link:focus-visible::after,
  .menu--main .menu__link.is-active::after,
  .menu--main .menu__item--active-trail > .menu__link::after {
    transform: scaleY(1);
  }

  /*
   * NO SIZE OVERRIDE FOR THE CURRENT ITEM.
   *
   * There used to be one here, left over from the desktop treatment where the
   * mark is a short horizontal underline:
   *
   *   inset-inline: var(--space-2xs) auto;
   *   inline-size: 1.5rem;
   *   bottom: calc(var(--space-2xs) + 2px);
   *
   * In the drawer the mark is a 3px bar down the LEADING EDGE, so a 1.5rem
   * width turned it into a solid block the width of two characters, sitting on
   * top of the label — "HUBS" rendered as a pink rectangle followed by "BS".
   *
   * The current item needs no different geometry from the hover mark, only a
   * different fill, and it already has that from the solid-background rule
   * above. So there is nothing to declare.
   */
}

/* Footer menus */
.menu--footer,
.menu--secondary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu--footer .menu__link,
.menu--secondary .menu__link {
  color: var(--footer-text);
  font-size: var(--step--1);
  text-decoration: none;
}

.menu--footer .menu__link:hover,
.menu--secondary .menu__link:hover {
  color: var(--me-magenta-300);
  text-decoration: underline;
}

/* Inline list of links (legal row). */
.menu--inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs) var(--space-m);
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu--inline .menu__link {
  color: var(--text-muted);
  font-size: var(--step--2);
  text-decoration: none;
}

.menu--inline .menu__link:hover {
  color: var(--text-primary);
}
