/**
 * Unsubscribe: show each channel's fields only while its box is ticked.
 *
 * This is CSS rather than JavaScript on purpose. The fields must be hidden in
 * the first paint — hiding them from a script means the visitor sees the whole
 * form appear and then collapse, which reads as a page that is broken.
 *
 * `assets/js/ld-forms.js` does the other half: it adds and removes `required`
 * as the boxes change, which CSS cannot do. The two are keyed on the same
 * Elementor field IDs, and `Forms\Unsubscribe::CHANNELS` is the third copy —
 * the one that decides what the server accepts. All three must agree.
 *
 * These rules lived in the Unsubscribe page's Custom CSS until 2026-08-20,
 * which put them in the database rather than in the deployment. The page was
 * later replaced and the rules went with it: production served the form fully
 * expanded, with every address field visible from the start. Here they ship
 * with the plugin and cannot be separated from the JavaScript they belong to.
 *
 * The selectors match Elementor's own `elementor-field-group-{id}` class, so
 * they are tied to the field IDs and not to the order of the form. `!important`
 * is needed to beat Elementor's field-group display.
 */

/* Email */
form.elementor-form:has([name="form_fields[unsubscribe_email]"]:not(:checked))
    .elementor-field-group-email { display: none !important; }

/* Phone */
form.elementor-form:has([name="form_fields[unsubscribe_phone]"]:not(:checked))
    .elementor-field-group-phone { display: none !important; }

/* Postal mail — the whole name and address block.
 *
 * Unit is hidden with the group but is never marked required: loanDepot's own
 * form leaves it optional, which is why it is absent from CHANNELS in the
 * JavaScript. Hidden and optional are not a contradiction here. */
form.elementor-form:has([name="form_fields[unsubscribe_mail]"]:not(:checked))
    :is(
        .elementor-field-group-first_name,
        .elementor-field-group-last_name,
        .elementor-field-group-address,
        .elementor-field-group-unit,
        .elementor-field-group-city,
        .elementor-field-group-state,
        .elementor-field-group-zip
    ) { display: none !important; }

/*
 * There is deliberately no rule here for the required asterisk. Elementor core
 * already draws it from `.elementor-mark-required`, which is the class the
 * script toggles:
 *
 *   .elementor-mark-required .elementor-field-label:after
 *     { color: red; content: "*"; padding-inline-start: .2em }
 *
 * The page CSS this file replaced carried its own copy. Restating it here would
 * be a second definition of something already correct, and — because this sheet
 * loads on every page — one that would quietly restyle the asterisk on every
 * other form on the site.
 */

/*
 * Contact a Loan Officer (officer and branch pages). `.ld-lead-form` is added
 * by assets/js/ld-forms.js (leadForm), so none of this applies if the script
 * does not run, and no other form on the site is touched. QA callouts 2026-10-09.
 */

/* Send is greyed out until the form can be sent. aria-disabled rather than
   disabled, so pressing it still reaches the script, which marks what is
   missing instead of doing nothing. !important beats the widget's own colours,
   hover included. */
.elementor-form.ld-lead-form .elementor-button[aria-disabled="true"] {
    background-color: #d9d9d9 !important;
    color: #595959 !important;
    border-color: transparent !important;
    box-shadow: none !important;
    cursor: not-allowed;
}

/* What is missing, under the button. Aligned to it by the script. */
.ld-lead-form .ld-lead-hint {
    flex-basis: 100%;
    width: 100%;
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.4;
    color: #595959;
}
.ld-lead-form .ld-lead-hint:empty,
.ld-lead-form.ld-lead-sent .ld-lead-hint { display: none; }

/* Elementor draws the error icon as a glyph from its eicons font, which this
   site never loads, so it rendered as an empty box. Same place, drawn as a
   mask so it takes the message's colour. */
.ld-lead-form .elementor-message.elementor-message-danger::before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-inline-end: 6px;
    vertical-align: -0.15em;
    font-family: inherit;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm-1 3h2v7h-2zm0 9h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm-1 3h2v7h-2zm0 9h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The success message: same words, same place, now a banner that cannot be
   missed. The script scrolls it into view and gives it focus. */
.elementor-form.ld-lead-form .elementor-message.elementor-message-success {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
    padding: 14px 18px;
    border: 1px solid #2e7d32;
    border-radius: 12px;
    background: #edf7ee;
    color: #1b5e20;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}
.elementor-form.ld-lead-form .elementor-message.elementor-message-success::before {
    content: "";
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin: 0;
    background: currentColor;
    background-image: none;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm-1.2 13.6 6.3-6.3-1.4-1.4-4.9 4.9-2.3-2.3-1.4 1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm-1.2 13.6 6.3-6.3-1.4-1.4-4.9 4.9-2.3-2.3-1.4 1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.elementor-form.ld-lead-form .elementor-message.elementor-message-success:focus { outline: none; }
.elementor-form.ld-lead-form .elementor-message.elementor-message-success:focus-visible { outline: 2px solid #1b5e20; outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
    .elementor-form.ld-lead-form .elementor-message.elementor-message-success { animation: ld-lead-sent .35s ease-out; }
}
@keyframes ld-lead-sent {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* An error under one field of a row stretched its neighbour and pulled that
   field's label away from its box. Keep each field's lines at the top. */
.ld-lead-form .elementor-field-group { align-content: flex-start; }
