/* The others in the project (app/src/presence.ts): their avatars in the
   header; over the room their cursors, outlines on the tables they have in
   hand, and their drags; along the guest rows and on the fields what they
   have selected or are typing in. Each person has a
   colour, --peer-color, set on their elements. */

/* The layer over the room: the room's size, scaled with it (room.ts
   applyRoomScale); nothing in it takes the pointer. Its scale is undone on
   the cursors and labels through --room-inverse-scale, so they keep their
   size on screen whatever the zoom. */
#presenceLayer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  --room-inverse-scale: 1;
}

.peerCursor {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  transform: translate(var(--x), var(--y)) scale(var(--room-inverse-scale));
  transform-origin: 0 0;
  will-change: transform;
  color: var(--peer-color);
}
.peerCursor[hidden] {
  display: none;
}
.peerCursor svg {
  width: 18px;
  height: 18px;
  flex: none;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 30%));
}
.peerCursor .peerName {
  margin: 14px 0 0 -4px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--peer-color);
  color: var(--white);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A dashed outline laid over a table in someone's hand, like the table
   itself (room.ts: centred on left/top, turned); the same for the size a
   resize of theirs is at. Their cursor beside it carries the name. */
.peerTable,
.peerResize {
  position: absolute;
  box-sizing: border-box;
  outline: 2px dashed var(--peer-color);
  outline-offset: 3px;
  border-radius: 16px;
  pointer-events: none;
}
.peerTable.round,
.peerResize.round {
  border-radius: 50%;
}

/* A guest in someone's hand: a ball at their pointer, in the guest's
   colour, ringed in theirs. */
.peerGuestGhost {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--guest-color);
  border: 2px solid var(--peer-color);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  /* To the point, then the room's scale undone, then centred on it — the
     centring last, or it would be scaled too and the ball sit off the point. */
  transform: translate(var(--x), var(--y)) scale(var(--room-inverse-scale)) translate(-50%, -50%);
  transform-origin: 0 0;
  will-change: transform;
}

/* A guest row someone has selected (their colour along its left edge) or
   in hand (dashed), and a field someone is typing in. */
.guestRow.peerSelected {
  box-shadow: inset 4px 0 0 var(--peer-color);
}
.guestRow.peerClaimed,
.peerHoldsField {
  outline: 2px dashed var(--peer-color);
  outline-offset: -2px;
}

/* Refused: the holder's mark flashes. */
.peerClaimFlash {
  animation: peerClaimFlash 0.6s ease-out;
}
@keyframes peerClaimFlash {
  0%,
  40% {
    box-shadow: 0 0 0 4px var(--peer-color);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* The signed-in person's own colour on the header button while others are
   here — the one place to see what they see you as. */
#accountButton.withPeers #accountAvatar,
#accountButton.withPeers .smallIcon {
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--peer-color);
}

/* The header: one circle per person, overlapping a little, the picture
   when there is one and the initials else. */
#presenceAvatars {
  display: flex;
  align-items: center;
  padding-left: 6px;
}
#presenceAvatars[hidden] {
  display: none;
}
.peerAvatar {
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  margin-left: -8px;
  border-radius: 50%;
  border: 2px solid var(--peer-color);
  background: var(--peer-color);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  flex: none;
}
.peerAvatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
/* Looking at another room than this computer. */
.peerAvatar.elsewhere {
  opacity: 0.55;
}
/* A click follows the person (presence.ts toggleFollowing); the one
   followed is ringed. */
.peerAvatar {
  cursor: pointer;
}
.peerAvatar.unreachable {
  cursor: default;
}
.peerAvatar.following {
  z-index: 1;
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--peer-color);
}
.peerAvatar.more {
  background: var(--surface);
  border-color: var(--border);
  color: var(--textMuted);
  cursor: default;
}
