/*
  Avatar 02 — Presence Avatar — standalone HTML/CSS/JS.
  No build step, no framework, no external dependency: copy index.html,
  this file, and script.js into any project as-is.
*/

:root {
  --presence-online: oklch(0.62 0.17 145);
  --presence-away: oklch(0.76 0.15 70);
  --presence-busy: oklch(0.58 0.2 27);
  --presence-offline: oklch(0.66 0 0);
}

.avatar02 {
  --avatar02-glyph: 12px;
  --avatar02-gap: 2px;
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  vertical-align: middle;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.avatar02--lg {
  --avatar02-glyph: 16px;
  --avatar02-gap: 2.5px;
  width: 3.5rem;
  height: 3.5rem;
}

/* The status isn't a dot stuck on top: a notch is cut out of the avatar and
   the status glyph sits inside it, so it reads on any background. */
.avatar02__face {
  --avatar02-r: calc(var(--avatar02-glyph) / 2);
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  background-color: oklch(0.93 0.02 250);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: oklch(0.38 0.05 250);
  user-select: none;
  -webkit-mask: radial-gradient(
    circle at calc(100% - var(--avatar02-r)) calc(100% - var(--avatar02-r)),
    transparent calc(var(--avatar02-r) + var(--avatar02-gap)),
    #000 calc(var(--avatar02-r) + var(--avatar02-gap) + 0.5px)
  );
  mask: radial-gradient(
    circle at calc(100% - var(--avatar02-r)) calc(100% - var(--avatar02-r)),
    transparent calc(var(--avatar02-r) + var(--avatar02-gap)),
    #000 calc(var(--avatar02-r) + var(--avatar02-gap) + 0.5px)
  );
}

.avatar02--lg .avatar02__face {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.avatar02__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 240ms ease-out;
}

.avatar02__image[data-loaded] {
  opacity: 1;
}

.avatar02__image[data-failed] {
  display: none;
}

.avatar02__glyph {
  position: absolute;
  right: 0;
  bottom: 0;
  display: block;
  width: var(--avatar02-glyph);
  height: var(--avatar02-glyph);
  animation: avatar02-swap 260ms cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

.avatar02__glyph svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Each status has its own shape, so it never depends on colour alone. */
.avatar02__glyph [data-shape] {
  display: none;
}
.avatar02__glyph[data-status="online"] [data-shape="online"],
.avatar02__glyph[data-status="away"] [data-shape="away"],
.avatar02__glyph[data-status="busy"] [data-shape="busy"],
.avatar02__glyph[data-status="offline"] [data-shape="offline"] {
  display: inline;
}

.avatar02__fill-online {
  fill: var(--presence-online);
}
.avatar02__fill-away {
  fill: var(--presence-away);
}
.avatar02__fill-busy {
  fill: var(--presence-busy);
}
.avatar02__stroke-offline {
  stroke: var(--presence-offline);
}

@keyframes avatar02-swap {
  from {
    transform: scale(0.4) rotate(-60deg);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar02__glyph {
    animation: none;
  }
  .avatar02__image {
    transition: none;
  }
}

/*
  Page layout — the canvas this resource is presented on. Adjust or drop it
  when placing the resource inside your own layout.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.5;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}
p,
ul,
fieldset {
  margin: 0;
  padding: 0;
}
ul {
  list-style: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.avatar02-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}
.avatar02-layout__card {
  container-type: inline-size;
  width: 100%;
  max-width: 40rem;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 16px 40px -16px rgba(0, 0, 0, 0.12);
}
.avatar02-layout__head {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.25rem 0;
}
.avatar02-layout__who {
  min-width: 0;
  flex: 1;
}
.avatar02-layout__name {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: oklch(0.205 0 0);
}
.avatar02-layout__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: oklch(0.556 0 0);
}
.avatar02-layout__current {
  color: oklch(0.371 0 0);
}
.avatar02-layout__context {
  display: none;
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.708 0 0);
}
.avatar02-layout__options {
  min-width: 0;
  border: 0;
  padding: 1rem 1.25rem 1.25rem;
}
.avatar02-layout__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.avatar02-layout__option {
  position: relative;
  display: flex;
  min-height: 2.75rem;
  cursor: pointer;
  align-items: center;
  gap: 0.625rem;
  border: 1px solid oklch(0.922 0 0);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  transition:
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.avatar02-layout__option:hover {
  background: oklch(0.985 0 0);
}
.avatar02-layout__option:has(:checked) {
  border-color: oklch(0.205 0 0);
  background: oklch(0.985 0 0);
}
.avatar02-layout__option:has(:focus-visible) {
  outline: 2px solid oklch(0.205 0 0);
  outline-offset: 2px;
}
.avatar02-layout__mark {
  display: block;
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}
.avatar02-layout__option-text {
  min-width: 0;
}
.avatar02-layout__option-label,
.avatar02-layout__option-hint {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar02-layout__option-label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: oklch(0.205 0 0);
}
.avatar02-layout__option-hint {
  font-size: 11px;
  line-height: 1rem;
  color: oklch(0.556 0 0);
}
.avatar02-layout__team {
  border-top: 1px solid oklch(0.97 0 0);
  background: oklch(0.985 0 0 / 0.6);
  padding: 0.875rem 1.25rem;
}
.avatar02-layout__team ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}
.avatar02-layout__member {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.avatar02-layout__member-name {
  display: block;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: oklch(0.269 0 0);
}
.avatar02-layout__member-note {
  display: block;
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.556 0 0);
}
@media (min-width: 40rem) {
  .avatar02-layout {
    padding: 2rem;
  }
}
@container (min-width: 32rem) {
  .avatar02-layout__context {
    display: block;
  }
}
