/* ========================= */
/* VARIABLES */
/* ========================= */

:root {
    --bg: #eef2f7;
    --page: #ffffff;
    --primary: #1d4ed8;
    --secondary: #0f172a;
    --muted: #64748b;
    --border: #e5e7eb;
    --radius: 18px;
    --shadow: 0 15px 40px rgba(0, 0, 0, 0.10);
}

/* Mode sombre */
body.dark {
    --bg: #050b18;
    --page: #020617;
    --primary: #7dd3fc;
    --secondary: #e5e7eb;
    --muted: #94a3b8;
    --border: #1e293b;
}

/* ========================= */
/* BASE */
/* ========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 40px;
    font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
    background: linear-gradient(180deg, #e0ecff, var(--bg));
    color: var(--secondary);
    line-height: 1.75;
}

/* ========================= */
/* TITRE PRINCIPAL */
/* ========================= */

h1 {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px 24px;
    text-align: center;
    font-weight: 600;
    border-radius: 12px;
    border-left: 8px solid currentColor;
    background: rgba(0, 0, 0, 0.05);
    overflow: hidden;
    white-space: nowrap;
    animation: typing 2s steps(40, end) forwards;
}

/* ========================= */
/* PAGES */
/* ========================= */

.page {
    max-width: 900px;
    margin: 4rem auto;
    padding: 4rem;
    background: var(--page);
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    /* ÉTAT VISIBLE PAR DÉFAUT */
    opacity: 1;
    transform: translateY(0);
}

/* Animation ajoutée par JS */
.page.animate {
    animation: fadeUp 0.7s ease forwards;
}

.page-garde {
    min-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

/* ========================= */
/* TEXTE */
/* ========================= */

p {
    margin: 1.1rem 0;
}

.texte-centre {
    text-align: center;
    color: var(--muted);
}

strong {
    color: var(--primary);
}

/* ========================= */
/* ANIMATIONS */
/* ========================= */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

/* ========================= */
/* SOMMAIRE */
/* ========================= */

.sommaire {
    list-style: none;
    padding: 0;
    margin-top: 3rem;
}

.sommaire li {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    margin-bottom: .6rem;
    border-radius: 12px;
    border-left: 6px solid transparent;
    transition: background 0.25s ease, transform 0.25s ease;
}

.sommaire li:hover {
    transform: translateX(6px);
}

.sommaire a {
    text-decoration: none;
    font-weight: 600;
}

.sommaire span {
    font-weight: 600;
    color: var(--muted);
}

/* ========================= */
/* COULEURS PAR CHAPITRE */
/* ========================= */

.introduction {
    color: #1f4bd8;
}

.chap2 {
    color: #0a8f08;
}

.chap3 {
    color: #d87c00;
}

.chap4 {
    color: #ea00ff;
}

.conclusion {
    color: #ff0303;
}

/* Fond au survol */
.sommaire li:has(.introduction):hover {
    background: rgba(31, 75, 216, 0.12);
    border-left-color: #1f4bd8;
}

.sommaire li:has(.chap2):hover {
    background: rgba(10, 143, 8, 0.12);
    border-left-color: #0a8f08;
}

.sommaire li:has(.chap3):hover {
    background: rgba(216, 124, 0, 0.12);
    border-left-color: #d87c00;
}

.sommaire li:has(.chap4):hover {
    background: rgba(234, 0, 255, 0.12);
    border-left-color: #ea00ff;
}

.sommaire li:has(.conclusion):hover {
    background: rgba(255, 3, 3, 0.12);
    border-left-color: #ff0303;
}

/* ========================= */
/* PARAGRAPHES PAR CHAPITRE */
/* ========================= */

.introduction-page p {
    background: rgba(31, 75, 216, 0.15);
    border-left: 6px solid #1f4bd8;
    color: #1f4bd8;
}

.chap2-page p {
    background: rgba(10, 143, 8, 0.15);
    border-left: 6px solid #0a8f08;
    color: #0a8f08;
}

.chap3-page p {
    background: rgba(216, 124, 0, 0.15);
    border-left: 6px solid #d87c00;
    color: #d87c00;
}

.chap4-page p {
    background: rgba(234, 0, 255, 0.15);
    border-left: 6px solid #ea00ff;
    color: #ea00ff;
}

.conclusion-page p {
    background: rgba(255, 3, 3, 0.15);
    border-left: 6px solid #ff0303;
    color: #ff0303;
}

.introduction-page p,
.chap2-page p,
.chap3-page p,
.chap4-page p,
.conclusion-page p {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: justify;
}

/* ========================= */
/* IMAGES */
/* ========================= */

.images-cote {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin: 2.5rem 0;
}

.image-stage {
    max-width: 260px;
    width: 100%;
    border-radius: 14px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
    transition: transform 0.25s ease;
}

.image-stage:hover {
    transform: scale(1.04);
}

/* ========================= */
/* PIED DE PAGE */
/* ========================= */

.pied-page {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px 0;
    font-size: 13px;
    text-align: center;
    font-style: italic;
    background: var(--bg);
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ========================= */
/* RESPONSIVE */
/* ========================= */

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    h1 {
        font-size: 22px;
        white-space: normal;
    }

    .images-cote {
        flex-direction: column;
        align-items: center;
    }

    .image-stage {
        max-width: 90%;
    }
}

/* =============================
   PAGE DE GARDE – CINÉMA
============================= */

.page-garde {
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: scale(1.05);
    animation: coverCine 1.6s cubic-bezier(.22, 1, .36, 1) forwards;
}

/* Voile cinématographique */
.page-garde::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
            rgba(255, 255, 255, 0.85),
            rgba(0, 0, 0, 0.15));
    opacity: 0;
    animation: fadeLight 1.4s ease forwards;
    animation-delay: .3s;
}

/* TITRE */
.page-garde h1 {
    opacity: 0;
    letter-spacing: 6px;
    transform: translateY(-40px);
    animation: titleCine 1.2s ease forwards;
    animation-delay: .8s;
}

/* TEXTE */
.page-garde .texte-centre {
    opacity: 0;
    transform: translateY(30px);
    animation: textCine 1s ease forwards;
}

.page-garde .texte-centre:nth-of-type(1) {
    animation-delay: 1.3s;
}

.page-garde .texte-centre:nth-of-type(2) {
    animation-delay: 1.6s;
}

/* KEYFRAMES */

@keyframes coverCine {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeLight {
    to {
        opacity: 1;
    }
}

@keyframes titleCine {
    to {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 2px;
    }
}

@keyframes textCine {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================
   ANIMATION CINÉMA – TOUTES LES PAGES
============================= */

/* PAGE (entrée générale) */
.page {
    opacity: 0;
    transform: scale(1.04) translateY(40px);
    transition: opacity 1s cubic-bezier(.22, 1, .36, 1),
        transform 1s cubic-bezier(.22, 1, .36, 1);
}

.page.animate {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* VOILE CINÉMATOGRAPHIQUE */
.page::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
}

.page.animate::before {
    opacity: 1;
}

/* =============================
   TITRES – STYLE CINÉMA
============================= */

.page h1 {
    opacity: 0;
    letter-spacing: 6px;
    transform: translateY(-40px);
    transition: all 1s cubic-bezier(.22, 1, .36, 1);
    transition-delay: 0.3s;
}

.page.animate h1 {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 2px;
}

/* =============================
   TEXTE – APPARITION DOUCE
============================= */

.page p,
.page .images-cote {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.9s ease;
}

.page.animate p,
.page.animate .images-cote {
    opacity: 1;
    transform: translateY(0);
}

/* Décalage progressif des paragraphes */
.page.animate p:nth-of-type(1) {
    transition-delay: 0.6s;
}

.page.animate p:nth-of-type(2) {
    transition-delay: 0.8s;
}

.page.animate p:nth-of-type(3) {
    transition-delay: 1s;
}

.page.animate p:nth-of-type(4) {
    transition-delay: 1.2s;
}

.page.animate p:nth-of-type(5) {
    transition-delay: 1.4s;
}

/* =============================
   SOMMAIRE – EFFET SPÉCIAL
============================= */

.sommaire li {
    opacity: 0;
    transform: translateX(-30px);
    transition: all 0.6s ease;
}

.page.animate .sommaire li {
    opacity: 1;
    transform: translateX(0);
}

/* =============================
   TRANSITION ENTRE CHAPITRES
============================= */

/* Page qui sort */
.page {
    will-change: opacity, transform;
}

.page:not(.animate) {
    opacity: 0;
    transform: translateY(60px) scale(0.98);
}

/* Page active */
.page.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Effet "fondu cinéma" entre deux pages */
.page+.page {
    transition-delay: 0.15s;
}

/* =============================
   ORGANIGRAMME
============================= */

.organigramme {
    margin: 60px auto;
    text-align: center;
}

.organigramme h2 {
    margin-bottom: 40px;
    font-size: 1.9rem;
    letter-spacing: 1px;
}

.orga-level {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.orga-box {
    background: linear-gradient(135deg, #f5f7fa, #e4e8ef);
    padding: 16px 20px;
    border-radius: 14px;
    min-width: 180px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    transition: transform .3s ease, box-shadow .3s ease;
}

.orga-box span {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: normal;
    opacity: .8;
}

.orga-box:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.15);
}

/* Directeur */
.orga-box.directeur {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    font-size: 1.1rem;
}

/* Petites boîtes */
.orga-box.small {
    font-size: 0.9rem;
}

/* Lignes */
.orga-connector {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #999, transparent);
    margin: 20px auto;
}

.organigramme {
    opacity: 0;
    transform: translateY(40px);
    transition: all 1s ease;
}

.page.animate .organigramme {
    opacity: 1;
    transform: translateY(0);
}

#dark-toggle {
    margin-bottom: 50px;
}

/* TRANSITION FLUIDE CLAIR ↔ SOMBRE */
body,
.page,
h1,
p,
.sommaire li,
.orga-box,
.pied-page {
    transition:
        background-color 0.6s ease,
        color 0.6s ease,
        border-color 0.6s ease,
        box-shadow 0.6s ease;
}
