/* --- SIDEBAR GLOBALE --- */
.sidebar-navigation {
    /* --- MODIFICATION MAJEURE --- */
    position: sticky;
    top: -0; /* Elle se calera en haut de son parent .main-layout */
    height: 1393px;
    left: 50px;
    margin-top: 0; /* On s'assure qu'il n'y a pas de marge qui pousse vers le bas */
    padding-top: 0;
    /* On enlève fixed pour permettre le scroll avec la page */
    display: flex;
    flex-direction: column; 
    justify-content: flex-start; 
    align-items: center; 
    
    width: 300px; 
    /* On ne force plus min-height: 100vh si on veut qu'elle grandisse avec son contenu */
    min-height: 100%; 
    
    overflow: visible;

    /* Tes backgrounds */
    background-image: url('../img/sidebar_bg.webp'), url('../img/bg2.webp');
    background-repeat:  repeat-y;
    background-position: center top, center 0;
    background-size: 100% auto, 100% auto;
    
    animation: scrollBackground 100s linear infinite;
    
    border-right: 2px solid var(--sign-brown);
    filter: drop-shadow(8px 0px 10px rgba(0, 0, 0, 0.8));
    
    /* On baisse le z-index pour qu'elle passe SOUS la bannière si besoin */
    z-index: 999; 
}

/* --- LE HEADER DE LA SIDEBAR (Engrenage) --- */
.sidebar-gear-header {
    width: 120px;
    height: 120px;
    margin: 20px auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* On garde gear-container pour les animations internes */
.gear-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* --- LE CONTENEUR DES BOUTONS --- */
.sidebar-buttons {
    
    position: relative;
    display: flex;
    flex-direction: column;
    width: 60%;
    height: auto;
    margin: 40px auto 0 auto; /* Haut | Droite | Bas | Gauche */
    
    /* Ou plus simplement si tu veux garder la syntaxe courte : */
    margin-top: 40px;
    gap: 10px;
    z-index: 5;
    filter: drop-shadow(4px 20px 15px rgba(0,0,0,1));
}

.rpg-button {
    display: flex;
    align-items: center;    
    justify-content: center; 
    width: 100%;
    max-width: 100%;
    aspect-ratio: 488 / 231; 
    
    background-color: transparent;
    border: none;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    margin: 0 auto;
    position: relative; /* Indispensable pour le positionnement du fond */
    overflow: visible;
    
    transition: transform 0.15s ease-out;
}

/* --- LE FOND ISOLÉ --- */
.rpg-button::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    
    background-image: url('../img/bg_button.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    
    z-index: 1; /* Derrière le texte */
}

.btn-text {
    position: relative; /* Pour passer au-dessus du fond */
    z-index: 2; 
    
    display: inline-block;
    font-family: 'Palatino';
    font-size: 2rem; 
    color: #0e0701; 
    text-transform: none; 
    text-shadow: 1px 1px 0px #eeeab8;
    
    padding: 0 40px; 
    text-align: center;
    transform: translateY(-6px); 

    transition: none;
}

/* --- ÉTAT SURVOLÉ (HOVER) --- */

.rpg-button:hover {
    transform: translateX(15px);
}

/* On applique le filtre UNIQUEMENT sur le pseudo-élément (le fond) */
.rpg-button:hover::before {
    filter: sepia(0.8) hue-rotate(320deg) saturate(1.2) brightness(1.1);
}

/* Le texte peut maintenant devenir bleu sans être pollué par le filtre */
.rpg-button:hover .btn-text {
    color: #0f22d1; 
    text-shadow: 1px 1px 0px #eeeab8;
}

/* --- ANIMATIONS --- */
.gear {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    
    /* L'ombre qui suit parfaitement la forme des dents */
    filter: drop-shadow(4px 4px 5px rgba(0, 0, 0, 0.6));
}

.gear-front {
    z-index: 3;
}

.gear-back {
    z-index: 2;
    /* Optionnel : on peut assombrir l'engrenage du fond pour donner de la profondeur */
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.8)) brightness(0.8);
}
.clockwise { animation: rotate-cw 8s linear infinite; }
.anti-clockwise { animation: rotate-acw 8s linear infinite; }

@keyframes rotate-cw { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes rotate-acw { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }

@keyframes scrollBackground {
    from { 
        /* On garde bg1 fixe en haut, et on part de 0 pour bg2 */
        background-position: center top, center 0; 
    }
    to { 
        /* On garde bg1 fixe, et on descend bg2 de la hauteur exacte de l'image */
        /* Remplace 512px par la hauteur réelle de ton fichier bg2 */
        background-position: center top, center 5120px; 
    }
}
#sidebar-overlay {
    display: none;
    position: fixed;
    /* On ancre l'overlay sur les 4 bords en même temps */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    
    /* On vire width/height qui sont redondants et posent problème */
    /* width: 100vw;  <-- Supprimé */
    /* height: 100vh; <-- Supprimé */
    
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;

    /* Petit bonus pour boucher les fuites de pixels sur certains navigateurs */
    transform: translateZ(0); 
}
/* On l'affiche seulement quand la sidebar est active (ex: via une classe sur le body) */
body.sidebar-open #sidebar-overlay {
    display: block;
}
