/* The site's three forms (Mega Forms): the footer newsletter (.newsletter), the welcome popups
   (.pse-welcome-popup-sec) and Contact us (.contact-form). This file is the only place they are
   styled. It loads after Mega Forms' own stylesheet (mega-forms.php) and keeps the look the
   Gravity forms had. Colours: release/COLOUR-PALETTE.md. */

.newsletter .mform_container,
.pse-welcome-popup-sec .mform_container,
.contact-form .mform_container {
    --pse-form-text: var(--e-global-color-text, #2b2e34);
    --pse-form-dark: #2b2e34;
    --pse-form-error: #c02b0a;
}
.newsletter li.mf-row-container,
.pse-welcome-popup-sec li.mf-row-container,
.contact-form li.mf-row-container {
    margin: 0;
}
.newsletter ul.mform_fields,
.newsletter ul.mf_col,
.pse-welcome-popup-sec ul.mform_fields,
.pse-welcome-popup-sec ul.mf_col,
.contact-form ul.mform_fields,
.contact-form ul.mf_col {
    margin: 0 !important;
    padding: 0;
    list-style: none;
}
/* Labels stay hidden, as the placeholders name each field. */
.newsletter .mfield .mf_notice,
.newsletter .mfield .mf_compound_notice,
.pse-welcome-popup-sec .mfield .mf_notice,
.pse-welcome-popup-sec .mfield .mf_compound_notice,
.contact-form .mfield .mf_notice,
.contact-form .mfield .mf_compound_notice {
    margin: 5px 0 0;
    padding: 0;
    background: none;
    color: var(--pse-form-error);
    font-size: 14px;
    line-height: 1.4;
}
/* The email field is one input wide, like the others. */
.newsletter .mf_sub_email,
.pse-welcome-popup-sec .mf_sub_email,
.contact-form .mf_sub_email {
    display: block;
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
}
.newsletter .mfield .mf_input_container input,
.pse-welcome-popup-sec .mfield .mf_input_container input,
.contact-form .mfield .mf_input_container input {
    width: 100%;
}
/* Fields keep their usual border when they have an error; the message under them says what to fix. */
.newsletter .mfield .mf_input_error input,
.newsletter .mfield .mf_sub_input_error input,
.pse-welcome-popup-sec .mfield .mf_input_error input,
.pse-welcome-popup-sec .mfield .mf_sub_input_error input,
.contact-form .mfield .mf_input_error input,
.contact-form .mfield .mf_input_error textarea,
.contact-form .mfield .mf_sub_input_error input {
    border-color: inherit;
}
/* Some errors (an expired security check) come with a Refresh button: the site's dark button. */
.newsletter .mform_error_msg .mf-refresh-btn,
.pse-welcome-popup-sec .mform_error_msg .mf-refresh-btn,
.contact-form .mform_error_msg .mf-refresh-btn {
    padding: 6px 16px;
    border-radius: 50px;
    background: var(--pse-form-dark);
    color: #fff;
    font-size: 14px;
    font-weight: 400;
}
.newsletter .mform_error_msg .mf-refresh-btn:hover,
.pse-welcome-popup-sec .mform_error_msg .mf-refresh-btn:hover,
.contact-form .mform_error_msg .mf-refresh-btn:hover {
    background: #82a0b9;
}
/* The theme removes outlines with `* :focus`; keyboard focus gets a ring back. */
.pse-welcome-popup-sec .mfield :is(input, select):focus-visible,
.contact-form .mfield :is(input, textarea):focus-visible,
.pse-welcome-popup-sec .mf-submit-btn:focus-visible,
.contact-form .mf-submit-btn:focus-visible {
    outline: 2px solid var(--e-global-color-primary, #2b2e34) !important;
    outline-offset: 2px;
}

/* --- Footer newsletter: one rounded field holding the email, the State select and the arrow. ---
   The form is a grid: its message (row 1) sits above the rounded field, which the form's ::before
   draws behind row 2 (the fields and the arrow), as the Gravity form showed it. */

.newsletter .single-mega-form {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 6px;
    align-items: center;
    width: 100%;
}
.newsletter .single-mega-form::before {
    content: "";
    grid-row: 2;
    grid-column: 1 / -1;
    align-self: stretch;
    border: 1px solid #bbb;
    border-radius: 30px;
}
/* After a sign-up Mega Forms removes the fields and keeps the form with its thank-you message,
   which then shows as plain text, without the rounded field. */
.newsletter .single-mega-form:not(:has(.mform_body))::before {
    display: none;
}
.newsletter .single-mega-form:has(:focus-visible)::before {
    outline: 2px solid var(--e-global-color-primary, #2b2e34);
    outline-offset: 2px;
}
.newsletter .mform_header {
    grid-row: 1;
    grid-column: 1 / -1;
}
.newsletter .mform_body {
    grid-row: 2;
    grid-column: 1;
    min-width: 0;
    padding: 4px 0 4px 21px;
}
.newsletter ul.mf_col {
    display: flex;
    align-items: center;
    gap: 12px;
}
.newsletter .mfield {
    margin: 0;
}
.newsletter .mfield_email {
    flex: 1 1 auto;
    min-width: 0;
}
.newsletter .mfield_select {
    flex: 0 0 184px;
    /* A select is as wide as its longest option unless allowed to be narrower. */
    min-width: 0;
    /* The inset the email text has inside the rounded field, on both sides of the State text,
       so the text clears the divider and the chevron clears the arrow. */
    padding: 0 20px;
    border-left: 1px solid #707070;
}
.newsletter .mfield .mf_input_container input,
.newsletter .mfield .mf_input_container select {
    height: 38px;
    min-height: 0;
    padding: 0;
    border: none;
    background-color: transparent;
    box-shadow: none;
    color: var(--pse-form-text);
}
.newsletter .mfield .mf_input_container input {
    font-size: 18px;
}
.newsletter .mfield .mf_input_container input::placeholder {
    color: #bbb;
    opacity: 1;
}
.newsletter .mfield .mf_input_container select {
    min-width: 0;
    padding-right: 20px;
    background-position: right center;
    font-size: 16px;
}
/* "State (optional)" reads as a placeholder until a state is chosen. */
.newsletter .mfield select:has(option[value=""]:checked),
.pse-welcome-popup-sec .mfield select:has(option[value=""]:checked) {
    color: #707070;
}
.newsletter .mform_footer {
    grid-row: 2;
    grid-column: 2;
    align-self: stretch;
    /* The button's hidden text ("Subscribe", for screen readers) must not widen the arrow. */
    min-width: 0;
    overflow: hidden;
    margin: 0;
    background: url(../../images/arrow.png) no-repeat center / 12px auto;
}
.newsletter .mf-submit-container,
.newsletter .mf-submit-btn {
    width: 100%;
    height: 100%;
}
.newsletter .mf-submit-btn {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    cursor: pointer;
}
/* On shop pages, css/custom-product-list.css paints every ".woocommerce .button" dark with
   !important. The button is only a clear layer over the arrow, and shows while a sign-up is
   sent, so it must stay clear there too. */
.newsletter .mf-submit-container .mf-submit-btn {
    border: none !important;
    background: transparent !important;
}
/* While a sign-up is sent, the arrow gives way to Mega Forms' dots, in the text colour. */
.newsletter .mform_footer:has(.mf-submit-processing) {
    background-image: none;
}
.newsletter .mf-submit-btn.mf-submit-processing {
    opacity: 1;
}
.newsletter .mf-submit-btn .mf-dots-spinner {
    width: 30px;
    height: 6px;
}
.newsletter .mf-submit-btn .mf-dots-spinner .mf-dot {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    border-color: var(--pse-form-dark);
    background: var(--pse-form-dark);
}
/* A field's error sits under the rounded field, across its width (so nothing between it and
   the form may be a positioned box). */
.newsletter li.mf-row-container,
.newsletter ul.mf_col,
.newsletter .mf_input_container {
    position: static;
}
.newsletter .mfield .mf_notice,
.newsletter .mfield .mf_compound_notice {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
}
.newsletter .mform_error_msg {
    margin: 0 0 8px !important;
    padding: 0;
    border: none;
    background: none;
    color: var(--pse-form-error);
    font-size: 14px;
    font-weight: 600;
}
.newsletter .mform_success_msg {
    margin: 0 !important;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
}
@media (max-width: 767px) {
    .newsletter .single-mega-form {
        grid-template-columns: minmax(0, 1fr) 30px 6px;
    }
    .newsletter .mfield_select {
        flex-basis: 128px;
    }
    /* 16 px also keeps iOS from zooming the page on focus. */
    .newsletter .mfield .mf_input_container input {
        font-size: 16px;
    }
}

/* --- Welcome popups: rounded fields and a full-width dark button. --- */

.pse-welcome-popup-sec .mfield {
    margin: 0 0 16px;
}
.pse-welcome-popup-sec .mform_footer {
    margin: 0;
    padding: 0;
}
.pse-welcome-popup-sec .mfield .mf_input_container input,
.pse-welcome-popup-sec .mfield .mf_input_container select {
    width: 100%;
    height: 38px;
    min-height: 0;
    padding: 0 20px;
    border: 1px solid #9e9e9e;
    border-radius: 50px;
    background-color: #fff;
    color: var(--pse-form-text);
    font-size: 15px;
}
.pse-welcome-popup-sec .mfield .mf_input_container select {
    padding-right: 36px;
    background-position: right 14px center;
}
.pse-welcome-popup-sec .mfield .mf_input_container input::placeholder {
    color: #9e9e9e;
    opacity: 1;
}
.pse-welcome-popup-sec .mf-submit-btn {
    width: 100%;
    height: 38px;
    padding: 0 20px;
    border: 1px solid var(--pse-form-dark);
    border-radius: 50px;
    background: var(--pse-form-dark);
    color: #fff;
    font-weight: 400;
}
.pse-welcome-popup-sec .mf-submit-btn:hover {
    background: none;
    color: var(--pse-form-dark);
}
/* The pointer is still on the button while it sends: keep it dark so the white dots show. */
.pse-welcome-popup-sec .mf-submit-btn.mf-submit-processing {
    background: var(--pse-form-dark);
}
.pse-welcome-popup-sec .mfield .mf_notice,
.pse-welcome-popup-sec .mfield .mf_compound_notice {
    color: red;
    text-align: left;
}
.pse-welcome-popup-sec .mform_error_msg {
    margin: 0 0 16px !important;
    padding: 12px 16px;
    border: 1px solid var(--pse-form-error);
    border-radius: 4px;
    background: #fff9f9;
    color: var(--pse-form-error);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}
.pse-welcome-popup-sec .mform_success_msg {
    margin: 0 0 20px !important;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font-size: 22px;
    line-height: 1.2em;
    text-align: center;
}

/* --- Contact us: light rounded fields, first and last name side by side. --- */

.contact-form .mfield {
    margin: 0 0 15px;
}
.contact-form .mfield .mf_input_container input,
.contact-form .mfield .mf_input_container textarea {
    min-height: 0;
    padding: 8px 12px;
    border: 1px solid #e0e4e7;
    border-radius: 25px;
    background: #fff;
    box-shadow: none;
    color: var(--pse-form-text);
    font-size: 16px;
}
.contact-form .mfield .mf_input_container input {
    height: 38px;
}
.contact-form .mfield .mf_input_container textarea {
    height: 190px;
    padding-top: 12px;
}
.contact-form .mfield .mf_input_container ::placeholder {
    color: rgb(43 46 52 / 36%);
    opacity: 1;
}
.contact-form .mf_input_name table {
    width: 100%;
    margin: 0;
    border: none;
    border-collapse: separate;
    border-spacing: 0;
}
/* Specific enough to replace Mega Forms' 1% gutters (body .single-mega-form .mf_input_compound table td…). */
.contact-form .single-mega-form .mf_input_compound.mf_input_name table td {
    width: 50%;
    padding: 0;
    border: none;
    vertical-align: top;
}
.contact-form .single-mega-form .mf_input_compound.mf_input_name table td.mf_sub_last_name {
    padding-left: 12px;
}
/* Small screens: last name under first name, as the Gravity form did (below 640 px). */
@media (max-width: 640px) {
    .contact-form .single-mega-form .mf_input_compound.mf_input_name :is(table, tbody, tr, td) {
        display: block;
        width: 100% !important;
    }
    .contact-form .single-mega-form .mf_input_compound.mf_input_name table td.mf_sub_last_name {
        margin-top: 15px;
        padding-left: 0 !important;
    }
}
.contact-form ul.mf_col > .mfield:last-child {
    margin-bottom: 0;
}
.contact-form .mform_footer {
    margin: 20px 0 0;
    padding: 0;
}
.contact-form .mf-submit-btn {
    width: 170px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 25px;
    background: var(--pse-form-dark);
    color: #fff;
    font-size: 16px;
    font-weight: normal;
    line-height: normal;
}
.contact-form .mf-submit-btn:hover {
    background: #82a0b9;
}
.contact-form .mform_error_msg {
    margin: 0 0 20px !important;
    padding: 12px 16px;
    border: 1px solid var(--pse-form-error);
    border-radius: 4px;
    background: #fff9f9;
    color: var(--pse-form-error);
    font-size: 14px;
}
.contact-form .mform_success_msg {
    margin: 0 !important;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
}
