@layer components {
  /* A list as an inbox: who, then what about them, and at the row's end when and in what state. */

  /* The link is the row's box, so it takes the focus ring */
  .inbox__link {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: var(--inline-space);
    min-width: 0;
    color: inherit;
    text-decoration: none;

    &:focus-visible {
      border-radius: inherit;
      outline: var(--focus-ring-size) solid var(--focus-ring-color);
      outline-offset: calc(-1 * var(--focus-ring-size));
    }
  }

  /* An avatar that ticks a box: the box lies unseen over it, and its tick takes the avatar's place. */
  .inbox__pick {
    cursor: pointer;
    flex-shrink: 0;
    position: relative;

    > input[type=checkbox] {
      appearance: none;
      cursor: pointer;
      inset: 0;
      margin: 0;
      position: absolute;

      &:focus-visible {
        outline: none;
      }
    }

    /* Hovered or focused, the avatar rings to say it can be ticked. */
    .inbox__avatar {
      outline: calc(var(--focus-ring-size) * 2) solid var(--avatar-ring-color, transparent);
      outline-offset: var(--focus-ring-size);
    }

    &:has(:focus-visible) {
      --avatar-ring-color: var(--color-link);
    }

    @media (any-hover: hover) {
      &:hover {
        --avatar-ring-color: var(--color-link);
      }
    }

    &:has(> :checked) {
      .avatar--initials {
        display: none;
      }

      .avatar__tick {
        display: grid;
      }
    }
  }

  /* A row that sends a form is a button, without a button's own look. */
  button.inbox__link {
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    text-align: start;
  }

  /* Sized by the row that holds it, which outranks the avatar's own type size. */
  .row .inbox__avatar {
    --avatar-size: 2.25rem;

    font-size: var(--text-x-small);
  }

  /* With no avatar to hold a row's height, the end keeps a row's usual room above and below. */
  .row:not(:has(.inbox__avatar)) .inbox__end {
    padding-block: calc(var(--block-space-half) * 0.75);
  }

  /* Nothing on a row is bold: its state is told by the word's colour alone. */
  .inbox__end .status {
    font-weight: normal;
  }
}
