/* OAIT Design System 2.1.0 · reference/css/avatar-badge.css
   Avatars and badges (unit c-containers).

   Components
   - Avatar (.oa-avatar): a person as a circle (40px default, 56px --md, 96px --lg) with two-letter
     initials, a photo, or the person icon; an organization or app as a rounded square (--org);
     stacks (.oa-avatar-stack).
   - Badge (.oa-badge): the count badge after a control's label; the icon badge (--icon) and the
     dot (--dot) on an icon's top inline-end corner.

   Implements canonical §10.26, §4.7, §5.2, §5.3, §9 (photography) and D-CSN-32, D-CSN-33, D-ARC-14,
   D-ARC-20, D-ARC-23, D-BCP-36, D-BCP-39, D-SEM-10, D-TYP-12.

   Tokens read: --color-primary-container, --color-on-primary-container, --color-surface-container-high,
   --color-on-surface, --color-surface, --color-primary, --color-on-primary, --color-primary-ink;
   --size-avatar-sm, --size-avatar-md, --size-avatar-lg, --size-tile-md, --size-icon-lg;
   --radius-full, --radius-box, --radius-12px, --radius-24px; --space-0-5, --space-1, --space-1-5,
   --space-2; --font-weight-bold; --text-label-sm, --text-label-md, --text-title-md, and
   --text-display-sm with their companions.
   Component-local properties: --oa-avatar-size, --oa-avatar-ring.

   Classes: .oa-avatar (+ --sm, --md, --lg, --org; __img, __icon), .oa-avatar-stack,
   .oa-badge (+ --icon, --dot).

   Relies on base.css for .oa-icon and .oa-visually-hidden. */


/* ---------------------------------------------------------------------------------------------
   1. Person avatar. A circle at avatar-sm 40px (the default and --sm: rows, tables, the header),
   avatar-md 56px (card headers) or avatar-lg 96px (profile, person record). Two-letter initials,
   bold, at round(size × 0.36) px, on-primary-container on primary-container; a photo covers the
   circle; without photo or initials, the person icon at 60% of the size (D-CSN-32, D-ARC-23).
   Decorative (aria-hidden) beside the visible name, otherwise role="img" named by the person.
   --------------------------------------------------------------------------------------------- */

.oa-avatar {
  --oa-avatar-size: var(--size-avatar-sm);
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  inline-size: var(--oa-avatar-size);
  block-size: var(--oa-avatar-size);
  overflow: hidden;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-container);
  color: var(--color-on-primary-container);
  font-size: calc(var(--oa-avatar-size) * 0.36);
  font-size: round(nearest, calc(var(--oa-avatar-size) * 0.36), 1px); /* lint-ok: the initials formula round(size × 0.36) px (canonical §10.26); the line above is the fallback */
  font-weight: var(--font-weight-bold);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
  -webkit-user-select: none; /* Safari on iOS reads only the prefixed property */
  user-select: none;
}

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

.oa-avatar--md {
  --oa-avatar-size: var(--size-avatar-md);
}

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

/* The photo: decorative inside a named or aria-hidden avatar (alt=""), covering the circle. A
   product swaps it for the initials when it fails to load. */
.oa-avatar__img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* The last fallback: the person icon at 60% of the avatar. */
.oa-avatar .oa-avatar__icon {
  font-size: calc(var(--oa-avatar-size) * 0.6);
}


/* ---------------------------------------------------------------------------------------------
   2. Organization or app (--org). A rounded square on surface-container-high with the logo at 64%,
   or on-surface initials in on-scale styles: label-md at 40 and 48px, title-md at 56px, display-sm
   at 96px; person avatars keep round(size × 0.36) (D-CSN-32). 48px by default, the tile-md size of
   company and app logo tiles; --sm 40px, --md 56px, --lg 96px. Corners about a third of the size:
   12px below 44px, 16px (box) from 44 to 56px, 24px for 64 to 96px (canonical §5.2, §5.3;
   D-CSN-32, D-ARC-14). No logo is fetched from a third party; without one, the initials tile
   (D-BCP-36).
   --------------------------------------------------------------------------------------------- */

.oa-avatar--org {
  --oa-avatar-size: var(--size-tile-md);
  border-radius: var(--radius-box);
  background-color: var(--color-surface-container-high);
  color: var(--color-on-surface);
  font-size: var(--text-label-md);
  line-height: var(--text-label-md--line-height);
  letter-spacing: var(--text-label-md--letter-spacing);
  font-weight: var(--text-label-md--font-weight);
}

/* 40px keeps label-md, as at 48px. */
.oa-avatar--org.oa-avatar--sm {
  --oa-avatar-size: var(--size-avatar-sm);
  border-radius: var(--radius-12px);
}

.oa-avatar--org.oa-avatar--md {
  --oa-avatar-size: var(--size-avatar-md);
  font-size: var(--text-title-md);
  line-height: var(--text-title-md--line-height);
  letter-spacing: var(--text-title-md--letter-spacing);
  font-weight: var(--text-title-md--font-weight);
}

.oa-avatar--org.oa-avatar--lg {
  --oa-avatar-size: var(--size-avatar-lg);
  border-radius: var(--radius-24px);
  font-size: var(--text-display-sm);
  line-height: var(--text-display-sm--line-height);
  letter-spacing: var(--text-display-sm--letter-spacing);
  font-weight: var(--text-display-sm--font-weight);
}

.oa-avatar--org .oa-avatar__img {
  inline-size: 64%;
  block-size: 64%;
  object-fit: contain;
}


/* ---------------------------------------------------------------------------------------------
   3. Stack. Avatars overlap by 8px, each ringed 2px in the ground color so they stay apart: the
   page surface by default; a stack on another ground sets --oa-avatar-ring to that ground's role
   (canonical §10.26). The ring is a box-shadow halo, not an edge: it is decoration and may vanish in
   forced colors (canonical §6.3's surface halo).
   --------------------------------------------------------------------------------------------- */

.oa-avatar-stack {
  --oa-avatar-ring: var(--color-surface);
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.oa-avatar-stack > .oa-avatar {
  box-shadow: 0 0 0 2px var(--oa-avatar-ring);
}

.oa-avatar-stack > .oa-avatar + .oa-avatar {
  margin-inline-start: calc(-1 * var(--space-2));
}


/* ---------------------------------------------------------------------------------------------
   4. Count badge. 24px tall and at least 24px wide, 6px inline padding, a pill in primary with
   on-primary text (6.19:1; 5.70:1 under the Tamakkan accent), label-sm with tabular figures; "99+"
   above 99. It sits 8px after its label (the host's gap). The number is written into the control's
   accessible name ("Filters, 1 filter on"); the badge itself is aria-hidden (D-CSN-33, D-ARC-20).
   The transparent 1px border keeps its shape in forced colors (D-SEM-10).
   --------------------------------------------------------------------------------------------- */

.oa-badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-inline-size: 24px; /* component constant: count badge (canonical §10.26) */
  block-size: 24px; /* component constant: count badge (canonical §10.26) */
  padding-inline: var(--space-1-5);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--text-label-sm);
  line-height: var(--text-label-sm--line-height);
  letter-spacing: var(--text-label-sm--letter-spacing);
  font-weight: var(--text-label-sm--font-weight);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}


/* ---------------------------------------------------------------------------------------------
   5. Icon badge and dot (M3 defaults). They sit on the top inline-end corner of a 24px icon
   centered in its positioned host (an icon button or a navigation indicator). The icon badge is
   16px tall with a count in label-sm; the dot is 6px, in primary-ink, because it carries meaning
   without words and must reach 3:1 (primary is 2.63:1 on surface). Their meaning is in the host's
   accessible name (canonical §2.2, §10.26; D-CSN-33).
   --------------------------------------------------------------------------------------------- */

.oa-badge--icon,
.oa-badge--dot {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.oa-badge--icon {
  inset-block-start: calc(50% - var(--size-icon-lg) / 2 - var(--space-1));
  inset-inline-start: calc(50% + var(--space-0-5));
  min-inline-size: 16px; /* component constant: icon badge (canonical §10.26) */
  block-size: 16px; /* component constant: icon badge (canonical §10.26) */
  padding-inline: var(--space-1);
}

.oa-badge--dot {
  inset-block-start: calc(50% - var(--size-icon-lg) / 2);
  inset-inline-start: calc(50% + var(--size-icon-lg) / 2 - 6px); /* layout maths: the dot's end meets the icon's end */
  min-inline-size: 0;
  inline-size: 6px; /* component constant: badge dot (canonical §10.26) */
  block-size: 6px; /* component constant: badge dot (canonical §10.26) */
  padding: 0;
  border-width: 3px;
  background-color: var(--color-primary-ink);
}
