/* ==========================================================================
   Profile Page — GP-DESIGN-002-B3
   Stitch-cold фон, avatar 80x80, pill-tabs, achievements grid, balance banner
   Depends on: design-tokens.css (CSS vars)
   ========================================================================== */

/* --- Profile View Container --- */
#tab-profile {
  min-height: 100%;
  background: var(--surface);
  padding-bottom: 100px;
}

/* --- Profile Pill Tabs (Персонаж / Город) --- */
.profile-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 20px 0;
}

.profile-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.profile-tab.active {
  background: var(--primary);
  color: var(--on-primary);
}

.profile-tab:not(.active) {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}

/* --- Profile Sub-screens --- */
.profile-screen {
  display: none;
}

.profile-screen.active {
  display: block;
  animation: profileFadeIn 0.3s ease forwards;
}

@keyframes profileFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Avatar Room (hero zone) --- */
.profile-avatar-room {
  margin: 16px 20px;
  background: var(--pixel-dark);
  border-radius: var(--radius-lg);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  height: 200px;
}

.profile-avatar-room__bg {
  position: absolute;
  inset: 0;
  background: url('/assets/rooms/room-cozy.png') center / cover;
  image-rendering: pixelated;
  opacity: 0.6;
}

/* Avatar placeholder — hidden until new sprites ready */

/* Name and rank — OUTSIDE the room */
.profile-avatar-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--on-surface);
  margin-top: 12px;
  text-align: center;
  padding: 0 20px;
}

.profile-avatar-rank {
  font-size: 14px;
  font-weight: 700;
  color: var(--xp-gold);
  margin-top: 4px;
  margin-bottom: 12px;
  text-align: center;
  padding: 0 20px;
}

/* --- XP Section --- */
.profile-xp-section {
  margin: 0 20px;
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.profile-xp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.profile-xp-level {
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface);
}

.profile-xp-label {
  font-size: 13px;
  color: var(--on-surface-variant);
  font-weight: 600;
}

.profile-xp-bar-outer {
  height: 12px;
  background: var(--surface-container);
  border-radius: 6px;
  overflow: hidden;
}

.profile-xp-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--xp-gold), #FBBF24);
  border-radius: 6px;
  min-width: 4px;
  transition: width 0.5s ease;
  position: relative;
}

.profile-xp-bar-inner::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  right: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
}

.profile-xp-progress-label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--on-surface-variant);
  font-weight: 600;
  text-align: center;
}

/* --- Stats Row --- */
.profile-stats-row {
  display: flex;
  gap: 10px;
  margin: 16px 20px;
}

.profile-stat-card {
  flex: 1;
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.profile-stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--on-surface);
}

.profile-stat-value--gold   { color: var(--xp-gold); }
.profile-stat-value--green  { color: var(--tertiary); }
.profile-stat-value--orange { color: var(--cta); }

.profile-stat-label {
  font-size: 11px;
  color: var(--on-surface-variant);
  font-weight: 600;
  margin-top: 2px;
}

/* --- Achievements --- */
.profile-achievements-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--on-surface);
  margin: 0 20px 12px;
}

.profile-achievements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 20px 16px;
}

/* Achievement card — container NEVER changes (locked = greyscale on internals only) */
.profile-ach-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow);
}

/* Locked: internal elements greyscale+opacity, card shape/shadow untouched */
.profile-ach-card--locked .profile-ach-icon,
.profile-ach-card--locked .profile-ach-name,
.profile-ach-card--locked .profile-ach-prog,
.profile-ach-card--locked .profile-ach-bar-inner {
  opacity: 0.5;
  filter: grayscale(100%);
  -webkit-filter: grayscale(100%);
}

.profile-ach-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.profile-ach-icon .material-symbols-outlined {
  font-size: 24px;
}

.profile-ach-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--on-surface);
}

.profile-ach-prog {
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.profile-ach-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-container);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.profile-ach-bar-inner {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.profile-ach-bar-inner--bronze { background: #CD7F32; }
.profile-ach-bar-inner--silver { background: #9BA3AF; }
.profile-ach-bar-inner--gold   { background: var(--xp-gold); }

/* --- Balance Banner --- */
.profile-balance-card {
  margin: 0 20px 16px;
  background: linear-gradient(135deg, var(--cta), #FB923C);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}

.profile-balance-card:active {
  transform: scale(0.98);
}

.profile-balance-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-balance-coin {
  width: 40px;
  height: 40px;
  background: var(--xp-gold);
  border-radius: 50%;
  border: 3px solid var(--pixel-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--pixel-dark);
  flex-shrink: 0;
}

.profile-balance-amount {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

.profile-balance-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

.profile-balance-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  padding: 10px 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

/* --- City Placeholder --- */
.profile-city-placeholder {
  margin: 20px;
  padding: 60px 20px;
  text-align: center;
  background: var(--surface-container-low);
  border-radius: var(--radius-lg);
}

.profile-city-placeholder .material-symbols-outlined {
  font-size: 48px;
  color: var(--outline);
  margin-bottom: 12px;
  display: block;
}

.profile-city-placeholder h3 {
  font-size: 18px;
  color: var(--on-surface-variant);
  font-weight: 700;
}

.profile-city-placeholder p {
  font-size: 13px;
  color: var(--on-surface-variant);
  opacity: 0.7;
  margin-top: 6px;
}

/* --- Profile Actions (Settings / Logout) --- */
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 20px 40px;
}

.profile-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 56px;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.profile-action-btn:active {
  transform: scale(0.98);
}

.profile-action-btn .material-symbols-outlined {
  font-size: 20px;
}

.profile-action-btn--danger {
  color: var(--error);
}

/* --- Loading / Error states --- */
.profile-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 14px;
}

.profile-error {
  margin: 16px 20px;
  padding: 12px 16px;
  background: rgba(172, 52, 52, 0.1);
  border-radius: 12px;
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
}
