/* Public profile dialog — scoped tokens so Account/Members pages both render it. */
.profile-popup-dialog {
  --pp-surface: color-mix(in srgb, var(--panel, #1a1a1a) 88%, #fff 4%);
  --pp-card: var(--panel, #1a1a1a);
  --pp-border: var(--line, #3a3a3a);
  --pp-border-light: color-mix(in srgb, var(--line, #3a3a3a) 70%, #fff 12%);
  --pp-text: var(--cream, #f2efe6);
  --pp-text-muted: var(--muted, #9a958c);
  --pp-accent: var(--gold-bright, #7cff4a);
  --pp-accent-hover: var(--gold, #00cc22);
  --pp-accent-soft: color-mix(in srgb, var(--gold, #00cc22) 14%, transparent);
  width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(92vh, 860px);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--pp-text);
  overflow: visible;
}

.profile-popup-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  animation: profile-popup-fade-in 0.15s ease-out;
}

html[data-theme="light"] .profile-popup-dialog {
  --pp-surface: #f1f5f9;
  --pp-card: #ffffff;
  --pp-border: #e2e8f0;
  --pp-border-light: #eef2f7;
  --pp-text: #0f172a;
  --pp-text-muted: #64748b;
  --pp-accent: var(--gold-bright, #1d4ed8);
  --pp-accent-hover: var(--gold, #1d4ed8);
  --pp-accent-soft: color-mix(in srgb, var(--gold, #1d4ed8) 12%, transparent);
}

html[data-theme="light"] .profile-popup-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

@keyframes profile-popup-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-popup-dialog[open] {
  animation: profile-popup-dialog-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes profile-popup-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.profile-popup {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--pp-accent) 8%, transparent), transparent 42%),
    var(--pp-card);
  border: 1px solid var(--pp-border);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  width: 100%;
  max-height: min(92vh, 860px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--pp-border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--pp-card) 92%, transparent);
  backdrop-filter: blur(6px);
}

.profile-popup-title {
  margin: 0;
  color: var(--pp-text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-popup-close {
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--pp-text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.profile-popup-close svg {
  width: 20px;
  height: 20px;
}

.profile-popup-close:hover {
  background: color-mix(in srgb, var(--pp-text) 10%, transparent);
  color: var(--pp-text);
}

.profile-popup-close:focus-visible {
  background: color-mix(in srgb, var(--pp-text) 10%, transparent);
  color: var(--pp-text);
  border-color: var(--pp-accent);
  outline: none;
}

.profile-popup-body {
  padding: 24px 22px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.profile-popup-body.loading .profile-popup-hero { opacity: 0; }
.profile-popup-body.loaded .profile-popup-hero { opacity: 1; transition: opacity 0.2s ease; }

.profile-popup .profile-popup-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

/* Size only — colored frame border comes from style_avatar_frames.css. */
.profile-popup .hero-avatar {
  --avatar-size: 104px;
  --photo-inset: 10px;
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  overflow: visible;
  border-radius: 50%;
  background: var(--pp-surface);
  box-sizing: border-box;
}

.profile-popup .hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-popup .hero-avatar .members-mark,
.profile-popup .hero-avatar .avatar-glyph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--pp-accent);
  background: var(--pp-surface);
  text-shadow: none;
  filter: none;
}

.profile-popup .hero-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.profile-popup .hero-name {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 750;
  color: var(--pp-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.profile-popup .profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
  color: var(--pp-text-muted);
  font-size: 0.95rem;
}

.profile-popup-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.profile-popup-stat {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--pp-border);
  background: var(--pp-surface);
  text-align: center;
}

.profile-popup-stat strong {
  color: var(--pp-text);
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.profile-popup-stat span {
  color: var(--pp-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.profile-popup-actions .profile-share-btn,
.profile-popup-actions .profile-upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--pp-border);
  background: var(--pp-surface);
  color: var(--pp-text);
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.profile-popup-actions .profile-share-btn:hover,
.profile-popup-actions button.profile-upvote-btn:hover:not(:disabled) {
  border-color: var(--pp-accent);
  color: var(--pp-accent);
}

.profile-popup-actions .profile-upvote-btn.upvoted,
.profile-popup-actions .profile-upvote-btn.is-upvoted,
.profile-popup-actions .profile-upvote-btn.is-own {
  border-color: var(--pp-accent);
  background: var(--pp-accent-soft);
  color: var(--pp-accent);
}

.profile-popup-actions .profile-upvote-btn.is-own {
  cursor: default;
}

.profile-popup-actions button.profile-upvote-btn:disabled {
  cursor: default;
  opacity: 0.95;
}

.profile-popup-achievements {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--pp-border);
}

.profile-popup-achievements h3,
.profile-popup-courses h3 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pp-accent);
}

.profile-popup-achievement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-popup-achievement-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--pp-border);
  background: var(--pp-surface);
  color: var(--pp-text);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.2;
}

.profile-popup-achievement-list li span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 13rem;
}

.profile-popup-courses {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--pp-border);
}

.profile-popup-course-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.profile-popup-course-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--pp-border);
  background: var(--pp-surface);
  color: var(--pp-text);
  text-decoration: none;
  font-weight: 650;
  font-size: 1rem;
}

.profile-popup-course-list a:hover {
  border-color: var(--pp-accent);
}

.profile-popup-course-list small {
  color: var(--pp-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.profile-popup-empty {
  margin: 0;
  color: var(--pp-text-muted);
  font-size: 0.95rem;
}

.profile-popup-error {
  text-align: center;
  padding: 40px 16px;
  color: var(--pp-text-muted);
  font-size: 0.95rem;
}

.profile-popup-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-avatar,
.skeleton-name,
.skeleton-meta,
.skeleton-stats {
  border-radius: 8px;
  background: var(--pp-surface);
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
}

.skeleton-name { height: 28px; width: 58%; }
.skeleton-meta { height: 18px; width: 38%; }
.skeleton-stats { height: 18px; width: 78%; }

@keyframes skeleton-loading {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.profile-popup .premium-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #fbbf24 70%, transparent);
  background: linear-gradient(180deg, rgba(253, 224, 71, 0.28), rgba(245, 158, 11, 0.12));
  color: #fbbf24;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.profile-popup .premium-pill--plus {
  border-color: rgba(96, 165, 250, 0.8);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.24), rgba(37, 99, 235, 0.12));
  color: #93c5fd;
}

@media (max-width: 480px) {
  .profile-popup-dialog {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }
  .profile-popup-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .profile-popup-dialog[open],
  .profile-popup-dialog::backdrop,
  .skeleton-avatar,
  .skeleton-name,
  .skeleton-meta,
  .skeleton-stats {
    animation: none !important;
    transition: none !important;
  }
}
