/**
 * LearningChief - Gamification Styles
 * XP bar, achievements, celebrations
 */

/* ========================================
   XP Bar Component
   ======================================== */

.xp-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: white;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.xp-level-badge {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.xp-level-badge .level-number {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

.level-up-pulse {
    animation: levelPulse 0.5s ease;
}

@keyframes levelPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

.xp-bar-track {
    flex: 1;
    height: 24px;
    background: #e5e7eb;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    min-width: 150px;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
    border-radius: 12px;
    transition: width 0.3s ease;
}

.xp-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

/* ========================================
   Floating XP Indicator
   ======================================== */

.xp-floater {
    position: fixed;
    font-size: 1.5rem;
    font-weight: 700;
    color: #6366f1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    opacity: 1;
    transform: translateX(-50%);
    z-index: 10001;
    transition: all 1s ease-out;
}

.xp-floater.float-up {
    opacity: 0;
    transform: translateX(-50%) translateY(-60px);
}

/* ========================================
   Achievement Popup
   ======================================== */

.achievement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.achievement-overlay.active {
    opacity: 1;
}

.achievement-popup {
    background: white;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    max-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.achievement-overlay.active .achievement-popup {
    transform: scale(1);
    animation: achievementBounce 0.5s ease;
}

@keyframes achievementBounce {
    0% {
        transform: scale(0.5);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.achievement-glow {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.3), transparent 70%);
    pointer-events: none;
}

.achievement-badge {
    font-size: 5rem;
    margin-bottom: 16px;
    animation: badgeGlow 1.5s ease infinite;
}

@keyframes badgeGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.8));
    }
}

.achievement-popup h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #f59e0b;
    margin-bottom: 8px;
}

.achievement-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.achievement-desc {
    font-size: 0.95rem;
    color: #6b7280;
    margin-bottom: 24px;
}

.achievement-dismiss {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.achievement-dismiss:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* ========================================
   Level Up Banner
   ======================================== */

.level-up-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10003;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.level-up-banner.active {
    opacity: 1;
}

.level-up-content {
    text-align: center;
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.level-up-banner.active .level-up-content {
    transform: scale(1);
}

.level-up-stars {
    font-size: 2rem;
    margin-bottom: 8px;
    animation: starSpin 1s ease;
}

@keyframes starSpin {
    from {
        transform: rotate(-30deg) scale(0);
    }

    to {
        transform: rotate(0deg) scale(1);
    }
}

.level-up-content h2 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    margin-bottom: 8px;
    animation: levelTextPop 0.5s ease;
}

@keyframes levelTextPop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.new-level {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 12px 32px;
    border-radius: 50px;
    display: inline-block;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
}

/* ========================================
   Badge Showcase (Dashboard)
   ======================================== */

.badge-showcase {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.badge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.badge-header h3 {
    font-size: 1.1rem;
    color: #1f2937;
    margin: 0;
}

.badge-count {
    font-size: 0.9rem;
    color: #6366f1;
    font-weight: 600;
    background: #eef2ff;
    padding: 4px 12px;
    border-radius: 50px;
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: 12px;
    transition: transform 0.2s, background 0.2s;
}

.badge-item.earned {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    cursor: default;
}

.badge-item.locked {
    background: #f3f4f6;
    opacity: 0.6;
}

.badge-item.earned:hover {
    transform: scale(1.05);
}

.badge-emoji {
    font-size: 2rem;
}

.badge-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
    line-height: 1.2;
}

.badge-item.locked .badge-name {
    color: #9ca3af;
}

/* ========================================
   XP Shop Button (inside XP bar)
   ======================================== */

.xp-shop-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}

.xp-shop-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.5);
}

.xp-shop-balance {
    font-size: 0.75rem;
}

/* ========================================
   XP Shop Modal & Panel
   ======================================== */

.shop-panel {
    max-width: 560px !important;
}

.shop-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    border: 2px solid #f59e0b;
}

.shop-balance-icon { font-size: 1.5rem; }
.shop-balance-amount { font-size: 1.4rem; font-weight: 800; color: #92400e; }
.shop-balance-label  { font-size: 0.85rem; color: #78350f; margin-left: 2px; }

.shop-balance.shake {
    animation: shopShake 0.4s ease;
}

@keyframes shopShake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-6px); }
    75%       { transform: translateX(6px); }
}

.shop-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e7eb;
}

/* ========================================
   Shop Grid & Items
   ======================================== */

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: 16px;
    border: 2px solid #e5e7eb;
    background: white;
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: center;
}

.shop-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.shop-item.owned  { border-color: #10b981; background: #f0fdf4; }
.shop-item.equipped { border-color: #6366f1; background: #eef2ff; }

.shop-item-avatar {
    font-size: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid transparent;
}

.shop-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.shop-item-name   { font-size: 0.9rem; font-weight: 700; color: #1f2937; }
.shop-item-rarity { font-size: 0.72rem; color: #6b7280; }

/* Rarity border accents */
.rarity-uncommon  { border-color: #10b981; }
.rarity-rare      { border-color: #3b82f6; }
.rarity-epic      { border-color: #8b5cf6; }
.rarity-legendary { border-color: #f59e0b; background: linear-gradient(135deg, #fffbeb, #fff); }

/* Shop buttons */
.shop-btn {
    width: 100%;
    border: none;
    border-radius: 50px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.shop-btn-buy      { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; }
.shop-btn-buy:hover { transform: scale(1.04); box-shadow: 0 3px 10px rgba(99,102,241,0.4); }
.shop-btn-equip    { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.shop-btn-equip:hover { transform: scale(1.04); }
.shop-btn-equipped { background: #eef2ff; color: #6366f1; border: 2px solid #6366f1; }
.shop-btn-owned    { background: #f0fdf4; color: #10b981; border: 2px solid #10b981; }
.shop-btn-locked   { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }

/* ========================================
   Avatar Frames (applied globally)
   ======================================== */

.frame-silver {
    border: 3px solid #9ca3af !important;
    box-shadow: 0 0 8px rgba(156,163,175,0.6) !important;
    border-radius: 50%;
}

.frame-gold {
    border: 3px solid #f59e0b !important;
    box-shadow: 0 0 10px rgba(245,158,11,0.7) !important;
    border-radius: 50%;
}

.frame-fire {
    border: 3px solid #ef4444 !important;
    box-shadow: 0 0 12px rgba(239,68,68,0.7), 0 0 4px rgba(249,115,22,0.5) !important;
    border-radius: 50%;
}

.frame-ice {
    border: 3px solid #60a5fa !important;
    box-shadow: 0 0 12px rgba(96,165,250,0.7), 0 0 4px rgba(186,230,253,0.8) !important;
    border-radius: 50%;
}

.frame-rainbow {
    border: 3px solid transparent !important;
    background-clip: padding-box !important;
    outline: 3px solid transparent;
    box-shadow: 0 0 0 3px transparent !important;
    border-radius: 50%;
    /* Simulated rainbow via filter */
    filter: drop-shadow(0 0 4px #ef4444) drop-shadow(0 0 6px #f59e0b) drop-shadow(0 0 4px #10b981);
}

.frame-galaxy {
    border: 3px solid #8b5cf6 !important;
    box-shadow: 0 0 8px rgba(139,92,246,0.6), 0 0 16px rgba(99,102,241,0.4), 0 0 24px rgba(168,85,247,0.2) !important;
    border-radius: 50%;
}

/* ========================================
   Settings avatar — lock overlay & hint
   ======================================== */

.settings-avatar-option.locked {
    position: relative;
    opacity: 0.65;
}

.avatar-lock {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 0.65rem;
    line-height: 1;
}

.settings-avatar-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 10px;
    margin-bottom: 0;
}

.link-btn {
    background: none;
    border: none;
    color: #6366f1;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    text-decoration: underline;
}

/* ========================================
   Header Integration
   ======================================== */

#xpBarContainer {
    margin-right: 12px;
}

@media (max-width: 768px) {
    #xpBarContainer {
        margin: 0 8px;
    }

    .xp-bar-wrapper {
        padding: 6px 12px;
    }

    .xp-level-badge {
        width: 32px;
        height: 32px;
    }

    .xp-bar-track {
        height: 20px;
        min-width: 100px;
    }

    .achievement-popup {
        padding: 30px 20px;
        margin: 20px;
    }

    .achievement-badge {
        font-size: 4rem;
    }

    .level-up-content h2 {
        font-size: 2.5rem;
    }

    /* Badge grid - horizontal scroll on mobile */
    .badge-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .badge-grid::-webkit-scrollbar {
        height: 4px;
    }

    .badge-grid::-webkit-scrollbar-track {
        background: #f0f0f0;
        border-radius: 4px;
    }

    .badge-grid::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 4px;
    }

    .badge-item {
        flex: 0 0 auto;
        min-width: 80px;
    }
}
/* ===== Shop enrichment: new frames, themes, titles ===== */

/* New avatar frames */
.frame-bronze  { border: 3px solid #b08d57 !important; box-shadow: 0 0 8px rgba(176,141,87,0.6) !important; border-radius: 50%; }
.frame-emerald { border: 3px solid #10b981 !important; box-shadow: 0 0 10px rgba(16,185,129,0.7) !important; border-radius: 50%; }
.frame-neon    { border: 3px solid #22d3ee !important; box-shadow: 0 0 10px rgba(34,211,238,0.85), 0 0 18px rgba(34,211,238,0.4) !important; border-radius: 50%; }
.frame-candy   { border: 3px solid #ec4899 !important; box-shadow: 0 0 10px rgba(236,72,153,0.7) !important; border-radius: 50%; }
.frame-ocean   { border: 3px solid #0ea5e9 !important; box-shadow: 0 0 10px rgba(14,165,233,0.6), 0 0 18px rgba(2,132,199,0.4) !important; border-radius: 50%; }
.frame-sunset  { border: 3px solid #f97316 !important; box-shadow: 0 0 10px rgba(249,115,22,0.6), 0 0 16px rgba(244,63,94,0.4) !important; border-radius: 50%; }
.frame-shadow  { border: 3px solid #334155 !important; box-shadow: 0 0 12px rgba(15,23,42,0.85) !important; border-radius: 50%; }
.frame-royal   { border: 3px solid #a855f7 !important; box-shadow: 0 0 10px rgba(168,85,247,0.7), 0 0 18px rgba(217,70,239,0.4) !important; border-radius: 50%; }

/* Colour themes — recolour the XP bar fill + level badge */
body.xp-theme-mint   .xp-bar-fill, body.xp-theme-mint   .xp-level-badge { background: linear-gradient(90deg,#34d399,#10b981,#059669); }
body.xp-theme-ocean  .xp-bar-fill, body.xp-theme-ocean  .xp-level-badge { background: linear-gradient(90deg,#38bdf8,#0ea5e9,#0284c7); }
body.xp-theme-forest .xp-bar-fill, body.xp-theme-forest .xp-level-badge { background: linear-gradient(90deg,#4ade80,#16a34a,#15803d); }
body.xp-theme-sunset .xp-bar-fill, body.xp-theme-sunset .xp-level-badge { background: linear-gradient(90deg,#fb923c,#f97316,#ef4444); }
body.xp-theme-candy  .xp-bar-fill, body.xp-theme-candy  .xp-level-badge { background: linear-gradient(90deg,#f9a8d4,#ec4899,#db2777); }
body.xp-theme-lava   .xp-bar-fill, body.xp-theme-lava   .xp-level-badge { background: linear-gradient(90deg,#f97316,#ef4444,#b91c1c); }
body.xp-theme-galaxy .xp-bar-fill, body.xp-theme-galaxy .xp-level-badge { background: linear-gradient(90deg,#818cf8,#8b5cf6,#a855f7); }
body.xp-theme-gold   .xp-bar-fill, body.xp-theme-gold   .xp-level-badge { background: linear-gradient(90deg,#fcd34d,#f59e0b,#d97706); }

/* Equipped title pill (shown above the XP bar) */
.xp-title-line { text-align: center; margin-bottom: 4px; }
.xp-title-pill {
    display: inline-block;
    padding: 2px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    box-shadow: 0 2px 6px rgba(99,102,241,0.35);
}

/* Shop previews for titles & themes + avatar sub-section headers */
.shop-item-title-pill {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 12px; border-radius: 999px;
    font-size: 0.8rem; font-weight: 700; color: #fff;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    white-space: nowrap; max-width: 100%;
}
.shop-item-swatch {
    width: 2.5rem; height: 2.5rem; border-radius: 50%;
    display: inline-block; border: 2px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.shop-subsection-title {
    font-size: 0.78rem; font-weight: 700; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
    margin: 14px 0 6px;
}
