/*
 * Hub CRPE : composants de quiz (lot B3) : les 7 formats (qcm, vrai_faux, intrus, categoriser, apparier, ordre, analyse),
 * correction, écran de résultat, flashcards. Reprend Quiz-mobile / Quiz-desktop / Resultat / Flashcards.
 * Les partiels Twig de chaque format sont écrits par C3 ; ils n'utilisent que ces classes et les jetons de crpe-base.css.
 * Règles : juste / faux = icône + mot (jamais la couleur seule) ; cibles ≥ 44 px (réponses 56 px) ; focus visible 3 px ;
 * pub en colonne latérale (desktop) ou sous le pied de l'écran (mobile), jamais entre énoncé, réponses et « Suivant ».
 */
/* ---------- Quiz ---------- */
.crpe-quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--crpe-muted); }
.crpe-quiz-progress { height: 6px; background: #e3e8ef; border-radius: 3px; margin: 10px 0 0; overflow: hidden; }
.crpe-quiz-progress > span { display: block; height: 100%; background: var(--crpe-accent-text); }
.crpe-q-format { font-size: 13px; font-weight: 700; color: var(--crpe-accent-text); display: flex; align-items: center; gap: 6px; }
.crpe-q-title { font-size: 21px; font-weight: 800; color: var(--crpe-ink); line-height: 1.35; }
.crpe-q-hint { font-size: 14px; color: var(--crpe-muted); }
.crpe-choices { display: flex; flex-direction: column; gap: 10px; list-style: none; padding: 0; margin: 0; }
.crpe-choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: left; background: #fff; border: 2px solid var(--crpe-line); border-radius: 12px; font: 600 16px var(--crpe-font); color: var(--crpe-ink); cursor: pointer; }
.crpe-choice:hover { border-color: #9fbbe0; }
.crpe-choice-key { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; background: #eef2f7; color: var(--crpe-ink-3); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.crpe-choice-mark { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.crpe-choice.is-selected { border-color: var(--crpe-accent-text); background: var(--crpe-accent-soft); }
.crpe-choice.is-selected .crpe-choice-key { background: var(--crpe-accent-text); color: #fff; }
.crpe-choice.is-correct { border-color: var(--crpe-ok); background: var(--crpe-ok-soft); }
.crpe-choice.is-correct .crpe-choice-key { background: var(--crpe-ok); color: #fff; }
.crpe-choice.is-correct .crpe-choice-mark { color: var(--crpe-ok); }
.crpe-choice.is-wrong { border-color: var(--crpe-ko); background: var(--crpe-ko-soft); }
.crpe-choice.is-wrong .crpe-choice-key { background: var(--crpe-ko); color: #fff; }
.crpe-choice.is-wrong .crpe-choice-mark { color: var(--crpe-ko); }
.crpe-choice.is-dim { opacity: .65; }
.crpe-feedback { border-radius: 12px; padding: 16px; font-size: 15.5px; line-height: 1.6; }
.crpe-feedback-ok { background: var(--crpe-ok-soft); }
.crpe-feedback-ko { background: var(--crpe-ko-soft); }
.crpe-feedback-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16.5px; margin-bottom: 6px; }
.crpe-feedback-ok .crpe-feedback-head { color: var(--crpe-ok); }
.crpe-feedback-ko .crpe-feedback-head { color: var(--crpe-ko); }
.crpe-feedback-src { margin-top: 10px; font-size: 13.5px; color: var(--crpe-muted); }
.crpe-quiz-actions { display: flex; gap: 10px; align-items: center; }
.crpe-sticky-bottom { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--crpe-line); padding: 12px 16px; }
.crpe-tf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.crpe-tf .crpe-choice { justify-content: center; min-height: 64px; font-size: 17px; }
.crpe-bucket { border: 2px dashed #b8c4d4; border-radius: 12px; padding: 10px; min-height: 92px; background: var(--crpe-paper); }
.crpe-bucket-title { font-size: 13.5px; font-weight: 800; color: var(--crpe-ink-3); margin-bottom: 8px; }
.crpe-token { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 10px; background: #fff; border: 2px solid var(--crpe-line); font: 600 15px var(--crpe-font); color: var(--crpe-ink); margin: 0 6px 6px 0; cursor: pointer; }
.crpe-token.is-selected { border-color: var(--crpe-accent-text); background: var(--crpe-accent-soft); box-shadow: 0 0 0 3px rgba(29, 95, 168, .18); }
.crpe-token.is-placed { border-style: solid; background: #fff; }
.crpe-pair-col { display: flex; flex-direction: column; gap: 8px; }
.crpe-pair-num { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; background: var(--crpe-ink); color: var(--crpe-accent); font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.crpe-order-item { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px; background: #fff; border: 2px solid var(--crpe-line); border-radius: 12px; font-weight: 600; }
.crpe-order-handle { color: #8796ab; }
.crpe-order-btns { margin-left: auto; display: flex; gap: 4px; }
.crpe-icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--crpe-line); background: #fff; color: var(--crpe-ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.crpe-sentence { font-size: 20px; line-height: 2.3; font-weight: 600; }
.crpe-seg { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; margin: 0 4px 8px 0; }
.crpe-seg-text { padding: 2px 8px; border-bottom: 3px solid var(--crpe-accent-text); }
.crpe-seg-tag { margin-top: 4px; min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--crpe-line); background: #fff; font: 600 13px var(--crpe-font); color: var(--crpe-ink); display: inline-flex; align-items: center; gap: 4px; }
.crpe-seg-tag.is-empty { color: var(--crpe-muted); border-style: dashed; }

/* ---------- Résultat ---------- */
.crpe-score { width: 168px; height: 168px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 168px; }
.crpe-score-in { width: 132px; height: 132px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.crpe-score-val { font-size: 40px; font-weight: 800; color: var(--crpe-ink); line-height: 1; }
.crpe-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.crpe-table th { text-align: left; font-size: 13px; color: var(--crpe-muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--crpe-line); }
.crpe-table td { padding: 12px 10px; border-bottom: 1px solid var(--crpe-line); vertical-align: middle; }


/* ---------- Écran de question : structure ---------- */
.crpe-quiz-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; padding-top: 28px; padding-bottom: 48px; }
.crpe-quiz-main { padding: 32px; border-radius: 20px; }
.crpe-quiz-side { display: flex; flex-direction: column; gap: 16px; padding-top: 120px; }
.crpe-quiz-side .crpe-ad-slot { margin: 0; }
.crpe-quiz-side .crpe-ad-slot .crpe-ad-box { min-height: 600px; }
.crpe-quiz-main .crpe-crumb { color: var(--crpe-muted); }
.crpe-quiz-main .crpe-crumb li + li::before { color: var(--crpe-muted); }
.crpe-quiz-main .crpe-crumb a { color: var(--crpe-accent-text) !important; text-decoration-color: currentColor; }
.crpe-quiz-main h1.crpe-q-title { font-size: 24px; margin: 8px 0 20px; }
.crpe-quiz-form { display: flex; flex-direction: column; gap: 14px; }
.crpe-quiz-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.crpe-quiz-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.crpe-quiz-foot { border-top: 1px solid var(--crpe-line); padding: 12px 16px; background: #fff; }
.crpe-quiz-foot-links { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 24px; }
.crpe-quiz-foot-links a { font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.crpe-q-keys { margin-top: 16px; font-size: 14px; color: var(--crpe-muted); }
.crpe-quiz-main p { color: var(--crpe-text); }
.crpe-feedback p + p { margin-top: 8px; }
.crpe-feedback p { color: var(--crpe-text); }
.crpe-feedback-src { color: var(--crpe-muted); }

@media (max-width: 991.98px) {
    .crpe-quiz-page { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    .crpe-quiz-side { padding-top: 0; }
    .crpe-quiz-side .crpe-ad-slot .crpe-ad-box { min-height: 280px; }
}
@media (max-width: 767.98px) {
    .crpe-quiz-main { padding: 16px; border-radius: 16px; }
    .crpe-quiz-main h1.crpe-q-title, .crpe-q-title { font-size: 19px; }
    /* Bouton principal collé en bas de l'écran, atteignable au pouce */
    .crpe-sticky-bottom { position: sticky; bottom: 0; z-index: 10; margin: 0 -16px -16px; }
    .crpe-sticky-bottom .crpe-btn { width: 100%; }
    .crpe-tf .crpe-choice { min-height: 64px; }
    .crpe-sentence { font-size: 18px; }
}

/* ---------- Réponses : focus, état coché, hors-contraste ---------- */
.crpe-choice:focus-visible, .crpe-token:focus-visible, .crpe-icon-btn:focus-visible, .crpe-seg-tag:focus-visible, .crpe-order-item:focus-visible { outline: 3px solid var(--crpe-accent-text); outline-offset: 2px; }
.crpe-choice[aria-pressed="true"], .crpe-choice[aria-checked="true"] { border-color: var(--crpe-accent-text); background: var(--crpe-accent-soft); }
.crpe-choice[aria-pressed="true"] .crpe-choice-key, .crpe-choice[aria-checked="true"] .crpe-choice-key { background: var(--crpe-accent-text); color: #fff; }
.crpe-choice[disabled] { cursor: default; }
.crpe-choice-text { flex: 1; min-width: 0; }
.crpe-token[disabled] { cursor: default; }
.crpe-token.is-correct { border-color: var(--crpe-ok); background: var(--crpe-ok-soft); }
.crpe-token.is-wrong { border-color: var(--crpe-ko); background: var(--crpe-ko-soft); }
.crpe-bucket.is-correct { border-color: var(--crpe-ok); background: var(--crpe-ok-soft); }
.crpe-bucket.is-wrong { border-color: var(--crpe-ko); background: var(--crpe-ko-soft); }
.crpe-order-item.is-correct { border-color: var(--crpe-ok); background: var(--crpe-ok-soft); }
.crpe-order-item.is-wrong { border-color: var(--crpe-ko); background: var(--crpe-ko-soft); }
.crpe-order-item.is-moving { border-color: var(--crpe-accent-text); box-shadow: 0 0 0 3px rgba(29, 95, 168, .18); }
.crpe-seg-tag.is-correct { border-color: var(--crpe-ok); background: var(--crpe-ok-soft); color: var(--crpe-ok); }
.crpe-seg-tag.is-wrong { border-color: var(--crpe-ko); background: var(--crpe-ko-soft); color: var(--crpe-ko); }
.crpe-pair-col .crpe-token { margin: 0; justify-content: flex-start; }
.crpe-pair-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.crpe-retired { background: var(--crpe-paper); border: 1px dashed #b8c4d4; border-radius: var(--crpe-radius); padding: 16px; color: var(--crpe-muted); }

/* ---------- Résultat : anneau de score, détail par question ---------- */
/* Le pourcentage s'écrit dans la variable --crpe-score (ex. style="--crpe-score: 75%") ; le chiffre reste en toutes lettres à côté. */
.crpe-score { background: conic-gradient(var(--crpe-accent-text) 0 var(--crpe-score, 0%), #e3e8ef 0); }
.crpe-score-lbl { font-size: 13.5px; color: var(--crpe-muted); margin-top: 4px; }
.crpe-qrow { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--crpe-line); font-size: 15px; }
.crpe-qrow:first-child { border-top: 0; }
.crpe-ok, .crpe-ko { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13.5px; font-weight: 800; }
.crpe-ok { color: var(--crpe-ok); }
.crpe-ko { color: var(--crpe-ko); }
.crpe-result-head { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
@media (max-width: 767.98px) { .crpe-result-head { flex-direction: column; align-items: flex-start; gap: 16px; } }

/* ---------- Flashcards (recto, verso, auto-évaluation) ---------- */
.crpe-fc-screen { background: var(--crpe-paper); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.crpe-fc { flex: 1; background: #fff; border: 1px solid var(--crpe-line); border-radius: 20px; box-shadow: 0 12px 28px rgba(15, 30, 54, .08); padding: 24px; display: flex; flex-direction: column; min-height: 320px; }
.crpe-fc-side { font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--crpe-muted); }
.crpe-fc-q { font-size: 21px; font-weight: 800; line-height: 1.35; margin-top: 18px; color: var(--crpe-ink); }
.crpe-fc-a { font-size: 17px; line-height: 1.6; margin-top: 18px; color: var(--crpe-text); }
.crpe-eval { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.crpe-eval button { min-height: 64px; border-radius: 12px; border: 2px solid var(--crpe-line); background: #fff; font: 700 14px var(--crpe-font); color: var(--crpe-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.crpe-eval button:focus-visible { outline: 3px solid var(--crpe-accent-text); outline-offset: 2px; }
.crpe-eval small { font-weight: 500; color: var(--crpe-muted); font-size: 12px; }
@media (min-width: 768px) { .crpe-fc-screen { max-width: 640px; margin: 0 auto; } }

@media (prefers-reduced-motion: reduce) { .crpe-choice, .crpe-token, .crpe-order-item { transition: none; } }
@media print { .crpe-quiz-side, .crpe-quiz-foot, .crpe-eval { display: none !important; } }

/* Réponses du moteur de quiz (vrais boutons radio) : mêmes cibles et mêmes états que .crpe-choice. Lot C3. */
.crpe-qradio { position: relative; }
.crpe-qradio input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.crpe-qradio input[type="radio"]:checked + .crpe-choice { border-color: var(--crpe-accent-text); background: var(--crpe-accent-soft); }
.crpe-qradio input[type="radio"]:checked + .crpe-choice .crpe-choice-key { background: var(--crpe-accent-text); color: #fff; }
.crpe-qradio input[type="radio"]:focus-visible + .crpe-choice { outline: 3px solid var(--crpe-accent-text); outline-offset: 2px; }
.crpe-qradio-choice .crpe-choice:hover { border-color: #9fbbe0; }
.crpe-tf .crpe-qradio { display: block; }
.crpe-tf .crpe-qradio .crpe-choice { justify-content: center; min-height: 64px; font-size: 17px; }
.crpe-q-format { margin: 0 0 12px 0; }
.crpe-sr-only { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Formats à réponse structurée du moteur de quiz (catégoriser, apparier, ordre, analyse) : une ligne = un libellé + une liste native. Lot C3. */
.crpe-rows { display: grid; gap: 10px; }
.crpe-row-select { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border: 2px solid var(--crpe-line); border-radius: 12px; background: #fff; }
.crpe-row-label { font-weight: 700; color: var(--crpe-ink); margin: 0; }
.crpe-select { min-height: 48px; border: 2px solid var(--crpe-line); border-radius: 10px; font-weight: 600; color: var(--crpe-ink); }
.crpe-select:focus { border-color: var(--crpe-accent-text); box-shadow: 0 0 0 3px rgba(29, 95, 168, .25); }
@media (max-width: 575px) { .crpe-row-select { grid-template-columns: 1fr; } }
