/**
 * Healio Variation Coupon — inline pricing block.
 *
 * One container, two states:
 *
 *   offer   → selling price · MRP · saving   +  pitch  +  code / apply
 *   applied → final price   · MRP · saving   +  confirmation
 *
 * The price row is state-aware: applying the coupon promotes the final price
 * into the lead position and widens the saving to cover the coupon too.
 *
 * Admin styles live at the bottom and are unchanged.
 *
 * @package Healio_Variation_Coupon
 */

:root {
	/* Brand */
	--hvc-primary: #6a38ff;
	--hvc-primary-dark: #5424e6;
	--hvc-primary-light: #7d51ff;
	--hvc-primary-soft: #f4f0ff;
	--hvc-primary-border: #d8c9ff;

	/* Status */
	--hvc-success: #1fa84a;
	--hvc-success-soft: #e6f7ec;
	--hvc-danger: #b42318;

	/* Neutrals */
	--hvc-surface: #ffffff;
	--hvc-border: #eaeaea;
	--hvc-text: #222222;
	--hvc-text-muted: #666666;

	/* Type scale */
	--hvc-size-final: 30px;
	--hvc-size-selling: 22px;
	--hvc-size-mrp: 14px;
	--hvc-size-meta: 13px;
	--hvc-size-micro: 12px;

	/* Shape */
	--hvc-radius-card: 12px;
	--hvc-radius-control: 10px;
	--hvc-radius-sm: 8px;
	--hvc-shadow: 0 1px 2px rgba(34, 34, 34, 0.04), 0 6px 18px -12px rgba(106, 56, 255, 0.32);
	--hvc-transition: 170ms cubic-bezier(0.4, 0, 0.2, 1);
	--hvc-control-height: 40px;
}

/* ======================================================================
   Block shell
   ====================================================================== */

.hvc-card-mount {
	/* Read back by coupon.js to confirm this stylesheet loaded AND matches. */
	--hvc-css-loaded: 1;
	--hvc-css-version: "1.2.0";
	display: block;
	width: 100%;
	clear: both;
	container-type: inline-size;
	container-name: hvc;
}

.hvc-card {
	display: none;
	box-sizing: border-box;
	width: 100%;
	margin: 10px 0 12px;
	padding: 10px 14px;
	border: 1px solid var(--hvc-border);
	border-radius: var(--hvc-radius-card);
	background: var(--hvc-surface);
	box-shadow: var(--hvc-shadow);
	color: var(--hvc-text);
	font-size: var(--hvc-size-meta);
	line-height: 1.3;
	-webkit-font-smoothing: antialiased;
}

.hvc-card--visible {
	display: block;
}

.hvc-card *,
.hvc-card *::before,
.hvc-card *::after {
	box-sizing: inherit;
}

.hvc-is-hidden {
	display: none !important;
}

.hvc-card__inner {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* Content fade on variation change — the box never moves. */
.hvc-card--swap .hvc-card__inner {
	animation: hvc-swap 220ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ======================================================================
   Price row — one line, both states
   ====================================================================== */

.hvc-row--price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 10px;
	min-width: 0;
}

.hvc-price,
.hvc-price .amount,
.hvc-price bdi {
	color: var(--hvc-text);
	font-size: var(--hvc-size-selling);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.015em;
	transition: color var(--hvc-transition);
}

/* Applied: the final price takes the lead slot and grows. */
.hvc-card--applied .hvc-price,
.hvc-card--applied .hvc-price .amount,
.hvc-card--applied .hvc-price bdi {
	color: var(--hvc-primary);
	font-size: var(--hvc-size-final);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
}

.hvc-mrp {
	display: inline-flex;
	align-items: baseline;
	gap: 4px;
	color: var(--hvc-text-muted);
	font-size: var(--hvc-size-mrp);
	font-weight: 400;
}

.hvc-mrp__value,
.hvc-mrp__value .amount,
.hvc-mrp__value bdi {
	color: var(--hvc-text-muted);
	font-size: var(--hvc-size-mrp);
	font-weight: 400;
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

.hvc-save {
	display: inline-flex;
	align-items: baseline;
	gap: 4px;
	margin-left: auto;
	padding: 2px 9px;
	border-radius: 999px;
	background: var(--hvc-success-soft);
	color: var(--hvc-success);
	font-size: var(--hvc-size-micro);
	font-weight: 700;
	white-space: nowrap;
}

.hvc-save .amount,
.hvc-save bdi {
	color: inherit;
	font-size: inherit;
	font-weight: inherit;
}

/* ======================================================================
   Offer state
   ====================================================================== */

.hvc-offer {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.hvc-offer__pitch {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	min-width: 0;
	color: var(--hvc-text);
	font-size: var(--hvc-size-meta);
	line-height: 1.25;
}

.hvc-offer__icon {
	flex: none;
	font-size: var(--hvc-size-meta);
	line-height: 1;
}

.hvc-offer__pitch-text {
	min-width: 0;
}

.hvc-inline-code {
	color: var(--hvc-primary);
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.hvc-inline-amount {
	font-weight: 700;
	white-space: nowrap;
}

.hvc-inline-amount .amount,
.hvc-inline-amount bdi {
	color: inherit;
	font-size: inherit;
	font-weight: 700;
}

.hvc-offer__action {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
	align-items: stretch;
}

/* Code field */
.hvc-code {
	width: 100%;
	min-width: 0;
	height: var(--hvc-control-height);
	margin: 0;
	padding: 0 12px;
	border: 1px dashed var(--hvc-primary-border);
	border-radius: var(--hvc-radius-control);
	background: var(--hvc-primary-soft);
	box-shadow: none;
	color: var(--hvc-primary);
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-align: center;
	text-transform: uppercase;
	cursor: pointer;
	transition: border-color var(--hvc-transition);
}

.hvc-code:hover {
	border-color: var(--hvc-primary);
}

.hvc-code:focus,
.hvc-code:focus-visible {
	border-style: solid;
	border-color: var(--hvc-primary);
	outline: 2px solid var(--hvc-primary);
	outline-offset: 2px;
}

/* Apply button */
.hvc-card .hvc-apply {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: var(--hvc-control-height);
	min-height: var(--hvc-control-height);
	padding: 0 20px;
	border: 0;
	border-radius: var(--hvc-radius-control);
	background-color: var(--hvc-primary);
	background-image: linear-gradient(135deg, var(--hvc-primary-light) 0%, var(--hvc-primary) 55%, var(--hvc-primary-dark) 100%);
	box-shadow: 0 1px 2px rgba(84, 36, 230, 0.24);
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.01em;
	text-transform: none;
	white-space: nowrap;
	cursor: pointer;
	transition: filter var(--hvc-transition), box-shadow var(--hvc-transition), transform var(--hvc-transition);
}

.hvc-card .hvc-apply:hover {
	filter: brightness(1.07);
	box-shadow: 0 4px 12px -2px rgba(84, 36, 230, 0.4);
	color: #fff;
	transform: translateY(-1px);
}

.hvc-card .hvc-apply:active {
	filter: brightness(0.96);
	transform: translateY(0);
}

.hvc-card .hvc-apply:focus-visible {
	outline: 2px solid var(--hvc-primary);
	outline-offset: 2px;
}

.hvc-card .hvc-apply[aria-disabled="true"] {
	cursor: progress;
	filter: saturate(0.8);
	transform: none;
}

.hvc-apply__label {
	display: inline-block;
	line-height: 1;
}

.hvc-spinner {
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: hvc-spin 640ms linear infinite;
}

/* ======================================================================
   Applied state — one confirmation line
   ====================================================================== */

.hvc-applied {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
	min-width: 0;
}

.hvc-applied__head {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	min-width: 0;
	color: var(--hvc-success);
	font-size: var(--hvc-size-meta);
	font-weight: 600;
}

.hvc-applied__check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--hvc-success);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
}

.hvc-applied__code {
	padding: 1px 7px;
	border: 1px solid var(--hvc-primary-border);
	border-radius: var(--hvc-radius-sm);
	background: var(--hvc-primary-soft);
	color: var(--hvc-primary);
	font-size: var(--hvc-size-micro);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	overflow-wrap: anywhere;
}

.hvc-applied__extra {
	margin: 0 0 0 auto;
	color: var(--hvc-text-muted);
	font-size: var(--hvc-size-micro);
	font-weight: 600;
	white-space: nowrap;
}

.hvc-applied__extra .hvc-inline-amount,
.hvc-applied__extra .amount,
.hvc-applied__extra bdi {
	color: var(--hvc-primary);
	font-size: inherit;
	font-weight: 700;
}

/* Success animation */
.hvc-card--enter .hvc-applied__check {
	animation: hvc-pop 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hvc-card--enter .hvc-price {
	animation: hvc-rise 280ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ======================================================================
   Note
   ====================================================================== */

.hvc-note {
	margin: 5px 0 0;
	color: var(--hvc-success);
	font-size: var(--hvc-size-micro);
	line-height: 1.35;
}

.hvc-note--error {
	color: var(--hvc-danger);
}

/* ======================================================================
   Narrow containers
   ====================================================================== */

@container hvc (max-width: 460px) {
	.hvc-card {
		padding: 12px 14px;
	}

	.hvc-save {
		margin-left: 0;
	}

	.hvc-offer__action {
		grid-template-columns: minmax(0, 1fr);
	}

	.hvc-card .hvc-apply {
		width: 100%;
	}

	.hvc-applied__extra {
		margin-left: 0;
		white-space: normal;
	}

	.hvc-card--applied .hvc-price,
	.hvc-card--applied .hvc-price .amount,
	.hvc-card--applied .hvc-price bdi {
		font-size: 24px;
	}
}

@container hvc (max-width: 330px) {
	.hvc-card {
		padding: 10px 12px;
	}

	.hvc-offer__pitch {
		align-items: flex-start;
		font-size: var(--hvc-size-micro);
	}
}

/* Viewport fallback for browsers without container query support. */
@media (max-width: 768px) {
	.hvc-card {
		padding: 12px 14px;
	}

	.hvc-save {
		margin-left: 0;
	}

	.hvc-offer__action {
		grid-template-columns: minmax(0, 1fr);
	}

	.hvc-card .hvc-apply {
		width: 100%;
	}

	.hvc-applied__extra {
		margin-left: 0;
		white-space: normal;
	}

	.hvc-card--applied .hvc-price,
	.hvc-card--applied .hvc-price .amount,
	.hvc-card--applied .hvc-price bdi {
		font-size: 24px;
	}
}

/* ======================================================================
   Motion
   ====================================================================== */

@keyframes hvc-swap {
	from {
		opacity: 0;
		transform: translateY(3px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes hvc-rise {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes hvc-pop {
	0% {
		opacity: 0;
		transform: scale(0.4);
	}

	100% {
		opacity: 1;
		transform: scale(1);
	}
}

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

@media (prefers-reduced-motion: reduce) {
	.hvc-card--swap .hvc-card__inner,
	.hvc-card--enter .hvc-applied__check,
	.hvc-card--enter .hvc-price {
		animation: none;
	}

	.hvc-card .hvc-apply,
	.hvc-code,
	.hvc-price {
		transition: none;
	}

	.hvc-card .hvc-apply:hover {
		transform: none;
	}

	.hvc-spinner {
		animation-duration: 1.6s;
	}
}

/* ======================================================================
   Admin — variation fields, validation feedback, live preview
   ====================================================================== */

.hvc-admin-field--discount .hvc-unit {
	display: inline-block;
	min-width: 1.4em;
	margin-left: 6px;
	color: var(--hvc-text-muted);
	font-weight: 600;
}

.hvc-admin-feedback {
	position: relative;
	transition: opacity var(--hvc-transition);
}

.hvc-admin-feedback:empty {
	display: none;
}

.hvc-admin-feedback.is-loading {
	opacity: 0.45;
}

.hvc-admin-status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	margin: 0 0 8px;
	font-size: 12px;
	line-height: 1.6;
}

.hvc-admin-status__pill {
	padding: 2px 9px;
	border-radius: 999px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.hvc-admin-status--valid .hvc-admin-status__pill {
	background: var(--hvc-success-soft);
	color: var(--hvc-success);
}

.hvc-admin-status--warning .hvc-admin-status__pill {
	background: #fcf9e8;
	color: #8a6100;
}

.hvc-admin-status--invalid .hvc-admin-status__pill {
	background: #fdeceb;
	color: var(--hvc-danger);
}

.hvc-admin-status__meta {
	color: var(--hvc-text-muted);
}

.hvc-admin-status__meta + .hvc-admin-status__meta::before {
	content: "·";
	margin-right: 10px;
	color: #c3c8d1;
}

.hvc-admin-status__link {
	margin-left: auto;
	text-decoration: none;
}

.hvc-admin-messages {
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
}

.hvc-admin-message {
	margin: 0 0 4px;
	padding: 6px 10px;
	border-left: 3px solid;
	border-radius: 0 4px 4px 0;
	font-size: 12px;
	line-height: 1.5;
}

.hvc-admin-message--error {
	border-color: var(--hvc-danger);
	background: #fdeceb;
	color: #7a1710;
}

.hvc-admin-message--warning {
	border-color: #dba617;
	background: #fcf9e8;
	color: #614c05;
}

.hvc-admin-message--notice {
	border-color: #7e8993;
	background: #f2f4f6;
	color: #3c434a;
}

.hvc-admin-preview {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 10px 12px;
	border: 1px solid var(--hvc-border);
	border-radius: var(--hvc-radius-sm);
	background: var(--hvc-primary-soft);
}

.hvc-admin-preview__label {
	color: var(--hvc-text-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.hvc-admin-preview__row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 8px;
	font-size: 13px;
}

.hvc-admin-preview__row > span + span::before {
	content: "→";
	margin-right: 8px;
	color: #b9b0d6;
	text-decoration: none;
}

.hvc-admin-preview__mrp,
.hvc-admin-preview__mrp .amount,
.hvc-admin-preview__mrp bdi {
	color: var(--hvc-text-muted);
	text-decoration: line-through;
}

.hvc-admin-preview__coupon {
	color: var(--hvc-primary);
	font-weight: 600;
}

.hvc-admin-preview__final,
.hvc-admin-preview__final .amount,
.hvc-admin-preview__final bdi {
	color: var(--hvc-primary);
	font-size: 15px;
	font-weight: 700;
	text-decoration: none;
}

.hvc-admin-preview__total {
	color: var(--hvc-success);
	font-size: 12px;
	font-weight: 600;
}
