/**
 * Gravity Forms Stripe Card field — dark-theme presentation.
 *
 * Enqueued by inc/extensions/gravity-forms-stripe.php on pages whose form has
 * a Stripe Card field (Donation form 5, Registration Payments form 4).
 *
 * Mirrors the floating-label inputs from src/scss/view/components/forms.scss:
 * 64px boxes, 1px border, small uppercase label pinned top-left inside the
 * box, value underneath. The theme's own rules float labels with a JS-driven
 * class that doesn't reach the Stripe field's sub-containers, so here the
 * sub-labels are simply pinned in their "has value" position. The Stripe
 * iframe's own text colours are set from PHP (gform_stripe_elements_style).
 *
 * Plain (un-nested) selectors on purpose: this is a payment page and nested
 * CSS would be dropped wholesale by older browsers. The long prefix is there
 * to out-rank the theme's
 * `.gform_wrapper.gravity-theme .gfield:not(...) label:first-of-type` rules.
 */

/* Main "Credit Card" label: a plain heading above the two boxes. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .gfield_label_before_complex {
	position: static !important;
	display: block;
	margin: 0 0 .5rem !important;
	transform: none !important;
	pointer-events: auto;
	color: var(--wp--custom--form--field--label--color) !important;
}

/* The two boxes, stacked with the same gap as the rest of the form. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard {
	display: flex;
	flex-direction: column;
	gap: var(--wp--custom--form--field--spacing, 1rem);
	margin: 0;
}

.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard > .ginput_full {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
}

/* Sub-labels ("Card Details", "Cardholder Name"): pinned top-left inside the box. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard label.gform-field-label--type-sub {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 3;
	margin: 0;
	transform: translate(9px, 9px) scale(.74);
	transform-origin: top left;
	white-space: nowrap;
	pointer-events: none;
	color: var(--wp--custom--form--field--label--color);
	transition: color .2s ease;
}

/* Stripe Elements mount point: same box as the neighbouring inputs. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--card {
	display: flex;
	flex-direction: column;
	justify-content: center;
	box-sizing: border-box;
	width: 100%;
	min-height: var(--wp--custom--form--field--min-height, 64px);
	padding: 20px 9px 0;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--form--field--radius, 0);
	background: var(--wp--custom--form--field--background-color, transparent);
	box-shadow: none;
	transition: var(--wp--custom--form--field--transition);
}

.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--card:hover {
	background: var(--wp--custom--form--field--background-color, transparent);
}

.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--card.StripeElement--focus {
	border-color: var(--wp--custom--form--field--focus--border-color);
	box-shadow: var(--wp--custom--form--field--focus--box-shadow);
}

.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--card.StripeElement--invalid {
	border-color: var(--wp--custom--form--field--error--color);
}

/* Cardholder Name text input lines up with the Stripe box and the other fields. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard input[type="text"] {
	padding-left: 9px !important;
}

/* Label picks up the focus / error colour like the floating labels do. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--focus + label.gform-field-label--type-sub,
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard input:focus + label.gform-field-label--type-sub {
	color: var(--wp--custom--form--field--border--focus);
}

.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .ginput_container_creditcard .StripeElement--invalid + label.gform-field-label--type-sub {
	color: #FF6B6B; /* Lighter than the theme's error red so the small label reads on dark. */
}

/* Stripe's inline error ("Your card number is incomplete."). The theme's generic
   .validation_message rule is sized for a one-line icon (width: 1.5em), which
   wraps this message one letter per line, and Gravity Forms adds a pale pink
   box, so reset the box and use a colour that reads on the dark form. */
.gform_wrapper.gravity-theme.gform-theme--no-framework .gfield--type-stripe_creditcard .validation_message.gfield_validation_message {
	width: auto;
	max-width: 100%;
	height: auto;
	min-height: 0;
	margin: .5rem 0 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	font-size: .8125rem;
	line-height: 1.4;
	color: #FF6B6B;
	white-space: normal;
}
