/* ========================================
   XP / Niveles — toast, widget de perfil, página de nivel
   ======================================== */

/* ── XP Toast (notificación sutil flotante) ──────────────────────── */

#xp-toasts {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}

.xp-toast {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 10px;
  background: rgba(20, 25, 22, 0.92);
  border: 1px solid rgba(255, 210, 63, 0.3);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: toast-slide-in 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: auto;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.xp-toast.-hiding {
  animation: toast-slide-out 160ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.xp-toast__bolt { font-size: 14px; line-height: 1; }
.xp-toast__text { letter-spacing: 0.04em; }

@media (max-width: 480px) {
  #xp-toasts { bottom: 5rem; right: 1rem; }
}

/* ── Tarjeta XP en el perfil ─────────────────────────────────────── */

.profile-xp-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
  margin-bottom: 8px; /* gap antes de los módulos */
}

.profile-xp-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 14px; height: 1px;
  background: var(--gold);
}

.profile-xp-card:hover {
  border-color: var(--line-strong);
}

/* Sección de barra — puede ser <a> (link al historial) o <div> */
.profile-xp-card__bar-section {
  display: block;
  padding: 14px 14px 0;
  color: inherit;
  text-decoration: none;
}

.profile-xp-card__level-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.profile-xp-card__level-current {
  font-family: var(--font-scoreboard);
  font-size: 22px;
  color: var(--gold);
  line-height: 1;
}

.profile-xp-card__level-next {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.05em;
}

.profile-xp-card__bar {
  height: 6px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.profile-xp-card__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #b8860b 0%, var(--gold) 55%, #ffe566 100%);
  border-radius: inherit;
  transition: width 0.5s ease;
}

.profile-xp-card__xp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding-bottom: 12px;
}

.profile-xp-card__xp-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.03em;
}

.profile-xp-card__xp-count strong {
  color: var(--fg-2);
  font-weight: 600;
}

.profile-xp-card__cta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
}
.profile-xp-card:hover .profile-xp-card__cta {
  opacity: 1;
}

/* Sección de recompensa — <details> colapsado por defecto: la card de
   nivel comía media pantalla; el detalle se abre tocando la fila. */
.profile-xp-card__reward {
  border-top: 1px solid var(--line);
  padding: 0 14px;
  background: rgba(255, 210, 63, 0.03);
}

.profile-xp-card__reward-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}
.profile-xp-card__reward-head::-webkit-details-marker { display: none; }
.profile-xp-card__reward-head::marker { content: ""; }

.profile-xp-card__reward-chev {
  display: inline-flex;
  color: var(--fg-3);
  transition: transform 180ms;
}
.profile-xp-card__reward[open] .profile-xp-card__reward-chev { transform: rotate(180deg); }
.profile-xp-card__reward[open] > .profile-xp-card__reward-items { margin-bottom: 12px; }

.profile-xp-card__reward-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.profile-xp-card__reward-missing {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  white-space: nowrap;
}
.profile-xp-card__reward-missing strong {
  color: var(--fg-2);
  font-weight: 600;
}

.profile-xp-card__reward-items {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.profile-xp-card__reward-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-xp-card__reward-item:last-child { border-bottom: none; }

.profile-xp-card__reward-item svg {
  color: var(--gold);
  flex-shrink: 0;
}

.profile-xp-card__reward-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--fg-2);
}

.profile-xp-card__reward-qty {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}

/* ── Nivel badge ─────────────────────────────────────────────────── */

.nivel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  background: rgba(255, 210, 63, 0.1);
  border: 1px solid rgba(255, 210, 63, 0.35);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.nivel-badge.-large {
  font-size: 15px;
  padding: 5px 14px;
}

/* ── Nivel bar ───────────────────────────────────────────────────── */

.nivel-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.nivel-bar.-hero {
  height: 10px;
  border-radius: 5px;
}

.nivel-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #c9960a 0%, var(--gold) 60%, #ffe566 100%);
  border-radius: inherit;
  transition: width 0.5s ease;
}

.nivel-xp-txt {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ── Página de nivel (/profile/xp_historial) ─────────────────────── */

.xp-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero */
.xp-hero {
  padding: 24px 20px 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.xp-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(255, 210, 63, 0.06) 0%, transparent 65%);
  pointer-events: none;
}

.xp-hero__level-num {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}
@media (min-width: 480px) {
  .xp-hero__level-num { font-size: 48px; }
}

.xp-hero__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
}

.xp-hero__progress {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-1);
}

.xp-hero__next {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.xp-hero__total {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
}

/* Próxima recompensa */
.xp-reward-card {
  padding: 18px;
  background: rgba(255, 210, 63, 0.04);
  border: 1px solid rgba(255, 210, 63, 0.22);
  border-radius: var(--radius);
}

.xp-reward-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 4px;
}

.xp-reward-card__label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.xp-reward-card__level {
  font-size: 12px;
  color: var(--ink-soft);
}

.xp-reward-card__items {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  overflow: hidden;
}

.xp-reward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.xp-reward-item:last-child { border-bottom: none; }

.xp-reward-item svg {
  color: var(--gold);
  flex-shrink: 0;
}

.xp-reward-item__lbl {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--fg-1);
}

.xp-reward-item__qty {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}

.xp-reward-card__missing {
  font-size: 13px;
  color: var(--ink-soft);
  padding-top: 14px;
  border-top: 1px solid rgba(255, 210, 63, 0.12);
}

.xp-reward-card__missing strong {
  color: var(--fg-1);
  font-weight: 600;
}

/* Cómo ganar XP */
.xp-sources {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.xp-sources__title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.xp-sources__group {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}

.xp-sources__group-label {
  padding: 8px 14px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.xp-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.xp-source-row:last-child { border-bottom: none; }

.xp-source-row.-highlight { background: rgba(255, 210, 63, 0.03); }

.xp-source-row__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.xp-source-row__name {
  font-size: 14px;
  color: var(--fg-1);
}

.xp-source-row__freq {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.xp-source-row__amount {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Historial de eventos */
.xp-log {}

.xp-log__title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.xp-log__list {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.xp-log__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.xp-log__row:last-child { border-bottom: none; }

.xp-log__source {
  font-size: 14px;
  color: var(--fg-1);
}

.xp-log__date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.xp-log__amount {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.xp-log__empty {
  font-size: 14px;
  color: var(--ink-soft);
  padding: 28px 16px;
  text-align: center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Invitaciones: banner one-time (variante) ────────────────────── */

.invite-reset-banner.-onetime {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.invite-reset-banner.-onetime > svg { color: var(--fg-2); }
.invite-reset-banner.-onetime strong { color: var(--fg-1); }

/* ── Nivel chip — etiqueta chica bajo el nombre en perfil público ──── */

.nivel-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--chip-color);
}

.nivel-chip.-dim    { --chip-color: #8a877c; --chip-border: rgba(138,135,124,0.4); --chip-bg: rgba(138,135,124,0.08); }
.nivel-chip.-sage   { --chip-color: #bad996; --chip-border: rgba(186,217,150,0.4); --chip-bg: rgba(186,217,150,0.08); }
.nivel-chip.-sky    { --chip-color: #76bcf5; --chip-border: rgba(118,188,245,0.4); --chip-bg: rgba(118,188,245,0.08); }
.nivel-chip.-gold   { --chip-color: var(--gold);   --chip-border: rgba(255,210, 63,0.45); --chip-bg: rgba(255,210, 63,0.08); }
.nivel-chip.-accent { --chip-color: var(--accent); --chip-border: rgba( 10,219,198,0.45); --chip-bg: rgba( 10,219,198,0.08); }
