/**
 * MYCAPTCHA — habillage du bloc anti-spam.
 * Conçu pour se poser dans n'importe quel thème : aucune couleur du thème
 * n'est écrasée, tout part de --mycaptcha-accent posé sur le bloc.
 *
 * @author Spline Online
 */

.mycaptcha-block {
    --mycaptcha-accent: #ff4fa3;
    --mycaptcha-tile-bg: #ffffff;
    --mycaptcha-tile-border: #d8dce2;
    margin: 1rem 0;
    padding: 0;
    text-align: left;
}

.mycaptcha-title {
    margin: 0 0 .5rem;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
}

.mycaptcha-grid {
    display: grid;
    gap: 8px;
    max-width: 340px;
    margin: 0;
    padding: 0;
}

.mycaptcha-grid--9 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 264px;
}

.mycaptcha-grid--8 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 344px;
}

.mycaptcha-tile {
    position: relative;
    display: block;
    width: 100%;
    min-width: 48px;
    min-height: 48px;
    aspect-ratio: 1 / 1;
    margin: 0;
    padding: 6px;
    background: var(--mycaptcha-tile-bg);
    border: 1px solid var(--mycaptcha-tile-border);
    border-radius: 10px;
    box-shadow: none;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}

/* Repli pour les navigateurs sans aspect-ratio. */
@supports not (aspect-ratio: 1 / 1) {
    .mycaptcha-tile {
        height: 72px;
    }
}

.mycaptcha-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.mycaptcha-tile:hover {
    border-color: var(--mycaptcha-accent);
}

.mycaptcha-tile:focus-visible {
    outline: 2px solid var(--mycaptcha-accent);
    outline-offset: 2px;
}

.mycaptcha-tile:active {
    transform: scale(.96);
}

.mycaptcha-tile.is-picked {
    border-color: var(--mycaptcha-accent);
    box-shadow: 0 0 0 2px var(--mycaptcha-accent) inset;
}

.mycaptcha-tile.is-picked::after {
    content: "";
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--mycaptcha-accent) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
}

.mycaptcha-message {
    margin: .5rem 0 0;
    font-size: .875rem;
    line-height: 1.35;
    opacity: .8;
}

.mycaptcha-block--error .mycaptcha-message,
.mycaptcha-block.is-invalid .mycaptcha-message {
    color: #c0392b;
    font-weight: 600;
    opacity: 1;
}

.mycaptcha-block--error .mycaptcha-tile,
.mycaptcha-block.is-invalid .mycaptcha-tile {
    border-color: #e6b0aa;
}

/* Champ piège : hors écran, jamais visible ni tabulable. */
.mycaptcha-trap {
    position: absolute !important;
    left: -9999px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

@media (max-width: 480px) {
    .mycaptcha-grid {
        gap: 6px;
    }

    .mycaptcha-grid--9 {
        max-width: 300px;
    }

    .mycaptcha-grid--8 {
        max-width: 340px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mycaptcha-tile {
        transition: none;
    }

    .mycaptcha-tile:active {
        transform: none;
    }
}
