/* Directorist's sidebar result section is a flex item with min-width:auto.
 * A multi-card track must not contribute its intrinsic width to that item.
 * Keep the real results column (including native cards/pagination) shrinkable.
 * No global overflow mask. Ordinary GRID columns have a separate scope below.
 */
body.apis360-all-listings-page .apis360-marketplace-content .listing-with-sidebar__contents,
body.apis360-all-listings-page .apis360-marketplace-content .listing-with-sidebar__listing,
body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-contents__listings,
body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-items {
    min-width: 0;
    max-width: 100%;
}

body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-items > .directorist-container-fluid {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
}

body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-items {
    width: 100%;
    container: apis360-marketplace-results / inline-size;
}

/* Ordinary GRID only: independent of the gallery, native LIST/MAP and Home.
 * Keep M2/M3 as full-row siblings rather than shrinking them into card cells.
 */
body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view > .directorist-container-fluid > .directorist-row > [class*="directorist-col-"]:not(.apis360-mkt-ad-slot-wrap) {
    box-sizing: border-box;
    min-width: 0;
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view > .directorist-container-fluid > .directorist-row > .apis360-mkt-ad-slot-wrap {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card img {
    max-width: 100%;
    object-fit: contain !important;
}

@media (min-width: 601px) {
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view > .directorist-container-fluid > .directorist-row > [class*="directorist-col-"]:not(.apis360-mkt-ad-slot-wrap) {
        flex-basis: 50% !important;
        width: 50% !important;
        max-width: 50% !important;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single {
        display: block !important;
        min-width: 0;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__thumb,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card figure,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card img {
        height: 180px !important;
        min-height: 0;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__content {
        min-width: 0;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card {
        padding-top: 0 !important;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__info {
        padding: 12px !important;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-title {
        font-size: 14px !important;
        line-height: 1.3 !important;
        overflow-wrap: anywhere;
        white-space: normal;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-title a {
        display: -webkit-box;
        overflow: hidden;
        white-space: normal;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__meta {
        gap: 6px;
        padding: 10px 12px !important;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-rating-meta {
        flex-wrap: wrap;
        gap: 3px;
        min-width: 0;
        max-width: 100%;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__meta__left {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

@media (min-width: 1081px) {
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view > .directorist-container-fluid > .directorist-row > [class*="directorist-col-"]:not(.apis360-mkt-ad-slot-wrap) {
        flex-basis: 25% !important;
        width: 25% !important;
        max-width: 25% !important;
    }
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-listing-single__thumb,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card figure,
    body.apis360-all-listings-page .apis360-marketplace-content .directorist-archive-grid-view .directorist-thumnail-card img {
        height: 150px !important;
    }
}

body.apis360-all-listings-page .apis360-mkt-top-gallery {
    --apis360-mkt-gallery-visible: 1;
    --apis360-mkt-gallery-gap: 12px;
    box-sizing: border-box;
    margin: 2px 0 24px;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    padding: 16px;
    border: 1px solid #e7d6c3;
    border-radius: 14px;
    background: linear-gradient(135deg, #fffaf4 0%, #fff 72%);
    box-shadow: 0 8px 26px rgba(35, 30, 24, .06);
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__heading {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 14px;
    min-width: 0;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__heading h2 {
    color: #30251b;
    flex: none;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .075em;
    line-height: 1.2;
    margin: 0;
    white-space: nowrap;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__actions {
    align-items: center;
    display: flex;
    flex: none;
    gap: 12px;
    white-space: nowrap;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__cta {
    align-items: center;
    color: #8b4300;
    display: inline-flex;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    min-height: 34px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__cta:hover {
    color: #542900;
    text-decoration-thickness: 2px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__cta:focus-visible {
    border-radius: 3px;
    outline: 3px solid #bd5b00;
    outline-offset: 2px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__cta-compact {
    display: none;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__controls {
    display: flex;
    flex: none;
    gap: 7px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__arrow {
    align-items: center;
    background: #fff;
    border: 1px solid #d8c9b9;
    border-radius: 50%;
    color: #26211d;
    cursor: pointer;
    display: inline-flex;
    box-sizing: border-box;
    flex: 0 0 34px;
    font-size: 21px;
    height: 34px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 34px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__arrow:hover {
    border-color: #ed800d;
    color: #b45700;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__arrow:focus-visible,
body.apis360-all-listings-page .apis360-mkt-top-gallery__card:focus-within {
    outline: 3px solid #bd5b00;
    outline-offset: -4px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__link:focus-visible {
    outline: 0;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__arrow:disabled {
    cursor: default;
    opacity: .4;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__viewport {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    touch-action: pan-y;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__track {
    display: flex;
    gap: var(--apis360-mkt-gallery-gap);
    min-width: 0;
    will-change: transform;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__card {
    background: #fff;
    border: 1px solid #e8ddd0;
    border-radius: 10px;
    box-sizing: border-box;
    flex: 0 0 calc((100% - (var(--apis360-mkt-gallery-visible) - 1) * var(--apis360-mkt-gallery-gap)) / var(--apis360-mkt-gallery-visible));
    min-width: 0;
    overflow: hidden;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__link {
    color: #24211e;
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__image {
    align-items: center;
    background: #f6f5f3;
    display: flex;
    height: 132px;
    justify-content: center;
    position: relative;
    width: 100%;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__image img {
    display: block;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    width: 100%;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__badge {
    background: #e67700;
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    left: 8px;
    letter-spacing: .08em;
    line-height: 1;
    padding: 6px 8px;
    position: absolute;
    top: 8px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    justify-content: space-between;
    min-height: 82px;
    padding: 10px 11px 12px;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__title {
    display: -webkit-box;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.32;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

body.apis360-all-listings-page .apis360-mkt-top-gallery__price {
    color: #1c2125;
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

/* Size against the inner results column, never the page/viewport with sidebar. */
@container apis360-marketplace-results (min-width: 440px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery {
        --apis360-mkt-gallery-visible: 2;
    }
}

@container apis360-marketplace-results (min-width: 640px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery {
        --apis360-mkt-gallery-visible: 3;
    }
}

/* Keep title, CTA and controls on one line within narrow result columns. */
@container apis360-marketplace-results (max-width: 520px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery__heading {
        gap: 6px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__heading h2 {
        font-size: 12px;
        letter-spacing: .035em;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__actions {
        gap: 7px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__controls {
        gap: 4px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__cta {
        font-size: 12px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__cta-full {
        display: none;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__cta-compact {
        display: inline;
    }
}

@container apis360-marketplace-results (max-width: 280px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery__heading h2 {
        font-size: 11px;
        letter-spacing: 0;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__actions {
        gap: 4px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__controls {
        gap: 3px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__cta {
        font-size: 11px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__arrow {
        flex-basis: 28px;
        font-size: 18px;
        height: 28px;
        width: 28px;
    }
}

@media (min-width: 1081px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery {
        --apis360-mkt-gallery-visible: 4;
    }
}

@media (max-width: 600px) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery {
        --apis360-mkt-gallery-visible: 1;
        margin-bottom: 16px;
        padding: 12px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__image {
        height: 150px;
    }
    body.apis360-all-listings-page .apis360-mkt-top-gallery__body {
        min-height: 70px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.apis360-all-listings-page .apis360-mkt-top-gallery__track {
        scroll-behavior: auto;
        transition: none !important;
    }
}
