/*
 * Gift card surfaces.
 *
 * Every colour and metric is a custom property with a fallback. Nothing here
 * uses !important outside the reduced-motion block, and every selector is
 * namespaced.
 */

.gc-form,
.gc-redemption,
.gc-balance,
.gc-account,
.gc-print {
	--gc-fg: #1f2328;
	--gc-muted: #5b6470;
	--gc-bg: #ffffff;
	--gc-panel: #f6f7f9;
	--gc-border: #dfe3e8;
	--gc-accent: #1f2328;
	--gc-accent-fg: #ffffff;
	--gc-focus: #2563eb;
	--gc-radius: 8px;
	--gc-gap: 12px;

	color: var(--gc-fg, #1f2328);
	font-size: 1rem;
	line-height: 1.5;

	/*
	 * The container-survival block. The redemption field lands inside whatever
	 * a theme uses for its cart totals, and several lay that out as a grid.
	 * Without these the field becomes one grid item and is squeezed into a
	 * label-width column — for a money field, that reads as broken rather than
	 * as merely misplaced.
	 */
	grid-column: 1 / -1;
	flex: 0 0 100%;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;

	margin: 0 0 var(--gc-gap, 12px);
	text-align: start;
}

.gc-form fieldset,
.gc-redemption__form {
	border: 1px solid var(--gc-border, #dfe3e8);
	border-radius: var(--gc-radius, 8px);
	padding: var(--gc-gap, 12px);
	margin: 0 0 var(--gc-gap, 12px);
}

.gc-form legend {
	padding: 0 0.4em;
	font-weight: 600;
}

.gc-form__field,
.gc-form__amount {
	display: block;
	margin: 0 0 0.75em;
}

.gc-form__label {
	display: block;
	margin-bottom: 0.25em;
	font-weight: 600;
}

.gc-form__hint {
	display: block;
	margin-top: 0.25em;
	color: var(--gc-muted, #5b6470);
	font-size: 0.85em;
}

.gc-form__field input,
.gc-form__field textarea,
.gc-redemption__input,
.gc-balance__input {
	width: 100%;
	max-width: 24em;
	/* 44px, the WCAG 2.2 target-size floor, without hard-coding a pixel height. */
	min-height: 2.75rem;
	box-sizing: border-box;
	font: inherit;
}

.gc-redemption__form,
.gc-balance__form {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: 0.5em;
}

.gc-redemption__label,
.gc-balance__label {
	flex: 1 0 100%;
	font-weight: 600;
}

.gc-redemption__button,
.gc-balance__button {
	min-height: 2.75rem;
	padding: 0.5em 1.1em;
	border: 1px solid var(--gc-accent, #1f2328);
	border-radius: var(--gc-radius, 8px);
	background: var(--gc-accent, #1f2328);
	color: var(--gc-accent-fg, #ffffff);
	font: inherit;
	cursor: pointer;
}

.gc-redemption__remove {
	background: none;
	border: 0;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.gc-redemption__applied {
	list-style: none;
	margin: 0 0 var(--gc-gap, 12px);
	padding: 0;
}

.gc-redemption__card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75em;
	padding: 0.5em 0;
	border-bottom: 1px solid var(--gc-border, #dfe3e8);
}

.gc-redemption__amount {
	font-variant-numeric: tabular-nums;
}

.gc-redemption__notice,
.gc-balance__result {
	margin: 0.5em 0 0;
}

.gc-account__note {
	color: var(--gc-muted, #5b6470);
	font-size: 0.9em;
}

/*
 * The printed card. Deliberately high-contrast and background-free: a printer
 * drops background colours by default, so anything that depends on one prints
 * as an empty box.
 */
.gc-print {
	border: 2px solid var(--gc-fg, #1f2328);
	border-radius: var(--gc-radius, 8px);
	padding: 1.5em;
	text-align: center;
}

.gc-print__value {
	margin: 0 0 0.5em;
	font-size: 2em;
	font-weight: 700;
}

.gc-print__code {
	margin: 0 0 0.75em;
	font-family: monospace;
	font-size: 1.3em;
	letter-spacing: 0.08em;
	word-break: break-all;
}

.gc-print__note,
.gc-print__message {
	margin: 0.25em 0 0;
	font-size: 0.9em;
}

.gc-redemption__input:focus-visible,
.gc-balance__input:focus-visible,
.gc-redemption__button:focus-visible,
.gc-balance__button:focus-visible {
	outline: 2px solid var(--gc-focus, #2563eb);
	outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
	.gc-form:not([data-gc-light]),
	.gc-redemption:not([data-gc-light]),
	.gc-balance:not([data-gc-light]),
	.gc-account:not([data-gc-light]) {
		--gc-fg: #e8eaed;
		--gc-muted: #a2abb6;
		--gc-bg: #16181c;
		--gc-panel: #1f2228;
		--gc-border: #343941;
		--gc-accent: #e8eaed;
		--gc-accent-fg: #16181c;
		--gc-focus: #7aa2f7;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gc-redemption,
	.gc-redemption * {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/*
 * The same field, drawn into the Cart and Checkout blocks.
 *
 * Deliberately almost no rules of its own: it reuses the class names above, so
 * there is one gift-card look rather than two that drift apart. Only the two
 * things the block context genuinely changes are set here - the name of an
 * applied card, which the classic markup does not print, and the summary
 * panel's own padding, which the field has to sit inside rather than beside.
 */
.gc-redemption--blocks {
	margin-top: var(--gc-gap, 12px);
}

.gc-redemption__name {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--gc-fg, #1f2328);
	overflow-wrap: anywhere;
}

/*
 * The form the redemption controls belong to, printed in the footer.
 *
 * It exists only because a supported placement -
 * `woocommerce_review_order_before_payment` - is inside WooCommerce's checkout
 * form, where a nested form tag is dropped by the parser. It holds nothing but
 * a nonce, so it must take up no room and must never be reached by a keyboard.
 */
.gc-redemption__owner {
	display: none;
}
