/* WAO Native Product Layout v1.2.0
 * All WooCommerce product pages using this child theme have the body class below.
 * CSS reorders the EXISTING DOM elements without cloning or JS moves.
 * Content remains present and accessible to Google and other crawlers.
 */

/* The support card already exists in the gallery column on desktop. */
@media (min-width: 768px) {
    /* End the sticky gallery at the visible bottom of the product summary.
     * The summary and metadata margins otherwise extend its scroll boundary. */
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .product_meta {
        margin-bottom: 0 !important;
    }
    /* The legacy gallery template emits a br before the support card. */
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > br {
        display: none !important;
    }
    body.wao-native-product-layout.single-product .content-single-images-wrapper > .woocommerce-product-gallery {
        margin-bottom: 0 !important;
    }
    body.wao-native-product-layout.single-product .content-single-images-wrapper > .wao-support-card {
        display: block !important;
        float: none !important;
        clear: both !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 16px 0 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
    }
}

@media (max-width: 767px) {
    /* Flatten only layout containers; keep ONE semantic H1 and ONE buy form. */
    body.wao-native-product-layout.single-product .content-single-wrapper {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary {
        display: contents !important;
    }
    /* Keep unclassified elements below the buy flow, in their DOM order. */
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > * { order: 50; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > * { order: 40; }

    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > h1.product_title {
        order: -20;
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin: 0 0 6px !important;
        padding: 0 !important;
        font-size: clamp(20px, 5.2vw, 24px) !important;
        line-height: 1.3 !important;
        font-weight: 500 !important;
        text-align: left;
        overflow-wrap: anywhere;
    }
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > .woocommerce-product-gallery {
        order: -10;
        display: block !important;
        float: none !important;
        clear: both !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .wao-price-rating-card { order: 0; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > form.cart { order: 1; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .button-wrap.wao-payment-icons { order: 2; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > .wao-support-card { order: 3; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > #units-sold.wao-sales-card { order: 4; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .container-card { order: 5; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .woocommerce-product-details__short-description { order: 6; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .wao-compat-card { order: 7; }
    /* Propaganda follows the purchase flow, before the remaining metadata. */
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > #nuestro { order: 30; }
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > br { display: none !important; }

    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .wao-price-rating-card,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > form.cart,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .button-wrap.wao-payment-icons,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > #units-sold.wao-sales-card,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .container-card,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .woocommerce-product-details__short-description,
    body.wao-native-product-layout.single-product .content-single-wrapper > .summary > .wao-compat-card,
    body.wao-native-product-layout.single-product .content-single-wrapper > .content-single-images-wrapper > .wao-support-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
}
