/**
 * Pre-Checkout Gateway
 *
 * Typography is deliberately inherited from the active theme: no font-family is
 * declared anywhere except `inherit` on form controls, which browsers otherwise
 * reset. Only spacing, structure and neutral surfaces are defined here.
 */

.pcg-gateway {
	--pcg-accent: #111111;
	--pcg-accent-contrast: #ffffff;
	--pcg-surface: #f6f6f4;
	--pcg-text: #000000;
	--pcg-border: rgba(0, 0, 0, 0.12);
	--pcg-border-strong: rgba(0, 0, 0, 0.28);
	--pcg-muted: rgba(0, 0, 0, 0.58);
	--pcg-error: #b3261e;
	--pcg-success: #1f6b3b;
	--pcg-radius: 2px;
	/* Matches Uncode's pill buttons. Change to 2px for square buttons. */
	--pcg-btn-radius: 10em;
	--pcg-gap: 56px;

	box-sizing: border-box;
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 8px 0 56px;
}

.pcg-gateway *,
.pcg-gateway *::before,
.pcg-gateway *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- layout - */

.pcg-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
	gap: var(--pcg-gap);
	align-items: start;
}

.pcg-col {
	min-width: 0;
}

.pcg-col--auth {
	padding-right: 8px;
}

/* ----------------------------------------------------------------- forms - */

.pcg-heading {
	margin: 0 0 28px;
	font-size: 1.5em;
	line-height: 1.2;
	letter-spacing: 0.01em;
}

.pcg-panel[hidden] {
	display: none;
}

.pcg-form {
	max-width: 460px;
	margin: 0;
}

.pcg-field {
	margin: 0 0 22px;
}

.pcg-field label,
.pcg-coupon label {
	display: block;
	margin-bottom: 8px;
	font-size: 0.82em;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--pcg-muted);
}

.pcg-optional {
	text-transform: none;
	letter-spacing: 0;
	opacity: 0.75;
}

.pcg-gateway input[type="text"],
.pcg-gateway input[type="email"],
.pcg-gateway input[type="password"],
.pcg-gateway input[type="date"] {
	width: 100%;
	padding: 13px 14px;
	font: inherit;
	font-size: 1em;
	color: inherit;
	background: transparent;
	border: 1px solid var(--pcg-border);
	border-radius: var(--pcg-radius);
	transition: border-color 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.pcg-gateway input[type="text"]:focus,
.pcg-gateway input[type="email"]:focus,
.pcg-gateway input[type="password"]:focus,
.pcg-gateway input[type="date"]:focus {
	border-color: var(--pcg-border-strong);
	outline: 2px solid transparent;
	outline-offset: 2px;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.pcg-gateway .pcg-field.is-invalid input {
	border-color: var(--pcg-error);
}

.pcg-checkbox {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 26px;
	font-size: 0.95em;
	cursor: pointer;
}

.pcg-checkbox input {
	width: 16px;
	height: 16px;
	margin: 0;
	flex: 0 0 auto;
}

/* --------------------------------------------------------------- buttons - */

/*
 * Uncode styles buttons through
 *   body.uncode-btn-circle .btn:not(.btn-default-shape):not(.btn-round):not(.btn-square)
 * which scores (0,5,1) and beats a plain `.pcg-gateway .pcg-btn`. Colour and
 * shape are therefore declared with matching specificity plus !important, and
 * only on this plugin's buttons - nothing else on the site is affected.
 *
 * One state model for every button here:
 *   rest  = white fill, black text, black border
 *   hover = black fill, white text
 * The primary action keeps a heavier border so it still reads as primary.
 */

.pcg-actions {
	margin: 0 0 18px;
}

body .pcg-gateway .pcg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 100%;
	min-height: 50px;
	padding: 14px 28px;
	font: inherit;
	font-size: 0.9em;
	line-height: 1.2;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	text-align: center;
	white-space: normal;
	cursor: pointer;
	box-shadow: none;
	background-color: var(--pcg-btn-bg, #ffffff) !important;
	color: var(--pcg-btn-text, #000000) !important;
	border: 1px solid var(--pcg-accent) !important;
	border-radius: var(--pcg-btn-radius) !important;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Hover, focus and active all invert to the filled state. */
body .pcg-gateway .pcg-btn:hover,
body .pcg-gateway .pcg-btn:focus,
body .pcg-gateway .pcg-btn:active,
body .pcg-gateway .pcg-btn:focus-visible {
	background-color: var(--pcg-accent) !important;
	color: var(--pcg-accent-contrast) !important;
	border-color: var(--pcg-accent) !important;
}

/* Primary action: same colours, heavier edge. */
body .pcg-gateway .pcg-btn--primary {
	border-width: 2px !important;
}

/* Apply Discount sits inline beside the coupon field. */
body .pcg-gateway .pcg-btn--outline {
	width: auto;
	min-height: 46px;
	padding: 12px 22px;
	white-space: nowrap;
}

body .pcg-gateway .pcg-btn:focus-visible {
	outline: 2px solid var(--pcg-accent);
	outline-offset: 3px;
}

body .pcg-gateway .pcg-btn[disabled],
body .pcg-gateway .pcg-btn.is-busy {
	opacity: 0.55;
	cursor: default;
	pointer-events: none;
}

/* ----------------------------------------------------------------- links - */

.pcg-links {
	margin: 0 0 12px;
	font-size: 0.95em;
	color: var(--pcg-muted);
}

.pcg-links a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.pcg-links a:hover {
	color: var(--pcg-accent);
}

.pcg-divider {
	position: relative;
	margin: 28px 0;
	text-align: center;
}

.pcg-divider::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 1px;
	background: var(--pcg-border);
}

.pcg-divider span {
	position: relative;
	padding: 0 14px;
	font-size: 0.8em;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--pcg-muted);
	background: #fff;
}

/* ---------------------------------------------------------------- errors - */

.pcg-field-error,
.pcg-form-error {
	display: block;
	margin-top: 7px;
	font-size: 0.85em;
	color: var(--pcg-error);
}

.pcg-form-error {
	margin: 0 0 20px;
	padding: 12px 14px;
	border: 1px solid var(--pcg-error);
	border-radius: var(--pcg-radius);
}

.pcg-field-error[hidden],
.pcg-form-error[hidden],
.pcg-alert[hidden],
.pcg-coupon__message[hidden] {
	display: none;
}

.pcg-alert {
	margin: 0 0 24px;
	padding: 12px 16px;
	font-size: 0.95em;
	border: 1px solid var(--pcg-border);
	border-radius: var(--pcg-radius);
	background: var(--pcg-surface);
}

/* ------------------------------------------------------------ cart card - */

.pcg-cart {
	padding: 32px;
	background: var(--pcg-surface);
	border: 1px solid var(--pcg-border);
	border-radius: var(--pcg-radius);
}

.pcg-cart__title {
	margin: 0 0 24px;
	font-size: 1.05em;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.pcg-cart__items {
	margin: 0;
	padding: 0;
	list-style: none;
}

.pcg-cart__item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr) auto;
	gap: 16px;
	align-items: start;
	padding: 0 0 20px;
	margin: 0 0 20px;
	border-bottom: 1px solid var(--pcg-border);
}

.pcg-cart__item:last-child {
	margin-bottom: 0;
}

.pcg-cart__thumb img {
	display: block;
	width: 72px;
	height: 72px;
	object-fit: cover;
	border-radius: var(--pcg-radius);
}

.pcg-cart__details {
	display: flex;
	flex-direction: column;
	gap: 5px;
	font-size: 0.95em;
}

.pcg-cart__name {
	line-height: 1.35;
}

.pcg-cart__meta,
.pcg-cart__qty {
	font-size: 0.85em;
	color: var(--pcg-muted);
}

.pcg-cart__meta p {
	margin: 0;
}

.pcg-cart__meta dl,
.pcg-cart__meta dt,
.pcg-cart__meta dd {
	display: inline;
	margin: 0;
	padding: 0;
	font-weight: inherit;
}

.pcg-cart__meta dd::after {
	content: " ";
}

.pcg-cart__unit {
	margin-left: 6px;
}

.pcg-cart__price {
	white-space: nowrap;
	font-size: 0.95em;
}

.pcg-cart__totals {
	margin-top: 24px;
}

.pcg-cart__row {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 9px 0;
	font-size: 0.95em;
}

.pcg-cart__row--discount {
	color: var(--pcg-success);
}

.pcg-cart__coupon-label {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.pcg-cart__coupon-remove {
	padding: 0 4px;
	font: inherit;
	font-size: 1.1em;
	line-height: 1;
	color: inherit;
	background: none;
	border: 0;
	cursor: pointer;
	opacity: 0.6;
}

.pcg-cart__coupon-remove:hover {
	opacity: 1;
}

.pcg-cart__row--total {
	margin-top: 8px;
	padding-top: 16px;
	border-top: 1px solid var(--pcg-border-strong);
	font-size: 1.1em;
}

.pcg-cart__note {
	margin: 10px 0 0;
	font-size: 0.82em;
	color: var(--pcg-muted);
}

/* --------------------------------------------------------------- coupon - */

.pcg-coupon {
	margin-top: 26px;
	padding-top: 24px;
	border-top: 1px solid var(--pcg-border);
}

.pcg-coupon__row {
	display: flex;
	gap: 10px;
}

.pcg-coupon__row input {
	flex: 1 1 auto;
	min-width: 0;
	background: #fff;
}

.pcg-coupon__message {
	margin: 10px 0 0;
	font-size: 0.87em;
}

.pcg-coupon__message.is-error {
	color: var(--pcg-error);
}

.pcg-coupon__message.is-success {
	color: var(--pcg-success);
}

/* ------------------------------------------------------- resume / empty - */

.pcg-resume {
	margin: 0 0 32px;
	padding: 20px;
	border: 1px solid var(--pcg-border);
	border-radius: var(--pcg-radius);
}

.pcg-resume p {
	margin: 0 0 14px;
}

body .pcg-gateway .pcg-resume .pcg-btn {
	width: auto;
}

.pcg-empty {
	max-width: 520px;
	margin: 40px auto;
	text-align: center;
}

body .pcg-gateway .pcg-empty .pcg-btn {
	width: auto;
}

/* ------------------------------------------------------------- is-loading */

.pcg-cart-review.is-loading {
	opacity: 0.55;
	transition: opacity 0.15s ease;
}

.pcg-signedin {
	max-width: 460px;
}

.pcg-signedin__who {
	margin: 0 0 28px;
	font-size: 1em;
	line-height: 1.6;
	color: var(--pcg-text);
}

.pcg-signedin .pcg-links {
	color: var(--pcg-text);
}

/* --------------------------------------------------- auth column, black - */

/*
 * Everything in the login / register column is set in solid black. The cart
 * card on the right keeps its softer secondary greys.
 */

.pcg-col--auth,
.pcg-col--auth .pcg-heading,
.pcg-col--auth .pcg-field label,
.pcg-col--auth .pcg-checkbox,
.pcg-col--auth .pcg-checkbox span,
.pcg-col--auth .pcg-optional,
.pcg-col--auth .pcg-links,
.pcg-col--auth .pcg-links a,
.pcg-col--auth .pcg-divider span,
.pcg-col--auth .pcg-resume p,
.pcg-gateway input[type="text"],
.pcg-gateway input[type="email"],
.pcg-gateway input[type="password"],
.pcg-gateway input[type="date"] {
	color: var(--pcg-text);
}

.pcg-col--auth .pcg-links a {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.pcg-col--auth .pcg-links a:hover {
	opacity: 0.7;
}

.pcg-gateway ::placeholder {
	color: rgba(0, 0, 0, 0.45);
	opacity: 1;
}

/* ---------------------------------------------------------- breakpoints - */

@media (max-width: 1024px) {
	.pcg-gateway {
		--pcg-gap: 32px;
	}

	.pcg-grid {
		grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
	}

	.pcg-cart {
		padding: 24px;
	}

	.pcg-col--auth {
		padding-right: 0;
	}
}

@media (max-width: 782px) {
	.pcg-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 40px;
	}

	/* Order is already form first, cart second in the DOM. */
	.pcg-form {
		max-width: none;
	}

	.pcg-gateway {
		padding-bottom: 40px;
	}
}

@media (max-width: 480px) {
	.pcg-cart {
		padding: 20px 18px;
	}

	.pcg-cart__item {
		grid-template-columns: 60px minmax(0, 1fr) auto;
		gap: 12px;
	}

	.pcg-cart__thumb img {
		width: 60px;
		height: 60px;
	}

	.pcg-coupon__row {
		flex-direction: column;
	}

	body .pcg-gateway .pcg-btn--outline {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pcg-gateway * {
		transition: none !important;
	}
}
