.mtx {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  align-items: center;
  width: 100%;
}

.mtx-summary {
  margin: 0;
  text-align: center;
  text-wrap: balance;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-ink);
}

/* --- The grid -------------------------------------------------------------
   A table, because it is one: options down the side, criteria across the top.
   It scrolls sideways on its own rather than pushing the page around. */

.mtx-table {
  width: 100%;
  overflow-x: auto;
}

.mtx-grid {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.mtx-grid th,
.mtx-grid td {
  padding: var(--space-2) var(--space-3);
  text-align: center;
  vertical-align: middle;
}

.mtx-grid thead th {
  border-bottom: 2px solid var(--c-line);
  font-size: var(--text-sm);
  color: var(--c-ink-muted);
  white-space: nowrap;
}

.crit-name {
  display: block;
  font-weight: 700;
  color: var(--c-ink);
}

.crit-weight {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-ink-muted);
}

.mtx-corner,
.mtx-option {
  text-align: left;
  min-width: 9rem;
}

.mtx-option {
  font-weight: 600;
  color: var(--c-ink);
  border-left: 4px solid var(--hue);
  text-wrap: balance;
}

.mtx-grid tbody tr {
  border-bottom: 1px solid var(--c-line);
}

.mtx-total-head,
.mtx-total {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--c-ink);
  min-width: 4rem;
}

/* The leader is marked, but the numbers are all still on screen: the point of a
   matrix is that anyone can check the arithmetic. */
.mtx-grid tbody tr.is-leader {
  background: var(--hue-tint);
}

.mtx-grid tbody tr.is-leader .mtx-total {
  color: var(--hue);
}

/* --- Cells ---------------------------------------------------------------- */

.mtx-cell {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.mtx-dot {
  font: inherit;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  cursor: pointer;

  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;

  background: var(--c-paper);
  color: var(--c-ink-muted);
  border: 1px solid var(--c-line);
  border-radius: 4px;
  transition: background-color 120ms ease, color 120ms ease;
}

.mtx-dot:hover {
  border-color: var(--hue);
  color: var(--c-ink);
}

.mtx-dot.is-on {
  background: var(--hue);
  border-color: var(--hue);
  color: var(--c-ink-inverse);
}

/* --- Setup ---------------------------------------------------------------- */

.mtx-setup {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  justify-content: center;
  width: 100%;
  border-top: 1px solid var(--c-line);
  padding-top: var(--space-6);
}

.mtx-field {
  flex: 1 1 16rem;
  max-width: 22rem;
}

.mtx-field textarea {
  font: inherit;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  resize: vertical;
  min-height: 7rem;
}

.mtx-hint {
  margin: 0;
  color: var(--c-ink-muted);
  font-size: var(--text-sm);
  text-align: center;
  text-wrap: balance;
}

.mtx-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* --- Fullscreen ----------------------------------------------------------- */

.toy.is-fullscreen .mtx {
  justify-content: center;
  height: 100%;
}

.toy.is-fullscreen .mtx-setup,
.toy.is-fullscreen .mtx-hint {
  opacity: 0;
  transition: opacity 200ms ease;
}

.toy.is-fullscreen .mtx-setup:focus-within,
.toy.is-fullscreen:hover .mtx-setup,
.toy.is-fullscreen:hover .mtx-hint {
  opacity: 1;
}
