/*
 * avatar: a person as a circle: initials (two letters, from the name) or a photo. Decorative next to
 * the visible name (aria-hidden); alone, it carries the name in aria-label or alt.
 * Markup: <span class="avatar" aria-hidden="true">AS</span>
 *         <img class="avatar" src="…" alt="Ana Souza">
 *         <ul class="avatar-group"><li><span class="avatar">…</span></li>…</ul>
 * The hue tokens --avatar-bg/--avatar-fg let a list color each person from the brand ramps; the
 * defaults are the action pair, which every brand proves at 4.5:1.
 */
@layer components {
  .avatar {
    display: inline-grid;
    flex: none;
    place-items: center;
    inline-size: var(--avatar-size, var(--space-10));
    block-size: var(--avatar-size, var(--space-10));
    overflow: hidden;
    border-radius: var(--radius-full);
    background: var(--avatar-bg, var(--color-action));
    color: var(--avatar-fg, var(--color-on-action));
    font-size: calc(var(--avatar-size, var(--space-10)) * 0.38);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-wide);
    line-height: var(--leading-none);
    text-transform: uppercase;
    object-fit: cover;
    user-select: none;
  }

  .avatar--sm {
    --avatar-size: var(--space-8);
  }

  .avatar--lg {
    --avatar-size: var(--space-16);
  }

  /* Muted: for lists where the person is not the point (audit log rows). */
  .avatar--muted {
    --avatar-bg: var(--color-surface-sunken);
    --avatar-fg: var(--color-text-muted);
  }

  /* Overlapping row; the surface-colored ring separates the circles. */
  .avatar-group {
    display: flex;
    margin: 0;
    padding: 0;
    padding-inline-start: var(--space-2);
    list-style: none;

    & > li {
      margin-inline-start: calc(-1 * var(--space-2));
    }

    & .avatar {
      box-shadow: 0 0 0 var(--space-1) var(--color-surface);
    }
  }

  /* "+3" at the end of a group. */
  .avatar--more {
    --avatar-bg: var(--color-surface-sunken);
    --avatar-fg: var(--color-text-muted);

    font-size: var(--text-xs);
    letter-spacing: normal;
    text-transform: none;
  }
}
