/**
 * WC Shop Grid Banner — front styles.
 *
 * Testing / regression (The7 and similar float-based shop grids):
 * - Regular product images must display at normal size in The7 theme
 * - Banner card must fill its slot vertically with object-fit: cover image
 * - Layout must work with 2, 3, and 4 column product grids in The7
 * - No width overrides on li.product that could break theme columns
 */

/* Ensure plugin styles never affect regular product cards (intent: theme owns layout). */
.woocommerce ul.products > li.product:not(.wc-sgb-banner-card) {
	/* Reset nothing — leave entirely to theme */
}

.woocommerce ul.products > li.product:not(.wc-sgb-banner-card) img {
	/* No override from this plugin */
}

/* Classic loop: banner li cooperates with theme column sizing — no ul.products grid override. */
.woocommerce ul.products > li.product.wc-sgb-banner-card {
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 0;
	margin-bottom: 0;
	list-style: none;
	--wc-sgb-order: 0;
	/* Do NOT set width or aspect-ratio here — inherit width from theme li.product sizing */
}

/* Sequential injection: match sibling product cell width when theme provides it */
.wc-sgb-banner-card--sequential {
	width: inherit;
}

/* Block grids: only nudge alignment when a shop-banner exists — do not force display:flex globally */
ul.wc-block-product-template:has(li.product-type-shop-banner) {
	align-items: stretch;
}

ul.wc-block-product-template li.wc-block-product.product-type-shop-banner,
ul.products li.product.product-type-shop-banner {
	order: var(--wc-sgb-order, 0);
}

/* Aspect ratio on the inner link, not the li (works without CSS grid on ul.products) */
.wc-sgb-banner-card .wc-sgb-banner-link {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	aspect-ratio: var(--wc-sgb-ratio, auto);
	min-height: 260px;
	width: 100%;
	height: 100%;
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	border-radius: 2px;
	background: #e5e5e5;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wc-sgb-banner-card .wc-sgb-banner-link:hover,
.wc-sgb-banner-card .wc-sgb-banner-link:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.wc-sgb-banner-card .wc-sgb-banner-img {
	flex: 1 1 auto;
	width: 100%;
	min-height: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	display: block;
}

/* Title + subtitle at top; CTA stays at bottom (.wc-sgb-banner-cta) */
.wc-sgb-banner-card .wc-sgb-banner-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 1rem 1.25rem 1.25rem;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
	pointer-events: none;
	z-index: 1;
}

.wc-sgb-banner-card .wc-sgb-banner-title {
	color: #fff;
	font-size: clamp(14px, 2.5vw, 22px);
	font-weight: 700;
	margin: 0 0 0.3rem;
	line-height: 1.2;
}

.wc-sgb-banner-card .wc-sgb-banner-subtitle {
	color: rgba(255, 255, 255, 0.88);
	font-size: clamp(11px, 1.8vw, 15px);
	margin: 0;
	line-height: 1.35;
}

/* No image: keep a minimum cell height */
.wc-sgb-banner-card .wc-sgb-banner-link--empty {
	min-height: 280px;
}

.wc-sgb-banner-card .wc-sgb-banner-cta {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 1.25rem;
	display: flex;
	justify-content: center;
	pointer-events: none;
	z-index: 2;
}

.wc-sgb-banner-card .wc-sgb-banner-cta-inner {
	pointer-events: none;
	display: inline-block;
	padding: 0.55rem 1.35rem;
	background: #fff;
	color: #111;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border-radius: 3px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.wc-sgb-banner-card .wc-sgb-banner-link:hover .wc-sgb-banner-cta-inner,
.wc-sgb-banner-card .wc-sgb-banner-link:focus-visible .wc-sgb-banner-cta-inner {
	background: #f5f5f5;
}

.wc-sgb-banner-card .wc-sgb-banner-link:focus-visible {
	outline: 2px solid #111;
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * WooCommerce Product Collection (block grid)
 * ------------------------------------------------------------------------- */

/*
 * Banner in block grid must match sibling product card size exactly.
 * Do not set width on li — let the block layout control columns (no ul grid overrides).
 */
ul.wc-block-product-template li.wc-block-product.product-type-shop-banner,
ul.wc-block-grid__products li.wc-block-product.product-type-shop-banner {
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 0;
}

/* Hide everything except the custom image block (fallback if extra wrappers exist) */
li.wc-block-product.product-type-shop-banner > *:not(.wp-block-woocommerce-product-image) {
	display: none !important;
}

li.wc-block-product.product-type-shop-banner > .wp-block-group:has(.wc-block-components-product-button),
li.wc-block-product.product-type-shop-banner > .wp-block-group:has(.custom-details-link),
li.wc-block-product.product-type-shop-banner > .wp-block-group:has(.product-action-container) {
	display: none !important;
}

li.wc-block-product.product-type-shop-banner [class*="uagb-block-"] {
	display: none !important;
}

li.wc-block-product.product-type-shop-banner .custom-details-link,
li.wc-block-product.product-type-shop-banner .product-action-container {
	display: none !important;
}

ul.wc-block-product-template li.wc-block-product.product-type-shop-banner .wc-sgb-wc-block-banner-image,
ul.wc-block-grid__products li.wc-block-product.product-type-shop-banner .wc-sgb-wc-block-banner-image {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-link {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	position: relative;
	width: 100%;
	min-height: 260px;
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	border-radius: 2px;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-link:hover,
li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-link:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-link:focus-visible {
	outline: 2px solid #111;
	outline-offset: 2px;
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-img,
li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-link > img {
	flex: 1 1 auto;
	width: 100%;
	min-height: 240px;
	height: 100%;
	object-fit: cover;
	object-position: center;
	display: block;
}

.wc-sgb-banner-blocks-link .wc-sgb-banner-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 1rem 1.25rem 1.25rem;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
	pointer-events: none;
	z-index: 1;
}

.wc-sgb-banner-blocks-link .wc-sgb-banner-title {
	color: #fff;
	font-size: clamp(14px, 2.5vw, 22px);
	font-weight: 700;
	margin: 0 0 0.3rem;
	line-height: 1.2;
}

.wc-sgb-banner-blocks-link .wc-sgb-banner-subtitle {
	color: rgba(255, 255, 255, 0.88);
	font-size: clamp(11px, 1.8vw, 15px);
	margin: 0;
	line-height: 1.35;
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-cta {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 1.1rem;
	display: flex;
	justify-content: center;
	pointer-events: none;
	z-index: 2;
}

li.wc-block-product.product-type-shop-banner .wc-sgb-banner-blocks-cta-inner {
	pointer-events: none;
	display: inline-block;
	padding: 0.55rem 1.35rem;
	background: #fff;
	color: #111;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border-radius: 3px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

/* Spectra uagb/woo-products: overlays injected server-side */
li.product-type-shop-banner .wc-sgb-banner-overlay,
li.type-shop-banner .wc-sgb-banner-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 1rem 1.25rem 1.25rem;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
	pointer-events: none;
	z-index: 1;
}

li.product-type-shop-banner .wc-sgb-banner-title,
li.type-shop-banner .wc-sgb-banner-title {
	color: #fff;
	font-size: clamp(14px, 2.5vw, 22px);
	font-weight: 700;
	margin: 0 0 0.3rem;
	line-height: 1.2;
}

li.product-type-shop-banner .wc-sgb-banner-subtitle,
li.type-shop-banner .wc-sgb-banner-subtitle {
	color: rgba(255, 255, 255, 0.88);
	font-size: clamp(11px, 1.8vw, 15px);
	margin: 0;
	line-height: 1.35;
}
