/* The top bar (owner, 29 November 2026, product/events-module.md decisions 22 to 24; mock-up
   product/phone-menu-mockup-20261129, "form B with left-aligned lines"), on every page of every site. It replaces the
   two-row and three-row phone bars of header-impact-20261128.css and events-link-20261128.css, which keep their bytes
   for pages cached before. One rule for every site: below 768 px (site.css's phone width) the bar has no visible
   organisation name, "Menu" at the left and My Donations at the right; from 768 px the name and the links show in the
   bar. The bar is one 64 px row at every width, so site.css's 80 px scroll padding (the bar plus 16 px) holds. */

/* The links in the bar. */
.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: var(--cn-type-control-large-size);
  line-height: var(--cn-type-control-large-lh);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.header-link[aria-current] {
  text-decoration: underline;
}
.header-link + .header-link,
.header-link + .header-action {
  margin-left: 0;
}
/* After the menu's links, the button keeps no margin of its own, so the free space sits before the first link. A menu
   holding only "Home" (hidden here) leaves the button's margin as site.css sets it, so it stays at the right. A rule of
   its own, so a browser that does not know :has() drops only this one; :where() keeps it as specific as the phone rule
   below, which wins there. */
.site-menu:where(:has(> .header-link + .header-link)) + .header-action {
  margin-left: 0;
}

/* Wide: the popover element draws no box, so its links are items of the bar's row. The author rule wins over the
   browser's [popover] display: none, and the popover's own text colour is not used. */
.site-menu {
  display: contents;
  color: inherit;
}
.site-header {
  anchor-name: --site-bar;
}

/* The Menu button (phones only): an outlined control, 48 px tall, two lines: a 16 px three-line icon on the top line,
   "Menu" on the bottom line. The icon is decorative; the button's name is "Menu". It is drawn with borders, not an
   inline svg: an event page places only drawings that pass the events allow-list (lib/event-svg.js), and borders take
   the forced colours. */
.menu-toggle {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  min-width: 48px;
  min-height: 48px;
  margin-left: auto;
  padding: 3px 12px;
  border: 1px solid var(--cn-component-button-outline-border);
  border-radius: var(--cn-component-button-radius);
  background: transparent;
  color: var(--cn-text-default);
  font-family: var(--font-ui);
  font-size: var(--cn-type-control-large-size);
  line-height: var(--cn-type-control-large-lh);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-toggle:hover {
  background: var(--cn-action-tertiary-hover);
}
.menu-toggle .menu-icon {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 20px;
}
/* Three 2 px lines at 3, 7 and 11 px of a 16 px square; open, two 14 px lines crossed at its centre. */
.menu-toggle .menu-lines {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
}
.menu-toggle .menu-lines::before,
.menu-toggle .menu-lines::after {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  box-sizing: border-box;
}
.menu-toggle .menu-lines::before {
  top: 3px;
  height: 10px;
  border-top: 2px solid;
  border-bottom: 2px solid;
}
.menu-toggle .menu-lines::after {
  top: 7px;
  border-top: 2px solid;
}
.menu-toggle .menu-word {
  font-size: var(--cn-type-control-medium-size);
  line-height: 20px;
  font-weight: 500;
}
/* Open: the button takes the tertiary tint and its lines become a cross. Its name stays "Menu"; screen readers hear
   "expanded". */
.site-header:has(.site-menu:popover-open) .menu-toggle {
  background: var(--cn-action-tertiary-active);
}
.site-header:has(.site-menu:popover-open) .menu-toggle .menu-lines::before,
.site-header:has(.site-menu:popover-open) .menu-toggle .menu-lines::after {
  top: 7px;
  left: 1px;
  width: 14px;
  height: 0;
  border-bottom: 0;
  transform: rotate(45deg);
}
.site-header:has(.site-menu:popover-open) .menu-toggle .menu-lines::after {
  transform: rotate(-45deg);
}

.site-menu::backdrop {
  background: transparent;
}

/* The My Donations button, two lines on phones and on desktop: the short name over "My Donations", both starting at the
   button's left padding. 1 px border + 3 px padding + 20 + 20 + 3 + 1 = 48 px. The two buttons use the same box, so
   their bottom lines share a baseline. */
.header-action {
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  min-height: 48px;
  padding: 3px 12px;
  text-align: left;
}
.header-action .bar-name {
  font-size: 13.83px;
  line-height: 20px;
  font-weight: 400;
}
.header-action .bar-label {
  font-size: var(--cn-type-control-medium-size);
  line-height: 20px;
  font-weight: 500;
}
/* The separator stays in the link's text, so its accessible name is still "<short name> · My Donations", but it is not
   drawn: the two lines carry the split. */
.header-action .bar-sep {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* "Home", first in the menu: phones only. */
.menu-home {
  display: none;
}
.menu-home + .header-link {
  margin-left: auto;
}
/* The organisation's full name for screen readers on phones, read just before "Menu"; not focusable. */
.site-name {
  display: none;
}

/* Phones (below 768 px). */
@media (max-width: 767.98px) {
  .site-header .brand {
    display: none;
  }
  .site-name {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .menu-toggle {
    display: inline-flex;
    margin-left: 0;
  }
  .site-menu:not(:popover-open) {
    display: none;
  }
  .header-row > .header-action {
    margin-left: auto;
  }
  .menu-home {
    display: flex;
  }
  /* The open menu, under the whole bar, the window's width, one 48 px row per link on the bar's 16 px inset. Phones
     only, so a menu left open while the window widens to 768 px or more draws no list. The first top is for browsers
     without anchor positioning. */
  .site-menu:popover-open {
    position: fixed;
    inset: auto;
    top: 64px;
    top: anchor(--site-bar bottom);
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100dvh - 64px);
    margin: 0;
    padding: 12px 0 11px;
    overflow: auto;
    border: 0;
    border-bottom: 1px solid var(--cn-component-header-border);
    background: var(--cn-component-header-background);
    color: var(--cn-text-default);
  }
  .site-menu:popover-open .header-link {
    display: flex;
    min-height: 48px;
    margin: 0;
    padding-inline: 16px;
  }
  .site-menu:popover-open .header-link:focus-visible {
    outline-offset: -3px;
  }
}

/* A menu left open while the window widens to 768 px or more: the browser keeps a popover in its top layer, where it
   cannot sit in the bar's row, so it is not drawn. The bar's links come back as soon as it closes: a tap or click
   anywhere, Escape, or the next page. */
@media (min-width: 768px) {
  .site-menu:popover-open {
    display: none;
  }
}

/* A browser without popovers (Safari before 17): no Menu button; the links, Home included on phones, stay in the bar,
   which wraps. */
@supports not selector(:popover-open) {
  .menu-toggle {
    display: none !important;
  }
  .site-menu {
    display: contents !important;
  }
  /* Phones only: from 768 px the links fit the 64 px bar. */
  @media (max-width: 767.98px) {
    .site-header,
    .header-row {
      height: auto;
    }
    .header-row {
      flex-wrap: wrap;
    }
  }
}
@media (forced-colors: active) {
  .menu-toggle {
    border-color: ButtonText;
  }
}
@media (max-width: 767.98px) and (forced-colors: active) {
  .site-menu:popover-open {
    border-bottom-color: CanvasText;
  }
}
