/*
 * Password requirements checker (js/password_requirements.js).
 *
 * Instances can be branded through custom properties, set anywhere above the checker:
 *   --password-requirements-success       color of a met requirement
 *   --password-requirements-success-text  color of the check mark on it
 * By default the success color follows --color-success when defined, and the text colors
 * follow the surrounding text, so the checker fits light and dark backgrounds.
 */

.password-requirements {
    --_success: var(--password-requirements-success, var(--color-success, #09a162));
    --_success-text: var(--password-requirements-success-text, #fff);

    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows 0.3s ease, visibility 0s linear 0.3s;
}

.password-requirements--open {
    grid-template-rows: 1fr;
    visibility: visible;
    transition: grid-template-rows 0.3s ease, visibility 0s;
}

.password-requirements__inner {
    min-height: 0;
    overflow: hidden;
}

.password-requirements__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.25rem 0.75rem;
    max-width: 30rem;
    margin: 0;
    padding: 0.5rem 0.25rem;
    list-style: none;
    font-size: 0.875rem;
    line-height: 1.3;
}

.password-requirements--centered .password-requirements__list {
    margin-inline: auto;
}

.password-requirements__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.password-requirements__item--met {
    opacity: 1;
}

/* Text for assistive technologies only. */
.password-requirements__state {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.password-requirements .check-mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    box-sizing: border-box;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid currentcolor;
    border-radius: 50%;
    transition: background-color 0.15s, border-color 0.15s;
}

.password-requirements .check-mark::before {
    content: "";
    width: 0.625rem;
    height: 0.625rem;
    background-color: transparent;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.25l2.25 2.25 4.75-4.75' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.password-requirements .check-mark--checked {
    border-color: var(--_success);
    background-color: var(--_success);
}

.password-requirements .check-mark--checked::before {
    background-color: var(--_success-text);
}

@media (prefers-reduced-motion: no-preference) {
    .password-requirements .check-mark--checked {
        animation: password-requirements-check 0.45s ease-out;
    }
}

@media (prefers-reduced-motion: reduce) {
    .password-requirements,
    .password-requirements--open,
    .password-requirements__item,
    .password-requirements .check-mark {
        transition: none;
    }
}

@keyframes password-requirements-check {
    0% { opacity: 0; transform: scale(0.6); }
    30% { opacity: 1; transform: scale(1.15) rotate(-14deg); }
    50% { transform: scale(1) rotate(10deg); }
    70% { transform: rotate(-6deg); }
    85% { transform: rotate(3deg); }
    100% { transform: rotate(0); }
}
