/**
 * Styles d'intégration XP pour Le Monde des Curieux
 * Compatible avec la charte graphique Minecraft existante
 * Responsive et optimisé tablettes éducatives
 */

/* =================
   VARIABLES COHÉRENTES
   ================= */
:root {
    /* Reprendre les couleurs existantes du site */
    --minecraft-green: #2a9d8f;
    --minecraft-orange: #e9c46a;
    --minecraft-red: #e76f51;
    --minecraft-blue: #264653;
    --minecraft-light: #f1faee;
    
    /* Nouvelles couleurs XP */
    --xp-gradient-start: #667eea;
    --xp-gradient-end: #764ba2;
    --xp-progress-fill: #00ff88;
    --xp-progress-bg: rgba(255,255,255,0.3);
    
    /* Animations */
    --bounce-timing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* =================
   INTÉGRATION HEADER
   ================= */

/* Adaptation au header existant de la mindmap */
.main-wrapper .xp-display-container {
    position: relative;
    margin: 0 0 20px 0;
    background: linear-gradient(135deg, var(--xp-gradient-start) 0%, var(--xp-gradient-end) 100%);
    border: 3px solid var(--minecraft-green);
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* S'intégrer harmonieusement avec la mindmap */
.mindmap-section + .xp-display-container,
.parcours-section .xp-display-container {
    background: linear-gradient(135deg, var(--minecraft-green) 0%, var(--minecraft-blue) 100%);
    border-color: var(--minecraft-orange);
}

/* Header des sections (français, anglais, etc.) */
.section-header .xp-display-container {
    margin: 10px 0;
    border-radius: 10px;
    font-family: 'Press Start 2P', cursive; /* Cohérence avec l'existant */
    font-size: 10px;
}

/* =================
   COMPOSANTS XP
   ================= */

.xp-level-badge {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.xp-level-badge::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.xp-level-badge:hover::before {
    animation: shine 1.5s ease-in-out infinite;
}

.level-number {
    font-family: 'Press Start 2P', cursive;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
}

.level-label {
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Barre de progression stylisée Minecraft */
.xp-bar {
    background: var(--xp-progress-bg);
    border: 2px solid rgba(255,255,255,0.5);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.3),
        0 1px 0 rgba(255,255,255,0.4);
    position: relative;
    overflow: hidden;
}

.xp-bar-fill {
    background: linear-gradient(90deg, 
        var(--xp-progress-fill) 0%, 
        #00cc6a 50%, 
        var(--xp-progress-fill) 100%);
    box-shadow: 
        0 0 10px rgba(0,255,136,0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255,255,255,0.4), 
        transparent);
    animation: progressShine 2s ease-in-out infinite;
}

.xp-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    text-shadow: 
        1px 1px 0 rgba(0,0,0,0.8),
        -1px -1px 0 rgba(255,255,255,0.3);
}

.weekly-xp {
    font-family: 'Press Start 2P', cursive;
    background: rgba(255,255,255,0.1);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* =================
   ANIMATIONS LEVEL UP
   ================= */

.level-up-animation {
    backdrop-filter: blur(5px);
    animation: levelUpAppear 0.5s var(--bounce-timing);
}

.level-up-content {
    background: linear-gradient(135deg, 
        var(--xp-gradient-start) 0%, 
        var(--xp-gradient-end) 50%,
        var(--minecraft-green) 100%);
    border: 4px solid var(--minecraft-orange);
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

.level-up-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, 
        rgba(255,255,255,0.1) 0%, 
        transparent 70%);
    animation: celebrationGlow 2s ease-in-out infinite alternate;
}

.level-up-content h2 {
    font-family: 'Press Start 2P', cursive;
    text-shadow: 
        3px 3px 0 rgba(0,0,0,0.5),
        0 0 20px rgba(255,255,255,0.5);
    animation: levelUpText 1s var(--bounce-timing);
    position: relative;
    z-index: 2;
}

.level-up-content p {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    opacity: 0.9;
    animation: fadeInUp 0.8s ease-out 0.3s both;
}

.rewards {
    position: relative;
    z-index: 2;
}

.reward {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    animation: rewardPop 0.6s var(--bounce-timing);
    animation-delay: calc(var(--reward-index, 0) * 0.2s);
    animation-fill-mode: both;
    transform: scale(0);
}

.continue-btn {
    background: linear-gradient(135deg, var(--minecraft-orange) 0%, #f4a261 100%);
    border: 3px solid var(--minecraft-green);
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    box-shadow: 
        0 4px 8px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.3s var(--bounce-timing);
    position: relative;
    z-index: 2;
}

.continue-btn:hover {
    background: linear-gradient(135deg, #f4a261 0%, var(--minecraft-orange) 100%);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 6px 12px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.4);
}

.continue-btn:active {
    transform: translateY(-1px) scale(1.02);
}

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

/* Tablettes (768px et moins) */
@media (max-width: 768px) {
    .xp-display-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 15px;
        gap: 12px;
    }
    
    .xp-level-badge {
        min-width: 80px;
        padding: 10px 15px;
    }
    
    .level-number {
        font-size: 20px;
    }
    
    .xp-progress-section {
        width: 100%;
        max-width: 300px;
    }
    
    .xp-bar {
        height: 24px;
    }
    
    .xp-text {
        font-size: 9px;
    }
    
    .weekly-xp {
        font-size: 9px;
        padding: 8px 12px;
    }
    
    .level-up-content {
        margin: 10px;
        padding: 25px 15px;
        max-width: 90vw;
    }
    
    .level-up-content h2 {
        font-size: 16px;
        line-height: 1.4;
    }
    
    .level-up-content p {
        font-size: 10px;
    }
    
    .reward {
        font-size: 10px;
        padding: 6px 12px;
    }
    
    .continue-btn {
        font-size: 10px;
        padding: 10px 20px;
    }
}

/* Smartphones (480px et moins) */
@media (max-width: 480px) {
    .xp-display-container {
        padding: 12px;
        margin: 5px 0;
        border-radius: 8px;
    }
    
    .xp-level-badge {
        min-width: 70px;
        padding: 8px 12px;
    }
    
    .level-number {
        font-size: 18px;
    }
    
    .level-label {
        font-size: 8px;
    }
    
    .xp-bar {
        height: 20px;
    }
    
    .xp-text {
        font-size: 8px;
    }
    
    .weekly-xp {
        font-size: 8px;
        padding: 6px 10px;
    }
    
    .level-up-content h2 {
        font-size: 14px;
    }
    
    .level-up-content p {
        font-size: 9px;
    }
}

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

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); opacity: 0; }
}

@keyframes progressShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes levelUpAppear {
    0% { 
        opacity: 0; 
        transform: scale(0.8); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

@keyframes levelUpText {
    0% { 
        transform: scale(0.5) translateY(-50px); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.1) translateY(-10px); 
        opacity: 0.8; 
    }
    100% { 
        transform: scale(1) translateY(0); 
        opacity: 1; 
    }
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rewardPop {
    0% { 
        transform: scale(0) rotate(-10deg); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.1) rotate(5deg); 
        opacity: 0.8; 
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1; 
    }
}

@keyframes celebrationGlow {
    0% { opacity: 0.1; transform: scale(1) rotate(0deg); }
    100% { opacity: 0.3; transform: scale(1.1) rotate(360deg); }
}

/* =================
   INTÉGRATION EXISTANT
   ================= */

/* Cohérence avec les boutons Minecraft existants */
.xp-display-container button,
.level-up-content button {
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Adaptation aux couleurs des sections */
.francais-section .xp-display-container {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.anglais-section .xp-display-container,
.english-section .xp-display-container {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.maths-section .xp-display-container {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

.sciences-section .xp-display-container {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

/* Mode nuit compatible */
@media (prefers-color-scheme: dark) {
    .xp-display-container {
        border-color: rgba(255,255,255,0.3);
        box-shadow: 
            0 4px 15px rgba(0,0,0,0.4),
            inset 0 1px 0 rgba(255,255,255,0.2);
    }
    
    .xp-bar {
        border-color: rgba(255,255,255,0.4);
    }
}

/* =================
   ÉTATS D'INTERACTION
   ================= */

.xp-display-container.gaining-xp {
    animation: xpGainPulse 0.6s ease-out;
}

.xp-display-container.level-up-ready {
    animation: levelUpReady 2s ease-in-out infinite;
}

@keyframes xpGainPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes levelUpReady {
    0%, 100% { box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
    50% { box-shadow: 0 4px 25px rgba(255,215,0,0.6); }
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .xp-display-container,
    .level-up-content,
    .xp-bar-fill,
    .level-number,
    .reward {
        animation: none !important;
        transition: none !important;
    }
    
    .xp-bar-fill::after {
        display: none;
    }
}