:root {
    --bg: #f4f6f8;
    --primary: #1e293b;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --text: #0f172a;
    --muted: #64748b;
    --card: #ffffff;
}

/* Base */

body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: white !important;
}

main {
    padding: 60px 40px;
    max-width: 1400px;
    margin: auto;
}

#title {
    text-align: center;
    font-size: 2.3rem;
    margin-bottom: 40px;
    font-weight: 600;
    color: white;
}

/* Timeline container */

#friseContainer {
    overflow-x: auto;
    padding-bottom: 40px;
}

#friseChronologique {
    display: flex;
    min-width: max-content;
    position: relative;
}

/* Chaque bloc */

.friseItem {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 220px;
}

/* Trait */
.trait::before {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
}

.trait {
    margin-top: 35px;
    height: 70px;
    width: 5px;
    background-color: var(--primary);
    display: flex;
    z-index: 5;
    position: absolute;
}

/* RECTANGLE PRINCIPAL */

.friseBloc {
    width: 100%;
    height: 70px;
    border: var(--primary) 2px solid;
}

/* Alternance moderne */

.friseBloc2 .friseBloc,
.friseBloc4 .friseBloc,
.friseBloc6 .friseBloc,
.friseBloc8 .friseBloc,
.friseBloc10 .friseBloc,
.friseBloc1 .friseBloc,
.friseBloc3 .friseBloc,
.friseBloc5 .friseBloc,
.friseBloc7 .friseBloc,
.friseBloc9 .friseBloc,
.friseBloc11 .friseBloc {
    background: var(--accent);
}

/* Contenu sous les rectangles */

.friseContent {
    padding: 10px 15px;
    text-align: center;
    display: grid;
    grid-template-rows: auto 1fr auto;
    row-gap: 2px;
    height: 100%;
    position: relative;
    z-index: 10;
}

.friseContent h3 {
    margin: 45px 0 2px 0px;
    font-weight: 600;
    color: white;
}

.friseContent p {
    color: white;
    margin-bottom: 2px;
}

/* Bouton moderne */

.btnVoirPlus {
    padding: 8px 18px 8px 18px;
    border-radius: 30px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.3s;
    align-self: end;
}

.btnVoirPlus:hover {
    background: var(--accent);
}

/* Bouton */

.btnVoirPlus {
    padding: 8px 18px;
    border-radius: 30px;
    border: none;
    background: white;
    color: var(--primary);
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.85rem;
    max-width: 100%;
    justify-self: center;
}

.btnVoirPlus:hover {
    background: rgb(144, 144, 144);
    color: rgb(244, 244, 244);
}

/* Section Plus Infos */

#PlusInfos {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 40px;
    margin-top: 80px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    color: black;
}

#PlusInfos.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#PlusInfos h2 {
    margin-top: 0;
    color: var(--primary);
}

#PlusInfos p {
    max-width: 800px;
    text-align: justify;
    color: var(--text);
}

#descriptionContainer {
    max-width: 800px;
    text-align: justify;
    color: var(--text);
    width: 100%;
}

/* Couleur statut tâches */ 

.termine { 
    color: green; 
} 

.enCours { 
    color: orange; 
} 

.pasCommence { 
    color: red; 
}

/* Carrousel */

#imagesContainer {
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    align-items: center;
    gap: 20px;
    width: 100%;
    margin-top: 30px;
}

#carrouselViewport {
    overflow: hidden;
    width: 100%;
    border-radius: 16px;
}

#carrousel {
    display: flex;
    transition: transform 0.5s ease;
}

.ImageVoirPlus {
    min-width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.prev, .next {
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 20px;
    transition: 0.3s;
}

.prev:hover, .next:hover {
    background: black;
}

/* Bouton fermer */

#closeButton {
    margin-top: 30px;
    padding: 10px 20px;
    border-radius: 30px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
}

/* --- RESPONSIVE TABLETTE & MOBILE --- */

@media (max-width: 1024px) {
    main {
        padding: 40px 20px;
    }

    /* On casse le mode horizontal pour passer en vertical */
    #friseChronologique {
        flex-direction: column;
        align-items: flex-start; /* Aligné à gauche */
        padding-left: 50px;     /* Espace pour le trait vertical */
        min-width: auto;
    }

    .friseItem {
        width: 100%;
        flex-direction: row;    /* Rectangle à gauche, texte à droite */
        align-items: flex-start;
        margin-bottom: 40px;
        gap: 20px;
    }

    /* On transforme le rectangle bleu en petit carré/indicateur */
    .friseBloc {
        width: 60px;
        min-width: 60px;
        height: 60px;
    }

    /* Le trait devient vertical et se place à gauche */
    .trait {
        position: absolute;
        left: 28px; /* Centré sous le carré de 60px */
        top: 60px;
        height: calc(100% - 20px);
        width: 4px;
        margin-top: 0;
    }

    /* On ajuste le contenu textuel */
    .friseContent {
        text-align: left;
        padding: 0;
    }

    .friseContent h3 {
        margin: 0 0 5px 0;
    }

    .btnVoirPlus {
        justify-self: start;
        margin-top: 10px;
    }

    /* Suppression de la flèche finale en mode mobile car elle ne fait plus sens */
    .last-rect::after {
        display: none;
    }

    /* On réduit l'espace autour du carrousel */
    #PlusInfos {
        padding: 20px;
    }

    #imagesContainer {
        grid-template-columns: 45px 1fr 45px; /* Flèches légèrement plus petites */
        gap: 10px;
    }

    .prev, .next {
        height: 45px;
        width: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        padding: 0;
    }
}

@media (max-width: 600px) {
    #title {
        font-size: 1.8rem;
    }

    #friseChronologique {
        padding-left: 30px;
    }

    .friseItem {
        gap: 15px;
    }

    .friseBloc {
        width: 40px;
        min-width: 40px;
        height: 40px;
    }

    .trait {
        left: 18px;
        top: 40px;
    }

    /* Sur petit mobile, on place souvent les flèches SUR l'image ou en dessous */
    #imagesContainer {
        display: block; /* On casse la grille */
        position: relative;
    }

    #carrouselViewport {
        width: 100%;
    }

    /* On positionne les flèches en flottant sur les côtés de l'image */
    .prev, .next {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 20;
        height: 40px;
        width: 40px;
        background: rgba(30, 41, 59, 0.7); /* var(--primary) avec transparence */
        font-size: 20px;
        border-radius: 50%; /* Boutons ronds sur mobile */
    }

    .prev {
        left: 10px;
    }

    .next {
        right: 10px;
    }
    
    /* On s'assure que les images gardent un bon ratio */
    .ImageVoirPlus {
        aspect-ratio: 4/3; /* Plus haut sur mobile pour mieux voir */
    }
}