/* ══════════════════════════════════════════════════════════
   PRODUCT CHECKOUT
   ──────────────────────────────────────────────────────────
   Everything is scoped under .product-checkout on purpose.
   event-registration-and-checkout's module.css defines `.loader`,
   `.hsfc-ErrorAlert` and `body.checkout-loading` rules GLOBALLY, so an
   unscoped rule here would either be overwritten by it or would reach into
   its markup. Loading is a class on this module's own wrapper (.is-loading)
   rather than the shared body class for the same reason.

   ⚠ WIDTH, ALIGNMENT AND SPACING BELONG TO THE LAYOUT SETTINGS. The stage
   open_tag builds is already placed by Content width, aligned by Alignment
   and padded by Spacing — exactly as form.module relies on. Nothing in here
   may set a max-width, centre itself with margin-inline: auto, or add its own
   outer padding: until 2026-10-05 this file capped the checkout at 40rem,
   always centred it and added a second set of gutters, so every Content
   width looked the same and Alignment did nothing.
   ══════════════════════════════════════════════════════════ */

.product-checkout {
	position: relative;
	display: grid;
	gap: var(--molecule-large);
	width: 100%;
}

/* ── Layout ────────────────────────────────────────────────
   Billing form left, sticky order card right, once the stage has room
   (same 60rem stage threshold and ~22rem side column as event-detail).
   Stacked, the card comes first: what you are buying and the button
   before the fields. */

.product-checkout__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--molecule-large);
	align-items: start;
}

.product-checkout__aside { order: -1; }

@container stage (min-width: 60rem) {
	.product-checkout__layout {
		grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem);
		gap: var(--organism-tiny);
	}
	.product-checkout__aside {
		order: 0;
		position: sticky;
		top: calc(var(--mvs-sticky-top, 0px) + var(--molecule-tiny));
	}
}

@supports not (container-type: inline-size) {
	@media (min-width: 60rem) {
		.product-checkout__layout { grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem); }
		.product-checkout__aside { order: 0; }
	}
}

.product-checkout__main {
	display: grid;
	gap: var(--molecule-standard);
	min-width: 0;
}

/* Section heading over the form: the theme's heading face with the short
   brand bar used on the job listing page. */
.product-checkout__heading {
	position: relative;
	margin: 0;
	padding-top: var(--atom-large);
	font-family: var(--font-family-heading);
	font-size: clamp(1.5rem, 3cqi, 2rem);
	font-weight: 600;
	line-height: 1;
	text-transform: uppercase;
	color: var(--heading-color);
}

.product-checkout__heading::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	inline-size: 2.5rem;
	block-size: 3px;
	border-radius: 3px;
	background: var(--hs-primary);
}

/* The order card: one white surface holding the summary, the add-ons and
   the action, separated by hairlines. */
.product-checkout__card {
	display: grid;
	gap: var(--molecule-small);
	padding: var(--molecule-standard);
	background: var(--hs-white);
	border: 1px solid var(--hs-neutral--dark);
	border-radius: var(--global-radius-md);
	box-shadow: 0 1rem 2.5rem -1.5rem color-mix(in srgb, var(--hs-black) 30%, transparent);
}

.product-checkout__card > * + * {
	padding-top: var(--molecule-small);
	border-top: 1px solid var(--hs-neutral--dark);
}

/* ── Order summary ─────────────────────────────────────── */

/* The card supplies the surface, so the summary is just its content. */
.product-checkout__summary {
	display: grid;
	gap: var(--atom-standard);
}

.product-checkout__summary-label {
	margin: 0;
	color: var(--pre-title-color);
	font-size: var(--pre-title-size);
	font-weight: var(--pre-title-weight);
	line-height: var(--pre-title-line-height);
	letter-spacing: var(--pre-title-tracking);
	text-transform: var(--pre-title-transform);
}

.product-checkout__summary-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--molecule-standard);
	flex-wrap: wrap;
}

.product-checkout__summary-name {
	font-size: 1.125rem;
	font-weight: 700;
	color: var(--heading-color);
}

/* Tabular numerals so a price column stays aligned if this module is ever
   repeated down a page — same treatment portal.css gives .portal-table .num. */
.product-checkout__summary-price {
	font-family: var(--font-family-heading);
	font-size: clamp(1.75rem, 4cqi, 2.25rem);
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	line-height: 1;
	color: var(--hs-primary);
	white-space: nowrap;
}

.product-checkout__summary-note {
	margin: 0;
	color: var(--text-color-secondary);
	font-size: var(--font-size-sm);
}

/* "each" qualifier next to the unit price — only rendered when multiples are
   allowed, where a bare figure would read as the order total. */
.product-checkout__summary-each {
	color: var(--text-color-secondary);
	font-size: var(--font-size-sm);
	font-weight: 400;
}

/* ── Quantity ──────────────────────────────────────────────
   Present only when the editor allows more than one. Sits between the summary
   and the form so it reads as part of "what am I buying", not as one more
   field of the billing form it visually precedes. */

.product-checkout__quantity {
	display: flex;
	align-items: center;
	gap: var(--atom-large);
	flex-wrap: wrap;
}

.product-checkout__quantity-label {
	color: var(--form-label-color);
	font-weight: 600;
}

.product-checkout__quantity-input {
	width: 6rem;
	min-height: 50px;
	padding: var(--atom-standard) var(--atom-large);
	border: var(--form-border-width) solid var(--form-input-border-color);
	/* Same corners as the HubSpot fields beside it, not the pill radius. */
	border-radius: var(--form-border-radius);
	background: var(--form-input-background-color);
	color: var(--form-input-text-color);
	font-family: inherit;
	font-size: var(--form-font-size);
	font-variant-numeric: tabular-nums;
	line-height: var(--form-line-height);
}

.product-checkout__quantity-input:focus {
	outline: none;
	border-color: var(--form-input-border-color--focus);
	background: var(--form-input-background-color--focus);
}

/* Locked down with the form while a submission is in flight, and hidden once
   it has posted — the same two states the form itself takes. */
.product-checkout.is-loading .product-checkout__quantity-input {
	opacity: 0.8;
	pointer-events: none;
}

.product-checkout.is-complete .product-checkout__quantity { display: none; }

/* ── Donation ──────────────────────────────────────────────
   Standalone (the product IS the donation) renders .is-open from the server;
   an offered add-on gets it from its checkbox. A class rather than `hidden`
   so the display is decided here in one place. Same input treatment, and
   the same loading / complete states, as quantity above. */

.product-checkout__donation {
	display: grid;
	gap: var(--atom-large);
}

/* The offer reads as an optional extra: a soft brand-tinted tile inside
   the card, opening to the amount when ticked. */
.product-checkout__card > .product-checkout__donation {
	padding: var(--atom-large) var(--molecule-small);
	border: 1px solid color-mix(in srgb, var(--hs-primary) 25%, transparent);
	border-radius: var(--global-radius-sm);
	background: color-mix(in srgb, var(--hs-primary) 6%, var(--hs-white));
}

.product-checkout__donation-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--atom-standard);
	color: var(--form-label-color);
	font-weight: 600;
	cursor: pointer;
}

.product-checkout__donation-check {
	width: 1.125rem;
	height: 1.125rem;
	margin: 0;
	accent-color: var(--hs-primary);
}

.product-checkout__donation-amount { display: none; }

.product-checkout__donation.is-open .product-checkout__donation-amount {
	display: flex;
	align-items: center;
	gap: var(--atom-standard) var(--atom-large);
	flex-wrap: wrap;
}

.product-checkout__donation-label {
	color: var(--form-label-color);
	font-weight: 600;
}

.product-checkout__donation-field {
	display: inline-flex;
	align-items: center;
	gap: var(--atom-small);
}

.product-checkout__donation-currency {
	color: var(--text-color-secondary);
	font-weight: 600;
}

.product-checkout__donation-input {
	width: 8rem;
	min-height: 50px;
	padding: var(--atom-standard) var(--atom-large);
	border: var(--form-border-width) solid var(--form-input-border-color);
	/* Same corners as the HubSpot fields beside it, not the pill radius. */
	border-radius: var(--form-border-radius);
	background: var(--form-input-background-color);
	color: var(--form-input-text-color);
	font-family: inherit;
	font-size: var(--form-font-size);
	font-variant-numeric: tabular-nums;
	line-height: var(--form-line-height);
}

.product-checkout__donation-input:focus {
	outline: none;
	border-color: var(--form-input-border-color--focus);
	background: var(--form-input-background-color--focus);
}

.product-checkout__donation-input[aria-invalid="true"] {
	border-color: var(--form-error-color);
}

/* Full row under the label + field, so the minimum always reads as part of
   the amount rather than trailing beside it. */
.product-checkout__donation-note {
	flex-basis: 100%;
	margin: 0;
	color: var(--text-color-secondary);
	font-size: var(--font-size-sm);
}

.product-checkout.is-loading .product-checkout__donation input {
	opacity: 0.8;
	pointer-events: none;
}

.product-checkout.is-complete .product-checkout__donation { display: none; }

/* ── Submission zone ───────────────────────────────────── */

.product-checkout__submission {
	display: grid;
	gap: var(--molecule-standard);
	justify-items: stretch;
}

.product-checkout__submit {
	justify-content: center;
	width: 100%;
}

/* Error / status slot — module.js writes editor richtext into
   .product-checkout__alert-body, or empties the slot entirely. */
.product-checkout__alert:empty { display: none; }

.product-checkout__alert-body {
	padding: var(--atom-standard) var(--atom-large);
	border-radius: var(--global-radius-sm);
	color: var(--status-bad);
	background: var(--status-bad-soft);
	font-size: var(--font-size-sm);
}

.product-checkout__alert-body :first-child { margin-top: 0; }
.product-checkout__alert-body :last-child  { margin-bottom: 0; }

/* 404 — shown in place of the whole checkout when there's no product. Given
   a roomier treatment than the panel the restricted state uses: that one is
   a prompt to do something, this one is a dead end. Width and alignment come
   from the layout settings (see the top of this file). */
.product-checkout__notfound {
	padding: var(--organism-small) var(--molecule-large);
}

.product-checkout__notfound :first-child { margin-top: 0; }
.product-checkout__notfound :last-child  { margin-bottom: 0; }
.product-checkout__notfound a { color: var(--hs-primary); }

/* Members-only wall — shown in place of the whole checkout when there is
   nothing an anonymous visitor can buy on this page. */
.product-checkout__gate {
	padding: var(--molecule-standard) var(--molecule-large);
	background: var(--hs-white);
	border: 1px solid var(--hs-neutral--dark);
	border-radius: calc(var(--global-radius-md) / 2);
}

.product-checkout__gate :first-child { margin-top: 0; }
.product-checkout__gate :last-child  { margin-bottom: 0; }

.product-checkout__notice {
	color: var(--text-color-secondary);
}

/* ── Embedded HubSpot form ─────────────────────────────── */

/* The embed ships its own submit button — hidden, because
   .product-checkout__submit drives cart creation first and only then hands
   the form over. Letting the native button through would post the form with
   an empty cart ID. */
.product-checkout .hsfc-NavigationRow__Buttons .hsfc-Button[type="submit"] {
	display: none;
	visibility: hidden;
	pointer-events: none;
}

.product-checkout.is-loading form {
	opacity: 0.8;
	pointer-events: none;
	cursor: not-allowed;
}

/* A multi-page form moves on with HubSpot's own Next button; "Complete
   purchase" only appears on its last page. module.js sets the class — see
   frm__watchPages(). A class, not `hidden`: .mvsButton sets its own display. */
.product-checkout.is-before-last-page .product-checkout__submit { display: none; }

/* Once the form has posted there is nothing left to edit — the page is on
   its way to Stripe or the thank-you page. */
.product-checkout.is-complete .product-checkout__form,
.product-checkout.is-complete .product-checkout__submit {
	display: none;
}

/* ── Loading overlay ───────────────────────────────────── */

.product-checkout__loading { display: none; }

.product-checkout.is-loading .product-checkout__loading {
	display: flex;
	position: absolute;
	inset: 0;
	z-index: 1;
	align-items: center;
	justify-content: center;
	background-color: color-mix(in srgb, var(--hs-white) 85%, transparent);
}

/* Same two-dot spinner as the other checkout modules, scoped and with its
   own keyframe names so it can't collide with theirs. */
.product-checkout .loader {
	--color-1: var(--hs-primary);
	--color-2: var(--hs-secondary);
	--size: 1px;

	display: block;
	position: relative;
	box-sizing: border-box;
	width: calc(48 * var(--size));
	height: calc(48 * var(--size));
	margin: calc(15 * var(--size)) auto;
	color: var(--color-1);
	animation: product-checkout-rotation 1s linear infinite;
}

.product-checkout .loader::after,
.product-checkout .loader::before {
	content: '';
	box-sizing: border-box;
	position: absolute;
	top: 0;
	width: calc(24 * var(--size));
	height: calc(24 * var(--size));
	background-color: var(--color-1);
	border-radius: 50%;
	animation: product-checkout-scale50 1s infinite ease-in-out;
}

.product-checkout .loader::before {
	top: auto;
	bottom: 0;
	background-color: var(--color-2);
	animation-delay: 0.5s;
}

@keyframes product-checkout-rotation {
	0%   { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

@keyframes product-checkout-scale50 {
	0%, 100% { transform: scale(0); }
	50%      { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.product-checkout .loader,
	.product-checkout .loader::after,
	.product-checkout .loader::before {
		animation-duration: 3s;
	}
}
