/* Done Digital Lead Machine — Popups
 * Distinct namespace (.ddlm-lpop-*) to avoid collision with the form-level
 * popup shell (.ddlm-popup-*) used by render_popup_overlay_html().
 */

.ddlm-lpop {
    position: fixed;
    inset: 0;
    z-index: 2147483645;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    visibility: hidden;
    pointer-events: none;
    /* Keep the container out of the tab/click path until visible, but delay hiding
       visibility until the fade-out finishes so transitions still play on close. */
    transition: visibility 0s linear 0.45s;
}

.ddlm-lpop.ddlm-lpop-visible {
    visibility: visible;
    pointer-events: auto;
    transition: visibility 0s linear 0s;
}

.ddlm-lpop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.56);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.ddlm-lpop.ddlm-lpop-visible .ddlm-lpop-overlay {
    opacity: 1;
}

.ddlm-lpop-dialog {
    position: relative;
    z-index: 1;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    padding: 32px 28px 28px;
    max-width: min(520px, 94vw);
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow: auto;
    transform: translateY(12px) scale(0.985);
    opacity: 0;
    /* Slight delay so the overlay lands just ahead of the dialog for a softer reveal. */
    transition:
        transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) 0.08s,
        opacity 0.4s ease 0.08s;
}

.ddlm-lpop.ddlm-lpop-visible .ddlm-lpop-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Respect users who prefer reduced motion: fade only, no movement or delay. */
@media (prefers-reduced-motion: reduce) {
    .ddlm-lpop-overlay,
    .ddlm-lpop-dialog {
        transition: opacity 0.2s ease;
    }
    .ddlm-lpop-dialog {
        transform: none;
    }
}

.ddlm-lpop-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ddlm-lpop-close:hover {
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
}

.ddlm-lpop-heading {
    margin: 0 0 10px 0;
    font-size: 22px;
    line-height: 1.25;
    /* font-family intentionally inherited so the site's heading font applies. */
}

.ddlm-lpop-description {
    margin: 0 0 20px 0;
    color: #475569;
    line-height: 1.5;
    /* font-family inherited: site's body font. */
}

.ddlm-lpop-align-left .ddlm-lpop-heading,
.ddlm-lpop-align-left .ddlm-lpop-description {
    text-align: left;
}

.ddlm-lpop-align-center .ddlm-lpop-heading,
.ddlm-lpop-align-center .ddlm-lpop-description {
    text-align: center;
}

.ddlm-lpop-align-right .ddlm-lpop-heading,
.ddlm-lpop-align-right .ddlm-lpop-description {
    text-align: right;
}

.ddlm-lpop-action {
    display: flex;
    justify-content: flex-start;
}

.ddlm-lpop-align-center .ddlm-lpop-action {
    justify-content: center;
}

.ddlm-lpop-align-right .ddlm-lpop-action {
    justify-content: flex-end;
}

.ddlm-lpop-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ddlm-lpop-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* The form's own heading/subheading visibility is controlled server-side via the
   form's show_heading/show_subheading settings, so no defensive display:none here.
   We only neutralize the form's card styling so it sits flush inside the popup.
   Post-submit field hiding is handled by forms.css / forms-embed-shield.css
   (.ddlm-submitted); popup CSS must not force display on form internals. */
.ddlm-lpop .ddlm-custom-form {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Lead Capture: give two-column forms room for half-width field pairs. */
.ddlm-lpop.ddlm-lpop-mode-form .ddlm-lpop-dialog {
    max-width: min(720px, 94vw);
}

/*
 * Keep half-width columns side-by-side on desktop. forms.css container queries
 * stack rows when the form is ≤400px wide — common inside the old 520px dialog —
 * which made Lead Capture popups look single-column on desktop.
 */
@media (min-width: 601px) {
    .ddlm-lpop .ddlm-form .ddlm-field-row,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .ddlm-lpop .ddlm-form .ddlm-field-column.ddlm-field-half-width,
    .ddlm-lpop .ddlm-form .ddlm-field-column.ddlm-empty-column,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-column.ddlm-field-half-width,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-column.ddlm-empty-column {
        flex: 1 1 0 !important;
        width: auto !important;
        max-width: calc(50% - 6px) !important;
    }
}

@media (max-width: 600px) {
    .ddlm-lpop .ddlm-form .ddlm-field-row,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-row {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 12px !important;
    }

    .ddlm-lpop .ddlm-form .ddlm-field-column.ddlm-field-half-width,
    .ddlm-lpop .ddlm-form .ddlm-field-column.ddlm-field-full-width,
    .ddlm-lpop .ddlm-form .ddlm-field-column.ddlm-empty-column,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-column.ddlm-field-half-width,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-column.ddlm-field-full-width,
    .ddlm-lpop .ddlm-custom-form[data-ddlm-embed="1"] .ddlm-field-column.ddlm-empty-column {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 auto !important;
    }

    .ddlm-lpop .ddlm-form-inline,
    .ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .ddlm-lpop .ddlm-form-inline > .ddlm-form-field,
    .ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline > .ddlm-form-field {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
}

/*
 * In-line forms in Lead Capture popups only: never more than 2 fields per row
 * (hello bars / embeds keep their existing in-line wrapping).
 */
.ddlm-lpop .ddlm-form-inline,
.ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    gap: 12px !important;
}

@media (min-width: 601px) {
    .ddlm-lpop .ddlm-form-inline > .ddlm-form-field,
    .ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline > .ddlm-form-field {
        flex: 1 1 calc(50% - 6px) !important;
        max-width: calc(50% - 6px) !important;
        min-width: 0 !important;
        width: auto !important;
        margin-bottom: 0 !important;
    }

    /* Lone leftover field before the submit control (e.g. 5th of 5) → full width. */
    .ddlm-lpop .ddlm-form-inline > .ddlm-form-field:nth-child(odd):nth-last-child(2),
    .ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline > .ddlm-form-field:nth-child(odd):nth-last-child(2) {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
}

.ddlm-lpop .ddlm-form-inline > .ddlm-form-submit,
.ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline > .ddlm-form-submit {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.ddlm-lpop .ddlm-form-inline > .ddlm-form-submit .ddlm-submit-btn,
.ddlm-lpop .ddlm-form.ddlm-form-layout-inline .ddlm-form-inline > .ddlm-form-submit .ddlm-submit-btn {
    width: 100% !important;
}

/* Two-column layout in popups: a single half-width field on a row spans full width. */
.ddlm-lpop .ddlm-field-row > .ddlm-field-column.ddlm-empty-column {
    display: none !important;
}

.ddlm-lpop .ddlm-field-row:has(> .ddlm-empty-column) > .ddlm-field-column:not(.ddlm-empty-column),
.ddlm-lpop .ddlm-field-row:has(> .ddlm-field-column:only-child) > .ddlm-field-column {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Prevent scroll-through while the popup is open. */
body.ddlm-lpop-no-scroll {
    overflow: hidden;
}

@media (max-width: 480px) {
    .ddlm-lpop-dialog {
        padding: 26px 18px 20px;
        border-radius: 12px;
    }

    .ddlm-lpop-heading {
        font-size: 20px;
    }
}
