/* --- IMPORTATION DE LA POLICE MATHÉMATIQUE (x arrondi avec boucles douces) --- */
@import url('https://fonts.googleapis.com/css2?family=STIX+Two+Text:ital,wght@1,400;1,600&display=swap');

/* --- DESIGN GLOBAL DU SITE --- */
body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: #f4f7f6; 
    margin: 0; 
    padding: 20px; 
    color: #333; 
}
.layout { 
    display: flex; 
    max-width: 1100px; 
    margin: 0 auto; 
    gap: 20px; 
}

/* --- MENU DE GAUCHE (Navigation) --- */
.sidebar { 
    width: 340px; 
    background: white; 
    padding: 20px; 
    border-radius: 12px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
}
.sidebar h2 { 
    color: #2c3e50; 
    margin-top: 0; 
    font-size: 1.4rem; 
    border-bottom: 2px solid #edf2f7; 
    padding-bottom: 10px; 
}

.chapitre-titre { 
    background: #2c3e50; 
    color: white; 
    padding: 10px 14px; 
    border-radius: 6px; 
    font-weight: bold; 
    margin-top: 15px; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    user-select: none; 
}
.chapitre-titre:hover { 
    background: #34495e; 
}

.liste-exercices { 
    padding-left: 5px; 
    margin-top: 5px; 
} 

.menu-btn { 
    display: block; 
    width: 100%; 
    text-align: left; 
    padding: 10px 12px; 
    margin: 4px 0; 
    border: none; 
    background: #edf2f7; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 0.95rem; 
    font-weight: 500; 
    transition: background 0.2s; 
}
.menu-btn:hover { 
    background: #cbd5e0; 
}

/* --- ZONE D'EXERCICE (À droite) --- */
.main-content { 
    flex: 1; 
    background: white; 
    padding: 30px; 
    border-radius: 12px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    display: none; 
}
.exo-header {
    color: #2c3e50; 
    text-align: center;
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 10px;
}
.box { 
    background: #edf2f7; 
    padding: 20px; 
    border-left: 5px solid #2b6cb0; 
    border-radius: 4px; 
    margin: 20px 0; 
    font-size: 1.2rem; 
}

/* --- AFFICHAGE MATHÉMATIQUE --- */
.math-center { 
    text-align: center; 
    font-size: 1.5rem; 
    margin: 15px 0; 
    font-family: 'STIX Two Text', 'Times New Roman', Times, serif; 
    font-style: normal; 
}
.math-inline { 
    display: inline;
    font-family: 'STIX Two Text', 'Times New Roman', Times, serif; 
    font-style: normal; 
    font-size: 1.15rem; 
}

/* Force le véritable 'x' mathématique arrondi avec boucles sur tous les navigateurs (Android, iOS, PC) */
var,
.var,
.math-center .var,
.math-inline .var,
.frac .var {
    font-family: 'STIX Two Text', 'Times New Roman', Times, serif !important;
    font-style: italic !important;
    font-weight: normal !important;
    padding: 0 1.5px;
}

.pi {
    font-style: italic;
    font-family: 'STIX Two Text', 'Times New Roman', Times, serif;
}

.crochet, .math-symbol {
    font-style: normal;
    display: inline-block;
}

/* --- BOUTONS D'ACTION --- */
.action-btn { 
    padding: 12px 24px; 
    border: none; 
    color: white; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: bold; 
    font-size: 1rem; 
    font-family: 'Segoe UI', sans-serif;
    transition: filter 0.2s;
    background: #2b6cb0; 
}
.action-btn:hover {
    filter: brightness(90%);
}
.corrige { 
    margin-top: 20px; 
    padding: 20px; 
    background: #fffaf0; 
    border-left: 5px solid #dd6b20; 
    display: none; 
    border-radius: 4px; 
}
.corrige h3 { margin-top: 0; color: #dd6b20; }

/* --- PARENTHÈSES DE HAUTEUR AJUSTÉE ET EXPOSANT OPTIMISÉ --- */
.parenth-grande {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-size: 1.5rem;
    margin: 0 4px;
    position: relative;
}
.parenth-grande .deliv {
    font-weight: 300;
    transform: scaleY(2.2);
    display: inline-block;
}
.parenth-grande sup {
    font-size: 0.7rem;
    position: absolute;
    right: -8px;
    top: -4px;
    vertical-align: baseline;
    margin: 0;
}

/* --- STYLE FRACTIONS --- */
.frac-container { 
    display: inline-flex !important; 
    align-items: center; 
    vertical-align: middle; 
    margin: 0 3px;
}
.frac { 
    display: inline-flex !important; 
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    vertical-align: middle; 
    padding: 0 2px; 
    font-size: 0.9em;
    line-height: 1;
}
.frac .top { 
    display: block; 
    text-align: center;
    padding: 0 2px 1px 2px;
    line-height: 1;
    width: 100%;
    box-sizing: border-box;
}
.frac .bottom { 
    display: block; 
    text-align: center;
    border-top: 1.3px solid #333; 
    padding: 1px 2px 0 2px; 
    line-height: 1;
    width: 100%;
    box-sizing: border-box;
}

/* ========================================================
   ADAPTATION MOBILE : PORTRAIT (< 768px) OU PAYSAGE (hauteur faible < 550px)
   ======================================================== */
@media screen and (max-width: 768px), screen and (orientation: landscape) and (max-height: 550px) {

    /* 1. Forcer l'affichage vertical : le menu au-dessus, l'exercice en dessous */
    .layout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 8px !important;
        box-sizing: border-box !important;
    }

    /* 2. La barre latérale et l'exercice prennent 100 % de la largeur */
    .sidebar {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px !important;
        box-sizing: border-box !important;
    }

    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    /* 3. Boutons du menu et d'action fluides */
    .menu-btn {
        width: 100% !important;
        padding: 12px 10px !important;
        font-size: 0.95rem !important;
        margin-bottom: 6px !important;
    }

    .action-btn {
        display: block !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-bottom: 10px !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    /* 4. Formules et défilement */
    .math-center {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        max-width: 100% !important;
        padding: 4px 0 !important;
        -webkit-overflow-scrolling: touch;
    }

    svg {
        max-width: 100% !important;
        height: auto !important;
    }

    table {
        font-size: 0.9rem !important;
    }
}