/* These Divi layouts pair a desktop slider with a separate mobile title below it. */
@media (max-width: 767px) {
    .et_pb_fullwidth_section:has(+ .inner-banner-row h1) .lps_baner_box:has(h1) {
        display: none;
    }
}

/* Keep the shared enquiry panel's white text readable against its green background. */
.check_now .et_pb_code_inner {
    background-color: #52695f;
}

/* Older article paragraphs use inline justification that leaves large gaps on phones. */
@media (max-width: 767px) {
    .single-post .entry-content p[style*="text-align: justify" i],
    .single-post .entry-content p[style*="text-align:justify" i] {
        text-align: start !important;
    }
}

/* Divi reserves a sidebar column on posts even when no sidebar was rendered. */
@media (min-width: 981px) {
    .single-post.et_right_sidebar #content-area:not(:has(> #sidebar)) > #left-area {
        float: none;
        width: 100%;
        max-width: 60rem;
        margin-inline: auto;
        padding-inline: 0;
    }
}

.single-post .entry-content .lps-missing-media {
    display: none !important;
}

/* Claim directory headings share a row with the service cards. Their tile
   narrows twice, when the grid changes to two and then four columns. */
.chese_box_sec .et_pb_column_1_4 > .all_headings {
    container-type: inline-size;
    container-name: lps-claim-directory-heading;
    display: grid;
    align-content: center;
    min-height: clamp(150px, 14vw, 180px);
}
.chese_box_sec .et_pb_column_1_4 > .all_headings h2 {
    margin-top: 0;
}
@container lps-claim-directory-heading (max-width: 248px) {
    .all_headings h2 {
        font-size: min(1.75rem, 12cqi);
        overflow-wrap: anywhere;
    }
}

/* The dedicated contact page uses a different CF7 layout from the shared panel. */
.wpcf7 .contact-page-form .contact_back_txt {
    box-sizing: border-box;
    width: 100%;
    height: 44px;
    padding: 8px 4px;
    font-size: 16px;
}
.wpcf7 .contact-page-form .contact_back_btn {
    min-height: 44px;
}

@media (max-width: 980px) {
    /* Leave the same gap between all three stacked practice-area controls. */
    .lps-practice-picker .lps-area-link {
        margin-block-start: 15px;
    }
}

@media (max-width: 600px) {
    .single-post .entry-content img:is(.alignright, .alignleft)[src*="//www.lpsolicitors.co.uk/wp-content/uploads/"] {
        float: none;
        display: block;
        max-width: 100%;
        height: auto;
        margin: 0.75rem auto;
    }
}

/* A three-item benefit list has one full-width final item on phones. */
@media (max-width: 767px) {
    .free-initial-sec ul:has(> li:nth-child(3):last-child) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .free-initial-sec ul:has(> li:nth-child(3):last-child) > li {
        width: auto !important;
        height: auto;
    }
    .free-initial-sec ul > li:nth-child(3):last-child {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
    }
    .free-initial-sec ul > li:nth-child(3):last-child > :is(br, p:empty) {
        display: none;
    }
    .free-initial-sec ul > li:nth-child(3):last-child h5 {
        margin: 0;
    }
}

.lps_baner_box a.lps-quick-exit {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 10px;
    padding: 6px 16px;
    border-radius: 4px;
    background: #1a3a7c;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}
a.lps-quick-exit:focus-visible {
    outline: 3px solid #991f6b;
    outline-offset: 2px;
}
.personal-injury-txt a.lps-quick-exit {
    text-decoration: underline;
}

.tnp-subscription input[type="email"],
.tnp-subscription input[type="submit"] {
    min-height: 44px;
}

@media (min-width: 768px) and (max-width: 980px) {
    /* The contact group can use the two columns beside Legal Services. */
    #footer-widgets .footer_main_ul > li:has(.footer_inner_ul iframe) {
        width: 66.66666% !important;
    }
    #footer-widgets .footer_inner_ul:has(iframe) {
        display: grid;
        grid-template-columns: minmax(0, 275px) minmax(0, 160px);
        align-items: center;
        column-gap: 16px;
    }
    #footer-widgets .footer_inner_ul:has(iframe) > li:has(> a) {
        grid-column: 1 / -1;
    }
    #footer-widgets .footer_inner_ul a {
        display: inline-flex;
        align-items: center;
        min-height: 28px;
    }
}

/* Divi already supplies a gap when these service-page modules stack. */
@media (max-width: 767px) {
    .et_pb_column > .free-initial-sec.landing:has(+ .personal-injury-txt),
    .et_pb_row > .et_pb_column:has(> .free-initial-sec.landing:last-child):has(+ .et_pb_column > .cfa_fee:first-child),
    .et_pb_row > .et_pb_column:has(+ .et_pb_column > .calculate-your-clam:first-child) {
        margin-bottom: 0 !important;
    }
    .et_pb_column > .free-initial-sec.landing + .personal-injury-txt,
    .et_pb_row > .et_pb_column:has(> .free-initial-sec.landing:last-child) + .et_pb_column:has(> .cfa_fee:first-child),
    .et_pb_row > .et_pb_column + .et_pb_column:has(> .calculate-your-clam:first-child) {
        margin-top: 0 !important;
    }
}

@media (min-width: 981px) {
    :is(.et_pb_row.lps-related-services-row, .lps-funding-section > .et_pb_row) {
        display: grid;
        grid-template-columns: minmax(0, 55fr) minmax(0, 40fr);
        gap: 5%;
        align-items: start;
    }
    .et_pb_row.lps-related-services-row.lps-rsi-enquiry-row {
        grid-template-columns: minmax(0, 43fr) minmax(0, 52fr);
    }
    .lps-related-services-row:has(> .et_pb_column > .free-initial-sec.landing:last-child):has(.category_frm) {
        &:not(.lps-balanced-enquiry-row) {
            grid-template-columns: minmax(0, 45fr) minmax(0, 50fr);
        }
        & .free-initial-sec ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
        & .free-initial-sec li { width: auto; }
    }
    :is(.et_pb_row.lps-related-services-row, .lps-funding-section > .et_pb_row) > .et_pb_column {
        width: auto !important;
        margin: 0 !important;
    }
    :is(.lps-related-services-row, .lps-funding-section > .et_pb_row)::after {
        display: none;
    }
    .lps-related-services-row .sidebar_links_box ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 12px;
        align-items: start;
    }
    .lps-related-services-row .sidebar_links_box li {
        min-width: 0;
        overflow-wrap: break-word;
    }

    /* A few service templates leave only the benefit icons in the article column.
       Give the enquiry more space only while that article module is empty. */
    .et_pb_row:has(> .et_pb_column:first-child > .personal-injury-txt:empty:first-child + .free-initial-sec.landing:last-child):has(> .et_pb_column:last-child > .cfa_fee + .category_frm) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        gap: clamp(24px, 3vw, 48px);
        align-items: center;

        &::after, & .personal-injury-txt:empty { display: none; }
        & > .et_pb_column { width: auto !important; min-width: 0; margin: 0 !important; }
        & .free-initial-sec ul, & .lps-enquiry-fields {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
        & .free-initial-sec ul li { width: auto; }
        & .lps-enquiry-fields { column-gap: 16px; align-items: end; }
    }

    /* The short introduction and secondary cards can sit alongside the enquiry.
       The original reading and keyboard order also serves the stacked phone layout. */
    :is(.lps-hub-enquiry-row, .et_section_specialty > .et_pb_row:has(#claim-calculator-information)) {
        display: flow-root;
        & > .et_pb_column:first-child {
            width: 39% !important;
            float: left;
            margin: 0 !important;
        }
        & > .et_pb_column:last-child { display: contents; }
        & > .et_pb_column:last-child > :is(.cfa_fee, .category_frm) {
            box-sizing: border-box;
            width: 56%;
            float: right;
            clear: right;
            margin: 0;
        }
        & > .et_pb_column:last-child > :is(.member_resolution, .calculate-your-clam, .check_now) {
            box-sizing: border-box;
            width: 39%;
            float: left;
            clear: left;
            margin: 16px 0 0;
        }
    }

    :is(.lps-related-services-row, .lps-funding-section, .lps-hub-enquiry-row, .et_section_specialty > .et_pb_row:has(#claim-calculator-information)) .category_frm {
        container: lps-service-enquiry / inline-size;
    }
    @container lps-service-enquiry (min-width: 24rem) {
        .lps-enquiry-fields {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            column-gap: 16px;
            align-items: end;
        }
    }
}

/* The ribbon projects 22px below the slider into the next section. */
@media (min-width: 981px) {
    .et_pb_fullwidth_section:has(.main_banner) ~ .et_pb_section.injury_service.chese_box_sec {
        padding-top: 38px;
    }
}

.home .who_we_are_txt {
    container: lps-consultation / inline-size;
}
@container lps-consultation (max-width: 28rem) {
    .who_we_are_txt .consult,
    .who_we_are_txt .get_online {
        float: none;
        width: auto;
        margin-top: 1rem;
    }
    .who_we_are_txt .consult a {
        display: block;
        width: fit-content;
        font-size: 1.375rem;
        white-space: nowrap;
    }
}

/* Keep the funding guide's illustrations in proportion to a short screen. */
@media (orientation: landscape) and (max-width: 980px) and (max-height: 500px) {
    .lps-funding-section .et_pb_image_wrap,
    .lps-funding-section .et_pb_image img {
        width: 100%;
    }
    .lps-funding-section .et_pb_image img {
        height: 46svh;
        object-fit: cover;
    }
}

/* On a short phone the separate mobile title should appear with its photo. */
@media (orientation: landscape) and (max-width: 767px) and (max-height: 500px) {
    .et_pb_fullwidth_section:has(+ .inner-banner-row h1) .main_banner:not(:has(a, button, input, select)),
    .et_pb_fullwidth_section:has(+ .inner-banner-row h1) .main_banner:not(:has(a, button, input, select)) .et_pb_slide {
        max-height: 34svh;
        overflow: hidden;
    }
    .et_pb_fullwidth_section:has(+ .inner-banner-row h1) .main_banner::after {
        max-height: 12svh;
    }
}
