/* ==========================================================================
   FICHIER: style.css - VERSION CORRIGÉE ET FINALE
   ========================================================================== */

:root {
    --or: #d4af37;
    --rouge-sang: #800000;
    --parchemin: #f4e4bc;
    --noir-fond: #1a1a1a;
    --ombre: rgba(0, 0, 0, 0.8);
    --sepia-ink: #FFD700; 
}

body, html {
    margin: 0; padding: 0; height: 100%;
    background-color: var(--noir-fond);
    font-family: 'IM Fell English', serif;
    color: #333;
    overflow: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Cinzel', serif;
    color: var(--rouge-sang);
    margin: 0 0 10px 0;
}

/* --- CARTE LEAFLET --- */
#map { height: 100vh; width: 100vw; background: #111; }

.leaflet-popup-content-wrapper {
    background: var(--parchemin);
    border: 2px solid var(--or);
    border-radius: 0;
    font-family: 'IM Fell English', serif;
}

.leaflet-tooltip {
    background: var(--parchemin);
    border: 1px solid var(--rouge-sang);
    font-family: 'Cinzel', serif;
    color: var(--rouge-sang);
}

/* --- UI GLOBALE (Boutons, Titres) --- */
.ui-container {
    position: fixed; top: 20px; left: 20px; z-index: 1000;
    display: flex; flex-direction: column; gap: 10px;
}

.btn-style {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--or);
    color: var(--or);
    padding: 8px 15px;
    text-decoration: none;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
}
.btn-style:hover { background: var(--or); color: #000; }

.page-title {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 1000; font-size: 2.5rem; color: var(--or);
    text-shadow: 2px 2px 0 #000; pointer-events: none;
}

.controls-bar {
    position: fixed; top: 80px; left: 20px; z-index: 1000;
    display: flex; flex-direction: column; gap: 10px;
}

.icon-btn {
    width: 40px; height: 40px;
    background: rgba(0, 0, 0, 0.8); border: 2px solid var(--or);
    color: var(--or); border-radius: 50%;
    cursor: pointer; font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center;
    transition: 0.3s;
}
.icon-btn:hover { background: var(--or); color: #000; box-shadow: 0 0 15px var(--or); }

/* --- PANNEAU CHRONOLOGIE (GAUCHE/PRINCIPAL) --- */
.timeline-box {
    position: fixed; 
    top: 20px; right: 20px; 
    z-index: 2500;
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid var(--or);
    padding: 15px; width: 300px;
    box-shadow: 0 0 20px var(--ombre);
    color: var(--or);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), right 0.4s;
    
    /* FLEXBOX POUR GÉRER LA HAUTEUR */
    max-height: 80vh; 
    display: flex; 
    flex-direction: column; 
    
    border-radius: 8px;
}

/* Ces éléments ne rétrécissent pas */
h3, .search-container, .slider-container, .tabs-container, .toggle-panel-btn {
    flex-shrink: 0;
}

.timeline-box.collapsed { transform: translateX(calc(100% + 20px)); }
.timeline-box.shifted { right: 400px; transition: right 0.4s, transform 0.4s; }
.timeline-box.shifted.collapsed { transform: translateX(100%); }

.toggle-panel-btn {
    position: absolute; top: 10px; left: -42px;
    width: 40px; height: 40px;
    background: #800000; color: var(--or);
    border: 2px solid var(--or); border-right: none;
    border-radius: 5px 0 0 5px;
    cursor: pointer; font-weight: bold; font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: -5px 0 10px rgba(0,0,0,0.5);
}
.toggle-panel-btn:hover { background: var(--or); color: #000; }

/* --- RECHERCHE --- */
.search-container input::placeholder { color: #888; font-style: italic; }
.search-container input:focus { outline: none; box-shadow: 0 0 5px var(--or); }

/* --- SLIDER --- */
.slider-container { padding: 10px 0 20px 0; text-align: center; }
.slider-label { font-family: 'Cinzel', serif; color: var(--or); margin-bottom: 10px; font-size: 1rem; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; cursor: pointer; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 12px; cursor: pointer; background: #333; border-radius: 6px; border: 1px solid #555; }
input[type=range]::-webkit-slider-thumb { height: 24px; width: 24px; border-radius: 50%; background: radial-gradient(circle, var(--or) 40%, #fff 45%, #ccc 100%); border: 2px solid #111; cursor: pointer; -webkit-appearance: none; margin-top: -7px; box-shadow: 0 2px 6px rgba(0,0,0,0.8); transition: transform 0.1s; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.1); }

/* --- BOUTONS D'ONGLETS (3 BOUTONS) --- */
.tabs-container { display: flex; margin-bottom: 10px; border-bottom: 1px solid var(--or); }
.tab-btn {
    flex: 1; /* Partage l'espace en 3 */
    background: rgba(0,0,0,0.5); border: none; border-top: 2px solid transparent;
    color: #888; padding: 10px 5px; font-family: 'Cinzel', serif; cursor: pointer; transition: 0.3s;
    text-transform: uppercase; font-size: 0.85rem; /* Police un peu plus petite */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab-btn:hover { color: var(--or); background: rgba(212, 175, 55, 0.1); }
.tab-btn.active { color: var(--or); border-top: 2px solid var(--or); background: linear-gradient(to bottom, rgba(212, 175, 55, 0.1), transparent); font-weight: bold; }

/* --- CONTENU DES ONGLETS (SCROLL AUTOMATIQUE) --- */
.tab-content {
    display: none;
    flex: 1; /* Prend tout l'espace restant */
    flex-direction: column; 
    min-height: 0; 
    overflow: hidden; 
}
.tab-content.active { display: flex; }

/* Les listes scrollent ici */
.char-list-container, #glossary-list, #lieux-list {
    flex: 1;
    overflow-y: auto; 
    min-height: 0;
    margin-top: 10px;
    padding-right: 5px;
}

/* --- ITEMS (Personnages, Lieux, Glossaire) --- */
.char-item, .location-item, .glossary-item {
    background-color: rgba(40, 40, 40, 0.8); 
    padding: 15px; margin-bottom: 10px;
    border-radius: 6px; border-left: 4px solid var(--sepia-ink); 
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    color: #e6e6e6;
    
    /* MODIFICATIONS APPLIQUÉES ICI : CURSEUR ET TRANSITION */
    cursor: pointer; 
    transition: transform 0.2s;
}

.char-item:hover, .location-item:hover, .glossary-item:hover {
    transform: translateX(5px);
    background-color: rgba(60, 60, 60, 0.9);
    border-color: var(--or);
}

/* Style spécifique pour l'onglet LIEUX */
.location-item {
    padding: 0; /* Pas de padding global car le label le fait */
    border: 1px solid #444;
    border-left: none;
    transition: 0.2s;
}
.location-item:hover { background-color: rgba(60, 60, 60, 0.9); border-color: var(--or); }
.location-item input { margin-right: 10px; accent-color: var(--rouge-sang); width: 18px; height: 18px; }

.char-name, .glossary-term { color: var(--sepia-ink); font-weight: bold; font-size: 1.1rem; text-shadow: 1px 1px 1px #000; margin-bottom: 5px; display: block; }
.char-desc, .glossary-desc { font-style: italic; color: #ccc; font-size: 0.9em; }

.status-vivant { border-left-color: green; }
.status-mort { border-left-color: black; opacity: 0.6; text-decoration: line-through; }
.status-emprisonné { border-left-color: red; }
.status-absent { border-left-color: grey; opacity: 0.6; background: #eee; color: #333; }

/* --- PANNEAU QUARTIER (DROITE) --- */
#sidebar {
    position: fixed; top: 0; right: -500px; width: 400px; height: 100%;
    background-color: rgba(15, 15, 15, 0.95) !important;
    border-left: 4px solid var(--rouge-sang);
    box-shadow: -10px 0 30px var(--ombre);
    z-index: 3000; transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex; flex-direction: column;
}
#sidebar.active { right: 0; }
.sidebar-content { padding: 30px; flex-grow: 1; overflow-y: auto; }

.close-btn {
    position: absolute; top: 10px; right: 10px;
    width: 30px; height: 30px; text-align: center;
    background: var(--rouge-sang); color: white;
    cursor: pointer; border-radius: 50%; font-weight: bold; line-height: 30px;
}

/* --- ACCORDÉON --- */
.accordion-header {
    background: rgba(212, 175, 55, 0.2); padding: 10px; margin-top: 10px; border: 1px solid var(--or);
    cursor: pointer; font-family: 'Cinzel', serif; display: flex; justify-content: space-between; align-items: center;
}
.accordion-header:hover { background: rgba(212, 175, 55, 0.4); }
.accordion-header::after { content: '▼'; font-size: 0.8em; transition: 0.3s; }
.accordion-header.active::after { content: '▲'; }
.accordion-content { display: none; padding: 10px; border: 1px solid var(--or); border-top: none; background: rgba(0,0,0,0.2); }
.accordion-content.open { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- MODE NUIT --- */
body.night-mode #map { filter: brightness(0.5) contrast(1.2) sepia(0.4) hue-rotate(180deg); transition: filter 1.5s ease; }
body.night-mode .leaflet-popup-content-wrapper, body.night-mode .timeline-box, body.night-mode #sidebar {
    background: #2c2216; color: #d4af37; border-color: #5e4b35;
}

/* --- SCROLLBAR --- */
* { scrollbar-width: thin; scrollbar-color: var(--or) var(--noir-fond); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0f0f0f; border-left: 1px solid #333; }
::-webkit-scrollbar-thumb { background-color: var(--or); border-radius: 4px; border: 1px solid #000; }
::-webkit-scrollbar-thumb:hover { background-color: #f4e4bc; }


.district-link:hover {
    background-color: rgba(212, 175, 55, 0.15) !important; /* Fond doré léger */
    border-color: var(--or) !important;
    transform: translateX(5px); /* Petit décalage vers la droite */
}

/* Transition douce */
.district-link {
    transition: all 0.2s ease;
}

.district-selected {
    filter: drop-shadow(0 0 15px var(--or));
    stroke-width: 3px !important;
}

/* ==========================================================================
   VERSION MOBILE : BOUTON FLOTTANT (BULLE) + PANNEAU HAUT
   ========================================================================== */
@media (max-width: 768px) {

    /* --- 1. LE PANNEAU (CHRONOLOGIE) --- */
    .timeline-box {
        width: 85%;
        max-height: 60vh;
        position: fixed;
        top: 100px;
        right: 0;           
        transition: right 0.3s ease-out;
        border-radius: 10px 0 0 10px;
        transform: none !important; 
    }

    /* --- 2. ÉTAT FERMÉ --- */
    .timeline-box.collapsed {
        right: -100%; 
        transform: none !important;
    }

    /* --- 3. LE BOUTON FLOTTANT (BULLE OR) --- */
    .toggle-panel-btn {
        position: fixed !important;
        bottom: 30px;
        right: 20px;
        left: auto !important;
        top: auto !important;
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        background-color: var(--or) !important;
        color: #000 !important;
        border: 2px solid #fff !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.6);
        z-index: 5000;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    /* --- Positionnement du bouton Retour Monde --- */
    .ui-container {
        position: fixed;
        top: auto !important;
        bottom: 20px !important;
        left: 20px !important;
        right: auto !important;
        transform: none !important;  
        width: auto !important;
        z-index: 2000;
    }

    .btn-style {
        background-color: rgba(0, 0, 0, 0.9) !important;
        border: 1px solid var(--or);
        color: var(--or);
        font-size: 0.9rem;
        padding: 10px 15px;
        box-shadow: 0 0 10px rgba(0,0,0,0.5);
    }

    /* --- 4. AJUSTEMENTS DIVERS --- */
    #sidebar { width: 100%; right: -100%; border: none; }
    #sidebar.active { right: 0; }
    .close-btn { top: 15px; right: 15px; width: 45px; height: 45px; font-size: 1.5rem; }
    .page-title { font-size: 1.5rem; width: 100%; top: 10px; text-align: center; }
}

/* ==========================================================================
   STYLE DU POPUP PERSONNAGE (CORRECTIF FINAL)
   ========================================================================== */
.char-popup-overlay {
    /* 1. Fixé par rapport à l'écran */
    position: fixed !important; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    
    /* 2. Z-INDEX SUPÉRIEUR À TOUT (Carte=100, Menu=2500, Mobile=5000) */
    z-index: 99999 !important; 
    
    /* 3. Fond noir semi-transparent */
    background: rgba(0, 0, 0, 0.85); 
    
    /* 4. Centrage flexbox */
    display: none; 
    align-items: center; 
    justify-content: center;
}

/* Affiché quand JS ajoute la classe active */
.char-popup-overlay.active {
    display: flex !important; 
    animation: fadeIn 0.2s ease-out;
}

/* Contenu du popup */
.char-popup-content {
    background: #1a1a1a;
    border: 2px solid var(--or);
    width: 90%;
    max-width: 400px;
    padding: 25px;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.9);
    text-align: center;
    color: #e6e6e6;
    font-family: 'IM Fell English', serif;
}

/* Bouton fermer du popup */
.close-btn-popup {
    position: absolute; top: 10px; right: 10px;
    background: var(--rouge-sang); color: white; border: 1px solid var(--or);
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; font-weight: bold;
    transition: transform 0.2s;
}
.close-btn-popup:hover { transform: scale(1.1); background: #a00000; }

.char-role-style { color: var(--or); font-style: italic; margin-bottom: 10px; }
.popup-divider { border-color: var(--or); opacity: 0.3; margin: 15px 0; }
.popup-description { font-style: italic; line-height: 1.5; color: #ccc; margin-top: 15px; text-align: justify; }