/* profile-editor.css */

/* --- Profile Dialog Overrides --- */
.profile-dialog {
  width: min(720px, calc(100vw - 24px));
  max-width: 720px;
  height: min(820px, calc(100dvh - 24px));
  max-height: none;
  overflow: hidden;
  padding: 16px;
  /* Inherits background #123536, color #f9f3e5 from base dialog */
}

.profile-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-dialog > :not(.profile-grid) {
  flex-shrink: 0;
}

.profile-dialog h2,
.profile-dialog label {
  margin: 0;
}

/* --- Profile Preview --- */
.profile-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
  flex-shrink: 0;
}

.profile-preview .profile-avatar {
  height: clamp(80px, 15dvh, 120px);
  width: auto;
  max-width: 160px;
  object-fit: contain;
  object-position: center;
}

/* --- Profile Tabs --- */
.profile-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 0;
}

.profile-tab {
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #f9f3e5;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s;
}

.profile-tab[aria-selected="true"] {
  border-color: #ffd700; /* Gold */
  background: rgba(255, 215, 0, 0.1);
  font-weight: bold;
}

.profile-tab:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

/* --- Profile Grid (Avatar Selection) --- */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  grid-auto-rows: 160px;
  gap: 8px;
  flex: 1;
  min-height: 80px;
  max-height: none;
  align-content: start;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  margin-bottom: 0;
}

.profile-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s;
  min-height: 44px;
  background: #204d45;
  color: #fff8e8;
  min-width: 0;
}

.profile-choice:hover {
  background: #28594f;
}

.profile-choice:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.profile-choice[aria-pressed="true"] {
  border-color: #ffd700;
  background: #3d5136;
}

.profile-choice img {
  width: 100%;
  height: 100px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 4px;
}

.profile-choice-label {
  font-size: 12px;
  color: #f9f3e5;
  margin-top: 4px;
  text-align: center;
  white-space: normal;
  flex-shrink: 0;
  line-height: 1.2;
  width: 100%;
}

/* --- Profile Actions --- */
.profile-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 10px 0 0;
  background: #123536; /* Teal */
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: static;
  flex-shrink: 0;
}

/* --- Profile Error --- */
.profile-error {
  color: #ff7f50; /* Coral */
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
}

/* --- Avatar Helper & General Overrides --- */

.topbar:has(.profile-trigger) {
  flex-wrap: wrap;
  gap: 8px;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 5px;
  min-height: 44px;
  border: 1px solid #e3c784;
  border-radius: 12px;
  background: #244f46;
  color: #fff1c9;
  font-size: 12px;
  white-space: nowrap;
}

.profile-trigger .avatar {
  width: 30px;
  height: 30px;
}

/* General profile avatar styling */
.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%; /* Waist-up focus for general avatars */
}

/* Clip existing avatar containers round overflow hidden */
.avatar,
.base-token,
.self-portrait {
  overflow: hidden;
  border-radius: 50%;
}

/* Seat portrait specific handling */
.seat-portrait {
  position: relative;
  /* Badge remains visible outside the clipped span */
}

.seat-portrait > span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden; /* Only this span is clipped */
}



/* Ensure profile-avatar inside these containers respects the clip */
.avatar .profile-avatar,
.base-token .profile-avatar,
.self-portrait .profile-avatar,
.seat-portrait > span .profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
}

/* Mobile Optimization for Tabs */
@media (max-width: 320px) {
  .profile-tabs {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .profile-tab {
    font-size: 12px;
    padding: 6px 2px;
  }
  
  .profile-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .profile-tab,
  .profile-choice,
  .profile-choice img {
    transition: none;
  }
}
