/* The name chip in the header for signed-in visitors, and the menu it opens (views/partials/account-menu.php).
   Phones: on the account pages only (elsewhere its links are in the main menu, see site-header.css). From 768px: at the right end of the header.
   site.js opens and closes the menu by toggling aria-expanded on the chip. */

.account-menu {
  position: relative;
  margin-left: auto; /* phones: pushed to the right, next to the Menu button */
}

@media (min-width: 768px) {
  .account-menu {
    order: 1; /* after the main links */
  }
}

/* --- The chip: initials in a blue circle, then the first name --- */
.account-menu__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--c-text);
  background-color: var(--c-page);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-pill);
  transition: border-color var(--duration-fast) var(--ease);
}

.account-menu__chip:hover {
  border-color: var(--c-accent-border);
}

.account-menu__name {
  max-width: var(--account-chip-name-w);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis; /* a long first name stops with "…" so the chip never crowds the header */
}

.account-menu__initials {
  display: inline-grid;
  place-items: center;
  width: var(--sp-8);
  height: var(--sp-8);
  font-weight: 600;
  color: var(--c-accent-text);
  background-color: var(--c-accent-border);
  border-radius: 50%;
}

.account-menu__chip .bi {
  transition: transform var(--duration-fast) var(--ease);
}

.account-menu__chip[aria-expanded="true"] .bi {
  transform: rotate(180deg);
}

/* --- The menu: name and email, the links, then Sign out --- */
.account-menu__list {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  z-index: 3;
  width: var(--account-menu-w);
  padding: var(--sp-2);
  background-color: var(--c-page);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
}

[aria-expanded="false"] + .account-menu__list {
  display: none;
}

.account-menu__who {
  display: grid;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  margin-bottom: var(--sp-1);
  border-bottom: var(--border-1) solid var(--c-line);
}

.account-menu__who strong,
.account-menu__who span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis; /* a long name or address stops with "…" instead of wrapping or widening the menu */
}

.account-menu__who strong {
  font-weight: 500;
}

.account-menu__who span {
  font-size: var(--fs-small);
  color: var(--c-text-muted);
}

.account-menu__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-small);
  color: var(--c-text);
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius-1);
}

.account-menu__link:hover,
.account-menu__link[aria-current="page"] {
  color: var(--c-accent-text);
  background-color: var(--c-accent);
}

/* Back to the website: phones only, where the account pages have no main menu. */
.account-menu__site {
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
  border-top: var(--border-1) solid var(--c-line);
}

@media (min-width: 768px) {
  .account-menu__site {
    display: none;
  }
}

.account-menu__out {
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
  border-top: var(--border-1) solid var(--c-line);
}
