/* Colors follow the theme (WoodMart variables), with Zonyx's as fallbacks. */
.adv-free-gift-notice,
.adv-free-gift-dialog {
	--adv-fg-ink: var(--wd-primary-color, #3a2c22);
	--adv-fg-accent: var(--wd-alternative-color, #c8b188);
	--adv-fg-track: rgba(0, 0, 0, 0.08);
	--adv-fg-radius: 8px;
}

/* Notice */
.adv-free-gift-notice:empty {
	display: none;
}

.adv-free-gift-notice {
	margin-bottom: 20px;
}

.adv-free-gift-notice__box {
	padding: 16px 18px 18px;
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-radius: var(--adv-fg-radius);
	background: #fbf8f3;
	background: color-mix(in srgb, var(--adv-fg-accent) 10%, #fff);
	color: var(--adv-fg-ink);
}

.adv-free-gift-notice__text {
	margin: 0 0 12px;
	font-size: 14px;
	line-height: 1.55;
}

.adv-free-gift-notice__text .amount {
	font-weight: 700;
}

/* "Click here": a pill, so it reads as a button inside the sentence. */
.adv-free-gift-notice .adv-free-gift-open {
	display: inline-block;
	padding: 1px 12px;
	border-radius: 999px;
	background: var(--adv-fg-ink);
	color: #fff;
	font-weight: 600;
	line-height: 1.7;
	text-decoration: none;
	white-space: nowrap;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.adv-free-gift-notice .adv-free-gift-open:hover,
.adv-free-gift-notice .adv-free-gift-open:focus-visible {
	color: #fff;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
	transform: translateY(-1px);
}

.adv-free-gift-notice .is-selected .adv-free-gift-open {
	background: transparent;
	box-shadow: inset 0 0 0 1px var(--adv-fg-ink);
	color: var(--adv-fg-ink);
}

/* Progress bar */
.adv-free-gift-progress {
	display: flex;
	align-items: center;
	gap: 10px;
}

.adv-free-gift-progress__track {
	position: relative;
	flex: 1;
	height: 10px;
	border-radius: 999px;
	background: var(--adv-fg-track);
	overflow: hidden;
}

.adv-free-gift-progress__fill {
	position: relative;
	display: block;
	height: 100%;
	border-radius: inherit;
	background-color: var(--adv-fg-accent);
	background-image: linear-gradient(
		45deg,
		rgba(255, 255, 255, 0.35) 25%,
		transparent 25%,
		transparent 50%,
		rgba(255, 255, 255, 0.35) 50%,
		rgba(255, 255, 255, 0.35) 75%,
		transparent 75%,
		transparent
	);
	background-size: 14px 14px;
	transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
	animation: adv-fg-stripes 0.8s linear infinite;
}

.adv-free-gift-progress__goal {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 2px solid var(--adv-fg-accent);
	border-radius: 50%;
	background: #fff;
	color: var(--adv-fg-accent);
}

.adv-free-gift-progress__goal svg {
	display: block;
}

/* Threshold reached: solid bar, one shine, the gift lights up. */
.is-eligible .adv-free-gift-progress__fill,
.is-selected .adv-free-gift-progress__fill {
	background-image: none;
	animation: none;
}

.is-eligible .adv-free-gift-progress__fill::after,
.is-selected .adv-free-gift-progress__fill::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
	transform: translateX(-100%);
	animation: adv-fg-shine 1.2s ease 0.9s 1;
}

.is-eligible .adv-free-gift-progress__goal,
.is-selected .adv-free-gift-progress__goal {
	border-color: var(--adv-fg-ink);
	background: var(--adv-fg-ink);
	color: #fff;
	animation: adv-fg-pop 0.5s ease-out 0.8s both;
}

@keyframes adv-fg-stripes {
	to {
		background-position: 14px 0;
	}
}

@keyframes adv-fg-shine {
	to {
		transform: translateX(100%);
	}
}

@keyframes adv-fg-pop {
	50% {
		transform: scale(1.25);
	}
}

/* Side cart: tighter. */
.widget_shopping_cart_content .adv-free-gift-notice {
	margin: 0;
	padding: 15px 15px 5px;
}

.widget_shopping_cart_content .adv-free-gift-notice__box {
	padding: 12px 14px 14px;
}

.widget_shopping_cart_content .adv-free-gift-notice__text {
	margin-bottom: 10px;
	font-size: 13px;
}

.widget_shopping_cart_content .adv-free-gift-progress__track {
	height: 8px;
}

.widget_shopping_cart_content .adv-free-gift-progress__goal {
	width: 28px;
	height: 28px;
}

/* Gift label next to the product name. */
.adv-free-gift-badge {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 8px;
	border-radius: 10px;
	background: var(--wd-primary-color, #3a2c22);
	color: #fff;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.6;
	vertical-align: middle;
}

/* Gift picker */
.adv-free-gift-dialog {
	width: min(760px, calc(100vw - 32px));
	max-height: calc(100vh - 64px);
	padding: 0;
	border: 0;
	border-radius: var(--adv-fg-radius);
	background: #fff;
	color: inherit;
	overflow: hidden;
}

.adv-free-gift-dialog[open] {
	display: flex;
	flex-direction: column;
}

.adv-free-gift-dialog::backdrop {
	background: rgba(0, 0, 0, 0.6);
}

.adv-free-gift-dialog__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 260px;
}

.adv-free-gift-dialog__loading::after {
	content: "";
	width: 36px;
	height: 36px;
	border: 3px solid var(--adv-fg-track);
	border-top-color: var(--adv-fg-accent);
	border-radius: 50%;
	animation: adv-fg-spin 0.8s linear infinite;
}

@keyframes adv-fg-spin {
	to {
		transform: rotate(360deg);
	}
}

.adv-free-gift-dialog.is-loading .adv-free-gift-products {
	opacity: 0.5;
	pointer-events: none;
}

.adv-free-gift-dialog__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 20px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.adv-free-gift-dialog__title {
	margin: 0;
	font-size: 20px;
}

.adv-free-gift-dialog__close {
	min-height: 0;
	padding: 0 8px;
	border: 0;
	background: none;
	color: inherit;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.adv-free-gift-dialog__error {
	margin: 12px 20px 0;
	color: #b81c23;
}

.adv-free-gift-products {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 16px;
	margin: 0;
	padding: 20px;
	overflow-y: auto;
	list-style: none;
}

.adv-free-gift-product {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 10px;
	border: 2px solid transparent;
	border-radius: var(--adv-fg-radius);
	text-align: center;
	transition: border-color 0.15s ease;
}

.adv-free-gift-product:hover {
	border-color: var(--adv-fg-track);
}

.adv-free-gift-product.is-selected {
	border-color: var(--adv-fg-accent);
}

.adv-free-gift-product img {
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	object-fit: contain;
}

.adv-free-gift-product__name {
	flex: 1;
	font-size: 14px;
	line-height: 1.4;
}

.adv-free-gift-product__choose {
	width: 100%;
}

@media (max-width: 480px) {
	.adv-free-gift-products {
		grid-template-columns: repeat(2, 1fr);
		gap: 10px;
		padding: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.adv-free-gift-progress__fill,
	.adv-free-gift-progress__fill::after,
	.adv-free-gift-progress__goal,
	.adv-free-gift-dialog__loading::after {
		transition: none !important;
		animation: none !important;
	}
}
