/* IconCaptcha, dressed as one of our form rows.

   The library ships a single hard-coded look — 330px wide box, blue accent, uppercase
   titles, 8px radius — that reads as a foreign widget dropped into the registration
   forms. It exposes no custom properties, so the only way to reskin it is to re-declare
   its own selectors. That works because app.js imports this file after the library
   stylesheet: the rules below have the same specificity and win on order alone. Keep
   that import order.

   Only the frame and the palette are ours. The icons themselves come from a PNG the
   server renders, and the geometry of the challenge strip (the 320px icons/selection
   area) is load-bearing: the click coordinates are mapped back to an icon using the
   element width, so resizing it would break the selection. */

.iconcaptcha-row {
    /* The bundle renders its own row block, so the form theme's .mb-3 never reaches it. */
    margin-bottom: 1rem;
}

.iconcaptcha-widget {
    /* The orange of the submit button and the site's links. Every accented pixel in the
       widget — the pulsing circle, the loader, the selection dot — comes from here. */
    --captcha-accent: #e55b25;
    --captcha-accent-dim: #c94c1e;

    /* The library caps the widget at 330px. The rest of the form is full width, and the
       captcha is just another row in it. */
    width: 100%;
    max-width: 100%;
    border-radius: var(--bs-border-radius);
}

.iconcaptcha-widget.iconcaptcha-theme-light {
    /* Matches .form-control: white field on a hairline border, not the library's grey. */
    background: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
}

.iconcaptcha-widget.iconcaptcha-theme-light.iconcaptcha-init:hover {
    background: var(--bs-tertiary-bg);
}

/* ===== Idle state ("Overte, že nie ste robot.") ===== */

.iconcaptcha-widget.iconcaptcha-init .iconcaptcha-modal__body-circle {
    border-width: 5px;
    border-color: var(--captcha-accent);
}

/* Same name as the library's, redeclared so the animation stops repainting the circle
   blue on every keyframe. */
@keyframes captcha-breathing {
    0%,
    100% {
        transform: scale(1) translateZ(0);
        border-color: var(--captcha-accent);
    }
    25% {
        transform: scale(0.8) translateZ(0);
        border-color: var(--captcha-accent-dim);
    }
    50% {
        transform: scale(1) translateZ(0);
        border-color: var(--captcha-accent);
    }
    75% {
        transform: scale(0.8) translateZ(0);
        border-color: var(--captcha-accent-dim);
    }
}

.iconcaptcha-widget.iconcaptcha-init .iconcaptcha-modal__body-title,
.iconcaptcha-widget.iconcaptcha-success .iconcaptcha-modal__body-title {
    font-size: 15px;
    font-weight: 500;
    /* The library shouts these in uppercase; the labels above it do not. */
    text-transform: none;
}

.iconcaptcha-widget.iconcaptcha-theme-light.iconcaptcha-init .iconcaptcha-modal__body-title {
    color: var(--bs-body-color);
}

/* ===== Challenge state ===== */

/* The instruction bar above the icons. */
.iconcaptcha-widget .iconcaptcha-modal__header span {
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__header {
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__header span {
    color: var(--bs-body-color);
}

/* The library emphasises the important word ("najmenej") with a <u>. */
.iconcaptcha-widget .iconcaptcha-modal__header span u {
    color: var(--captcha-accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.iconcaptcha-widget .iconcaptcha-modal__body-selection > i {
    background: var(--captcha-accent);
}

.iconcaptcha-widget .iconcaptcha-modal__body .captcha-loader {
    border-width: 5px;
    border-color: var(--captcha-accent);
}

/* ===== Result states ===== */

/* Wrong icon / too many attempts: a headline and one line of explanation. */
.iconcaptcha-widget .iconcaptcha-modal__body-title {
    top: 10px;
    font-size: 16px;
    font-weight: 600;
    text-transform: none;
}

.iconcaptcha-widget .iconcaptcha-modal__body-subtitle {
    top: 33px;
    font-size: 12px;
}

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__body-subtitle {
    color: var(--bs-secondary-color);
}

/* The same red the invalid-feedback text under the field is drawn in. */
.iconcaptcha-widget.iconcaptcha-theme-light.iconcaptcha-error .iconcaptcha-modal__body-title {
    color: var(--bs-danger);
}

.iconcaptcha-widget.iconcaptcha-theme-light.iconcaptcha-success .iconcaptcha-modal__body-title {
    color: var(--bs-success);
}

.iconcaptcha-widget.iconcaptcha-theme-light.iconcaptcha-success .iconcaptcha-modal__body-checkmark svg {
    stroke: var(--bs-success);
}

/* An unsolved captcha fails validation like any other field, and the form theme marks
   the fields it can reach with .is-invalid. The widget is not an input, so the red
   border has to be inferred from the error message the row renders next to it. */
.iconcaptcha-row:has(.invalid-feedback) .iconcaptcha-widget.iconcaptcha-theme-light {
    border-color: var(--bs-form-invalid-border-color);
}

/* ===== Attribution footer ===== */

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__footer {
    padding-top: 5px;
    padding-bottom: 5px;
    border-top: var(--bs-border-width) solid var(--bs-border-color);
}

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__footer > span a,
.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__body-info a {
    /* The library prints the credit link in bold uppercase blue, which ends up louder
       than the instruction it sits under. Attribution stays, the shouting does not. */
    color: #adb5bd;
    font-weight: 500;
    text-transform: none;
}

.iconcaptcha-widget.iconcaptcha-theme-light .iconcaptcha-modal__footer > span a:hover {
    color: var(--captcha-accent);
}
