/* Members (public/pages/members.js) and the invitation join panel (app.js renderJoin). Tokens only. */

/* Glance: role mix next to four KPI tiles. */
.members-glance { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--gutter); align-items: start; }
.members-mix { display: flex; align-items: center; }
.members-mix .viz { width: 100%; margin: 0; }
.members-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); }

/* People, invitations: one aligned grid per row. */
.members-list { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line-subtle); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-panel); }
.members-row {
  display: grid;
  grid-template-columns: 32px minmax(10rem, 1.3fr) 7.5rem minmax(12rem, 1fr) minmax(7.5rem, auto) 6.5rem;
  gap: var(--s-4);
  align-items: center;
  min-height: 64px;
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--line-subtle);
}
.members-row:first-child { border-top: 0; }
.members-row.is-ended { color: var(--text-2); }
.members-row.is-ended .mark-avatar { opacity: 0.55; filter: grayscale(1); }
.members-avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-full); }
.members-row.is-pending .members-avatar { border: 1px dashed var(--line-strong); color: var(--text-3); }
.members-who { display: grid; min-width: 0; }
.members-who strong { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.members-who .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members-row > .ui-pill { justify-self: start; }
.members-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }
/* Auditors carry two actions (Extend, Revoke). */
@media (min-width: 1200px) {
  .members-row.is-auditor { grid-template-columns: 32px minmax(10rem, 1.3fr) 7.5rem minmax(12rem, 1fr) minmax(7.5rem, auto) auto; }
}
.members-list + .ui-empty, .members-list + .ui-disclosure, .ui-empty + .ui-disclosure { margin-top: var(--s-4); }

/* Scope as the six product marks; platforms outside the scope fade. */
.members-scope { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); min-width: 0; }
.members-marks .is-out { opacity: 0.3; filter: grayscale(1); }
.members-marks { display: inline-flex; gap: var(--s-1); }
.members-scope-text { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Invitation life left. */
.members-expiry { display: grid; gap: var(--s-1); color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); white-space: nowrap; }
.members-expiry-bar { display: block; height: 4px; overflow: hidden; border-radius: var(--r-full); background: var(--seq-0); }
.members-expiry-bar > span { display: block; width: calc(var(--ratio, 0) * 100%); height: 100%; border-radius: inherit; background: var(--chart-1); }
.members-expiry[data-tone="warn"] { color: var(--warn); }
.members-expiry[data-tone="warn"] .members-expiry-bar > span { background: var(--warn); }

/* Shown-once invitation link. */
.members-created { margin: 0; }
.members-created label { margin-top: var(--s-3); }
.members-inline { display: flex; gap: var(--s-2); align-items: center; }
.members-inline input { flex: 1 1 auto; }
.members-inline > button { flex: none; }
.members-created input { font-family: var(--font-mono); font-size: var(--fs-xs); }

/* Forms in drawers. */
.members-form { display: grid; gap: var(--s-5); }
.members-form > p.muted { margin: 0; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.members-form label { margin-top: 0; }
.members-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.members-fieldset[hidden] { display: none; }
.members-fieldset legend { margin-bottom: var(--s-2); padding: 0; color: var(--text); font-size: var(--fs-sm); font-weight: 550; line-height: var(--lh-sm); }
.members-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.members-choice { display: flex; gap: var(--s-3); align-items: flex-start; margin: 0; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--raised); cursor: pointer; font-weight: 450; }
.members-choice:hover { border-color: var(--line-strong); }
.members-choice:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.members-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.members-choice input { margin-top: 2px; flex: none; }
.members-choice-body { display: grid; gap: var(--s-1); }
.members-choice-title { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text); font-weight: 600; }
.members-choice .hint { margin: 0; }
.members-check { display: inline-flex; align-items: center; gap: var(--s-2); margin: 0; font-weight: 500; cursor: pointer; }
.members-platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.members-platform { display: flex; align-items: center; gap: var(--s-2); min-height: 40px; margin: 0; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-sm); font-weight: 500; cursor: pointer; }
.members-platform:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.members-platform:has(input:disabled) { cursor: default; opacity: 0.55; }
.members-platform:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.members-platform input { flex: none; }
.members-email { display: grid; gap: var(--s-2); }
.members-drawer-who { display: flex; gap: var(--s-4); align-items: center; margin-bottom: var(--s-6); }
.members-drawer-who > div { display: grid; gap: var(--s-2); justify-items: start; }
.members-danger { margin-top: var(--s-8); padding-top: var(--s-5); border-top: 1px solid var(--line-subtle); }
.members-danger h3 { margin: 0; font-size: var(--fs-md); line-height: var(--lh-md); }
.members-danger .hint { margin: var(--s-1) 0 var(--s-3); }

/* Workspace name (inside the settings disclosure). */
.members-name-form { max-width: 560px; }
.members-name-form label { margin-top: 0; }

/* A member's own view. */
.members-self { max-width: 720px; }
.members-self-head { display: flex; gap: var(--s-4); align-items: center; }
.members-self-head h2 { margin: 0; font-size: var(--fs-xl); line-height: var(--lh-xl); }
.members-self-head p { margin: var(--s-1) 0 0; }
.members-self-facts { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); justify-content: start; gap: var(--s-2) var(--s-10); margin: var(--s-6) 0 var(--s-4); }
.members-self-facts dt { margin-bottom: var(--s-2); color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; line-height: var(--lh-xs); text-transform: uppercase; }
.members-self-facts dd { margin: 0; }
.members-self .button-row { margin-top: var(--s-5); }

/* Join a workspace (app.js renderJoin): a centered decision card. */
.join-panel { width: 100%; max-width: 560px; margin-inline: auto; padding: var(--s-8); border-radius: var(--r-lg); }
.join-panel h2 { margin: 0; font-size: var(--fs-xl); line-height: var(--lh-xl); }
.join-panel .fact-list { margin: var(--s-5) 0; }
.join-panel > p { margin: 0 0 var(--s-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.join-panel .button-row { margin-top: var(--s-6); }
.join-panel .button-row > * { flex: 1 1 0; justify-content: center; }

@media (max-width: 1199px) {
  .members-row { grid-template-columns: 32px minmax(0, 1fr) auto auto; grid-template-areas: 'avatar who role actions' 'avatar scope state actions'; row-gap: var(--s-2); }
  .members-row > :nth-child(1) { grid-area: avatar; align-self: start; }
  .members-row > :nth-child(2) { grid-area: who; }
  .members-row > :nth-child(3) { grid-area: role; }
  .members-row > :nth-child(4) { grid-area: scope; }
  .members-row > :nth-child(5) { grid-area: state; justify-self: end; }
  .members-row > :nth-child(6) { grid-area: actions; }
}
@media (max-width: 899px) {
  .members-glance { grid-template-columns: 1fr; }
}
@media (max-width: 639px) {
  .ui-stat-grid.members-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .members-row { grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: 'avatar who role' 'avatar scope scope' 'avatar state actions'; padding: var(--s-3) var(--s-4); }
  .members-row > :nth-child(5) { justify-self: start; }
  /* An auditor's label and last access read in full: the role pill moves under them. */
  .members-row.is-auditor { grid-template-areas: 'avatar who who' 'avatar role role' 'avatar scope scope' 'avatar state actions'; }
  .members-row.is-auditor .members-who > * { white-space: normal; }
  .members-choices { grid-template-columns: 1fr; }
  /* An address is long by nature and must stay readable in full on a phone. */
  .members-who strong, .members-who .small { overflow: visible; white-space: normal; overflow-wrap: anywhere; }
  .members-inline { flex-direction: column; align-items: stretch; }
  .members-self-facts { grid-template-columns: 1fr; }
  .join-panel { padding: var(--s-5); }
  .join-panel .button-row { flex-direction: column; align-items: stretch; }
}
