/* Members directory modal — roster plus, for moderators, ban/unban actions. */

.membersOverlay {
  position: fixed;
  inset: 0;
  background-color: rgb(10 20 17 / 55%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-5);
  animation: membersOverlayIn 150ms var(--ease) both;
}

@keyframes membersOverlayIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.membersContent {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  max-width: 420px;
  width: 100%;
  max-height: min(560px, calc(100dvh - var(--sp-8)));
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-3);
  animation: membersModalIn 180ms var(--ease) both;
}

@keyframes membersModalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- Anchored-popover presentation (#55) --------------------------------
   Add .popoverSurface to a surface's .membersOverlay root and mount it inside
   the header's .headerPopoverAnchor (Header.css) wrapping the surface's own
   button: on wide viewports the modal becomes a popover hanging from that
   button, right-edge-aligned to it, with no backdrop — the app stays live
   behind it (outside-mousedown dismissal lives with the anchor in header.rs).
   Narrow viewports take nothing from this block, so the full-surface overlay
   above applies unchanged — a popover anchored to a header icon degrades
   badly on a phone. Only the notification inbox opts in today; converting
   another surface is this class plus the anchor wrapper. */

/* Exact complement of the app's 768px mobile breakpoint; browsers too old
   for range syntax fall back to the modal, which is just the old behavior. */
@media (width > 768px) {
  .popoverSurface {
    position: absolute;
    inset: auto;

    /* The 32px bell sits centered in the 56px bar, so +20px from its bottom
       reads as an 8px gap under the bar itself. */
    top: calc(100% + 20px);
    right: 0;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    animation: none;
  }

  .popoverSurface .membersContent {
    /* Popover voice (ProfilePopover / context-menu family): fixed width,
       tighter radius and padding than the modal, drop-in from the bar.
       Height arithmetic: the top edge sits 64px down (56px bar + 8px gap);
       16px bottom margin. The interior .membersList scrolls, as ever. */
    width: 400px;
    max-height: min(560px, calc(100dvh - 80px));
    padding: var(--sp-5);
    border-radius: var(--r-lg);
    animation: popoverSurfaceIn 120ms var(--ease) both;
  }
}

@keyframes popoverSurfaceIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.membersHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.membersHeader h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--text);
}

.membersSubtitle {
  margin: 3px 0 0;
  font-size: var(--fs-md);
  color: var(--text-3);
}

.membersCloseButton {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition:
    color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease);
}

.membersCloseButton:hover {
  color: var(--text);
  background-color: var(--surface-3);
}

/* Scrollable roster; hover wash bleeds into the negative margin. */
.membersList {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 calc(var(--sp-2) * -1);
  padding: 0 var(--sp-2);
}

.membersState {
  padding: var(--sp-5) 0;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-md);
}

/* Each row is a button: the whole surface opens the member detail sidebar
   (#57) — the hover wash is a real affordance now, not just decoration. */
.memberRow {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 7px var(--sp-2);
  border-radius: var(--r-md);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease);
}

.memberRow:hover {
  background: var(--surface-2);
}

.memberAvatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
  color: #ffffff;
  border-radius: 9px;
  user-select: none;
}

.memberAvatar.hue-0 { background: var(--hue-0); }
.memberAvatar.hue-1 { background: var(--hue-1); }
.memberAvatar.hue-2 { background: var(--hue-2); }
.memberAvatar.hue-3 { background: var(--hue-3); }
.memberAvatar.hue-4 { background: var(--hue-4); }
.memberAvatar.hue-5 { background: var(--hue-5); }
.memberAvatar.hue-6 { background: var(--hue-6); }
.memberAvatar.hue-7 { background: var(--hue-7); }

.memberName {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-base);
  font-weight: 550;
  color: var(--text);
}

/* Role badges — IdP-assigned, display only. Plain members carry none. */
.memberBadges {
  display: flex;
  gap: var(--sp-1);
  flex-shrink: 0;
}

.roleBadge {
  padding: 2px 8px;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-2);
}

/* Accent mint is a brand constant, so this reads in both themes. */
.roleBadge.role-admin {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}

.roleBadge.role-moderator {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--link);
}

/* Banned members: danger-toned badge; the name dims but stays legible (the
   row is information, not an interaction). Danger tokens are theme-aware. */
.roleBadge.roleBadgeBanned {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.memberRowBanned .memberName {
  color: var(--text-3);
}

.membersNote {
  margin: var(--sp-4) 0 0;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

@media (max-width: 480px) {
  .membersContent {
    padding: var(--sp-5);
    max-height: calc(100dvh - var(--sp-6));
  }

  .membersHeader h2 {
    font-size: var(--fs-lg);
  }
}
