/* ==========================================================================
   TeamTrek — the access matrix
   --------------------------------------------------------------------------
   The enterprise instrument, inside the shared panel frame.

   At two thousand people the question stops being what is recorded and
   becomes who may read it. So the hero is not hours: it is a role down the
   side, a scope across the top, and a mark where the two meet.

   Every row begins with the same mark in the same column. That is the
   argument the page makes in one picture: whatever else a role can reach,
   every person can always open their own record.

   The frame around it lives in panel.css. Everything here is the
   instrument.
   ========================================================================== */
.scopes {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: .875rem .875rem .5rem;
}

/* The scopes, above the rows. The role column matches the rows' own, so a
   heading sits over its own column. */
.scopes__head,
.scopes__row {
  display: grid;
  grid-template-columns: 10rem repeat(4, minmax(0, 1fr)) 5rem;
  gap: .375rem;
  align-items: center;
}
.scopes__head {
  margin: 0 0 .5rem;
  font-size: .625rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--neutral-500);
}
.scopes__head span { text-align: center; }
.scopes__head span:first-child { text-align: left; }
.scopes__head span:last-child { text-align: right; }

/* ------------------------------------------------------------- the rows */
.scopes__rows { display: grid; grid-auto-rows: minmax(0, 1fr); gap: .375rem; min-height: 0; }

.scopes__who { min-width: 0; font-size: .75rem; color: var(--neutral-500); }
.scopes__who b {
  display: block;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* One cell: a scope this role either reaches or does not. A reached scope
   is filled; one it does not reach is an empty tray rather than a cross,
   because a cross reads as a refusal and this is simply the shape of the
   role. */
.scopes__cell {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 26px;
  border-radius: var(--r-xs);
  background: var(--neutral-100);
  color: transparent;
  transition: background-color var(--dur-ui) var(--ease-ui);
}
.scopes__cell--yes { background: var(--primary-500); color: #fff; }
/* The scope every role has, and the only one some roles have. */
.scopes__cell--own { background: var(--primary-700); color: #fff; }
.scopes__cell .icon { width: 13px; height: 13px; }

/* The role being read, from the rail. Only the marks it reaches take the
   outline: outlining the empty cells too drew four boxes around nothing,
   which read as a selection rather than as a scope. */
.scopes__row.is-now .scopes__cell--yes,
.scopes__row.is-now .scopes__cell--own { box-shadow: inset 0 0 0 2px var(--primary-800); }
.scopes__row.is-now .scopes__who b { color: var(--primary-700); }

.scopes__people {
  text-align: right;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- the key */
.scopes__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem 1rem;
  margin: .75rem 0 0; padding-top: .625rem;
  border-top: 1px solid var(--neutral-150);
  font-size: .625rem; color: var(--neutral-500);
}
.scopes__key { display: inline-flex; align-items: center; gap: .375rem; }
.scopes__key i { width: 11px; height: 11px; border-radius: 3px; background: var(--primary-500); }
.scopes__key--own i { background: var(--primary-700); }
.scopes__key--no i { background: var(--neutral-100); box-shadow: inset 0 0 0 1px var(--neutral-200); }

@media (prefers-reduced-motion: reduce) {
  .scopes__cell { transition: none; }
}

/* ------------------------------------------------------------- narrower */
@media (max-width: 959px) {
  .scopes { padding: .75rem .75rem .5rem; }
  .scopes__head,
  .scopes__row { grid-template-columns: 8rem repeat(4, minmax(0, 1fr)) 4rem; }
  .scopes__rows { grid-auto-rows: 40px; }
}

/* --------------------------------------------------------------- phones */
@media (max-width: 599px) {
  .scopes { padding: .625rem .5rem .5rem; }
  .scopes__head,
  .scopes__row { grid-template-columns: 5.5rem repeat(4, minmax(0, 1fr)) 3.25rem; gap: .25rem; }
  .scopes__head { font-size: .75rem; letter-spacing: .04em; }
  /* Four scope headings do not fit at this width; the key under the matrix
     carries them, and the rail names the one being read. */
  .scopes__head span:not(:first-child):not(:last-child) { font-size: 0; }
  .scopes__who b { font-size: .75rem; }
  .scopes__who { font-size: 0; }
  .scopes__people { font-size: .75rem; }
  .scopes__foot { font-size: .75rem; gap: .25rem .75rem; }
}
