/* ═══════════════════════════════════════════════════════════
   Курс.Один — Gamification Styles
   XP bar, badges, leaderboard, reward popup, animations
   ═══════════════════════════════════════════════════════════ */

/* ── Header mini widget ── */
.gam-header-widget {
    display: flex;
    align-items: center;
}

.gam-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-2, rgba(255,255,255,0.06));
    text-decoration: none;
    color: var(--text-primary, #fff);
    font-size: 0.8rem;
    transition: background 0.2s;
}

.gam-mini:hover {
    background: var(--surface-3, rgba(255,255,255,0.12));
}

.gam-mini__streak {
    font-size: 0.75rem;
}

.gam-mini__level {
    font-weight: 700;
    color: var(--accent, #6c5ce7);
}

.gam-mini__bar {
    width: 48px;
    height: 5px;
    background: var(--surface-3, rgba(255,255,255,0.1));
    border-radius: 3px;
    overflow: hidden;
}

.gam-mini__fill {
    height: 100%;
    background: linear-gradient(90deg, #6c5ce7, #a29bfe);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.gam-mini__xp {
    font-weight: 600;
    color: var(--accent, #a29bfe);
    font-size: 0.75rem;
}

/* ── Profile card (achievements page) ── */
.gam-achievements {
    max-width: 900px;
    margin: 0 auto;
}

.gam-profile-card {
    background: var(--surface-1, #1e1e2e);
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
}

.gam-profile-card__level {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}

.gam-profile-card__level-num {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #6c5ce7, #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.gam-profile-card__level-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
}

.gam-profile-card__stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.gam-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.gam-stat__value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary, #fff);
}

.gam-stat__label {
    font-size: 0.75rem;
    color: var(--text-secondary, #999);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── XP progress bar ── */
.gam-xp-bar {
    margin-top: 8px;
}

.gam-xp-bar__track {
    height: 10px;
    background: var(--surface-3, rgba(255,255,255,0.08));
    border-radius: 5px;
    overflow: hidden;
}

.gam-xp-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, #6c5ce7, #a29bfe, #fd79a8);
    border-radius: 5px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.gam-xp-bar__fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: xpShimmer 2s ease-in-out infinite;
}

@keyframes xpShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.gam-xp-bar__labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    margin-top: 4px;
}

/* ── Badge grid ── */
.gam-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.gam-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    background: var(--surface-1, #1e1e2e);
    transition: transform 0.2s, box-shadow 0.2s;
}

.gam-badge:hover {
    transform: translateY(-2px);
}

.gam-badge--earned {
    border-color: rgba(108, 92, 231, 0.4);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.1);
}

.gam-badge--earned:hover {
    box-shadow: 0 4px 24px rgba(108, 92, 231, 0.2);
}

.gam-badge--locked {
    opacity: 0.45;
    filter: grayscale(0.8);
}

.gam-badge__icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
    transition: transform 0.3s;
}

.gam-badge--earned .gam-badge__icon {
    animation: badgeBounce 0.6s ease;
}

.gam-badge--earned:hover .gam-badge__icon {
    transform: scale(1.2);
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.gam-badge__name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
}

.gam-badge__desc {
    font-size: 0.72rem;
    color: var(--text-secondary, #999);
}

.gam-badge__date {
    font-size: 0.65rem;
    color: var(--text-tertiary, #666);
    margin-top: 6px;
}

/* ── Leaderboard table ── */
.gam-leaderboard {
    max-width: 800px;
    margin: 0 auto;
}

.gam-lb-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-1, #1e1e2e);
    border-radius: 12px;
    overflow: hidden;
}

.gam-lb-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.gam-lb-table tbody tr {
    transition: background 0.15s;
}

.gam-lb-table tbody tr:hover {
    background: var(--surface-2, rgba(255,255,255,0.03));
}

.gam-lb-table tbody td {
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--text-primary, #fff);
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.04));
}

.gam-lb-rank {
    font-size: 1.1rem;
    font-weight: 700;
    width: 50px;
}

.gam-lb-name {
    font-weight: 600;
}

.gam-lb-level {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-3, rgba(108, 92, 231, 0.15));
    color: var(--accent, #a29bfe);
}

.gam-lb-xp {
    font-weight: 700;
    color: var(--accent, #6c5ce7);
}

.gam-lb-me {
    background: rgba(108, 92, 231, 0.08) !important;
}

.gam-lb-gold td { color: #ffd700; }
.gam-lb-silver td { color: #c0c0c0; }
.gam-lb-bronze td { color: #cd7f32; }

.gam-lb-gold .gam-lb-name,
.gam-lb-silver .gam-lb-name,
.gam-lb-bronze .gam-lb-name {
    color: var(--text-primary, #fff);
}

/* ── Reward popup overlay ── */
.gam-reward-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
}

.gam-reward-overlay--visible {
    opacity: 1;
}

.gam-reward-popup {
    background: var(--surface-1, #1e1e2e);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 20px;
    padding: 36px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: rewardSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(108, 92, 231, 0.15);
}

@keyframes rewardSlideIn {
    from {
        transform: scale(0.6) translateY(30px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.gam-reward__xp {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    animation: xpPulse 0.8s ease;
}

@keyframes xpPulse {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.gam-reward__level {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.2rem;
    color: var(--text-primary, #fff);
    margin-bottom: 16px;
    padding: 10px 20px;
    background: rgba(108, 92, 231, 0.1);
    border-radius: 12px;
    animation: levelGlow 1.5s ease infinite alternate;
}

@keyframes levelGlow {
    from { box-shadow: 0 0 8px rgba(108, 92, 231, 0.2); }
    to { box-shadow: 0 0 20px rgba(108, 92, 231, 0.4); }
}

.gam-reward__level-icon {
    font-size: 1.5rem;
    animation: levelSpin 0.6s ease;
}

@keyframes levelSpin {
    from { transform: rotate(-180deg) scale(0); }
    to { transform: rotate(0) scale(1); }
}

.gam-reward__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.gam-reward__badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: badgeDrop 0.6s ease;
}

@keyframes badgeDrop {
    0% { transform: translateY(-40px) scale(0); opacity: 0; }
    60% { transform: translateY(5px) scale(1.1); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.gam-reward__badge-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(108, 92, 231, 0.5));
}

.gam-reward__badge-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary, #fff);
}

.gam-reward__close {
    margin-top: 12px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .gam-badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .gam-profile-card__stats {
        gap: 14px;
    }

    .gam-profile-card {
        padding: 20px;
    }

    .gam-reward-popup {
        padding: 24px;
    }

    .gam-mini__bar {
        display: none;
    }

    .gam-lb-table {
        font-size: 0.8rem;
    }

    .gam-lb-table thead th,
    .gam-lb-table tbody td {
        padding: 8px 10px;
    }
}
