/* =========================================================
   FLOATING LABELS
   Append this to the end of assets/css/forms.css
   ========================================================= */

.registration-form .field {
    position: relative;
}

/*
 * The label text is injected in data-floating-label by registration.js.
 * It appears when the field has focus or contains a value.
 */
.registration-form .field::before {
    content: attr(data-floating-label);
    position: absolute;
    z-index: 2;
    top: -6px;
    left: 13px;
    max-width: calc(100% - 26px);
    padding: 0 5px;
    background: #fff;
    color: #243f8f;
    font-size: 9px;
    line-height: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease, color .15s ease;
}

.registration-form .field.floating-active::before,
.registration-form .field:focus-within::before {
    opacity: 1;
    transform: translateY(0);
}

/* Hide the placeholder while a field has focus, so the floating label takes over. */
.registration-form .field:focus-within input::placeholder,
.registration-form .field:focus-within textarea::placeholder {
    color: transparent;
}

/* Keep enough room so text never collides with the floating label. */
.registration-form .field.floating-active input,
.registration-form .field:focus-within input,
.registration-form .field.floating-active select,
.registration-form .field:focus-within select {
    padding-top: 3px;
}

.registration-form .field.floating-active textarea,
.registration-form .field:focus-within textarea {
    padding-top: 18px;
}

/*
 * For selects, the first disabled option is the placeholder.
 * Once another option is selected, only the selected value remains inside.
 */
.registration-form .field.floating-active select {
    color: #243f8f;
}

/* Error state: floating label follows the same red visual language. */
.registration-form .field.has-error::before {
    color: #b42318;
}

/*
 * If an error message sits directly below a floating field, keep a little
 * breathing room from the label/input.
 */
.registration-form .field.floating-active .field-error,
.registration-form .field:focus-within .field-error {
    margin-top: 7px;
}

@media (max-width: 600px) {
    .registration-form .field::before {
        top: -6px;
        left: 14px;
        font-size: 9px;
    }
}
