/* FPLF MOBILE HERO + RESULTS SPACING */

@media (max-width: 779px) {

/* Entire Search Legal Forms hero */
    .fplf-search-hero {
        min-height: auto !important;

        display: flex !important;
        flex-direction: column !important;

        gap: 22px !important;

        margin: 0 !important;

        padding-top: 36px !important;
        padding-right: 20px !important;
        padding-bottom: 30px !important;
        padding-left: 20px !important;

        box-sizing: border-box !important;
    }

/* Remove FacetWP's own bottom spacing from search */
    .fplf-search-hero .facetwp-facet {
        margin-bottom: 0 !important;
    }

/* Results start directly after hero */
    .fplf-results-wrap {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

/* Filter button spacing */
    .fplf-mobile-filter-button {
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }
}

/* State separator - show only when State exists */
.fplf-result-state:not(:empty)::after {
    content: " •";
    margin-left: 4px;
}

/* FPLF FORMS ARCHIVE - MOBILE PAGE WIDTH */

@media (max-width: 779px) {

    body.post-type-archive-forms #page {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.post-type-archive-forms #content {
        display: block !important;

        width: 100% !important;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }

    body.post-type-archive-forms #primary {
        float: none !important;

        width: 100% !important;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }

    body.post-type-archive-forms #main {
        width: 100% !important;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;
    }
}

/* =========================================
   FPLF MOBILE RESULTS CONTROLS
========================================= */

@media (max-width: 779px) {

    /* =====================================
       MAIN GRID
    ===================================== */

    .fplf-results-controls {
        display: grid !important;

        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 1fr) !important;

        grid-template-areas:
            "count count"
            "filter sort";

        column-gap: 10px !important;
        row-gap: 12px !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 0 24px !important;
        padding: 0 !important;

        align-items: stretch !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       RESULT COUNT
    ===================================== */

    .fplf-result-count-control {
        grid-area: count !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        text-align: left !important;

        box-sizing: border-box !important;
    }

    .fplf-result-count-control .facetwp-facet,
    .fplf-result-count-control .facetwp-facet-result_count {
        width: 100% !important;
        max-width: 100% !important;

        margin: 0 !important;
        padding: 0 !important;

        white-space: nowrap !important;
        text-align: left !important;

        font-size: 14px !important;
        font-weight: 500 !important;
        line-height: 1.3 !important;

        color: #344054 !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       FILTER FORMS
    ===================================== */

    .fplf-mobile-filter-button {
        grid-area: filter !important;

        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        height: 48px !important;
        min-height: 48px !important;

        margin: 0 !important;
        padding: 6px 8px !important;

        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.15 !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       SORT WRAPPER
    ===================================== */

    .fplf-sort-control,
    .fplf-sort-facet {
        grid-area: sort !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: hidden !important;

        box-sizing: border-box !important;
    }


    /* FacetWP inner wrapper */
    .fplf-sort-control .facetwp-facet,
    .fplf-sort-facet .facetwp-facet,
    .fplf-sort-control .facetwp-facet-sort_results,
    .fplf-sort-facet .facetwp-facet-sort_results {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: hidden !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       ACTUAL SORT SELECT
    ===================================== */

    .fplf-sort-control select,
    .fplf-sort-facet select,
    .facetwp-facet-sort_results select {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        height: 48px !important;
        min-height: 48px !important;

        margin: 0 !important;

        padding-top: 4px !important;
        padding-right: 18px !important;
        padding-bottom: 4px !important;
        padding-left: 8px !important;

        font-size: 12px !important;
        font-weight: 500 !important;
        line-height: 1.1 !important;

        box-sizing: border-box !important;
    }
}

/* =========================================
   FPLF FACETWP MOBILE FLYOUT - FINAL
========================================= */

@media (max-width: 779px) {

    /* =====================================
       MAIN FLYOUT PANEL
    ===================================== */

    body .facetwp-flyout {
        width: 92vw !important;
        max-width: 400px !important;

        padding: 24px 18px 36px !important;

        background: #ffffff !important;
        color: #173b64 !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        box-sizing: border-box !important;

        box-shadow: 8px 0 30px rgba(15, 42, 74, 0.16);
    }


    /* =====================================
       IMPORTANT INNER WIDTH FIX
       Prevents Reset button / categories
       from overflowing the flyout
    ===================================== */

    body .facetwp-flyout .facetwp-flyout-wrap,
    body .facetwp-flyout .facetwp-flyout-content {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow-x: hidden !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       TITLE
    ===================================== */

    body .facetwp-flyout::before {
        content: "Filter Forms";

        display: block;

        margin: 4px 48px 24px 0;

        font-size: 22px;
        font-weight: 700;
        line-height: 1.2;

        color: #174f87;
    }


    /* =====================================
       CLOSE BUTTON
    ===================================== */

    body .facetwp-flyout-close {
        position: absolute !important;

        top: 16px !important;
        right: 16px !important;

        width: 36px !important;
        height: 36px !important;

        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        margin: 0 !important;
        padding: 0 !important;

        border: 1px solid #d7e0ea !important;
        border-radius: 50% !important;

        background: #ffffff !important;
        color: #174f87 !important;

        font-size: 18px !important;
        font-weight: 600 !important;
        line-height: 1 !important;

        cursor: pointer;
    }


    /* =====================================
       FILTER ROWS
    ===================================== */

    body .facetwp-flyout .flyout-row {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 0 24px !important;
        padding: 0 0 24px !important;

        border-bottom: 1px solid #edf1f5 !important;

        box-sizing: border-box !important;
    }

    body .facetwp-flyout .flyout-row:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;

        border-bottom: 0 !important;
    }


    /* =====================================
       SECTION HEADINGS
    ===================================== */

    body .facetwp-flyout .flyout-row h3 {
        margin: 0 0 14px !important;
        padding: 0 !important;

        font-size: 18px !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;

        color: #173b64 !important;
    }


    /* =====================================
       FLYOUT ITEM
    ===================================== */

    body .facetwp-flyout .flyout-item {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       FACET WRAPPERS
    ===================================== */

    body .facetwp-flyout .facetwp-facet {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       RESET FILTERS - TOP
    ===================================== */

    body .facetwp-flyout
    .flyout-row.name-reset_filters {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 0 24px !important;
        padding: 0 0 24px !important;

        overflow: hidden !important;

        border-bottom: 1px solid #edf1f5 !important;

        box-sizing: border-box !important;
    }


    /* Hide duplicate Reset Filters heading */
    body .facetwp-flyout
    .flyout-row.name-reset_filters > h3 {
        display: none !important;
    }


    body .facetwp-flyout
    .flyout-row.name-reset_filters .flyout-item,
    body .facetwp-flyout
    .facetwp-facet-reset_filters {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }


    /* Actual Reset Filters button */
    body .facetwp-flyout
    .facetwp-facet-reset_filters .facetwp-reset {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        height: 46px !important;
        min-height: 46px !important;

        margin: 0 !important;
        padding: 8px 14px !important;

        border: 1px solid #2463c7 !important;
        border-radius: 6px !important;

        background: #ffffff !important;
        color: #174f87 !important;

        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;

        box-sizing: border-box !important;

        cursor: pointer;
    }

    body .facetwp-flyout
    .facetwp-facet-reset_filters .facetwp-reset:hover {
        background: #f5f8fc !important;
    }


    /* =====================================
       CHECKBOX ROWS
    ===================================== */

    body .facetwp-flyout .facetwp-checkbox {
        position: relative !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        min-height: 30px;

        margin: 0 0 6px !important;

        padding-top: 5px !important;
        padding-right: 38px !important;
        padding-bottom: 5px !important;

        font-size: 15px !important;
        font-weight: 500 !important;
        line-height: 1.35 !important;

        color: #344054 !important;

        box-sizing: border-box !important;

        cursor: pointer;
    }


    /* =====================================
       LABEL TEXT
    ===================================== */

    body .facetwp-flyout .facetwp-display-value {
        max-width: 100% !important;

        font-size: 15px !important;
        font-weight: 500 !important;

        color: #344054 !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       COUNTS
    ===================================== */

    body .facetwp-flyout .facetwp-counter {
        margin-left: 3px !important;

        font-size: 13px !important;
        font-weight: 400 !important;

        color: #8a96a6 !important;
    }


    /* =====================================
       SEE MORE / SEE LESS
    ===================================== */

    body .facetwp-flyout .facetwp-toggle {
        margin-top: 8px !important;
        padding: 0 !important;

        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;

        color: #2463c7 !important;

        text-decoration: none !important;

        /*
         DO NOT set display here.
         FacetWP controls which toggle is visible.
        */
    }

    body .facetwp-flyout .facetwp-toggle:hover {
        text-decoration: underline !important;
    }


    /* =====================================
       CATEGORY + / -
    ===================================== */

    body .facetwp-flyout .facetwp-expand {
        position: relative !important;

        float: right !important;

        right: 0 !important;

        width: auto !important;
        max-width: none !important;

        margin: 0 2px 0 8px !important;
        padding: 0 !important;

        color: #2463c7 !important;

        font-size: 15px !important;
        font-weight: 700 !important;
        line-height: 1.35 !important;

        white-space: nowrap !important;
    }


    /* =====================================
       NESTED CATEGORIES
    ===================================== */

    body .facetwp-flyout .facetwp-depth {
        margin-left: 18px !important;

        max-width: calc(100% - 18px) !important;

        box-sizing: border-box !important;
    }


    /* =====================================
       GLOBAL OVERFLOW SAFETY
    ===================================== */

    body .facetwp-flyout *,
    body .facetwp-flyout *::before,
    body .facetwp-flyout *::after {
        box-sizing: border-box !important;
    }

/* =====================================
   FLYOUT SINGLE SCROLL FIX - CORRECTED
===================================== */

/* Outer drawer */
body .facetwp-flyout {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;

    display: flex !important;
    flex-direction: column !important;

    overflow: hidden !important;

    padding-bottom: 0 !important;
}


/* =====================================
   RESET FACETWP POSITIONING
   Important: keep content in normal flow
===================================== */

body .facetwp-flyout .facetwp-flyout-wrap {
    position: static !important;

    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    flex: 1 1 auto !important;

    display: flex !important;
    flex-direction: column !important;

    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: hidden !important;

    box-sizing: border-box !important;
}


/* ONLY this area scrolls */
body .facetwp-flyout .facetwp-flyout-content {
    position: static !important;

    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;

    flex: 1 1 auto !important;

    margin: 0 !important;

    /* little breathing room at bottom */
    padding: 0 0 36px 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;

    box-sizing: border-box !important;
}


/* =====================================
   RESET FILTERS MUST STAY IN NORMAL FLOW
===================================== */

body .facetwp-flyout .flyout-row.name-reset_filters,
body .facetwp-flyout .flyout-row.name-reset_filters .flyout-item,
body .facetwp-flyout .facetwp-facet-reset_filters,
body .facetwp-flyout .facetwp-facet-reset_filters .facetwp-reset {
    position: static !important;

    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;

    transform: none !important;
}


/* Prevent page behind drawer from scrolling */
body:has(.facetwp-flyout.active) {
    overflow: hidden !important;
}
}

/* Mobile button grid only where the result card itself uses its mobile layout (GenerateBlocks loop item ≤ 767 px).
   At 768–779 px the card keeps its desktop layout (buttons absolutely positioned in the right column), so a
   full-width grid there covered the title (OPEN_ISSUES #22, fixed 2026-11-05; was max-width: 779px). */
@media (max-width: 767px) {

    .fplf-result-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        gap: 8px !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}
/* =========================================
   MOBILE RESULT TAXONOMY
========================================= */

@media (max-width: 779px) {

    /* Hide category hierarchy on result cards */
    .fplf-result-categories {
        display: none !important;
    }

    /* State stays visible, but remove separator */
    .fplf-result-state:not(:empty)::after {
        content: "" !important;
        margin-left: 0 !important;
    }
}

