/* Case « Je ne suis pas un robot ».
 *
 * Toutes les proprietes visibles sont FORCEES (couleur, taille, graisse) :
 * le bloc est injecte au milieu du formulaire du theme, qui colore ses
 * labels — sans cela le libelle heritait d'un orange incoherent.
 *
 * La case native est conservee dans le DOM (accessibilite, navigation
 * clavier, lecteurs d'ecran) mais rendue invisible ; c'est .ov-cas-mark qui
 * est dessine, et le focus clavier reste visible dessus.
 */

.ov-cas-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    max-width: 340px;
    /* marge basse genereuse : le bloc ne doit jamais toucher le bouton */
    margin: 8px 0 28px;
    padding: 14px 16px;
    border: 1px solid #e2e5ea;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color .25s ease, box-shadow .25s ease;
}

.ov-cas-box.is-checked {
    border-color: #a7e3bd;
    box-shadow: 0 1px 3px rgba(34, 160, 82, .12);
}

/* Envoi tente sans avoir coche : on le signale franchement, une seule fois. */
.ov-cas-box.has-error {
    border-color: #d92d20;
    background: #fffbfa;
    animation: ov-cas-shake .32s ease-in-out;
}

.ov-cas-box.has-error .ov-cas-mark {
    border-color: #d92d20;
}

@keyframes ov-cas-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

.ov-cas-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    user-select: none;
}

/* Case native : presente pour les technologies d'assistance, invisible a l'oeil. */
.ov-cas-cb {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.ov-cas-mark {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    box-sizing: border-box;
    border: 2px solid #cfd4dc;
    border-radius: 7px;
    background: #fff;
    transition: background-color .2s ease, border-color .2s ease;
}

.ov-cas-label:hover .ov-cas-mark {
    border-color: #9aa3b2;
}

/* Anneau de focus clavier reporte sur la case dessinee. */
.ov-cas-cb:focus-visible + .ov-cas-mark {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.ov-cas-mark svg {
    width: 16px;
    height: 16px;
    display: block;
}

.ov-cas-mark svg path {
    fill: none;
    stroke: #fff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* la coche est « effacee » au repos puis tracee a la validation */
    stroke-dasharray: 26;
    stroke-dashoffset: 26;
}

/* --- etat validé --- */
.ov-cas-cb:checked + .ov-cas-mark {
    background: #22a052;
    border-color: #22a052;
    animation: ov-cas-pop .32s cubic-bezier(.34, 1.56, .64, 1);
}

.ov-cas-cb:checked + .ov-cas-mark svg path {
    animation: ov-cas-draw .3s .06s ease-out forwards;
}

@keyframes ov-cas-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes ov-cas-draw {
    to { stroke-dashoffset: 0; }
}

.ov-cas-text {
    font-size: 15px;
    line-height: 1.25;
    font-weight: 400;
    /* forcé : le theme colore les labels de formulaire */
    color: #344054;
}

/* --- statut a droite --- */
.ov-cas-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
    color: #667085;
}

.ov-cas-state.ok {
    color: #22a052;
    animation: ov-cas-fade .3s ease-out;
}

.ov-cas-state.error {
    color: #d92d20;
    font-weight: 500;
}

@keyframes ov-cas-fade {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Petit rond tournant pendant le calcul (cas rare : clic tres precoce). */
.ov-cas-state.pending::before {
    content: '';
    width: 13px;
    height: 13px;
    border: 2px solid #d0d5dd;
    border-top-color: #667085;
    border-radius: 50%;
    animation: ov-cas-spin .7s linear infinite;
}

@keyframes ov-cas-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .ov-cas-box {
        max-width: 100%;
        padding: 13px 14px;
    }

    .ov-cas-text {
        font-size: 14px;
    }
}

/* Respect du reglage systeme « animations reduites ». */
@media (prefers-reduced-motion: reduce) {
    .ov-cas-cb:checked + .ov-cas-mark,
    .ov-cas-cb:checked + .ov-cas-mark svg path,
    .ov-cas-state.ok,
    .ov-cas-state.pending::before {
        animation: none;
    }

    .ov-cas-cb:checked + .ov-cas-mark svg path {
        stroke-dashoffset: 0;
    }
}
