/* Native TUH field settings define the order; this grid defines the spacing. */
html body .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px !important;
    align-items: start;
}

html body .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper > .form-row {
    grid-column: 1 / -1;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    clear: none !important;
}

html body .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper > .tuh-field-half {
    grid-column: span 1;
}

html body #tuh-register-form .tuh-fields-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
}

html body #tuh-register-form .tuh-fields-row > .tuh-form-field {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin: 0;
    grid-column: 1 / -1;
}

html body #tuh-register-form .tuh-fields-row > .tuh-field-half {
    grid-column: span 1;
}

/* TUH already provides the account card; avoid a second card on its form. */
html body .tuh-account-login-integrated #tuh-register-form {
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

html body #tuh-register-form .tuh-field-half > .tuh-form-label {
    white-space: nowrap;
}

@media (max-width: 767px) {
    html body .tuh-account-login-integrated .tuh-account-integrated-wrapper {
        --tuh-integrated-padding-sides: 0px !important;
    }
}

/* On phones keep the longer e-mail/address inputs wide and pair short data. */
@media (min-width: 360px) and (max-width: 767px) {
    html body.portal-theme .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper > #billing_email_field,
    html body.portal-theme .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper > #billing_postcode_field {
        grid-column: 1 / -1;
    }
}

/* Small screens need the full row rather than squeezed half-width inputs. */
@media (max-width: 359px) {
    html body .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper,
    html body #tuh-register-form .tuh-fields-row {
        grid-template-columns: minmax(0, 1fr);
    }

    html body .tuh-checkout-wrapper .woocommerce-billing-fields > .woocommerce-billing-fields__field-wrapper > .tuh-field-half,
    html body #tuh-register-form .tuh-fields-row > .tuh-field-half {
        grid-column: 1 / -1;
    }
}
