/* Soler — product card (template-parts/product-card.php), the same on every page: homepage carousel,
   shop, categories, search and related products. Its inside scales with the card's own width
   (container query units), so one card fits a wide carousel slot and a narrow phone column alike. */

.pcard {
	position: relative;
	container-type: inline-size;
	height: 100%;
}

.pcard__link {
	position: relative;
	display: block;
	color: inherit;
}

.pcard__media {
	position: relative;
	aspect-ratio: 4 / 5;
	margin: 0;
	overflow: hidden;
	background: #ececea;
	box-shadow: var(--shadow-card);
	--pad: 20px;
	--pad-bottom: 96px;
}

/* Packshots are on white; multiply melts the white into the card's grey. */
.pcard__media img {
	position: absolute;
	top: var(--pad);
	left: var(--pad);
	width: calc(100% - 2 * var(--pad));
	height: calc(100% - var(--pad) - var(--pad-bottom));
	object-fit: contain;
	mix-blend-mode: multiply;
	transition: transform 1.2s var(--ease-out);
}

.pcard:hover .pcard__media img {
	transform: scale(1.05);
}

.pcard__media .pcard__placeholder {
	top: 18%;
	left: 25%;
	width: 50%;
	height: 44%;
	opacity: 0.7;
}

/* A small ink stamp in the top corner: По рецепта / Изчерпан / Промоция. */
.pcard__flag {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	padding: 3px 9px 4px;
	border: 1px solid currentColor;
	color: var(--green);
	background: rgba(255, 253, 248, 0.82);
	font-size: 12px;
	font-style: italic;
	letter-spacing: 0.02em;
	pointer-events: none;
	transform: rotate(-2deg);
}

.pcard--out .pcard__flag {
	color: var(--muted);
}

.pcard--out .pcard__media img {
	opacity: 0.55;
}

.pcard__meta {
	position: absolute;
	right: 8px;
	bottom: 8px;
	left: 24px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 4px;
	pointer-events: none;
}

/* The chips sit over the image link; only they catch the pointer. */
.pcard__meta > * {
	pointer-events: auto;
}

/* Border instead of padding, so the two-line clamp can't leak a third line into the padding. */
html .pcard__name {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	max-width: 100%;
	border: solid var(--green);
	border-width: 8px 14px;
	background: var(--green);
	color: var(--cream);
	font-size: 14px;
	line-height: 1.35;
	text-align: right;
	transition: background-color 0.35s ease, border-color 0.35s ease;
}

html .pcard__name:hover,
html .pcard__name:focus-visible,
.pcard__link:hover ~ .pcard__meta .pcard__name {
	border-color: var(--green-deep);
	background: var(--green-deep);
	color: var(--cream);
}

.pcard__row {
	display: flex;
	align-items: stretch;
	gap: 4px;
}

.pcard__price {
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding: 6px 14px;
	background: #fff;
	color: var(--green);
	font-size: 14px;
	white-space: nowrap;
}

.pcard__price del {
	opacity: 0.55;
}

.pcard__price ins {
	text-decoration: none;
}

/* The stamp already says it. */
.pcard__price .soler-rx-badge {
	display: none;
}

/* Quick buy: one piece straight into the cart. A cream ink fills it from the left on hover. */
html .pcard__buy {
	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
	overflow: hidden;
	padding: 6px 12px;
	background: var(--green-deep);
	color: var(--cream);
	font-size: 13px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
	transition: color 0.4s var(--ease-out);
}

.pcard__buy::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--cream);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.55s var(--ease-out);
}

html .pcard__buy:hover,
html .pcard__buy:focus-visible {
	color: var(--green);
}

.pcard__buy:hover::before,
.pcard__buy:focus-visible::before {
	transform: scaleX(1);
}

.pcard__buy .soler-icon {
	flex: none;
	width: 1.15em;
	height: 1.15em;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.5s var(--ease-out);
}

.pcard__buy:hover .soler-icon {
	transform: translateY(-2px) rotate(-8deg);
}

.pcard__buy.loading {
	pointer-events: none;
	opacity: 0.7;
}

.pcard__buy.loading .soler-icon {
	animation: pcard-bag 0.7s ease-in-out infinite alternate;
}

@keyframes pcard-bag {
	to { transform: translateY(-3px) rotate(-10deg); }
}

/* WooCommerce appends a "view cart" link after adding; the bookmark's bag already shows it. */
.pcard__row .added_to_cart {
	display: none;
}

/* Proportions follow the card's width wherever container units are supported. */
@supports (width: 1cqi) {
	.pcard__media {
		--pad: 10.4cqi;
		--pad-bottom: max(26.4cqi, 96px);
	}

	.pcard__flag {
		top: 3.2cqi;
		left: 3.2cqi;
		font-size: clamp(11px, 3.2cqi, 13px);
	}

	.pcard__meta {
		right: 2.8cqi;
		bottom: 2.8cqi;
		left: 9.6cqi;
		gap: max(4px, 1.4cqi);
	}

	html .pcard__name {
		border-width: max(7px, 2.4cqi) max(11px, 6cqi);
		font-size: clamp(13px, 4.1cqi, 18px);
	}

	.pcard__row {
		gap: max(4px, 1.4cqi);
	}

	.pcard__price {
		padding: max(5px, 2cqi) max(10px, 6cqi);
		font-size: clamp(13px, 4.1cqi, 18px);
	}

	html .pcard__buy {
		padding: max(5px, 2cqi) max(10px, 5.2cqi);
		font-size: clamp(12px, 3.7cqi, 16px);
	}
}

/* Narrow cards (two columns on a phone): the bag alone says "buy". */
@container (max-width: 210px) {
	.pcard__buy-label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	html .pcard__buy {
		padding-inline: 10px;
	}

	.pcard__buy.is-added::after {
		content: "✓";
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pcard__media img,
	.pcard__buy .soler-icon {
		transition: none;
	}
}
