/**
 * Dopamine UI Styles
 * 
 * Styles for XP bars, achievements, level-ups, and other reward UI elements
 */

/* ==================== TOP BAR (XP, Level, Streak) ==================== */

/* The id is kept so existing `#game-ui-overlay` overrides still win on
   specificity; the class is what every instance actually carries. */
#game-ui-overlay,
.game-ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
    z-index: 1000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.game-ui-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

/* Level Badge */
.level-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    min-width: 60px;
}

.level-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
}

.level-number {
    font-size: 24px;
    font-weight: 800;
    color: white;
    line-height: 1;
}

/* XP Bar */
.xp-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.xp-bar-bg {
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 6px;
    transition: width 0.5s ease-out;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.6);
}

.xp-text {
    font-size: 11px;
    color: white;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Streak Badge */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ff8800 0%, #ff4400 100%);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(255, 136, 0, 0.4);
}

.streak-icon {
    font-size: 20px;
    animation: flicker 2s infinite;
}

.streak-number {
    font-size: 18px;
    font-weight: 800;
    color: white;
}

/* ==================== ACHIEVEMENT POPUP ==================== */

.achievement-popup {
    position: fixed;
    top: calc(var(--dopamine-toast-top, 80px) + env(safe-area-inset-top, 0px));
    right: var(--dopamine-toast-right, 20px);
    left: var(--dopamine-toast-left, auto);
    background: var(--dopamine-toast-bg, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border-radius: var(--dopamine-toast-radius, 16px);
    padding: 16px;
    box-shadow: var(--dopamine-toast-shadow, 0 8px 32px rgba(0, 0, 0, 0.4));
    animation: slideIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10000;
    max-width: var(--dopamine-toast-max-width, 320px);
    overflow: hidden;
}

.achievement-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 2s infinite;
}

.achievement-content {
    position: relative;
    display: flex;
    gap: 12px;
    align-items: center;
}

.achievement-icon {
    font-size: 48px;
    animation: bounce 0.6s ease-out;
}

.achievement-info {
    flex: 1;
}

.achievement-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--dopamine-toast-muted, rgba(255, 255, 255, 0.9));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievement-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--dopamine-toast-text, white);
    margin: 2px 0;
}

.achievement-desc {
    font-size: 13px;
    color: var(--dopamine-toast-muted, rgba(255, 255, 255, 0.8));
    margin-bottom: 4px;
}

.achievement-xp {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--dopamine-toast-accent, #ffd700);
}

/* ==================== LEVEL UP OVERLAY ==================== */

.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.3s ease-out;
}

.level-up-content {
    text-align: center;
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.level-up-title {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 16px;
}

.level-up-number {
    font-size: 120px;
    font-weight: 900;
    color: white;
    text-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 215, 0, 0.4);
    animation: glow 1s ease-in-out infinite alternate;
}

.level-up-subtitle {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    margin-top: 16px;
}

/* ==================== FLOATING TEXT ==================== */

.floating-text {
    position: fixed;
    font-weight: 800;
    text-shadow: 
        2px 2px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    pointer-events: none;
    z-index: 9998;
    animation: floatUp 2s ease-out forwards;
}

/* ==================== ANIMATIONS ==================== */

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes glow {
    from {
        text-shadow: 
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.4);
    }
    to {
        text-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.8),
            0 0 90px rgba(255, 215, 0, 0.6);
    }
}

@keyframes shine {
    0% { left: -100%; }
    30% { left: 100%; }
    100% { left: 100%; }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes floatUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100px);
        opacity: 0;
    }
}

@keyframes xp-pulse {
    0% { transform: scaleY(1); }
    50% { transform: scaleY(1.2); }
    100% { transform: scaleY(1); }
}

@keyframes level-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
    .game-ui-top-bar {
        gap: 8px;
        padding: 10px 12px;
    }
    
    .level-badge {
        padding: 6px 10px;
        min-width: 50px;
    }
    
    .level-number {
        font-size: 20px;
    }
    
    .xp-bar-bg {
        height: 10px;
    }
    
    .xp-text {
        font-size: 10px;
    }
    
    .achievement-popup {
        right: var(--dopamine-toast-right, 12px);
        max-width: min(var(--dopamine-toast-max-width, 320px), calc(100% - 24px));
    }
    
    .level-up-number {
        font-size: 80px;
    }
}

/* Users who asked the OS for less motion get the same information without
   the movement. Floating text keeps its place until the script removes it:
   its animation ends at opacity 0, so cutting the duration would hide it. */
@media (prefers-reduced-motion: reduce) {
    .game-ui-overlay *,
    .achievement-popup,
    .achievement-popup *,
    .level-up-overlay,
    .level-up-overlay * {
        animation: none !important;
        transition: none !important;
    }

    .floating-text {
        animation: none !important;
    }
}
