/* ==========================================================================
   VARIABLES GLOBALES (Thème "Trame Cosmique")
   ========================================================================== */
:root {
    /* Couleurs de fond (L'espace pré-géométrique et l'expansion) */
    --bg-void: #050508; /* Noir profond, presque absolu */
    --bg-surface: #111116; /* Fond des cartes/chapitres */
    
    /* Typographie et luminosité (L'information quantique) */
    --text-primary: #e0e0e6; /* Blanc cassé pour éviter la fatigue visuelle */
    --text-secondary: #9aa0a6; /* Gris bleuté pour les méta-données et notes */
    --accent-glow: #4da6ff; /* Bleu "radiation/intrication" */
    --accent-warm: #ff8c42; /* Orange "étoile/chaleur thermodynamique" */
    
    /* Structure et espacement */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --border-radius: 8px;
    
    /* Typographie */
    --font-heading: 'Cinzel', 'Georgia', serif; /* Typographie élégante et classique pour les titres */
    --font-body: 'Inter', system-ui, -apple-system, sans-serif; /* Lisibilité optimale pour les textes longs */
}

/* ==========================================================================
   RESET & FONDATIONS
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Scrollbar personnalisée (Thème spatial) */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-void);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-surface);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==========================================================================
   HEADER / NAVIGATION (Minimaliste et fonctionnel)
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(10px); /* Effet verre dépoli */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#app-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-transform: uppercase;
}

.controls button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: var(--spacing-xs);
}

.controls button:hover {
    color: var(--bg-void);
    background: var(--text-primary);
    border-color: var(--text-primary);
    box-shadow: 0 0 10px rgba(224, 224, 230, 0.3);
}

/* ==========================================================================
   MISE EN PAGE DU LIVRE (Desktop Centré)
   ========================================================================== */
.book-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

/* ==========================================================================
   TYPOGRAPHIE INTERNE DES CHAPITRES
   ========================================================================== */
.chapter {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateY(20px);
    animation: fade-in-up 0.8s ease forwards;
}

/* Animation d'apparition douce lors du scroll/chargement */
@keyframes fade-in-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    line-height: 1.3;
    position: relative;
    padding-bottom: var(--spacing-xs);
}

/* Petit filet décoratif sous les titres */
.chapter h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--accent-glow);
    box-shadow: 0 0 8px var(--accent-glow);
}

.chapter h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.chapter p {
    margin-bottom: var(--spacing-sm);
    text-align: justify;
    hyphens: auto; /* Permet une meilleure justification sur mobile */
}

.chapter em {
    color: var(--text-secondary);
    font-style: italic;
}

/* ==========================================================================
   CONTENEURS VISUELS (Images & WebGL)
   ========================================================================== */
.visual-container {
    margin: var(--spacing-md) 0;
    padding: 0 !important; /* Force la suppression des marges internes */
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    min-height: 300px; /* Hauteur par défaut pour éviter les sauts de mise en page */
}

/* Affichage écran uniquement */
.screen-only {
    display: block;
}

/* Caché sur écran, affiché à l'impression */
.print-only {
    display: none;
}

/* Style de l'image de fallback / impression */
.static-container img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1s ease;
}

.static-container img[src] {
    opacity: 1; /* Révélation douce après le lazy load */
}

/* Conteneur pour le futur Canvas WebGL */
.interactive-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Loader textuel temporaire */
.loader {
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 2px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.3; }
    50% { opacity: 1; text-shadow: 0 0 10px var(--accent-glow); }
    100% { opacity: 0.3; }
}

/* ==========================================================================
   GLOSSAIRE (Affichage en grille)
   ========================================================================== */
.glossary-section {
    border-bottom: none; /* Pas de filet après le dernier élément */
}

.glossary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.glossary-entry {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.glossary-visual {
    width: 100%;
    height: 150px;
    background: var(--bg-void);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.glossary-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.glossary-text h3 {
    margin-top: 0;
    color: var(--accent-warm);
    font-family: var(--font-heading);
    font-size: 1.2rem;
}

.glossary-text p {
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* ==========================================================================
   MEDIA QUERIES (Mobile First vers Desktop)
   ========================================================================== */
@media (min-width: 768px) {
    /* Header plus large sur desktop */
    #app-title {
        font-size: 1.5rem;
    }

    /* Le glossaire passe sur 2 colonnes */
    .glossary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


#app-footer {
    width: 100%;
    background-color: #050508;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 10px;
    margin-top: 40px;
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.contact-link {
    color: #00ffaa;
    text-decoration: none;
    transition: opacity 0.2s;
}

.contact-link:hover {
    opacity: 0.8;
}

/* Adaptation Mobile */
@media (max-width: 600px) {
    .footer-content {
        flex-direction: column;
        gap: 5px;
    }
    .separator {
        display: none;
    }
}
.zenodo-link {
    color: #4da6ff; /* Bleu scientifique pour le distinguer */
    text-decoration: none;
    font-weight: bold;
    transition: opacity 0.2s;
}

.zenodo-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}