/**
 * Avatar Component Styles
 * Styling for user avatars with image support and initials fallback
 */

/* ============================================
   Base Avatar Styles
   ============================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
  vertical-align: middle;
}

/* ============================================
   Avatar Sizes
   ============================================ */

/* Small: 24px (sidebar user list, typing indicators) */
.avatar-small {
  width: 24px;
  height: 24px;
  font-size: 10px;
  font-weight: 600;
  line-height: 24px;
}

/* Medium: 32px (message feed, top nav) */
.avatar-medium {
  width: 32px;
  height: 32px;
  font-size: 14px;
  font-weight: 600;
  line-height: 32px;
}

/* Large: 48px (user profile dropdown) */
.avatar-large {
  width: 48px;
  height: 48px;
  font-size: 18px;
  font-weight: 600;
  line-height: 48px;
}

/* ============================================
   Avatar Type: Image
   ============================================ */

.avatar-image {
  object-fit: cover;
  background: var(--color-background, #F8F8F8);
}

/* ============================================
   Avatar Type: Initials
   ============================================ */

.avatar-initials {
  text-align: center;
  color: #FFFFFF;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   Avatar Loading States
   ============================================ */

/* Loading skeleton (for pre-render placeholders) */
.avatar-skeleton {
  background: linear-gradient(
    90deg,
    #E0E0E0 25%,
    #F0F0F0 50%,
    #E0E0E0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Lazy loading state (for Intersection Observer) */
.avatar-loading {
  background: #E0E0E0;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.avatar-loading.avatar-image {
  /* Subtle pulse effect while loading */
  animation: avatar-loading-pulse 1.5s ease-in-out infinite;
}

@keyframes avatar-loading-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.8;
  }
}

/* ============================================
   Avatar in Different Contexts
   ============================================ */

/* Avatar in message feed */
.message .avatar {
  margin-right: 8px;
}

/* Avatar in top navigation */
.top-nav .avatar {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.top-nav .avatar:hover {
  opacity: 0.8;
}

/* Avatar in sidebar user list */
.sidebar .avatar {
  margin-right: 8px;
}

/* ============================================
   Accessibility
   ============================================ */

/* Focus visible for keyboard navigation */
.avatar:focus-visible {
  outline: 2px solid var(--color-primary-purple, #4A154B);
  outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .avatar-skeleton,
  .avatar-loading {
    animation: none;
  }

  .avatar-skeleton {
    background: #E0E0E0;
  }

  .avatar-loading {
    opacity: 0.7;
  }
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* On very small screens, ensure avatars don't break layout */
@media (max-width: 320px) {
  .avatar-large {
    width: 40px;
    height: 40px;
    font-size: 16px;
    line-height: 40px;
  }
}
