/* ==========================================================================
   Profile customization page (LITE / PREMIUM / FOUNDER)
   ========================================================================== */

.profile-page {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-3xl);
}

.profile-intro {
  max-width: 760px;
  margin: 0 auto var(--space-xl);
  text-align: center;
}
.profile-intro h1 {
  margin: 0 0 var(--space-sm);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: var(--gradient-gold, linear-gradient(135deg, #fcd34d, #fbbf24, #f59e0b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.profile-intro p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  line-height: 1.6;
}

.profile-root {
  --profile-name-color: var(--color-text);
  --profile-frame-color: rgba(99, 102, 241, 0.5);
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  background: linear-gradient(145deg, var(--color-bg-card), var(--color-bg-elevated));
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  isolation: isolate;
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
  animation: profileCardIn 0.7s var(--ease-out-soft) both;
}

.profile-root.bg-aurora {
  background:
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.32), transparent 48%),
    radial-gradient(circle at 85% 25%, rgba(34, 211, 238, 0.24), transparent 45%),
    linear-gradient(145deg, var(--color-bg-card), var(--color-bg-elevated));
}
.profile-root.bg-nebula {
  background:
    radial-gradient(circle at 20% 80%, rgba(244, 114, 182, 0.28), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.3), transparent 45%),
    linear-gradient(145deg, var(--color-bg-card), var(--color-bg-elevated));
}
.profile-root.bg-obsidian {
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.18), transparent 55%),
    linear-gradient(145deg, #0b0b0e, #17120c);
}
.profile-root.bg-royal {
  background:
    radial-gradient(circle at 20% 10%, rgba(240, 171, 252, 0.24), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.2), transparent 45%),
    linear-gradient(145deg, #100b1c, #1a1024);
}

.profile-root.frame-gold {
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: var(--shadow-xl), 0 0 60px rgba(251, 191, 36, 0.16);
}
.profile-root.frame-founder {
  border-color: rgba(240, 171, 252, 0.7);
  box-shadow: var(--shadow-xl), 0 0 70px rgba(240, 171, 252, 0.18);
}
.profile-root.style-founder::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 22px, rgba(251, 191, 36, 0.04) 22px 23px);
}

.profile-banner {
  position: relative;
  min-height: 132px;
  display: flex;
  align-items: flex-end;
  padding: var(--space-lg);
  background: linear-gradient(110deg, #1c1305, #4a2f08 45%, #1c1305);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  overflow: hidden;
}
.profile-banner[hidden] { display: none; }
.profile-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 35%, rgba(251, 191, 36, 0.22) 50%, transparent 65%);
  animation: profileBannerSheen 6s var(--ease-in-out-soft) infinite;
}
.profile-banner-text {
  position: relative;
  z-index: 1;
  color: #fbbf24;
  font-weight: 800;
  font-size: var(--text-sm);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.profile-body {
  position: relative;
  padding: clamp(var(--space-lg), 4vw, var(--space-2xl));
}

.profile-head {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin-top: calc(-1 * var(--space-2xl));
  margin-bottom: var(--space-xl);
}

.profile-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 104px;
  height: 104px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover, #818cf8));
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 0 0 4px var(--color-bg-card), 0 12px 30px rgba(0, 0, 0, 0.45);
  overflow: visible;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.profile-avatar.avatar-frame-glow {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 0 6px rgba(251, 191, 36, 0.28), 0 12px 34px rgba(251, 191, 36, 0.3);
}
.profile-avatar.avatar-frame-animated::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(#f0abfc, #fbbf24, #f0abfc, #7dd3fc, #f0abfc);
  animation: profileAvatarSpin 5s linear infinite;
  z-index: -1;
}
.profile-avatar.avatar-frame-animated::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.65);
  animation: profileAvatarPulse 2.8s var(--ease-in-out-soft) infinite;
}

.profile-identity { min-width: 0; padding-top: var(--space-xl); }
.profile-name-line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.profile-prefix {
  padding: 2px var(--space-sm);
  border: 1px solid var(--profile-frame-color, rgba(99, 102, 241, 0.5));
  border-radius: var(--radius-sm);
  background: var(--color-accent-glow);
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.profile-name {
  color: var(--profile-name-color);
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  font-weight: 800;
  text-shadow: 0 0 18px color-mix(in srgb, var(--profile-name-color), transparent 70%);
}
.profile-founder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #2b1a04;
  font-size: 0.9rem;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.5);
}
.profile-subtitle {
  margin: var(--space-xs) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.profile-bio {
  margin: var(--space-sm) 0 0;
  max-width: 62ch;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.profile-bio[hidden] { display: none; }

.profile-medal {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--radius-lg);
  background: rgba(251, 191, 36, 0.08);
  animation: profileCardIn 0.8s var(--ease-out-soft) 0.1s both;
}
.profile-medal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fde68a, #d97706);
  color: #3b2405;
  font-weight: 900;
  font-size: 0.8rem;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.35);
}
.profile-medal-svg {
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.45));
}
.profile-medal-text strong { display: block; font-size: var(--text-base); color: var(--collection-gold, #fbbf24); }
.profile-medal-text span { font-size: var(--text-xs); color: var(--color-text-dim); }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.profile-stat {
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
}
.profile-stat span { display: block; color: var(--color-text-dim); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.profile-stat strong { display: block; margin-top: var(--space-xs); font-size: var(--text-base); }

.profile-username-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}
.profile-username-row input {
  flex: 1 1 240px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text);
  font: inherit;
}
.profile-username-hint { flex-basis: 100%; margin: 0; color: var(--color-text-dim); font-size: var(--text-xs); }
.profile-username-row.needs-minecraft-name {
  padding: var(--space-md);
  border: 1px solid rgba(103, 232, 249, 0.55);
  border-radius: var(--radius-lg);
  background: rgba(103, 232, 249, 0.07);
}
.profile-username-row.needs-minecraft-name .profile-username-hint { color: #a5f3fc; }

.profile-empty {
  padding: var(--space-xl);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--color-text-muted);
}
.profile-empty[hidden] { display: none; }

.profile-customizer { margin-top: var(--space-3xl); }
.profile-customizer > h2 { margin: 0 0 var(--space-sm); font-size: var(--text-2xl); text-align: center; }
.profile-customizer > p { margin: 0 0 var(--space-xl); text-align: center; color: var(--color-text-muted); }

.profile-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}
.profile-group {
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, var(--color-bg-card), var(--color-bg-elevated));
}
.profile-group h3 { margin: 0 0 var(--space-sm); font-size: var(--text-lg); }
.profile-group > p { margin: 0 0 var(--space-md); color: var(--color-text-dim); font-size: var(--text-xs); }

/* Supabase profile editor: the browser only sends whitelisted visual fields. */
#profile-supabase-panel:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}
#profile-supabase-panel .profile-group select,
#profile-supabase-panel .profile-group input[type="url"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text);
  font: inherit;
}
#profile-supabase-panel .profile-group select:disabled,
#profile-supabase-panel .profile-group input:disabled { opacity: 0.55; cursor: not-allowed; }
#profile-supabase-panel .sub-current-actions { grid-column: 1 / -1; }

.profile-options { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.profile-option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.profile-option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--color-accent); }
.profile-option.selected { border-color: var(--color-success); box-shadow: 0 0 0 1px var(--color-success) inset; }
.profile-option.locked { opacity: 0.55; cursor: not-allowed; }
.profile-option:disabled { opacity: 0.65; cursor: not-allowed; }
.profile-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--swatch, var(--color-accent));
}
.profile-option-tier { color: var(--collection-gold, #fbbf24); font-size: var(--text-xs); font-weight: 700; }

.profile-upsell {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-lg);
  background: var(--color-accent-glow);
  text-align: center;
}
.profile-upsell[hidden] { display: none; }

/* Background from public.profiles: blurred and darkened so text stays legible. */
.profile-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--profile-bg-image, none);
  background-size: cover;
  background-position: center;
  filter: blur(10px) saturate(1.2);
  transform: scale(1.08);
  opacity: 0;
  transition: opacity var(--transition-base);
}
.profile-root.has-profile-bg .profile-bg { opacity: 1; }
.profile-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 11, 20, 0.72), rgba(8, 11, 20, 0.9)),
              radial-gradient(circle at 50% 0%, rgba(251, 191, 36, 0.12), transparent 60%);
  backdrop-filter: blur(2px);
}
.profile-root.has-profile-bg { border-color: rgba(251, 191, 36, 0.28); }
.profile-banner,
.profile-body { position: relative; z-index: 1; }

/* Tier accents match the site privilege showcase. */
.profile-root.plan-lite { border-color: rgba(103, 232, 249, 0.35); }
.profile-root.plan-premium {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: var(--shadow-xl), 0 0 50px rgba(251, 191, 36, 0.12);
}
.profile-root.plan-founder {
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: var(--shadow-xl), 0 0 80px rgba(245, 158, 11, 0.2);
}
.profile-root.plan-founder .profile-banner-text {
  color: #fde68a;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.6);
}
.profile-root.plan-free .profile-name { text-shadow: none; }

.profile-page.founder-page { position: relative; isolation: isolate; }
.profile-page.founder-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-2xl);
  background: radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.14), transparent 55%),
              radial-gradient(ellipse at 50% 100%, rgba(240, 171, 252, 0.08), transparent 50%);
}

.profile-perks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
}
.profile-perk {
  padding: 6px 10px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.08);
  color: var(--collection-gold, #fbbf24);
  font-size: var(--text-xs);
}
.profile-root.plan-lite .profile-perk {
  border-color: rgba(103, 232, 249, 0.35);
  background: rgba(103, 232, 249, 0.08);
  color: #a5f3fc;
}
.profile-root.plan-founder .profile-perk {
  border-color: rgba(240, 171, 252, 0.4);
  background: rgba(240, 171, 252, 0.1);
  color: #f0abfc;
}
.profile-perk-free { opacity: 0.85; }
.profile-medal-extra { margin-left: var(--space-sm); color: var(--color-text-muted); }

/* Icons of awards the player owns. Never rendered for missing awards. */
.profile-awards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
}
.profile-awards[hidden] { display: none; }
.profile-awards-label {
  width: 100%;
  color: var(--color-text-dim);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.profile-award {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius-md);
  background: radial-gradient(circle at 50% 35%, rgba(251, 191, 36, 0.16), rgba(15, 23, 42, 0.7));
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.profile-award:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.3);
}
.profile-award svg {
  display: block;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

.profile-plan-tag,
.profile-preview-tag {
  margin-left: var(--space-sm);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
}
.profile-plan-tag {
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
}
.profile-preview-tag {
  border: 1px solid rgba(103, 232, 249, 0.45);
  background: rgba(103, 232, 249, 0.1);
  color: #a5f3fc;
}
#profile-supabase-panel .profile-group.is-preview {
  border-style: dashed;
  border-color: rgba(103, 232, 249, 0.45);
}
.profile-privilege-group { border-color: rgba(251, 191, 36, 0.28); }
.profile-lock-note { margin: var(--space-sm) 0 0; color: #a5f3fc; font-size: var(--text-xs); }
.profile-lock-note a { color: #fbbf24; text-decoration: underline; }
.sub-current-actions .profile-lock-note { margin: 0; }

@keyframes profileCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes profileBannerSheen {
  0%, 42% { transform: translateX(-110%); opacity: 0; }
  56% { opacity: 0.9; }
  84% { opacity: 0.9; }
  100% { transform: translateX(110%); opacity: 0; }
}
@keyframes profileAvatarSpin { to { transform: rotate(360deg); } }
@keyframes profileAvatarPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); }
  50% { box-shadow: 0 0 18px rgba(251, 191, 36, 0.5); }
}

@media (max-width: 640px) {
  .profile-head { margin-top: calc(-1 * var(--space-xl)); }
  .profile-avatar { width: 84px; height: 84px; }
  .profile-body { padding: var(--space-md); }
}

@media (prefers-reduced-motion: reduce) {
  .profile-root,
  .profile-medal,
  .profile-banner::after,
  .profile-avatar.avatar-frame-animated::before,
  .profile-avatar.avatar-frame-animated::after { animation: none; }
}
