/*
 * Christmas mode: Santa hat on discounted combo product images.
 * Loaded only while Christmas mode is on. The hat image URL comes from
 * --lc-xmas-hat (set inline by inc/christmas.php). Purely decorative:
 * a CSS pseudo-element, so screen readers ignore it and it takes no clicks.
 */

:root {
	--lc-xmas-hat-size: 30%;
	--lc-xmas-hat-tilt: -16deg;
}

/* Hat anchors: Blocksy cards (figure), product collection blocks, classic WooCommerce
   loops and the single product gallery. */
.llamacorp-xmas-hat figure,
.llamacorp-xmas-hat .wc-block-components-product-image,
.llamacorp-xmas-hat .wp-block-woocommerce-product-image,
.llamacorp-xmas-hat > a.woocommerce-LoopProduct-link,
.llamacorp-xmas-hat-single .woocommerce-product-gallery .ct-product-gallery-container,
.llamacorp-xmas-hat-single .woocommerce-product-gallery:not(:has(.ct-product-gallery-container)) {
	position: relative;
}

.llamacorp-xmas-hat figure::before,
.llamacorp-xmas-hat .wc-block-components-product-image::before,
.llamacorp-xmas-hat .wp-block-woocommerce-product-image::before,
.llamacorp-xmas-hat > a.woocommerce-LoopProduct-link::before,
.llamacorp-xmas-hat-single .woocommerce-product-gallery .ct-product-gallery-container::before,
.llamacorp-xmas-hat-single .woocommerce-product-gallery:not(:has(.ct-product-gallery-container))::before {
	content: "";
	position: absolute;
	z-index: 3;
	top: 3%;
	right: 3%;
	width: var(--lc-xmas-hat-size);
	max-width: 160px;
	aspect-ratio: 128 / 112;
	background: var(--lc-xmas-hat) no-repeat center / contain;
	transform: rotate(calc(var(--lc-xmas-hat-tilt) * -1));
	transform-origin: 50% 100%;
	filter: drop-shadow(0 3px 4px rgba(61, 55, 99, 0.28));
	pointer-events: none;
	animation: lc-xmas-hat-wiggle 4s ease-in-out infinite;
}

/* Only one figure per card gets the hat (cards can contain extra figures). */
.llamacorp-xmas-hat figure ~ figure::before,
.llamacorp-xmas-hat figure figure::before {
	content: none;
}

/* Single product: a bit smaller relative to the large gallery. */
.llamacorp-xmas-hat-single .woocommerce-product-gallery .ct-product-gallery-container::before,
.llamacorp-xmas-hat-single .woocommerce-product-gallery:not(:has(.ct-product-gallery-container))::before {
	width: 22%;
	max-width: 180px;
}

@keyframes lc-xmas-hat-wiggle {

	0%,
	100% {
		rotate: 0deg;
	}

	50% {
		rotate: 4deg;
	}
}

@media (max-width: 689px) {

	:root {
		--lc-xmas-hat-size: 32%;
	}
}

@media (prefers-reduced-motion: reduce) {

	.llamacorp-xmas-hat *::before,
	.llamacorp-xmas-hat-single *::before {
		animation: none !important;
	}
}
