/**
 * Shared product card — Electro-style vertical card.
 *
 * One card component used by the WooCommerce loop (shop archive, category
 * archive, search results) and the homepage product tabs section. Grid
 * column sizing for the WooCommerce loop lives here; the homepage keeps its
 * own Bootstrap .row/.col-* grid in template-parts/home/product-tabs.php.
 *
 * Moved out of assets/css/pages/home.css so the card has one canonical
 * stylesheet instead of being duplicated per page.
 *
 * @package PackagingCommerce
 */

/* ── WooCommerce loop grid — shop, category, and search archives ────── */

/* Single grid owner for the product loop: display, columns, and gap all
   live here. woocommerce-base.css only strips WC's legacy float/width. */

.woocommerce ul.products {
	display: grid;
	width: 100%;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
}

/* 2 columns once a card has room to stay readable. */
@media (min-width: 30rem) {
	.woocommerce ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 12px;
	}
}

@media (min-width: 48rem) {
	.woocommerce ul.products {
		gap: 16px;
	}
}

/*
 * The grid sits beside a sticky sidebar from 62rem (992px) up (see
 * .pkgc-shop__layout in shop.css), so the grid area is narrower than the
 * viewport from that point on. Only add a 3rd column once the sidebar
 * layout is active and there is width to spare.
 */
@media (min-width: 75rem) {
	.woocommerce ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 90rem) {
	.woocommerce ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 20px;
	}
}

.woocommerce ul.products li.product {
	display: block;
	width: 100%;
	max-width: none;
	min-width: 0;
	margin: 0;
	float: none;
	clear: none;
}

/*
 * WooCommerce core ships `<ul class="products columns-4">` and its own
 * woocommerce-smallscreen.css targets `ul.products[class*=columns-] li.product`
 * (and the :nth-child(2n) sibling) below 768px with float:right/left and
 * width:48%, which outranks the plain selector above on specificity alone
 * regardless of load order. Matching the same selector shape neutralises it
 * without touching the "columns-4" class WooCommerce adds automatically.
 */
.woocommerce ul.products[class*="columns-"] li.product,
.woocommerce ul.products[class*="columns-"] li.product:nth-child(2n) {
	float: none;
	clear: none;
	width: 100%;
	max-width: none;
	min-width: 0;
	margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   SHARED — Electro vertical product card (shop loop + product tabs)
══════════════════════════════════════════════════════════════════════ */

.pkgc-electro-card {
	position: relative;
	width: 100%;
	max-width: none;
	min-width: 0;
	background-color: var(--brand-color-surface);
	border: 1px solid var(--brand-color-border);
	border-radius: var(--brand-radius-md);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	margin: 0;
	transition: box-shadow var(--brand-transition-fast),
	            transform var(--brand-transition-fast);
}

.pkgc-electro-card:hover,
.pkgc-electro-card:focus-within {
	box-shadow: var(--brand-shadow-md);
	transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
	.pkgc-electro-card {
		transition: box-shadow var(--brand-transition-fast);
	}

	.pkgc-electro-card:hover,
	.pkgc-electro-card:focus-within {
		transform: none;
	}
}

/* Image area — 1:1 square, capped so wide columns don't inflate card height */
.pkgc-electro-card__img-wrap {
	position: relative;
	aspect-ratio: 1;
	max-height: 220px;
	overflow: hidden;
	background-color: var(--brand-color-surface-alt);
	flex-shrink: 0;
}

.pkgc-electro-card__img-link {
	display: block;
	width: 100%;
	height: 100%;
}

.pkgc-electro-card__img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	padding: var(--brand-space-3);
	transition: transform var(--brand-transition-base);
}

.pkgc-electro-card:hover .pkgc-electro-card__img {
	transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
	.pkgc-electro-card__img {
		transition: none;
	}

	.pkgc-electro-card:hover .pkgc-electro-card__img {
		transform: none;
	}
}

/* Product placeholder — small structured SVG, not blank white */
.pkgc-electro-card__img-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	color: var(--brand-color-border);
	padding: var(--brand-space-4);
}

/* Circular badge — Electro style: top-right circle */
.pkgc-electro-card__badge {
	position: absolute;
	inset-block-start: var(--brand-space-3);
	inset-inline-end: var(--brand-space-3);
	width: 44px;
	height: 44px;
	border-radius: var(--brand-radius-full);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: var(--brand-weight-bold);
	color: #fff;
	text-align: center;
	line-height: 1.1;
	z-index: 2;
}

.pkgc-electro-card__badge--new {
	background-color: var(--brand-color-primary);
}

.pkgc-electro-card__badge--sale {
	background-color: var(--brand-color-accent);
}

/* Out-of-stock overlay — WooCommerce loop context only */
.pkgc-electro-card__badge--outofstock {
	position: static;
	width: auto;
	height: auto;
	min-width: 44px;
	min-height: 28px;
	padding-inline: var(--brand-space-2);
	border-radius: var(--brand-radius-full);
	background-color: var(--brand-color-muted);
	font-size: 11px;
}

/* Card body */
.pkgc-electro-card__body {
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: var(--brand-space-2) var(--brand-space-3);
	text-align: center;
	flex: 1;
}

.pkgc-electro-card__cat {
	font-size: 12px;
	color: var(--brand-color-primary);
	text-decoration: none;
	font-weight: var(--brand-weight-medium);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	display: block;
}

.pkgc-electro-card__cat:hover {
	text-decoration: underline;
}

.pkgc-electro-card__title {
	min-height: calc(14px * 1.375 * 2);
	font-size: 14px;
	font-weight: var(--brand-weight-medium);
	line-height: var(--brand-leading-snug);
	color: var(--brand-color-ink);
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.pkgc-electro-card__title a {
	color: var(--brand-color-ink);
	text-decoration: none;
}

.pkgc-electro-card__title a:hover {
	color: var(--brand-color-primary);
}

.pkgc-electro-card__price {
	font-size: 16px;
	font-weight: var(--brand-weight-bold);
	color: var(--brand-color-ink);
	margin-block-start: auto;
	padding-block-start: var(--brand-space-1);
}

.pkgc-electro-card__price del {
	font-size: 13px;
	color: var(--brand-color-muted);
	font-weight: var(--brand-weight-regular);
	margin-inline-end: 4px;
}

.pkgc-electro-card__price ins {
	text-decoration: none;
	color: var(--brand-color-accent);
}

/* Action footer — always visible on every breakpoint and every card state,
   so every card has an equal, non-empty action area regardless of hover. */
.pkgc-electro-card__actions {
	flex-shrink: 0;
	min-height: 44px;
	border-block-start: 1px solid var(--brand-color-border);
}

.pkgc-electro-card__actions .add_to_cart_button,
.pkgc-electro-card__actions .button,
.pkgc-electro-card__actions .pkgc-card-action-link {
	display: block !important;
	width: 100% !important;
	min-height: 44px !important;
	text-align: center !important;
	border-radius: 0 !important;
	padding-block: var(--brand-space-3) !important;
	font-size: 13px !important;
	font-weight: var(--brand-weight-bold) !important;
	background-color: var(--brand-color-primary) !important;
	color: #fff !important;
	border: none !important;
	text-decoration: none !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: background-color var(--brand-transition-fast) !important;
}

.pkgc-electro-card__actions .add_to_cart_button:hover,
.pkgc-electro-card__actions .button:hover,
.pkgc-electro-card__actions .pkgc-card-action-link:hover {
	background-color: var(--brand-color-primary-dark) !important;
}

.pkgc-electro-card__actions .add_to_cart_button.loading {
	opacity: 0.75;
}

/* ── Mobile card tuning — compact, readable, no clipped text ─────────── */

@media (max-width: 35.99rem) {
	.pkgc-electro-card__img-wrap {
		max-height: none;
	}

	.pkgc-electro-card__img {
		padding: var(--brand-space-2);
	}

	.pkgc-electro-card__body {
		padding: var(--brand-space-2) var(--brand-space-3);
	}

	.pkgc-electro-card__title {
		font-size: 15px;
	}

	.pkgc-electro-card__price {
		font-size: 15px;
	}

	.pkgc-electro-card__actions .add_to_cart_button,
	.pkgc-electro-card__actions .button,
	.pkgc-electro-card__actions .pkgc-card-action-link {
		font-size: 13px !important;
		padding-inline: var(--brand-space-2) !important;
	}
}
