/* ============================================================
   CÁPSULAS GAMIFICADAS — VISTA DE PERFIL
   ------------------------------------------------------------
   Cabecera con avatar, estadísticas, galería de logros (ganados y
   pendientes) e historial de cápsulas.
   ============================================================ */

.profile {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.profile[hidden] {
  display: none;
}

/* ─── Cabecera ────────────────────────────────────────────── */
.profile__header {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.profile__avatar {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  object-fit: cover;
  image-rendering: pixelated;
  background: var(--panel-3);
  box-shadow: var(--outline-ring), var(--bevel-out);
}

.profile__identity {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.profile__name {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.profile__role {
  font-family: var(--font-pixel);
  font-size: 19px;
  color: var(--accent-ink);
}

.profile__email {
  font-size: var(--fs-body-sm);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile__level {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--ink-2);
}

.profile__header-actions {
  display: flex;
  flex: 0 0 auto;
  align-self: flex-start;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ─── Secciones ───────────────────────────────────────────── */
.profile__section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.profile__section-title {
  font-family: var(--font-display);
  font-size: var(--fs-display-sm);
  color: var(--ink);
}

/* F5.3: separa "solicitar baja" del resto — mismo tratamiento visual
   que .alert--error, para que se lea como zona sensible sin agregar
   un token de color nuevo. */
.profile__danger {
  padding: var(--sp-4);
  border-radius: var(--radius-sm);
  border-left: var(--px) solid var(--redstone);
  background: rgba(var(--redstone-rgb), 0.08);
}

.profile__stats {
  gap: var(--sp-3);
}

.profile__stats .stat-block {
  flex: 1 1 120px;
}

.profile__empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  box-shadow: var(--outline-ring);
}

/* ─── Formulario de edición ───────────────────────────────── */
.profile__form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.profile__form-actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ─── Galería de logros ───────────────────────────────────── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.badge-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--panel);
  box-shadow: var(--outline-ring), var(--bevel-out);
}

/* Los pendientes se apagan, pero siguen legibles: la idea es que se
   vean como una meta, no como un error. */
.badge-card[data-earned='false'] {
  background: var(--bg-2);
  box-shadow: var(--outline-ring);
}
.badge-card[data-earned='false'] .badge-card__name {
  color: var(--ink-2);
}
.badge-card[data-earned='false'] .badge-card__icon {
  color: var(--panel-3);
}

.badge-card__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--bg-2);
  font-family: var(--font-pixel);
  font-size: 26px;
  line-height: 1;
  box-shadow: var(--chip-ring), var(--bevel-in);
}

.badge-card[data-earned='true'] .badge-card__icon {
  background: var(--inset);
}

.badge-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.badge-card__name {
  font-family: var(--font-display);
  font-size: var(--fs-display-xs);
  line-height: 1.6;
  color: var(--ink);
}

.badge-card__desc {
  font-size: var(--fs-body-sm);
  color: var(--muted);
}

.badge-card__progress {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.badge-card__track {
  flex: 1;
  height: 10px;
  background: var(--panel-3);
  box-shadow: var(--chip-ring), var(--bevel-in);
  overflow: hidden;
}

.badge-card__fill {
  display: block;
  height: 100%;
  background: var(--gold);
  transition: width var(--dur-slow) var(--ease);
}

.badge-card__count {
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}

/* ─── Historial ───────────────────────────────────────────── */
.history {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.history__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel);
  box-shadow: var(--outline-ring);
  border-left: var(--px) solid var(--grass);
}

.history__check {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: var(--grass);
  color: var(--on-grass);
  font-family: var(--font-pixel);
  font-size: 18px;
  box-shadow: var(--chip-ring);
}

.history__body {
  min-width: 0;
}

.history__title {
  font-family: var(--font-display);
  font-size: 9px;
  line-height: 1.7;
  color: var(--ink);
}

.history__meta {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--muted);
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .profile__header {
    gap: var(--sp-4);
  }
  .profile__avatar {
    width: 64px;
    height: 64px;
  }
  .badge-grid {
    grid-template-columns: 1fr;
  }
  .profile__stats .stat-block {
    flex: 1 1 calc(50% - var(--sp-3));
  }
}
