/* --- profile menu ------------------------------------------------------ */

/* In the top layer, hung under the profile button where anchor positioning
   exists, centred on screen by the browser's default elsewhere. */
.profile-menu {
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  margin: 0;
  padding: 16px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--menu-shadow);
  opacity: 1;
  transform: none;
  transition:
    opacity 160ms ease-out,
    transform 160ms ease-out,
    overlay 160ms allow-discrete,
    display 160ms allow-discrete;
}

@starting-style {
  .profile-menu:popover-open {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.profile-menu:not(:popover-open) {
  opacity: 0;
  transform: translateY(-4px);
}

@supports (position-area: bottom) {
  .profile-menu {
    position-anchor: --profile-menu;
    position-area: bottom span-left;
    position-try-fallbacks: flip-inline;
    margin-top: 8px;
    inset: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-menu,
  .profile-link .chevron {
    transition: none;
  }
}

.pm-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar.pm-avatar {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.pm-who {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.pm-name {
  font-weight: 600;
}

.pm-email {
  overflow: hidden;
  font-size: 13px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Four figures in a row, the numbers set to line up. */
.pm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.pm-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--radius);
  background: var(--chip);
}

.pm-stat-value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.pm-stat-label {
  overflow: hidden;
  max-width: 100%;
  font-size: 11px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.pm-label {
  font-size: 12px;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
  color: var(--muted);
}

/* Signing out, below everything else and set apart by a rule. */
.pm-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: var(--border-w) solid var(--line);
}

button.pm-logout {
  justify-content: flex-start;
  width: 100%;
}

/* Controls made for the bar stretch to the menu's width here. */
.profile-menu .seg {
  display: flex;
}

.profile-menu .seg button {
  flex: 1 1 0;
  min-width: 0;
  font-size: 13px;
}

.profile-menu select.switcher {
  width: 100%;
}

/* Settings: an icon button at the end of the name line. */
.btn-link.pm-settings {
  flex-shrink: 0;
  width: 44px;
  margin-left: auto;
  padding: 0;
}

.profile-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Language picker: a native select dressed as a bordered button. */
select.switcher {
  height: 44px;
  padding: 0 32px 0 12px;
  color: var(--ink);
  background-color: var(--surface);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5l5-5' stroke='%23888078' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  font-size: 14px;
}

select.switcher:hover {
  border-color: var(--accent);
}

select.switcher option {
  color: var(--ink);
  background: var(--surface);
}
