/* The Roles pages (packs/administration; D-51, D-231, D-232, D-233): what Administration::RolesListComponent, RoleOverviewComponent, RoleMayDoComponent,
   RoleMaySeeComponent, RoleHoldersComponent, RoleGroupsComponent, AccessConfirmationComponent, SignInStatusComponent and GroupMappingsComponent add to the shared
   components they are arranged from (PageSectionComponent, CardComponent, BadgeComponent, ButtonComponent, CalloutComponent, EmptyStateComponent, IconComponent and the
   form system, Forms::*, which bring their own look). These rules only lay out what is between them.

   * Cards (the roles, a role's holders, the Okta groups that give it, every mapping): a grid of as many columns as fit, one at 320 CSS px, never a wide table. A
     card's footer holds its one link (End), which wraps a long name onto more lines instead of widening the card. The person looking has the accent edge as well as
     the word "You", so the edge is never the only signal (WCAG 1.4.1).
   * Rows (what a role may do, what it may see): the label and, under it, the key and the risk or the level; the Remove link at the end of the row, or under it when
     there is no room. A capability's module heads its group.
   * The add forms sit under their section's list, one reading column, as every form is; a sentence says why when there is no form.
   * The marks (runs Tessera, administrative, the sign-in state) are words beside a badge or an icon: color is never the only signal.

   Tokens only and logical properties only, both enforced (test/styles/tokens_test.rb, test/styles/components_test.rb), so it reads on the light shell and the
   console, in light and in dark, and mirrors in a right-to-left language. Nothing pinned to an edge or sticky (WCAG 2.4.11), no height in vh, and everything that
   holds words may shrink and wrap (an address or a group's name has no spaces to break at, so it breaks anywhere), so a language 40% longer never widens the page
   (WCAG 1.4.10). */

/* ── Words in their own direction ────────────────────────────────────────── */
.role-pages [dir="auto"],
.roles-list [dir="auto"],
.role-overview [dir="auto"],
.role-may-do [dir="auto"],
.role-may-see [dir="auto"],
.role-holders [dir="auto"],
.role-groups [dir="auto"],
.access-confirmation [dir="auto"],
.sign-in-status [dir="auto"],
.group-mappings [dir="auto"] {
  unicode-bidi: isolate;
}

/* ── The roles ───────────────────────────────────────────────────────────── */
/* The list: the figures, the search and the module chips (the shared filter bar's look), then a table per group. A row's first cell holds the name (the link),
   its marks, its key and its description, each on a line of its own; the other cells are short. Under 48rem each row is a card (DataTableComponent). */
.roles-list {
  display: grid;
  gap: var(--space-4);
  min-inline-size: 0;
}

.roles-list__search-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.roles-list__count:empty {
  display: none;
}

.roles-table__link {
  display: inline-block;
  min-block-size: 24px;
  font-weight: 600;
}

/* Every group's table has the same columns at the same widths, so the eye runs down one column across the modules. */
.roles-table {
  table-layout: fixed;
  inline-size: 100%;
  font-size: var(--text-sm);
}

.roles-table th[scope="col"]:nth-child(1) {
  inline-size: 36%;
}

.roles-table th[scope="col"]:nth-child(2) {
  inline-size: 8%;
}

.roles-table th[scope="col"]:nth-child(3) {
  inline-size: 22%;
}

.roles-table th[scope="col"]:nth-child(4) {
  inline-size: 22%;
}

.roles-table th[scope="col"]:nth-child(5) {
  inline-size: 12%;
}

.roles-table th[scope="row"],
.roles-table td {
  overflow-wrap: anywhere;
}

.roles-table__marks,
.roles-table__key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* Two lines of what the role is for; the role's page has all of it. */
.roles-table__description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.roles-table__description,
.roles-table__quiet {
  color: var(--fg2);
  font-size: var(--text-sm);
  font-weight: 400;
}

.roles-table__key {
  font-size: var(--text-sm);
  font-weight: 400;
}

.roles-table__count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* The cards: a role's holders and the Okta groups that give it. */
.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-3);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role-card {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* The footer sits at the foot of the card whatever is above it, so the links of a row line up. */
.role-card > .card-body {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: var(--space-1);
}

.role-card .card-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.role-card__line {
  margin-block: 0;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.role-card__quiet {
  color: var(--fg2);
  font-size: var(--text-sm);
}

.role-card[data-self] {
  border-color: var(--tone-accent-line);
  border-inline-start-width: 4px;
}

.role-card__action {
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

/* ── What a role is ──────────────────────────────────────────────────────── */
.role-overview__facts {
  display: grid;
  gap: var(--space-2);
  max-inline-size: 72ch;
  margin: 0;
}

.role-overview__fact {
  display: grid;
  gap: var(--space-1);
  min-inline-size: 0;
}

.role-overview__label {
  color: var(--fg2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.role-overview__value {
  margin: 0;
  overflow-wrap: anywhere;
}

.role-overview__marks {
  display: grid;
  gap: var(--space-2);
  max-inline-size: 72ch;
  margin-block: var(--space-3) 0;
  padding: 0;
  list-style: none;
}

.role-overview__mark {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  overflow-wrap: anywhere;
}

/* ── What a role may do and see ──────────────────────────────────────────── */
.role-group + .role-group {
  margin-block-start: var(--space-3);
}

.role-group__title {
  margin-block: 0 var(--space-2);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.role-items {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  min-inline-size: 0;
  padding-block: var(--space-2);
  border-block-end: 1px solid var(--rule);
}

.role-item__text {
  display: grid;
  flex: 1 1 16rem;
  gap: var(--space-1);
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.role-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  color: var(--fg2);
  font-size: var(--text-sm);
}

.role-item__action {
  max-inline-size: 100%;
  white-space: normal;
  text-align: center;
}

.role-section__kept {
  max-inline-size: 72ch;
  margin-block: var(--space-3) 0;
  color: var(--fg2);
  overflow-wrap: anywhere;
}

.role-section__add {
  margin-block-start: var(--space-4);
}

/* ── The confirmations ───────────────────────────────────────────────────── */
.access-confirmation__lines {
  display: grid;
  gap: var(--space-1);
  min-inline-size: 0;
  max-inline-size: 72ch;
}

.access-confirmation__line,
.access-confirmation__what {
  margin-block: 0;
  overflow-wrap: anywhere;
}

.access-confirmation__line {
  color: var(--fg2);
  font-size: var(--text-sm);
}

.access-confirmation__what {
  max-inline-size: 72ch;
  margin-block: var(--space-3);
}

.access-confirmation__back,
.role-pages__back {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-block-start: var(--space-3);
}

.access-confirmation .form-actions .btn {
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

/* ── Group sign-in ───────────────────────────────────────────────────────── */
.sign-in-status__state {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block: 0 var(--space-2);
  font-size: var(--text-md);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sign-in-status__icon {
  flex: none;
  inline-size: 1.25em;
  block-size: 1.25em;
}

.sign-in-status__line {
  max-inline-size: 72ch;
  margin-block: 0 var(--space-2);
  overflow-wrap: anywhere;
}

.sign-in-status__quiet {
  color: var(--fg2);
  font-size: var(--text-sm);
}

.sign-in-status__effects {
  display: grid;
  gap: var(--space-1);
  max-inline-size: 72ch;
  margin-block: 0 var(--space-3);
  padding-inline-start: var(--space-4);
  overflow-wrap: anywhere;
}

/* ── Making a role ───────────────────────────────────────────────────────── */
/* What it may do, folded by module, and how far it sees into each compartment, a choice each in as many columns as fit. */
.role-form__holds {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.role-form__legend {
  padding: 0;
  font-weight: 600;
}

.role-form__help {
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
}

.role-form__module {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding-block: var(--space-2);
  padding-inline: var(--space-3);
}

.role-form__module-summary {
  min-block-size: 24px;
  cursor: pointer;
  font-weight: 600;
}

.role-form__module[open] > .role-form__module-summary {
  margin-block-end: var(--space-2);
}

.role-form__depths {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-3);
}

.role-form__suggested {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--tone-info-line);
  border-inline-start-width: 4px;
  border-radius: var(--radius-md);
  background: var(--tone-info-bg);
  color: var(--tone-info-fg);
}

.role-form__suggested > * {
  margin: 0;
}

.role-form__suggestions {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-inline-start: var(--space-4);
}

/* A long list of capabilities, folded by module: each summary is a row a person opens. */
.role-group__summary {
  min-block-size: 24px;
  cursor: pointer;
}

details.role-group {
  border-block-end: 1px solid var(--rule);
  padding-block: var(--space-2);
}

details.role-group[open] > .role-group__summary {
  margin-block-end: var(--space-2);
}
