.form--centered {
    text-align: center;
}

.form--danger {
    margin-top: var(--space-larger);
    padding: var(--space-medium);

    text-align: right;

    background-color: var(--color-red-1);
}

label {
    display: block;
    margin-bottom: var(--space-small);
    padding-right: var(--space-small);
    padding-left: var(--space-small);
}

.label--checkbox,
.label--radio {
    margin-bottom: 0;
}

.label__help {
    color: var(--color-text-secondary);
    font-size: var(--size-small);
}

input,
textarea {
    width: 100%;
    padding: var(--space-small);

    color: inherit;
    font-family: inherit;
    font-size: var(--size-normal);
    line-height: 1.5;

    background-color: var(--color-white);
    box-shadow: 2px 2px 4px var(--color-grey-2) inset;
    border: var(--width-border) solid var(--color-border);
    border-radius: var(--radius);

    transition: border-color 0.2s ease-in-out;
}

textarea {
    max-width: 100%;
    min-height: 15rem;
}

.input--number-3 {
    width: 8rem;
}

/**
 * Custom checkboxes to improve contrast and size
 *
 * @see https://www.a11ywithlindsey.com/blog/create-custom-keyboard-accesible-checkboxes
 */
input[type="checkbox"],
input[type="radio"] {
    position: absolute;

    overflow: hidden;
    clip-path: rect(0 0 0 0);

    width: 1px;
    height: 1px;
}

input[type="checkbox"] + label,
input[type="radio"] + label {
    position: relative;

    display: inline-flex;

    align-items: baseline;

    border-radius: var(--border-radius-small);
}

input[type="checkbox"]:focus + label,
input[type="radio"]:focus + label {
    outline: var(--outline-width) solid var(--outline-color);
    outline-offset: var(--outline-offset);
}

input[type="checkbox"] + label::before,
input[type="radio"] + label::before {
    content: '';

    position: relative;
    top: 0.5rem;

    width: 2.5rem;
    height: 2.5rem;
    margin-right: var(--space-small);

    flex-shrink: 0;

    background-color: var(--color-white);
    border: var(--width-border) solid var(--color-border);
    border-radius: 0.5rem;

    transition:
        border-color 0.2s ease-in-out,
        background-color 0.2s ease-in-out;
}

input[type="radio"] + label::before {
    border-radius: 50%;
}

input[type="checkbox"]:checked + label::after,
input[type="radio"]:checked + label::after {
    content: '';

    position: absolute;

    width: 1.5rem;
    height: 0.75rem;
    margin-top: 1.2rem;
    margin-left: 0.5rem;

    border-bottom: var(--width-border) solid var(--color-text);
    border-left: var(--width-border) solid var(--color-text);

    transform: rotate(-45deg);
}

input[type="radio"]:checked + label::after {
    height: 1.5rem;
    margin-top: 1rem;

    background-color: var(--color-text);
    border-top: var(--width-border) solid var(--color-text);
    border-right: var(--width-border) solid var(--color-text);
    border-radius: 50%;
}

.form-group--invalid input,
.form-group--invalid textarea,
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--color-border-error);
}

select {
    width: 100%;
    padding: var(--space-small);

    color: inherit;
    font-family: inherit;
    font-size: var(--size-normal);
    text-overflow: ellipsis;

    background-color: var(--color-grey-1);
    border: var(--width-border) solid var(--color-border);
    border-radius: var(--radius);

    transition:
        background-color 0.2s ease-in-out,
        border-color 0.2s ease-in-out;
}

@media (min-width: 800px) {
    select {
        width: auto;
        min-width: 50%;
    }
}

select:not([multiple]) {
    padding-right: 3.5rem;

    background-color: var(--color-white);
    background-image: url("../../icons/angle-down.svg");
    background-repeat: no-repeat;
    background-position: right 0.75rem top 58%;
    background-size: 2.5rem;

    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
}

select:not([disabled]):hover,
select:not([disabled]):focus {
    background-color: var(--color-white);
}

select[disabled] {
    color: var(--color-text-secondary);

    border-color: var(--color-border-disabled);
}

fieldset {
    --fieldset-background: var(--color-pampas);

    min-width: auto;
    margin-top: var(--space-medium);
    margin-bottom: var(--space-medium);
    padding: var(--space-small);

    background-color: var(--fieldset-background);
    border: none;
    border-radius: var(--radius);
}

@media (min-width: 1100px) {
    fieldset {
        padding: var(--space-medium);
    }
}

legend {
    padding: var(--space-smaller) var(--space-small);

    background-color: var(--fieldset-background);
    border-radius: var(--radius);
}

.fieldset__caption {
    padding-right: 0.5em;
    padding-left: 0.5em;

    color: var(--color-text-secondary);
    font-size: var(--size-small);
}

.form-group {
    margin-bottom: var(--space-medium);
}

.form-group__stack {
    display: flex;

    align-items: center;
}

.form-group__stack > * + * {
    margin-left: var(--space-smaller);
}

.form-group__stack > button {
    flex-shrink: 0;
}

.form-group__caption {
    margin-top: var(--space-smaller);
    margin-bottom: var(--space-smaller);
    padding-right: var(--space-small);
    padding-left: var(--space-small);

    color: var(--color-text-secondary);
    font-size: var(--size-small);
}

.form-group__caption--alt {
    margin-top: 0;
    padding-left: calc(2 * var(--space-small) + 2.5rem);
}

.form-group__caption--alt::before {
    content: '➜';
}

.form-group__error {
    margin-top: var(--space-small);
    margin-bottom: var(--space-small);
    padding-right: var(--space-small);
    padding-left: var(--space-small);

    color: var(--color-text-error);
    font-size: var(--size-small);
    font-weight: bold;
}

.form__actions {
    display: flex;
    margin-bottom: var(--space-medium);

    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.form__actions > * + * {
    margin-top: var(--space-medium);
}

@media (min-width: 800px) {
    .form__actions {
        flex-direction: row-reverse;
    }

    .form__actions > * + * {
        margin-top: 0;
    }
}

.form-details {
    margin-bottom: var(--space-medium);
    padding-left: var(--space-small);
}

.form-details summary {
    padding: var(--space-smaller) var(--space-small);

    cursor: pointer;
}

.form-details__content {
    padding-top: var(--space-small);
    padding-bottom: var(--space-small);
}

@media (min-width: 800px) {
    .form-details__content {
        padding: var(--space-medium);
    }
}

.form-group--terms {
    padding: var(--space-medium);

    background-color: var(--color-pampas);
    border-radius: var(--radius);
}

.form-group--terms .form-group__caption {
    margin-top: 0;
}
