/* Form controls, shared by the contact, sign-in and backroom forms */
.field {
    display: grid;
    align-content: start;
    gap: 8px;

    > label {
        font-weight: 700;
        font-size: calc(15rem / 16);
        color: var(--navy);

        span {
            font-weight: 400;
            color: var(--ink-soft);
        }
    }

    .help-text {
        font-size: calc(15rem / 16);
        color: var(--ink-soft);
    }

    /* Validation messages from Symfony forms */
    ul {
        list-style: none;
        padding: 0;
        font-weight: 700;
        font-size: calc(15rem / 16);
        color: var(--red);
    }
}

/* :where() leaves components free to adjust a control */
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"]), select, textarea) {
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    border: 1.5px solid var(--steel);
    border-radius: 8px;
    background-color: #ffffff;
    color: var(--ink);
    font: inherit;
    font-size: calc(17rem / 16);
    transition: border-color 160ms ease-out;

    &:hover {
        border-color: var(--steel-dark);
    }

    &:focus-visible {
        border-color: var(--navy);
        outline-offset: 1px;
    }

    &:disabled {
        background-color: var(--ground);
        color: var(--ink-soft);
    }
}

:where(select) {
    appearance: none;
    padding-right: 40px;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2314263f' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center / 12px;
}

:where(textarea) {
    resize: vertical;
}

:where(input[type="checkbox"]) {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    accent-color: var(--navy);
}

/* A checkbox beside its label, with any hint under the label */
.check {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;

    small,
    .help-text {
        display: block;
        font-weight: 400;
        font-size: calc(15rem / 16);
        color: var(--ink-soft);
    }
}

/* An on/off setting: a checkbox with role="switch", or a .switch inside a link that flips it */
input[role="switch"],
.switch {
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 28px;
    margin: 0;
    border-radius: 999px;
    background-color: var(--steel);
    cursor: pointer;
    transition: background-color 160ms ease-out;

    &::before {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background-color: #ffffff;
        box-shadow: 0 1px 3px rgba(13, 27, 47, 0.35);
        transition: translate 160ms var(--ease-out);
    }
}

input[role="switch"]:checked,
[aria-checked="true"] > .switch {
    background-color: var(--green);

    &::before {
        translate: 18px 0;
    }
}

.switch-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;

    b {
        display: block;
    }

    small {
        font-size: calc(15rem / 16);
        color: var(--ink-soft);
    }

    &:hover .switch {
        background-color: var(--steel-dark);
    }

    &[aria-checked="true"]:hover .switch {
        background-color: #15542a;
    }
}

/* A message at the top of a form or page */
.alert {
    padding: 16px 16px;
    border-radius: 8px;
    font-weight: 700;

    &.is-success {
        background: var(--green-tint);
        color: var(--green);
    }

    &.is-error {
        background: var(--red-tint);
        color: var(--red);
    }
}

/* A flash message spans the page under the header */
.flash {
    border-radius: 0;
    text-align: center;
}

/* A password input with a show/hide button inside its right edge */
.password-input {
    position: relative;

    input {
        padding-right: 52px;
    }

    /* Edge adds its own reveal button; ours replaces it */
    input::-ms-reveal {
        display: none;
    }
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 50px;
    height: 100%;
    border: 0;
    border-radius: 0 8px 8px 0;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    transition: color 160ms ease-out;

    &:hover {
        color: var(--navy);
    }

    .icon {
        width: 20px;
        height: 20px;
    }

    &[aria-pressed="true"] .is-show,
    &[aria-pressed="false"] .is-hide {
        display: none;
    }
}
