@layer components {

  /* The team in the pages' menu (shared/_team_switch): its name opens the others to switch to, renaming it
     and a new team. */
  .team-switch__toggle {
    anchor-name: --team-switch;

    &.page-nav__link {
      color: var(--color-ink);
    }

    &::after {
      content: "▾";
      color: var(--color-ink-muted);
    }
  }

  /* A popover under its button, its right edge on the button's (or its left one, short of room on the left). */
  .team-switch__menu {
    position-anchor: --team-switch;
    position-area: bottom span-left;
    position-try-fallbacks: flip-inline;
    inset: auto; /* the popover's own inset: 0 would stretch it over its area */
    min-width: 200px;
    margin: 6px 0 0;
    padding: 4px;
    color: var(--color-ink);
    background: var(--color-surface);
    border: 1px solid var(--color-edge);
    border-radius: 6px;
    box-shadow: 0 8px 24px color-mix(in oklch, var(--black) 40%, transparent);

    &:popover-open {
      display: grid;
    }
    padding: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-edge);
    border-radius: 6px;
    box-shadow: 0 8px 24px color-mix(in oklch, var(--black) 40%, transparent);

    form {
      display: contents;
    }
  }

  .team-switch__item,
  button.team-switch__item {
    display: block;
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    text-align: left;
    color: var(--color-ink);
    background: none;
    border: 0;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;

    &:hover {
      background: color-mix(in oklch, var(--color-surface), var(--color-ink) 10%);
    }
  }

  .team-switch__item.is-current {
    font-weight: 600;
    cursor: default;

    &:hover {
      background: none;
    }
  }

  .team-switch__item--action {
    color: var(--color-ink-muted);
  }
}
