/**
 * AffiliateBooster Blocks - responsive safety net.
 *
 * Enqueued on the frontend and in the editor, after every per-block stylesheet,
 * so it can neutralise the fixed widths declared by the older block CSS.
 * Scoped to the plugin's own wrapper classes only.
 */

/* ---------------------------------------------------------------------------
 * 1. Images can never be wider than their column.
 *    `max-width` beats `width` per spec, so the design's own width is kept on
 *    wide screens and simply capped on narrow ones. `height` is intentionally
 *    left alone so blocks that crop with object-fit keep working.
 * ------------------------------------------------------------------------- */
.affiliate-sp-image img,
.affiliate-toppick-image img,
.affiliate-tipbox-img-wrapper img,
.affiliate-toppickspecs-img-wrapper img,
.affiliate-singleproductspecs-img-wrapper img,
.affiliate-singleproductproscons-img-wrapper img,
.affiliate-productverdict-img-wrapper img,
.affiliate-pr-image img,
[class*="affiliate-coupon-image"] img,
[class*="affiliate-coupon-imagetop"] img,
[class*="affiliate-coupon-imagebottom"] img,
[class*="affiliate-coupon-code-image"] img {
	max-width: 100% !important;
}

/* ---------------------------------------------------------------------------
 * 2. Flex children default to min-width:auto, which refuses to shrink below the
 *    intrinsic image width. Let them shrink.
 * ------------------------------------------------------------------------- */
.affiliate-sp-img-wrapper,
.affiliate-tipbox-img-wrapper,
.affiliate-toppickspecs-img-wrapper,
.affiliate-singleproductspecs-img-wrapper,
.affiliate-singleproductproscons-img-wrapper,
.affiliate-productverdict-img-wrapper,
.affiliate-pr-image {
	min-width: 0;
}

/* ---------------------------------------------------------------------------
 * 3. Mobile: image columns stack instead of squeezing the image.
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {

	.affiliate-sp-wrapper .affiliate-sp-img-wrapper,
	.affiliate-tipbox-wrapper .affiliate-tipbox-img-wrapper {
		flex: 0 0 100%;
		max-width: 100%;
	}

	.affiliate-toppickspecs-img-wrapper,
	.affiliate-singleproductspecs-img-wrapper,
	.affiliate-singleproductproscons-img-wrapper,
	.affiliate-productverdict-img-wrapper {
		float: none;
		width: 100%;
		max-width: 100%;
	}

	.affiliate-sp-wrapper .affiliate-sp-cntn-wrapper {
		margin-left: 0;
	}
}

/* ---------------------------------------------------------------------------
 * 4. Oversized buttons.
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {

	.affiliate-abbtn-wrapper .btn-is-large,
	.affiliate-abbtn-wrapper .btn-is-extra-large {
		width: 100% !important;
		max-width: 100%;
	}

	.affiliate-abbtn-wrapper .btn-is-medium {
		max-width: 100%;
	}

	.affiliate-abbtn-wrapper .btn-is-flex-large,
	.affiliate-abbtn-wrapper .btn-is-flex-extra-large {
		min-width: 0 !important;
		max-width: 100%;
	}
}

/* ---------------------------------------------------------------------------
 * 5. Comparison and product tables scroll horizontally on small screens.
 *    The wrapper element is part of the saved block markup, so no markup change
 *    is needed. Keeps the real table semantics (headers, columns) intact.
 * ------------------------------------------------------------------------- */
@media (max-width: 1024px) {

	.wp-block-affiliate-booster-ab-product-table-1,
	.wp-block-affiliate-booster-ab-product-table-2,
	.wp-block-affiliate-booster-ab-product-table-3,
	.wp-block-affiliate-booster-ab-comparison-table {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		padding-bottom: 8px;
	}

	.wp-block-affiliate-booster-ab-product-table-1 table,
	.wp-block-affiliate-booster-ab-product-table-2 table,
	.wp-block-affiliate-booster-ab-product-table-3 table,
	.wp-block-affiliate-booster-ab-comparison-table table {
		min-width: 720px;
		width: 100%;
	}
}
