/* ============================================================
   profile.css — Profile Page Styles
   Mahjong Sensei
   ============================================================ */

/* ─── Profile Body Container ─────────────────────────────────────────────── */
.profile-body {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ─── Profile Hero (Header) ──────────────────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

.profile-hero__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.profile-hero__avatar-emoji {
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.profile-hero__info {
  flex: 1;
  min-width: 0;
}

.profile-hero__name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.profile-hero__name {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--color-text);
  line-height: var(--lh-tight);
}

.profile-hero__name-input {
  font-size: var(--fs-xl);
  font-weight: 800;
  max-width: 280px;
}

.profile-hero__badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.rank-badge--lg {
  font-size: var(--fs-sm);
  padding: 0.25rem 0.75rem;
}

.profile-tier-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: capitalize;
}

.profile-tier-badge--beginner     { background: #e8f5e9; color: #2e7d32; }
.profile-tier-badge--intermediate { background: #e3f2fd; color: #1565c0; }
.profile-tier-badge--advanced     { background: #fce4ec; color: #ad1457; }

.profile-hero__level {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.profile-hero__level-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.profile-xp-track {
  flex: 1;
  min-width: 80px;
  max-width: 240px;
  height: 10px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.profile-xp-track__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.profile-hero__xp-text {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.profile-hero__mini-stats {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ─── Quick Stats Strip ──────────────────────────────────────────────────── */
.profile-quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.profile-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  transition: box-shadow 0.15s ease;
}

.profile-stat-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.profile-stat-card__value {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: var(--lh-tight);
  margin-bottom: 0.25rem;
}

.profile-stat-card__label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ─── Generic Profile Section ────────────────────────────────────────────── */
.profile-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.profile-section__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
}

.profile-section__count {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.profile-section__link {
  font-size: var(--fs-sm);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  align-self: flex-start;
}

.profile-section__link:hover {
  text-decoration: underline;
}

.profile-empty {
  padding: 1.5rem;
  text-align: center;
}

/* ─── Achievement Showcase ───────────────────────────────────────────────── */
.achievement-showcase {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

.achievement-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.875rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 90px;
}

.achievement-card--unlocked {
  border-color: var(--color-primary);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-primary) 5%, var(--color-surface)),
    var(--color-surface));
}

.achievement-card--unlocked:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.achievement-card--locked {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.achievement-card--lg {
  min-height: 120px;
  padding: 1.25rem 0.75rem;
  gap: 0.5rem;
}

.achievement-card__icon {
  font-size: 1.75rem;
  line-height: 1;
}

.achievement-card--lg .achievement-card__icon {
  font-size: 2rem;
}

.achievement-card__name {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
  line-height: var(--lh-tight);
}

.achievement-card__desc {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: var(--lh-normal);
}

.achievement-card__lock {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.7rem;
  opacity: 0.7;
}

/* ─── Pin Picker ─────────────────────────────────────────────────────────── */
.pin-picker {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.pin-picker__title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.pin-picker__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pin-picker__item {
  text-align: left;
  justify-content: flex-start;
}

.pin-picker__close {
  align-self: flex-end;
  margin-top: 0.25rem;
}

/* ─── Full Achievement Grid Overlay ──────────────────────────────────────── */
.achievement-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 400;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.achievement-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.achievement-overlay__header h3 {
  font-size: var(--fs-xl);
  font-weight: 800;
}

.achievement-full-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  flex: 1;
}

/* ─── Game History ───────────────────────────────────────────────────────── */
.game-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.game-history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  border-left-width: 4px;
  transition: box-shadow 0.1s ease;
}

.game-history-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.game-history-item--win  { border-left-color: var(--color-success); }
.game-history-item--last { border-left-color: var(--color-danger); }
.game-history-item--mid  { border-left-color: var(--color-border); }

.game-history-item__placement {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--color-text);
  min-width: 40px;
}

.game-history-item__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.game-history-item__date {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.game-history-item__accuracy {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.game-history-item__action {
  flex-shrink: 0;
}

/* ─── Character Collection ───────────────────────────────────────────────── */
.character-collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
}

.character-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  min-height: 120px;
}

.character-card--unlocked {
  border-color: var(--color-border);
}

.character-card--unlocked:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border-color: var(--color-primary);
}

.character-card--locked {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.character-card--equipped {
  border-color: var(--color-primary) !important;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-primary) 8%, var(--color-surface)),
    var(--color-surface));
}

.character-card__avatar {
  font-size: 2.5rem;
  line-height: 1;
}

.character-card__name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text);
}

.character-card__sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  line-height: var(--lh-tight);
}

.character-card__equipped-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-primary-text);
  background: var(--color-primary);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.character-card__lock {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ─── Cosmetics Section ──────────────────────────────────────────────────── */
.cosmetics-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  position: relative;
}

.cosmetics-row__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text);
  min-width: 110px;
}

.cosmetics-row__current {
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.cosmetics-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 50;
}

.lock-label {
  font-size: var(--fs-xs);
  opacity: 0.6;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .profile-hero {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }

  .profile-hero__name-row {
    justify-content: center;
  }

  .profile-hero__badges {
    justify-content: center;
  }

  .profile-hero__level {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .profile-xp-track {
    max-width: 200px;
    width: 200px;
  }

  .profile-hero__mini-stats {
    justify-content: center;
  }

  .achievement-showcase {
    grid-template-columns: repeat(3, 1fr);
  }

  .character-collection {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .profile-quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .achievement-showcase {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .achievement-overlay {
    padding: 1rem;
  }
}
