/* Badges — medallas en el perfil.
 *
 * El layout base (`.profile-badges-row`, `.profile-badge-chip`) vive en
 * `social-overrides.css`. Acá sólo las piezas nuevas: imágenes dentro del
 * chip, el pulse de "just unlocked", y el toast + confetti overlay.
 */

/* Count "5 / 12" a la derecha del header. */
.profile-badges-count {
    color: #6b7588;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Compact friends card: counter sits between title and Buscar button. */
.friends-section-compact .section-header {
    gap: 0.6rem;
    align-items: center;
}

.friends-section-compact .friends-count {
    color: #9ca9bb;
    font-size: 0.78rem;
    font-weight: 600;
    flex: 1 1 auto;
}

/* Recientes block inside the search panel. Only renders when the user has at
 * least one friend, so new users see the plain search input. */
.friends-recent {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #1f2633;
}

.friends-recent-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7588;
    margin-bottom: 0.45rem;
}

.friends-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.friends-recent-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    border: 1px solid #2e3646;
    border-radius: 999px;
    background: #171d27;
    color: #e6ebf2;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.friends-recent-chip:hover {
    border-color: #3b4556;
    background: #1c2230;
}

.friends-recent-chip .friends-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
}

/* Icono dentro del chip. PNGs ya vienen con fondo transparente (ver
 * badges_service.badge_icon_filename); no hace falta máscara circular. */
.profile-badge-chip img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
}

/* Override del placeholder de social-overrides.css: el chip original era
 * 78×78 fijo, pensado para íconos sin texto largo. Ensanchamos y forzamos
 * el nombre a una sola línea para que el ícono quede centrado sin cortes. */
.profile-badges-row .profile-badge-chip {
    width: auto;
    min-width: 96px;
    max-width: 112px;
    /* Let the chip grow to fit (icon + label) + padding. No fixed height:
     * otherwise extra vertical space pushes the visual weight off-center
     * (hamburger body sits low in each icon). */
    height: auto;
    min-height: 0;
    padding: 0.55rem 0.6rem;
    gap: 0.35rem;
    font-size: 0.6rem;
}

.profile-badges-row .profile-badge-chip span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Empty state cuando no hay badges (usuario nuevo nunca debería llegar acá
 * porque la API siempre devuelve los 12 con earned=false). */
.profile-badges-row:empty::before {
    content: 'Todavía no hay medallas disponibles.';
    color: #6b7588;
    font-size: 0.78rem;
    padding: 0.5rem 0.25rem;
}

/* Locked: grayscale + dimming. Override del chip default. */
.profile-badge-chip.locked {
    opacity: 0.78;
}

.profile-badge-chip.locked img {
    filter: grayscale(1) brightness(0.9);
    opacity: 0.55;
}

.profile-badge-chip.locked span {
    color: #6b7588;
    font-weight: 500;
}

/* Pulse animado cuando un check-in acaba de desbloquear una medalla. El JS
 * agrega la clase .just-unlocked al chip correspondiente por ~1s. */
.profile-badge-chip.just-unlocked {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35), 0 0 24px rgba(245, 158, 11, 0.4);
    animation: badge-chip-pop 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes badge-chip-pop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}


/* ========= Toast ========= */

.badge-toast-container {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    max-width: 92vw;
}

.badge-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #1c2230, #131821);
    border: 1px solid #f59e0b;
    border-radius: 14px;
    padding: 0.75rem 1rem 0.75rem 0.75rem;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 28px rgba(245, 158, 11, 0.18);
    min-width: 260px;
    max-width: 360px;
    opacity: 0;
    transform: translateY(-14px);
    transition: opacity 0.28s, transform 0.28s;
    pointer-events: auto;
}

.badge-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.badge-toast img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px #f59e0b;
    background: #0d1119;
}

.badge-toast-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.badge-toast-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #f59e0b;
    text-transform: uppercase;
}

.badge-toast-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e6ebf2;
}

.badge-toast-desc {
    font-size: 0.75rem;
    color: #9ca9bb;
}


/* ========= Badge detail modal ========= */

.badge-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(4, 7, 13, 0.72);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.badge-detail-overlay.show {
    opacity: 1;
}

.badge-detail-card {
    position: relative;
    background: linear-gradient(160deg, #1c2230, #0f141c);
    border: 1px solid #2e3646;
    border-radius: 20px;
    padding: 2rem 1.75rem 1.75rem;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(245, 158, 11, 0.12);
    transform: translateY(12px) scale(0.96);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
}

.badge-detail-overlay.show .badge-detail-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.badge-detail-card.locked {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.badge-detail-close {
    position: absolute;
    top: 0.45rem;
    right: 0.6rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #9ca9bb;
    font-size: 1.4rem;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    border-radius: 999px;
    display: grid;
    place-items: center;
    transition: background 0.15s, color 0.15s;
}

.badge-detail-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e6ebf2;
}

.badge-detail-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    display: block;
    margin: 0 auto 1rem;
}

.badge-detail-card.locked .badge-detail-icon {
    filter: grayscale(1) brightness(0.85);
    opacity: 0.55;
}

.badge-detail-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #e6ebf2;
    margin: 0 0 0.35rem;
    letter-spacing: 0.01em;
}

.badge-detail-description {
    font-size: 0.88rem;
    color: #9ca9bb;
    line-height: 1.4;
    margin: 0 0 1rem;
}

.badge-detail-progress {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

.badge-detail-date {
    font-size: 0.82rem;
    font-weight: 700;
    color: #f59e0b;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.1);
    display: inline-block;
}

.badge-detail-locked {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7588;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(107, 117, 136, 0.1);
    display: inline-block;
}


/* Chip becomes a button now that it's clickable. Strip default button styling. */
.profile-badges-row button.profile-badge-chip {
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, border-color 0.15s;
}

.profile-badges-row button.profile-badge-chip:hover {
    border-color: #3b4556;
}

.profile-badges-row button.profile-badge-chip:active {
    transform: scale(0.96);
}

.profile-badges-row button.profile-badge-chip:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
