/* ALTCHA — PQC verification panel */
altcha-widget {
    display: block;
    width: 100%;
    max-width: 260px;

    --altcha-color-base: #1b1f2b;
    --altcha-color-text: #fff;
    --altcha-color-border: #434957;
    --altcha-color-border-focus: #fff;
    --altcha-color-active: #00602a;
    --altcha-color-error-text: #ffb4aa;
    --altcha-border-radius: 4px;
    --altcha-max-width: 100%;
}

.altcha {
    background: var(--altcha-color-base, transparent);
    border: var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);
    border-radius: var(--altcha-border-radius, 3px);
    color: var(--altcha-color-text, currentColor);
    display: flex;
    flex-direction: column;
    max-width: var(--altcha-max-width, 260px);
    position: relative;
    font-family: inherit;
    box-shadow: 0 6px 18px #1b1f2b14;
}

.altcha:focus-within {
    border-color: var(--altcha-color-border-focus, currentColor);
}

.altcha[data-floating] {
    background: var(--altcha-color-base, white);
    display: none;
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, .2));
    left: -100%;
    position: fixed;
    top: -100%;
    width: var(--altcha-max-width, 260px);
    z-index: 999999;
}

.altcha[data-floating="top"] .altcha-anchor-arrow {
    border-bottom-color: transparent;
    border-top-color: var(--altcha-color-border, #a0a0a0);
    bottom: -12px;
    top: auto;
}

.altcha[data-floating="bottom"]:focus-within::after {
    border-bottom-color: var(--altcha-color-border-focus, currentColor);
}

.altcha[data-floating="top"]:focus-within::after {
    border-top-color: var(--altcha-color-border-focus, currentColor);
}

.altcha[data-floating]:not([data-state="unverified"]) {
    display: block;
}

.altcha-anchor-arrow {
    border: 6px solid transparent;
    border-bottom-color: var(--altcha-color-border, #a0a0a0);
    content: "";
    height: 0;
    left: 12px;
    position: absolute;
    top: -12px;
    width: 0;
}

.altcha-main {
    align-items: center;
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    position: relative;
}

.altcha-code-challenge {
    background: var(--altcha-color-base, white);
    border: 1px solid var(--altcha-color-border-focus, currentColor);
    border-radius: var(--altcha-border-radius, 3px);
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, .2));
    padding: .5rem;
    position: absolute;
    top: 2.5rem;
    z-index: 9999999;
}

.altcha-code-challenge > form {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.altcha-code-challenge-input {
    border: 1px solid currentColor;
    border-radius: 3px;
    box-sizing: border-box;
    outline: none;
    font-size: 16px;
    padding: .35rem;
    width: 220px;
}

.altcha-code-challenge-input:focus {
    outline: 2px solid color-mix(
        in srgb,
        var(--altcha-color-active, #1d1dc9) 20%,
        transparent
    );
}

.altcha-code-challenge-input:disabled {
    opacity: .7;
}

.altcha-code-challenge-image {
    background-color: #fff;
    border: 1px solid currentColor;
    border-radius: 3px;
    box-sizing: border-box;
    object-fit: contain;
    height: 50px;
    width: 220px;
}

.altcha-code-challenge-audio,
.altcha-code-challenge-reload {
    background: color-mix(
        in srgb,
        var(--altcha-color-text, currentColor) 10%,
        transparent
    );
    border: 0;
    border-radius: 3px;
    color: var(--altcha-color-text, currentColor);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .35rem;
}

.altcha-code-challenge-audio:disabled,
.altcha-code-challenge-reload:disabled {
    opacity: .7;
    pointer-events: none;
}

.altcha-code-challenge-audio > *,
.altcha-code-challenge-reload > * {
    height: 20px;
    width: 20px;
}

.altcha-code-challenge-buttons {
    display: flex;
    justify-content: space-between;
}

.altcha-code-challenge-buttons-left {
    display: flex;
    gap: .25rem;
}

.altcha-code-challenge-verify {
    align-items: center;
    background: var(--altcha-color-active, #1d1dc9);
    border: 0;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    display: flex;
    gap: .5rem;
    font-size: 100%;
    padding: .35rem 1rem;
}

.altcha-code-challenge-verify:disabled {
    opacity: .7;
    pointer-events: none;
}

.altcha-code-challenge-arrow {
    border: 6px solid transparent;
    border-bottom-color: var(--altcha-color-border, currentColor);
    content: "";
    height: 0;
    left: .15rem;
    position: absolute;
    top: -12px;
    width: 0;
}

.altcha[data-floating="top"] .altcha-code-challenge {
    top: -150px;
}

.altcha[data-floating="top"] .altcha-code-challenge-arrow {
    border-bottom-color: transparent;
    border-top-color: var(--altcha-color-border, currentColor);
    bottom: -12px;
    top: auto;
}

.altcha-label {
    cursor: pointer;
    flex-grow: 1;
    margin: 0;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.5;
}

.altcha-logo {
    color: currentColor !important;
    opacity: .7;
}

.altcha-logo:hover {
    opacity: 1;
}

.altcha-error {
    color: var(--altcha-color-error-text, #f23939);
    display: flex;
    font-size: .85rem;
    gap: .3rem;
    padding: 0 .7rem .7rem;
    line-height: 1.5;
}

.altcha-footer {
    align-items: center;
    background-color: var(--altcha-color-footer-bg, transparent);
    display: flex;
    font-size: .75rem;
    opacity: .7;
    justify-content: end;
    padding: .2rem .7rem;
}

.altcha-footer:hover {
    opacity: 1;
}

.altcha-footer a {
    color: currentColor;
}

/* Toggle */
.altcha-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 28px;
    position: relative;
}

.altcha-checkbox input {
    appearance: none;
    box-sizing: border-box;
    position: relative;
    width: 48px;
    height: 28px;
    margin: 0;
    border: 1px solid #aab1bf;
    border-radius: 999px;
    background: #343b4b;
    cursor: pointer;
}

.altcha-checkbox input::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform .18s ease;
}

.altcha-checkbox input:checked {
    background: #00602a;
    border-color: #a7d9b4;
}

.altcha-checkbox input:checked::before {
    transform: translateX(20px);
}

.altcha-checkbox input:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
}

/* Loading */
.altcha-checkbox .altcha-spinner {
    position: absolute;
    width: 24px;
    height: 24px;
    inset: 2px auto auto 12px;
}

.altcha-checkbox-verifying input {
    appearance: none;
    opacity: 0;
    pointer-events: none;
}

.altcha-spinner {
    animation: altcha-spinner .75s infinite linear;
    transform-origin: center;
}


.altcha[data-state="verified"] .altcha-label {
    color: #fff;
}

/* Overlay */
.altcha-overlay {
    --altcha-color-base: #fff;
    --altcha-color-text: #000;
    animation: overlay-slidein .5s forwards;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    left: 50%;
    width: 260px;
    opacity: 0;
    position: fixed;
    top: 45%;
    transform: translate(-50%, -50%);
}

.altcha-overlay-backdrop {
    background: #00000080;
    display: none;
    inset: 0;
    position: fixed;
    z-index: 99999999;
}

.altcha-overlay-close-button {
    align-self: flex-end;
    background: none;
    border: none;
    padding: .25rem;
    cursor: pointer;
    color: currentColor;
    font-size: 130%;
    line-height: 1;
    opacity: .7;
}

@media (max-height: 450px) {
    .altcha-overlay {
        top: 10% !important;
        transform: translate(-50%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .altcha-checkbox input::before {
        transition: none;
    }
}

@media (forced-colors: active) {
    .altcha-checkbox input {
        appearance: auto;
    }

    .altcha-checkbox input::before {
        display: none;
    }
}

@keyframes overlay-slidein {
    to {
        opacity: 1;
        top: 50%;
    }
}

@keyframes altcha-spinner {
    to {
        transform: rotate(360deg);
    }
}