/* Approved compact card sizing, 2026-10-29. Preserve the full-width gray wrapper and
 * the controller's live top edge, height, categories, scrolling and controls.
 * Mobile and the unenhanced fallback keep their existing layouts.
 */
@media (min-width: 1025px) {
    body.gato-local-products-centered #gato-local-header .gpn-host > .wpr-sub-mega-menu.gpn-compact-wrap {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact {
        --gpi-sidebar: 360px;
        --gpi-card-max: 312px;
        /* Sidebar + two cards + 80px rails + 14px gap + 8px padding + 2px border. */
        width: min(calc(100% - 48px), calc(var(--gpi-sidebar) + var(--gpi-card-max) + var(--gpi-card-max) + 104px)) !important;
        margin-inline: auto !important;
        overflow-x: hidden !important;
        transition: none !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact .gpn-body {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        grid-template-columns: var(--gpi-sidebar) minmax(0, 1fr) !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact .gpn-products-column {
        width: auto !important;
        padding-inline: 24px 56px !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact .gpn-product-list {
        width: 100% !important;
        grid-auto-columns: min(var(--gpi-card-max), calc((100% - 14px) / 2)) !important;
    }

    /* Bound these square source images independently of the card width.
     * The 150px frame clips empty source margins while keeping the chassis whole. */
    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact .gpn-image :is(.wp-image-13768, .wp-image-7149) {
        width: 240px !important;
        height: 240px !important;
        max-width: 100% !important;
        object-fit: contain !important;
        transform: none !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact .gpn-scroll-next {
        right: 6px !important;
    }

    body.gato-local-products-centered #gato-local-header .gpn-product-description {
        white-space: normal !important;
    }
}

@media (min-width: 1025px) and (max-width: 1279px) {
    body.gato-local-products-centered #gato-local-header .gpn.is-enhanced.gpn-compact {
        --gpi-sidebar: 320px;
    }
}

/* Approved 2026-10-29: align the enhanced dropdown with the header grid.
 * The existing compact layout above remains the unenhanced fallback. */
@media (min-width: 1025px) {
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact {
        width: min(1440px, calc(100% - 48px)) !important;
        margin-inline: auto !important;
    }
    /* Bound the viewport to complete cards, preserving the accepted card/image sizes. */
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact .gpn-product-list {
        width: min(100%, 646px) !important;
        grid-auto-columns: min(312px, calc((100% - 14px) / 2)) !important;
        margin-inline: 0 !important;
    }
    /* Short catalogues keep their natural size and the same left starting edge. */
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact .gpn-product-list:has(> .gpn-product:nth-child(2):last-child) {
        width: min(100%, 646px) !important;
        grid-auto-columns: min(312px, calc((100% - 14px) / 2)) !important;
    }
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact .gpn-product-list:has(> .gpn-product:only-child) {
        width: min(100%, 320px) !important;
        grid-auto-columns: min(312px, 100%) !important;
    }
}
@media (min-width: 1440px) {
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact .gpn-product-list {
        width: min(100%, 972px) !important;
        grid-auto-columns: min(312px, calc((100% - 28px) / 3)) !important;
    }
}
@media (min-width: 1025px) and (max-width: 1199px) {
    /* Match the existing narrow-desktop header's 20px inset exactly. */
    body.gato-local-products-centered #gato-local-header.gch-centered .gpn.is-enhanced.gpn-compact {
        width: calc(100% - 40px) !important;
    }
}
