/* ==========================================================================
   Mon Examen Civique — expérience quiz (refonte v2)
   Dépend de tokens.css et home-v2.css (chrome de page : header/footer/boutons).
   Le JavaScript de scoring (copié depuis quiz_detail.html) pilote les
   éléments par id et par les classes exactes : .option-btn (+ .selected,
   .disabled, .correct, .wrong), .feedback-panel (+ .success, .error),
   .opt-key. Ces noms sont un contrat avec le script : ne pas les renommer
   sans mettre à jour le <script> en conséquence.
   ========================================================================== */

.qv2-shell {
    max-width: 720px;
    margin-inline: auto;
    padding-block: clamp(1.5rem, 4vw, 3rem) 4rem;
    padding-inline: var(--v2-pad-x);
}

/* Repère de contexte au-dessus de la carte — donne au quiz une "scène"
   propre plutôt qu'une carte isolée sur la page (V3-A, étape 1). */
.qv2-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-inline: 0.25rem;
}

a.qv2-context__back {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    font-size: var(--v2-text-xs);
    font-weight: 700;
    color: var(--v2-ink-2);
    text-decoration: none;
    letter-spacing: 0.02em;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    transition: color var(--v2-duration-fast) var(--v2-ease-out);
}

a.qv2-context__back:hover { color: var(--v2-blue); }

.qv2-context__back svg { transition: transform var(--v2-duration-fast) var(--v2-ease-out); }
a.qv2-context__back:hover svg { transform: translateX(-2px); }

.qv2-context__trail {
    font-size: var(--v2-text-xs);
    color: var(--v2-ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* La carte lit comme une fenêtre d'application réelle : même traitement
   d'ombre teintée que la démo interactive du hero (.v2-demo), pas comme
   une carte parmi d'autres du site. */
.qv2-card {
    background: var(--v2-white);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-lg);
    padding: clamp(1.75rem, 4vw, 2.75rem);
    box-shadow: 0 32px 64px -32px rgba(var(--v2-blue-rgb), 0.28), var(--v2-shadow-lift);
}

.qv2-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.qv2-meta__cat {
    display: block;
    font-size: var(--v2-text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--v2-blue);
    margin-bottom: 0.375rem;
}

.qv2-meta__level {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.qv2-meta__title {
    font-family: var(--v2-font-title);
    font-size: var(--v2-text-lg);
    font-weight: 700;
    color: var(--v2-ink);
}

.qv2-meta__badge {
    font-size: var(--v2-text-xs);
    font-weight: 600;
    color: var(--v2-ink-3);
    padding: 0.1875rem 0.5625rem;
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-pill);
    white-space: nowrap;
}

.qv2-timer {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--v2-text-sm);
    font-weight: 600;
    color: var(--v2-ink-2);
    font-variant-numeric: tabular-nums;
    flex: none;
    padding-top: 0.125rem;
}

.qv2-progress {
    margin-bottom: 2rem;
}

.qv2-progress__label {
    display: block;
    font-size: var(--v2-text-xs);
    font-weight: 600;
    color: var(--v2-ink-2);
    margin-bottom: 0.625rem;
}

/* Rail plus affirmé : progression visiblement plus présente qu'une
   fine barre discrète (audit v2, critère 05). */
.qv2-progress__rail {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: var(--v2-rail);
    overflow: visible;
}

.qv2-progress__fill {
    display: block;
    position: relative;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: var(--v2-blue);
    overflow: visible;
    transition: width var(--v2-duration-slow) var(--v2-ease-out);
}

/* Marqueur à l'extrémité de la progression : pur CSS, suit toujours la
   largeur réelle définie par le script puisqu'il est positionné par
   rapport au bord droit de .qv2-progress__fill lui-même. */
.qv2-progress__fill::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--v2-white);
    border: 2.5px solid var(--v2-blue);
    transform: translate(50%, -50%);
    box-shadow: 0 1px 4px rgba(15, 61, 99, 0.25);
}

.qv2-question {
    margin: 0 0 1.75rem;
    font-family: var(--v2-font-title);
    font-weight: 700;
    font-size: clamp(1.3125rem, 1.1rem + 1vw, var(--v2-text-2xl));
    line-height: 1.35;
    color: var(--v2-ink);
    min-height: 2.4em;
}

.qv2-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Boutons de réponse — noms de classes fixés par le script (voir en-tête).
   Chaque bouton est recréé par le script à chaque question (innerHTML vidé
   puis reconstruit) : l'animation d'entrée ci-dessous rejoue donc naturellement
   à chaque changement de question, sans aucune modification du JS. */
.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-height: 3.25rem;
    padding: 1.0625rem 1.25rem;
    background: var(--v2-white);
    border: 1.5px solid var(--v2-border);
    border-radius: var(--v2-radius-sm);
    font: inherit;
    font-size: var(--v2-text-base);
    text-align: left;
    color: var(--v2-ink-2);
    cursor: pointer;
    transition: border-color var(--v2-duration-base) var(--v2-ease-out),
                background var(--v2-duration-base) var(--v2-ease-out),
                opacity var(--v2-duration-base) var(--v2-ease-out),
                transform var(--v2-duration-fast) var(--v2-ease-out),
                box-shadow var(--v2-duration-fast) var(--v2-ease-out);
    animation: qv2-option-in var(--v2-duration-base) var(--v2-ease-out) both;
}

.qv2-options .option-btn:nth-child(1) { animation-delay: 0ms; }
.qv2-options .option-btn:nth-child(2) { animation-delay: 40ms; }
.qv2-options .option-btn:nth-child(3) { animation-delay: 80ms; }
.qv2-options .option-btn:nth-child(4) { animation-delay: 120ms; }

@keyframes qv2-option-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.option-btn:hover:not(.disabled) {
    border-color: var(--v2-blue);
    background: var(--v2-blue-tint);
    color: var(--v2-ink);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 61, 99, 0.08);
}

.option-btn:active:not(.disabled) {
    transform: scale(0.99);
}

.option-btn.selected:not(.correct):not(.wrong) {
    border-color: var(--v2-blue);
    background: var(--v2-blue-tint);
    color: var(--v2-ink);
    animation: qv2-option-in var(--v2-duration-base) var(--v2-ease-out) both,
               qv2-select-pulse 260ms var(--v2-ease-out);
}

@keyframes qv2-select-pulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.975); }
    100% { transform: scale(1); }
}

.option-btn.disabled:not(.correct):not(.wrong) {
    opacity: 0.55;
}

.option-btn.correct {
    border-color: var(--v2-success);
    background: var(--v2-success-tint);
    color: var(--v2-ink);
    font-weight: 600;
    opacity: 1;
}

.option-btn.wrong {
    border-color: var(--v2-red);
    background: var(--v2-red-tint);
    color: var(--v2-ink);
    opacity: 1;
}

.opt-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--v2-blue-tint-2);
    color: var(--v2-blue);
    font-size: var(--v2-text-xs);
    font-weight: 700;
    transition: background var(--v2-duration-base) var(--v2-ease-out),
                color var(--v2-duration-base) var(--v2-ease-out);
}

.option-btn.correct .opt-key {
    background: var(--v2-success);
    color: #fff;
}

.option-btn.wrong .opt-key {
    background: var(--v2-red);
    color: #fff;
}

/* Panneau de correction — noms de classes fixés par le script */
.feedback-panel {
    display: none;
    margin-top: 1.25rem;
    padding: 1.125rem 1.25rem;
    border-radius: var(--v2-radius-sm);
    border: 1px solid transparent;
    animation: qv2-feedback-in var(--v2-duration-slow) var(--v2-ease-out) both;
}

@keyframes qv2-feedback-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.feedback-panel.success {
    background: var(--v2-success-tint);
    border-color: rgba(31, 122, 77, 0.25);
}

.feedback-panel.error {
    background: var(--v2-red-tint);
    border-color: rgba(163, 42, 46, 0.2);
}

.fb-header,
#fbHeader {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: var(--v2-text-base);
    margin-bottom: 0.5rem;
}

.feedback-panel.success #fbHeader { color: var(--v2-success); }
.feedback-panel.error #fbHeader { color: var(--v2-red); }

/* Badge circulaire plutôt qu'un simple glyphe : plus de poids visuel sur
   le moment de feedback, qui doit se sentir comme une étape à part entière
   de la progression, pas une simple mention en passant. */
.fb-icon,
#fbIcon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.feedback-panel.success #fbIcon {
    background: var(--v2-success);
    color: #fff;
    animation: qv2-icon-pop 420ms var(--v2-ease-out) both;
}

.feedback-panel.error #fbIcon {
    background: var(--v2-red);
    color: #fff;
}

/* Réponse correcte : petit élan de récompense.
   Réponse incorrecte : reste calme (simple fondu du panneau), pour que
   l'erreur se lise comme une information, pas une sanction. */
@keyframes qv2-icon-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    65%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.fb-content,
#fbContent {
    margin: 0;
    font-size: var(--v2-text-sm);
    color: var(--v2-ink-2);
    line-height: 1.55;
}

.qv2-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.75rem;
}

.qv2-footer .v2-btn--primary {
    min-width: 12rem;
}

/* Retour visuel pendant le verrou anti-double-clic de "Question suivante"
   (voir isAdvancing dans quiz_detail_v2.html) : le bouton reste en place,
   sans saut de layout, mais signale clairement qu'il est temporairement
   inactif. */
#nextBtn:disabled {
    opacity: 0.6;
    cursor: default;
}

#nextBtn {
    display: none;
}

/* Toast de progression (série de bonnes réponses, jalons...) */
.qv2-toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    max-width: 22rem;
    padding: 0.875rem 1.25rem;
    background: var(--v2-white);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius);
    box-shadow: var(--v2-shadow-lift);
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    transition: transform var(--v2-duration-slow) var(--v2-ease-out),
                opacity var(--v2-duration-slow) var(--v2-ease-out);
    pointer-events: none;
}

.qv2-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.qv2-toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--v2-blue-tint);
    color: var(--v2-blue);
}

.qv2-toast.encourage .qv2-toast__icon {
    background: var(--v2-red-tint);
    color: var(--v2-red);
}

.qv2-toast__title {
    display: block;
    font-size: var(--v2-text-sm);
    font-weight: 700;
    color: var(--v2-ink);
}

.qv2-toast__message {
    display: block;
    font-size: var(--v2-text-xs);
    color: var(--v2-ink-3);
}

@media (max-width: 480px) {
    .qv2-context { margin-bottom: 0.75rem; }
    .qv2-context__trail { display: none; }
    .qv2-card { padding: 1.25rem; box-shadow: var(--v2-shadow-lift); }
    .qv2-toast { left: 1rem; right: 1rem; max-width: none; }
    .option-btn { padding: 1rem 1.125rem; }
}

/* Toute la micro-motion ajoutée dans cette passe (entrée des options,
   pulse de sélection, pop de l'icône de feedback, marqueur de progression)
   respecte prefers-reduced-motion : on coupe l'animation, jamais l'état
   final (les éléments restent visibles/à leur place). */
@media (prefers-reduced-motion: reduce) {
    .option-btn,
    .option-btn.selected:not(.correct):not(.wrong),
    .feedback-panel.success #fbIcon,
    .feedback-panel {
        animation: none !important;
    }

    .option-btn:hover:not(.disabled) {
        transform: none;
    }

    .qv2-progress__fill {
        transition: none;
    }
}
