
/* =========================================================
   PAGE CHAPITRE
   ========================================================= */

.page-chapitre {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 25px 15px 50px;
    box-sizing: border-box;
}


/* =========================================================
   EN-TÊTE DU CHAPITRE
   ========================================================= */

.chapitre-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;

    margin-bottom: 25px;

    text-align: left;
}

.chapitre-icone {
    width: 72px;
    height: 72px;

    flex: 0 0 72px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f8fafc;

    border: 1px solid #e2e8f0;
    border-radius: 16px;
}

.chapitre-icone img {
    width: 58px;
    height: 58px;

    object-fit: contain;
    display: block;
}

.chapitre-header h1 {
    margin: 0 0 5px;

    color: #1e293b;

    font-size: 30px;
    line-height: 1.2;
    font-weight: 800;
}

.chapitre-header p {
    margin: 0;

    color: #94a3b8;

    font-size: 13px;
    font-weight: 600;
}


/* =========================================================
   BLOC SCORE
   ========================================================= */

.bloc-score-chapitre {
    width: 100%;

    margin-bottom: 40px;

    text-align: center;
}

.titre-score-chapitre {
    margin-bottom: 15px;

    color: #334155;

    font-size: 20px;
    font-weight: 800;
}

.score-wrapper-chapitre {
    width: 220px;
    height: 220px;

    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: center;
}


/* =========================================================
   CERCLE DE SCORE
   ========================================================= */

.score-wrapper-chapitre .score {
    --value: 0;
    --thickness: 11px;

    width: 220px;
    height: 220px;

    position: relative;

    border-radius: 50%;

    display: grid;
    place-items: center;

    --color:
        hsl(
            calc(var(--value) * 1.2),
            85%,
            48%
        );

    overflow: visible;
}

.score-wrapper-chapitre .score::before {
    content: "";

    position: absolute;

    inset: 0;

    border-radius: 50%;

    background:
        conic-gradient(
            var(--color)
            calc(var(--progress) * 1%),
            #ececec 0
        );

    animation:
        fill 1.2s ease forwards;
}

.score-wrapper-chapitre .score::after {
    content: "";

    position: absolute;

    inset: var(--thickness);

    background:
        linear-gradient(
            #fff,
            #f7f7f7
        );

    border-radius: 50%;
}

.score-wrapper-chapitre .inside {
    position: relative;

    z-index: 2;

    text-align: center;
}

.score-wrapper-chapitre .value {
    font-size: 42px;
    font-weight: 800;

    font-family:
        Inter,
        sans-serif;

    color: #000;
}


/* =========================================================
   HALO POUR LES GROS SCORES
   ========================================================= */

.score-wrapper-chapitre .score[style*="--value:9"],
.score-wrapper-chapitre .score[style*="--value:100"] {

    filter:
        drop-shadow(
            0 0 14px
            color-mix(
                in srgb,
                var(--color) 50%,
                transparent
            )
        );
}


/* =========================================================
   100 % : ANIMATION ARC-EN-CIEL
   ========================================================= */

.score-wrapper-chapitre .score.perfect::before {

    background:
        conic-gradient(
            red,
            orange,
            yellow,
            #00d95f,
            cyan,
            violet,
            red
        );

    animation:
        rainbow 1.2s linear,
        finalGreen .2s 1.2s forwards;
}


/* =========================================================
   BADGE DE RÉUSSITE
   ========================================================= */

.score-wrapper-chapitre .badge {

    width: 27px;
    height: 27px;

    border-radius: 50%;

    background: #22c55e;

    color: white;

    display: grid;
    place-items: center;

    margin: auto auto 6px;

    font-size: 15px;
    font-weight: 900;

    animation:
        pop .5s .9s both;
}


/* =========================================================
   MESSAGE CONNEXION
   ========================================================= */

.connexion-chapitre {
    margin-top: 12px;

    color: #94a3b8;

    font-size: 13px;
    font-weight: 600;
}

.connexion-chapitre a {
    color: #2563eb;

    font-weight: 800;

    text-decoration: none;
}

.connexion-chapitre a:hover {
    text-decoration: underline;
}


/* =========================================================
   EXERCICES
   ========================================================= */

.chapitre-exercices {
    margin-bottom: 40px;
}

.chapitre-exercices h2 {
    margin: 0 0 15px;

    color: #1e293b;

    font-size: 22px;
    font-weight: 800;
}

.chapitre-exercices-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(210px, 1fr));

    gap: 12px;
}


/* =========================================================
   CARTE EXERCICE
   ========================================================= */

.chapitre-exercice {
    display: flex;
    flex-direction: column;

    overflow: hidden;

    min-width: 0;

    background: #f8fafc;

    border: 1px solid #e2e8f0;
    border-radius: 12px;

    color: #334155;

    text-decoration: none;

    transition:
        transform .18s ease,
        background .18s ease,
        border-color .18s ease,
        box-shadow .18s ease;
}

.chapitre-exercice:hover {
    transform: translateY(-2px);

    background: #fff;

    border-color: #93c5fd;

    box-shadow:
        0 6px 16px rgba(37, 99, 235, .10);
}


/* =========================================================
   IMAGE EXERCICE
   ========================================================= */

.chapitre-exercice-image {
    width: 100%;
    
    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    background: #fff;

    border-bottom: 1px solid #edf1f5;
}

.chapitre-exercice-image img {
    width: 100%;
    height: 100%;

    object-fit: contain;

    display: block;

    transition: transform .2s ease;
}

.chapitre-exercice:hover
.chapitre-exercice-image img {
    transform: scale(1.02);
}


/* =========================================================
   CONTENU EXERCICE
   ========================================================= */

.chapitre-exercice-contenu {
    position: relative;

    min-height: 90px;

    padding: 10px 52px 10px 11px;

    box-sizing: border-box;
}

.chapitre-exercice-nom {
    color: #334155;

    font-size: 13px;
    line-height: 1.3;
    font-weight: 800;
}


/* =========================================================
   NIVEAUX
   ========================================================= */

.chapitre-exercice-niveaux {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;

    margin-top: 8px;
}

.chapitre-exercice-niveaux span {
    padding: 3px 6px;

    background: #eaf2ff;

    border-radius: 5px;

    color: #2563eb;

    font-size: 10px;
    line-height: 1;
    font-weight: 800;
}


/* =========================================================
   SCORE DES EXERCICES
   ========================================================= */

.chapitre-exercice-score {
    position: absolute;

    right: 9px;
    bottom: 9px;

    width: 34px;
    height: 34px;

    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    border: 3px solid #cbd5e1;

    font-size: 9px;
    font-weight: 800;

    background: #f1f5f9;
    color: #94a3b8;
}

.chapitre-exercice-score.score-faible {
    background: #fff7ed;
    border-color: #fb923c;
    color: #c2410c;
}

.chapitre-exercice-score.score-moyen {
    background: #fefce8;
    border-color: #facc15;
    color: #a16207;
}

.chapitre-exercice-score.score-bon {
    background: #f0fdf4;
    border-color: #84cc16;
    color: #4d7c0f;
}

.chapitre-exercice-score.score-tres-bon {
    background: #ecfdf5;
    border-color: #22c55e;
    color: #15803d;
}

.chapitre-exercice-score.score-excellent {
    background: #fffbeb;
    border-color: #eab308;
    color: #a16207;

    box-shadow:
        0 0 0 2px rgba(234, 179, 8, .10);
}


/* =========================================================
   PDF / FICHES À IMPRIMER
   ========================================================= */

.chapitre-pdfs {
    margin-top: 40px;
    margin-bottom: 40px;

    padding: 20px;

    background: #f8fafc;

    border: 1px solid #e2e8f0;
    border-radius: 15px;

    text-align: center;
}

.chapitre-pdfs h2 {
    margin: 0 0 18px;

    color: #1e293b;

    font-size: 22px;
    font-weight: 800;
}

.chapitre-pdfs-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(100px, 120px));

    justify-content: center;

    gap: 14px;

    margin-bottom: 20px;
}


/* Carte PDF */

.chapitre-pdf {
    min-width: 0;

    padding: 6px;

    background: #fff;

    border: 1px solid #e2e8f0;
    border-radius: 9px;

    box-shadow:
        0 2px 7px rgba(15, 23, 42, .04);

    box-sizing: border-box;

    transition:
        transform .18s ease,
        box-shadow .18s ease,
        border-color .18s ease;
}

.chapitre-pdf:hover {
    transform: translateY(-2px);

    border-color: #93c5fd;

    box-shadow:
        0 5px 14px rgba(37, 99, 235, .10);
}


/* Vignette 200 × 280 */

.chapitre-pdf-image {
    width: 100%;

    aspect-ratio: 200 / 280;

    overflow: hidden;

    background: #fff;

    border-radius: 6px;
}

.chapitre-pdf-image img {
    width: 100%;
    height: 100%;

    object-fit: contain;

    display: block;
}


/* Nom de la fiche */

.chapitre-pdf-nom {
    margin-top: 8px;

    color: #475569;

    font-size: 11px;
    line-height: 1.25;
    font-weight: 700;
}


/* Bouton vers tous les PDF */

.chapitre-pdfs-lien {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 10px 18px;

    background: #2563eb;

    border-radius: 8px;

    color: #fff;

    font-size: 13px;
    font-weight: 800;

    text-decoration: none;

    transition:
        background .15s ease,
        transform .15s ease,
        box-shadow .15s ease;
}

.chapitre-pdfs-lien:hover {
    background: #1d4ed8;

    transform: translateY(-1px);

    box-shadow:
        0 4px 10px rgba(37, 99, 235, .20);
}


/* =========================================================
   NAVIGATION CHAPITRES
   ========================================================= */

.navigation-chapitres {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 15px;

    margin-top: 40px;
}

.chapitre-navigation {
    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;

    padding: 12px;

    background: #f8fafc;

    border: 1px solid #e2e8f0;
    border-radius: 12px;

    text-decoration: none;

    transition:
        background .15s ease,
        border-color .15s ease,
        transform .15s ease;
}

.chapitre-navigation:hover {
    background: #fff;

    border-color: #93c5fd;

    transform: translateY(-1px);
}

.chapitre-navigation.suivant {
    justify-content: flex-end;

    text-align: right;
}

.chapitre-navigation img {
    width: 46px;
    height: 46px;

    flex: 0 0 46px;

    object-fit: contain;
}

.chapitre-navigation small {
    display: block;

    margin-bottom: 3px;

    color: #94a3b8;

    font-size: 11px;
    font-weight: 700;
}

.chapitre-navigation strong {
    display: block;

    color: #334155;

    font-size: 13px;
    line-height: 1.25;
}

/* =========================================================
   ANIMATION DU SCORE
   ========================================================= */

/* halo >90 */

.score[style*="--value:9"],
.score[style*="--value:100"] {
    filter:
        drop-shadow(
            0 0 14px
            color-mix(
                in srgb,
                var(--color) 50%,
                transparent
            )
        );
}


/* 100 % */

.perfect::before {

    background:
        conic-gradient(
            red,
            orange,
            yellow,
            #00d95f,
            cyan,
            violet,
            red
        );

    animation:
        rainbow 1.2s linear,
        finalGreen .2s 1.2s forwards;
}


.badge {

    width: 24px;
    height: 24px;

    border-radius: 50%;

    background: #22c55e;

    color: white;

    display: grid;
    place-items: center;

    margin: auto auto 5px;

    animation:
        pop .5s .9s both;
}


/* =========================================================
   ANIMATIONS
   ========================================================= */

@property --progress {
    syntax: "<number>";
    initial-value: 0;
    inherits: false;
}


@keyframes fill {

    from {
        --progress: 0;
    }

    to {
        --progress: var(--value);
    }
}


@keyframes rainbow {

    to {
        transform: rotate(360deg);
    }
}


@keyframes finalGreen {

    to {

        background:
            conic-gradient(
                #22c55e 100%,
                #ececec 0
            );
    }
}


@keyframes pop {

    from {

        transform:
            scale(.3);

        opacity: 0;
    }

    to {

        transform:
            scale(1);

        opacity: 1;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .page-chapitre {
        padding: 18px 8px 35px;
    }

    .chapitre-header {
        gap: 12px;
    }

    .chapitre-icone {
        width: 58px;
        height: 58px;
        flex-basis: 58px;
    }

    .chapitre-icone img {
        width: 46px;
        height: 46px;
    }

    .chapitre-header h1 {
        font-size: 24px;
    }

    .chapitre-header p {
        font-size: 12px;
    }

    .score-wrapper-chapitre {
        width: 180px;
        height: 180px;
    }

    .score-wrapper-chapitre .score {
        width: 180px;
        height: 180px;
    }

    .score-wrapper-chapitre .value {
        font-size: 34px;
    }

    .chapitre-exercices-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 8px;
    }

    .chapitre-exercice-image {
        height: 80px;
    }

    .chapitre-exercice-contenu {
        min-height: 88px;

        padding: 8px 48px 8px 8px;
    }

    .chapitre-exercice-nom {
        font-size: 11px;
    }

    .chapitre-pdfs {
        padding: 14px;
    }

    .chapitre-pdfs-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));

        gap: 8px;
    }

    .chapitre-pdf {
        padding: 5px;
    }

    .chapitre-pdf-nom {
        font-size: 10px;
    }

    .navigation-chapitres {
        gap: 8px;
    }

    .chapitre-navigation {
        padding: 8px;
        gap: 7px;
    }

    .chapitre-navigation img {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .chapitre-navigation strong {
        font-size: 11px;
    }

}


/* =========================================================
   TRÈS PETITS ÉCRANS
   ========================================================= */

@media (max-width: 420px) {

    .chapitre-exercices-grid {
        grid-template-columns: 1fr;
    }

    .chapitre-exercice {
        flex-direction: row;
    }

    .chapitre-exercice-image {
        width: 110px;
        height: 82px;

        flex: 0 0 110px;

        border-bottom: none;
        border-right: 1px solid #edf1f5;
    }

    .chapitre-pdfs-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        max-width: 260px;

        margin-left: auto;
        margin-right: auto;
    }

    .navigation-chapitres {
        grid-template-columns: 1fr;
    }

    .chapitre-navigation.suivant {
        justify-content: flex-start;
        text-align: left;
    }

}