/*
 * Gift card product form. Inherits the theme's typography and inputs; the choice buttons follow
 * WoodMart's text swatches (size buttons on variable products) through the theme's CSS variables,
 * with the site accent (Add to cart colour) for hover and the selected choice. The fallbacks are
 * for other themes.
 */
.odgc-form {
	--odgc-accent: var(--wd-primary-color, var(--btn-accented-bgcolor, #d2a66c));
	--odgc-accent-text: var(--btn-accented-color, #fff);
	--odgc-title: var(--wd-title-color, #242424);
	--odgc-error: #d0021b;

	align-items: start;
	container-type: inline-size;
	display: grid;
	gap: 15px 20px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	margin: 0 0 20px;
	width: 100%;
}

.odgc-form > * {
	grid-column: 1 / -1;
}

/* Side by side when the summary is wide enough: name + email, From + delivery date. */
@container (min-width: 420px) {
	.odgc-form > :is(.odgc-field--recipient-name, .odgc-field--recipient-email, .odgc-field--sender-name, .odgc-field--delivery-date) {
		grid-column: auto;
	}
}

.odgc-form fieldset {
	border: 0;
	margin: 0;
	min-width: 0;
	padding: 0;
}

.odgc-form p {
	margin: 0;
}

/* Like the attribute labels of variable products ("Size:"). */
.odgc-form legend,
.odgc-form .odgc-field > label {
	color: var(--odgc-title);
	display: block;
	float: none;
	font-family: inherit;
	font-size: inherit;
	font-weight: 600;
	letter-spacing: normal;
	line-height: 1.4;
	margin: 0 0 5px;
	padding: 0;
	text-transform: none;
	width: auto;
}

.odgc-form .odgc-field > label {
	font-size: 0.9em;
}

.odgc-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* WoodMart text swatch, style 4 (wd-text-style-4). */
.odgc-form .odgc-choice {
	align-items: center;
	background-color: transparent;
	border: 1px solid var(--wd-swatch-brd-color, var(--brdcolor-gray-200, rgba(0, 0, 0, 0.1)));
	border-radius: var(--wd-brd-radius, 0);
	color: var(--color-gray-900, #242424);
	cursor: pointer;
	display: inline-flex;
	font-size: 14px;
	font-weight: 600;
	justify-content: center;
	line-height: 1.2;
	margin: 0;
	min-height: 30px;
	min-width: 30px;
	padding: 5px 10px;
	position: relative;
	text-align: center;
	transition: 0.25s;
}

.odgc-form .odgc-choice .woocommerce-Price-amount {
	color: inherit;
	font-weight: inherit;
}

/* Real radio, visually hidden: keeps keyboard and screen reader behaviour. */
.odgc-form .odgc-choice input {
	height: 1px;
	left: 0;
	margin: 0;
	opacity: 0;
	pointer-events: none;
	position: absolute;
	top: 0;
	width: 1px;
}

.odgc-form .odgc-choice:has(input:checked) {
	background-color: var(--odgc-accent);
	border-color: var(--odgc-accent);
	color: var(--odgc-accent-text);
}

@media (hover: hover) {
	.odgc-form .odgc-choice:hover {
		border-color: var(--odgc-accent);
	}
}

.odgc-form .odgc-choice:has(input:focus-visible) {
	outline: 2px solid var(--odgc-title);
	outline-offset: 2px;
}

/* The only delivery option of a format (physical: post to the buyer): checked, posted, not shown. */
.odgc-form .odgc-choice--sole {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
}

/* The fixed delivery note then sits right under the "Delivery" label. */
.odgc-form .odgc-choices:not(:has(.odgc-choice:not(.odgc-choice--sole):not([hidden]))) {
	display: none;
}

.odgc-form .odgc-help--delivery {
	font-size: 0.9em;
	opacity: 1;
}

/* Browsers without :has() keep the native radio. */
@supports not selector(:has(*)) {
	.odgc-form .odgc-choice {
		gap: 0.4rem;
	}

	.odgc-form .odgc-choice input {
		height: auto;
		opacity: 1;
		pointer-events: auto;
		position: static;
		width: auto;
	}
}

.odgc-form [hidden] {
	display: none !important;
}

.odgc-form input.input-text,
.odgc-form textarea {
	width: 100%;
}

.odgc-form textarea {
	height: auto;
	min-height: 0;
	resize: vertical;
}

/* "Other amount": a short number field with the currency inside, right under the amount buttons. */
.odgc-custom-amount {
	margin-top: 10px;
}

.odgc-custom-amount__box {
	display: inline-block;
	max-width: 100%;
	position: relative;
	width: 160px;
}

/* Same inner padding as the theme's text inputs (WoodMart: 0 15px), room on the right for "€". */
.odgc-form .odgc-custom-amount input.input-text {
	-moz-appearance: textfield;
	appearance: textfield;
	padding: 0 32px 0 15px;
	text-align: left;
}

.odgc-form .odgc-custom-amount--invalid input.input-text,
.odgc-form .odgc-custom-amount--invalid input.input-text:focus {
	border-color: var(--odgc-error);
}

.odgc-form .odgc-error {
	color: var(--odgc-error);
	opacity: 1;
}

.odgc-form .odgc-error:empty {
	display: none;
}

/* Add to cart while the "Other amount" is invalid. */
form.cart:has([data-odgc-form]) .single_add_to_cart_button:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.odgc-form .odgc-custom-amount input::-webkit-inner-spin-button,
.odgc-form .odgc-custom-amount input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.odgc-custom-amount__currency {
	color: var(--odgc-title);
	pointer-events: none;
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
}

.odgc-custom-amount .screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	overflow: hidden;
	position: absolute;
	width: 1px;
}

.odgc-help,
.odgc-counter {
	display: block;
	font-size: 0.8em;
	line-height: 1.4;
	margin-top: 5px;
	opacity: 0.75;
}

/* Helper lines under the choice buttons and the amount field: one small gap above each. */
.odgc-form fieldset .odgc-help {
	margin-top: 6px;
}

.odgc-counter {
	margin-top: 3px;
	text-align: right;
}

.odgc-form .optional {
	font-weight: 400;
	opacity: 0.7;
}
