/* ========== Gamification Badge & Toast ========== */

/* Badge inline en el user-pill del header (desktop/tablet) */
.gam-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
    cursor: pointer;
    /* fondo suave para mejorar contraste sobre header brand */
    background: rgba(255, 255, 255, 0.18);
}
.gam-badge:hover,
.gam-badge:focus-visible {
    transform: scale(1.15);
    background: rgba(255, 255, 255, 0.32);
    outline: none;
}

/* Layout del user-pill: badge a la izquierda del nombre */
.user-pill .pill-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toast de subida de nivel */
.gam-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.5);
    z-index: 100000;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
    opacity: 0;
    max-width: 90vw;
}
.gam-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.gam-toast .gam-toast-icon {
    font-size: 28px;
    line-height: 1;
}
.gam-toast .gam-toast-close {
    background: transparent;
    border: 0;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 8px;
    opacity: 0.85;
}
.gam-toast .gam-toast-close:hover { opacity: 1; }

@media (max-width: 767px) {
    .gam-toast {
        top: 12px;
        font-size: 14px;
        padding: 12px 16px;
    }
    .gam-toast .gam-toast-icon { font-size: 22px; }
}

/* ========== Página de perfil ========== */
.gam-profile {
    max-width: 1100px;
    margin: var(--space-lg) auto;
    padding: 0 var(--space-md);
    container-type: inline-size;
}

.gam-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    padding: var(--space-xl);
    text-align: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}
.gam-hero-icon {
    font-size: clamp(4rem, 12vw, 6rem);
    line-height: 1;
    margin-bottom: 8px;
}
.gam-hero-nivel {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.85;
    margin-bottom: 4px;
}
.gam-hero-nombre {
    font-size: clamp(1.5rem, 5vw, 2.25rem);
    font-weight: 700;
    margin: 0 0 12px 0;
}
.gam-hero-desc {
    font-size: var(--text-base);
    line-height: 1.5;
    max-width: 640px;
    margin: 0 auto var(--space-lg);
    opacity: 0.95;
}
.gam-progress-wrap {
    max-width: 480px;
    margin: 0 auto;
}
.gam-progress-bar {
    background: #ffffff;
    border-radius: 999px;
    height: 22px;
    overflow: hidden;
    margin-bottom: 8px;
    position: relative;
}
.gam-progress-fill {
    background: linear-gradient(90deg, #1e8c3a 0%, #28a745 60%, #34c05a 100%);
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    min-width: 4px;                      /* visible incluso al 0% */
}
.gam-progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 55%);
}
.gam-progress-fill-pct {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.gam-progress-info {
    font-size: var(--text-xs);
    opacity: 0.9;
    display: flex;
    justify-content: space-between;
}
.gam-progress-info strong { font-size: var(--text-base); }

@container (min-width: 700px) {
    .gam-hero { padding: 48px; }
    .gam-hero-icon { font-size: 120px; }
}

/* Timeline de niveles */
.gam-section-title {
    margin: var(--space-xl) 0 var(--space-md);
    font-size: var(--text-xl);
    font-weight: 600;
    color: #333;
}

.gam-timeline {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.gam-level-card {
    flex: 0 0 140px;
    scroll-snap-align: start;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    transition: all 0.2s ease;
}
.gam-level-card.is-current {
    border-color: #667eea;
    background: linear-gradient(135deg, #f3f4ff 0%, #faf5ff 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}
.gam-level-card.is-locked { opacity: 0.55; }
.gam-level-card-icon { font-size: 40px; line-height: 1; }
.gam-level-card-name { font-weight: 600; margin-top: 6px; font-size: var(--text-sm); }
.gam-level-card-pts { font-size: var(--text-xs); color: #666; margin-top: 2px; }

@media (min-width: 768px) {
    .gam-timeline {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        overflow: visible;
    }
    .gam-level-card { flex: initial; }
}

/* Tabla de acciones */
.gam-acciones {
    margin-top: var(--space-md);
}
.gam-categoria {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: var(--space-sm);
    overflow: hidden;
}
.gam-categoria summary {
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    cursor: pointer;
    background: #f9fafb;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.gam-categoria summary::-webkit-details-marker { display: none; }
.gam-categoria summary::after {
    content: '▾';
    transition: transform 0.2s;
    color: #666;
}
.gam-categoria[open] summary::after { transform: rotate(180deg); }

.gam-accion-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid #f3f4f6;
    font-size: var(--text-sm);
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.gam-accion-label { flex: 1; min-width: 180px; }
.gam-accion-pts {
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}
.gam-accion-pts small {
    font-weight: 400;
    color: #999;
    margin-left: 4px;
}

/* Nota explicativa bajo el encabezado de acciones */
.gam-accion-nota {
    color: #444;
    font-size: var(--text-xs);
    margin: 0 0 var(--space-sm);
    line-height: 1.5;
}

/* ========== RESPONSIVE MOBILE (≤767px) ========== */
@media (max-width: 767px) {
    .gam-profile {
        margin-top: var(--space-md);
    }
    .gam-section-title {
        margin-top: var(--space-lg);
    }
    .gam-progress-info {
        flex-wrap: wrap;
        gap: var(--space-xs);
        justify-content: center;
        text-align: center;
    }
    .gam-accion-label {
        min-width: 0;
    }
    .gam-accion-row {
        padding: var(--space-sm) var(--space-md);
    }
}
