/* ==========================================================================
   COMPONENT — Product image flags: "Allahindlus" (and "Otsas", "Uus")
   --------------------------------------------------------------------------
   One badge for every surface that shows a discounted product — the
   catalogue card, the homepage cards, the hero product, the product page —
   drawn once here so the mark cannot drift between them. Whether it shows is
   avallone_sale_display() (inc/pricing.php).

   The tag is the Figma asset's shape (allahindlus-label): leading corners
   barely rounded, the trailing end a half-circle, filled --color-primary
   (#A20007, sampled from the design). It carries the word; a verified
   percentage has the "%" mark on the price row (.sale-percent, below).

   Placement: .product-flags is one column in the image corner opposite the
   wishlist heart, so flags stack instead of overlapping each other or the
   heart, at every card width down to the 136px panel of a 320px phone.
   ========================================================================== */

[data-sale-mark][hidden],
.sale-badge[hidden] {
	display: none;
}

.product-flags {
	position: absolute;
	inset-block-start: var(--space-sm);
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	/* Clear of the 36px heart in the other corner, with 8px to spare. */
	max-width: calc(100% - var(--space-sm) * 2 - 36px - var(--space-xs));
	/* The image link underneath keeps every click. */
	pointer-events: none;
}

.product-flags--start {
	inset-inline-start: var(--space-sm);
}

.product-flags--end {
	inset-inline-end: var(--space-sm);
	align-items: flex-end;
}

/* "Otsas" keeps its own look (catalog.css) but takes its place in the stack. */
.product-flags .catalog-card__flag {
	position: static;
}

.sale-badge {
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	background-color: var(--color-primary);
	color: var(--color-on-dark);
	font-family: var(--font-meta);
	font-weight: 700;
	text-transform: uppercase;
	white-space: nowrap;
	border-start-start-radius: 4px;
	border-end-start-radius: 4px;
	border-start-end-radius: var(--radius-pill);
	border-end-end-radius: var(--radius-pill);
}

/* Cards: 22px tall, 10px capitals — "ALLAHINDLUS" is ~88px wide. */
.sale-badge--card {
	padding: 4px 10px 4px 7px;
	font-size: 10px;
	line-height: 14px;
	letter-spacing: 0.06em;
}

/* Product page photograph: the design's 32px tag height. */
.sale-badge--summary {
	padding: 8px 16px 8px 12px;
	font-size: 13px;
	line-height: 16px;
	letter-spacing: 0.08em;
}

/* Inline beside a price (live search, mega-menu featured product). */
.sale-badge--inline {
	padding: 2px 8px 2px 6px;
	font-size: 9px;
	line-height: 14px;
	letter-spacing: 0.06em;
	vertical-align: middle;
}

/*
 * Phones (QA D2 F1/F2, 05.11.2026): on a two-column card the image is only
 * 124px (related row at 320) to ~190px wide, and the 36px heart sits 8px in on
 * catalogue, wishlist and related cards but 16px in on the homepage grid. No
 * badge budget beside the heart holds "ALLAHINDLUS" in every engine there
 * (it needs 74-82px; 64px was left at 320), so on phones the card flags leave
 * the heart's corner altogether: they sit on the plate's foot, bottom-left,
 * 4px over its edge. The plate's bottom ~12px is empty canvas under the
 * bottle, and every card leaves 12px or more before its text, so the tag
 * covers neither the product nor the heart nor the eyebrow, and the whole
 * width of the plate is its budget. Two flags sit side by side and wrap
 * upwards if the plate is too narrow for both.
 *
 * The hero card and the product photograph are not cards and keep their
 * corner; the Uued tooted stack card has its own foot placement below.
 */
@media (max-width: 599px) {

	:is(.catalog-card, .product-card--grid, .product-card--build) .product-flags--card {
		inset-block-start: auto;
		inset-block-end: -4px;
		inset-inline-start: var(--space-xs);
		inset-inline-end: auto;
		flex-direction: row;
		flex-wrap: wrap-reverse;
		align-items: flex-end;
		max-width: calc(100% - var(--space-xs) * 2);
	}

	.sale-badge--card {
		padding: 3px 8px 3px 6px;
		font-size: 9px;
		letter-spacing: 0.04em;
	}
}

/*
 * The "Uued tooted" stack cards draw a small plate (104px below 1024, ~130px
 * on short laptop windows) with the heart in its top corner: no room beside
 * it, so the flags sit along the plate's foot, where the bottle's base leaves
 * the corner free, at every width.
 */
.product-card--stack .product-flags {
	inset-block-start: auto;
	inset-block-end: var(--space-xs);
	inset-inline-start: var(--space-xs);
	max-width: calc(100% - var(--space-xs) * 2);
}

@media (max-width: 1023px) {

	.product-card--stack .sale-badge--card {
		padding: 3px 8px 3px 6px;
		font-size: 9px;
		letter-spacing: 0.04em;
	}
}

/*
 * "UUS" — the manual new-product flag (inc/product-new.php). Below the sale
 * tag in the same stack, so the two never overlap. Cream with a burgundy word
 * and the heart's own shadow: it reads as a label, not as an offer, and stays
 * clearly apart from the red sale tag and the ink "Otsas" pill.
 */
.new-badge {
	display: inline-flex;
	align-items: center;
	border-radius: var(--radius-pill);
	background-color: var(--color-cream);
	color: var(--color-primary-dark);
	box-shadow: var(--shadow-sm);
	font-family: var(--font-meta);
	font-weight: 700;
	text-transform: uppercase;
	white-space: nowrap;
}

.new-badge--card {
	padding: 4px 10px;
	font-size: 10px;
	line-height: 14px;
	letter-spacing: 0.1em;
}

.new-badge--summary {
	padding: 8px 16px;
	font-size: 13px;
	line-height: 16px;
	letter-spacing: 0.12em;
}

@media (max-width: 599px) {

	.new-badge--card {
		padding: 3px 8px;
		font-size: 9px;
	}
}

/* Live search rows: the mark on its own line above the price, right-aligned
   like the price, so the row's one-line price never grows wider. */
.search-mode__result-price .sale-badge--inline {
	display: flex;
	width: max-content;
	margin-inline-start: auto;
	margin-block-end: 2px;
}

/* Mega-menu featured product: before the price, on its line. */
.mega-menu__featured-price .sale-badge--inline {
	margin-inline-end: var(--space-xs);
}

/*
 * An alcohol-free sale price is WooCommerce's pair, which carries two
 * position:absolute .screen-reader-text spans ("Algne hind oli …"). With no
 * positioned ancestor inside the card they resolved against the page, escaped
 * the related row's horizontal scroller and widened a 390px product page to
 * 627px. Positioning the price row keeps them inside their card.
 */
.catalog-card__price,
.product-card__price,
.home-new__lead-price,
.home-hero__price {
	position: relative;
}

/* ==========================================================================
   The "%" mark before a discounted price — the approved design's
   allahindlus-label (9daa906), removed 04.11.2026 and restored 05.11.2026.
   Shown only with a substantiated percentage (template-parts/product/
   sale-percent.php). Values are the original ones: Inter's per-cent (small
   round counters, upright slash), the leading corners barely rounded and the
   trailing end a true half-circle; 32 × 23 against a card's 18px price, the
   design's own 45 × 32 on the product page.
   ========================================================================== */

.sale-percent {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	align-self: center;
	background-color: var(--color-primary);
	color: var(--color-on-dark);
	font-family: var(--font-meta);
	font-weight: 700;
	line-height: 1;
	text-align: center;
	border-start-start-radius: 6px;
	border-end-start-radius: 6px;
}

.sale-percent[hidden] {
	display: none;
}

.sale-percent--card {
	width: 32px;
	height: 23px;
	border-start-end-radius: 12px;
	border-end-end-radius: 12px;
	font-size: 12px;
}

.sale-percent--summary {
	width: 45px;
	height: 32px;
	border-start-end-radius: 16px;
	border-end-end-radius: 16px;
	font-size: 16px;
}
