/* help.css v2.0 - Styles améliorés avec accessibilité et animations optimisées */

/**
 * VARIABLES CSS UNIFIÉES
 */
:root {
    /* Couleurs */
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --error-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --info-color: #9b59b6;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --background-light: #f5f7fa;
    --background-lighter: #f1f1f1;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3498db, #2980b9);
    --gradient-accent: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 40px;
    
    /* Border & Radius */
    --border-radius: 12px;
    --border-radius-sm: 5px;
    --border-radius-full: 50%;
    
    /* Shadows */
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
    --shadow-deep: 0 10px 40px rgba(0, 0, 0, 0.2);
    
    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.5s ease;
    
    /* Font */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 14px;
    --line-height-base: 1.6;
}

/**
 * RESET & BASE
 */
body {
    font-family: var(--font-family);
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, var(--background-light) 0%, #c3cfe2 100%);
    min-height: 200vh;
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

.main-content {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
}

h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
}

/**
 * BOUTON D'AIDE
 */
.help-button {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    width: 50px !important;
    height: 50px !important;
    border-radius: var(--border-radius-full) !important;
    background: var(--gradient-primary) !important;
    color: white !important;
    border: 2px solid transparent !important;
    font-size: 1.8em !important;
    font-weight: bold !important;
    cursor: pointer !important;
    box-shadow: var(--shadow-soft) !important;
    transition: var(--transition) !important;
    z-index: 1000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    outline: none !important;
    
    /* Accessibilité */
    font-family: var(--font-family) !important;
}

.help-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.help-button:focus {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
}

.help-button:active {
    transform: scale(0.95);
}

/* Indicateur visuel: le bouton a un badge si l'aide est disponible */
.help-button::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #f1c40f;
    border-radius: var(--border-radius-full);
    top: -3px;
    right: -3px;
    opacity: 0.8;
    box-shadow: 0 0 0 2px white;
}

/**
 * PANNEAU D'AIDE
 */
.help-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: var(--shadow-hover);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    overflow: hidden;
    
    /* Accessibilité */
    border: 1px solid #e0e0e0;
}

.help-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.help-panel-content {
    padding: var(--spacing-lg);
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    direction: rtl;
    background: white;
}

/**
 * SCROLLBAR PERSONNALISÉE
 */
.help-panel-content::-webkit-scrollbar {
    width: 8px;
}

.help-panel-content::-webkit-scrollbar-track {
    background: var(--background-lighter);
    border-radius: 4px;
}

.help-panel-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    transition: var(--transition-fast);
}

.help-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/**
 * TYPOGRAPHIE DANS LE PANNEAU
 */
.help-panel h3 {
    color: var(--primary-color);
    margin: 0 0 var(--spacing-md) 0;
    text-align: center;
    font-size: 1.3em;
    font-weight: 600;
}

.help-panel h4 {
    color: var(--text-dark);
    margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
    font-size: 1.1em;
    font-weight: 600;
}

.help-panel h5 {
    color: var(--error-color);
    margin: var(--spacing-md) 0 var(--spacing-xs) 0;
    font-size: 1em;
    font-weight: 600;
}

.help-panel p {
    line-height: var(--line-height-base);
    margin-bottom: var(--spacing-sm);
    color: var(--text-dark);
}

.help-panel ul,
.help-panel ol {
    margin: var(--spacing-sm) 0;
    padding-right: var(--spacing-lg);
}

.help-panel li {
    margin-bottom: var(--spacing-xs);
    color: var(--text-dark);
}

/**
 * MÉTADONNÉES DU PANNEAU
 */
.help-metadata {
    font-size: 0.85em;
    color: var(--text-light);
    text-align: center;
    margin-bottom: var(--spacing-md);
    font-style: italic;
}

/**
 * OVERLAY (FOND SEMI-TRANSPARENT)
 */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 998;
    background: transparent;
    display: none;
}

.help-overlay.show {
    display: block;
}

/**
 * SECTIONS DE CONTENU STYLISÉES
 */

/* Section: Règle Mathématique */
.math-rule {
    background: #e8f4f8;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    text-align: center;
}

/* Section: Exemple */
.example-section {
    background: rgba(52, 152, 219, 0.1);
    border-right: 3px solid var(--primary-color);
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
    border-radius: var(--border-radius-sm);
}

/* Section: Avertissement */
.warning-section {
    background: rgba(231, 76, 60, 0.1);
    border-right: 3px solid var(--error-color);
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
    border-radius: var(--border-radius-sm);
}

/* Section: Exercices */
.exercise-list {
    background: rgba(155, 89, 182, 0.1);
    border-right: 3px solid var(--info-color);
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
    border-radius: var(--border-radius-sm);
}

/* Section: Application */
.application-section {
    background: rgba(39, 174, 96, 0.1);
    border-right: 3px solid var(--success-color);
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
    border-radius: var(--border-radius-sm);
}

/* Section: Règles Complémentaires */
.complementary-rules {
    background: rgba(243, 156, 18, 0.1);
    border-right: 3px solid var(--warning-color);
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
    border-radius: var(--border-radius-sm);
}

/* Section: Conseil Final */
.final-tip {
    background: var(--gradient-accent);
    color: white;
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    border-radius: var(--border-radius-sm);
    text-align: center;
    font-weight: 500;
}

/**
 * MATHJAX - FORCER LTR
 */
.help-panel-content .MathJax,
.help-panel-content .MathJax_Display,
.help-panel-content mjx-container {
    direction: ltr !important;
    text-align: left !important;
}

/**
 * ACCESSIBILITÉ: RÉDUCTION DES ANIMATIONS
 * Pour les utilisateurs ayant activé "Réduire les mouvements"
 */
@media (prefers-reduced-motion: reduce) {
    :root {
        --transition: none !important;
        --transition-fast: none !important;
        --transition-slow: none !important;
    }
    
    .help-button,
    .help-panel,
    .help-panel-content::-webkit-scrollbar-thumb {
        transition: none !important;
    }
    
    .help-button:hover {
        transform: none;
    }
    
    .help-button:active {
        transform: none;
    }
}

/**
 * RESPONSIVE: TABLETTES ET PETITS ÉCRANS
 */
@media (max-width: 768px) {
    .help-panel {
        width: 280px;
        left: 10px;
        max-height: 350px;
    }
    
    .help-panel-content {
        max-height: 310px;
        padding: var(--spacing-md);
    }
    
    .help-button {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.5em !important;
        left: 15px !important;
        top: 15px !important;
    }
}

/**
 * RESPONSIVE: MOBILE (écrans très petits)
 */
@media (max-width: 480px) {
    .help-panel {
        width: calc(100vw - 30px);
        left: 15px;
        right: 15px;
        max-height: 60vh;
        top: auto;
        bottom: 20px;
    }
    
    .help-panel-content {
        max-height: calc(60vh - 50px);
        padding: var(--spacing-md);
    }
    
    .help-button {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.3em !important;
        bottom: 20px !important;
        top: auto !important;
        left: 15px !important;
    }
    
    .main-content {
        padding: var(--spacing-lg);
    }
}

/**
 * THÈME SOMBRE (optionnel)
 * Activé si l'utilisateur a préféré le mode sombre
 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    }
    
    .main-content,
    .help-panel {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .help-panel-content {
        background: #2d2d2d;
    }
    
    .help-panel h3,
    .help-panel h4,
    .help-panel h5,
    .help-panel p,
    .help-panel li {
        color: #e0e0e0;
    }
    
    .help-panel-content::-webkit-scrollbar-track {
        background: #1a1a1a;
    }
    
    .example-section {
        background: rgba(52, 152, 219, 0.2);
    }
    
    .warning-section {
        background: rgba(231, 76, 60, 0.2);
    }
    
    .exercise-list {
        background: rgba(155, 89, 182, 0.2);
    }
    
    .application-section {
        background: rgba(39, 174, 96, 0.2);
    }
    
    .complementary-rules {
        background: rgba(243, 156, 18, 0.2);
    }
    
    .math-rule {
        background: rgba(52, 152, 219, 0.15);
        border-color: var(--primary-color);
    }
}