/*
 * The popup ships with the widget (D-012): no Handy Lightbox, no Elementor Pro
 * Popup template, nothing that can be deactivated out from under a buy button.
 *
 * Everything is scoped under .aio-occ and every colour that an editor can change
 * is a custom property, so the Elementor style controls set one value rather
 * than overriding a rule.
 *
 * Every rule that styles a <p> carries a second class. Elementor ships
 * `.elementor-element p { font-size: inherit; font-weight: inherit }`, and a
 * single class loses to it: the test banner, the price and the footnote all
 * rendered at the theme's 20px body size, unweighted, until this was done.
 */

.aio-occ {
	--aio-occ-accent: currentColor;
	--aio-occ-surface: #fff;
	--aio-occ-overlay: rgba(0, 0, 0, 0.6);
	--aio-occ-ink: #333;
	--aio-occ-muted: #6b6b6b;
	--aio-occ-line: #d8d8d8;
	--aio-occ-error: #b3261e;
}

.aio-occ__trigger-wrap {
	display: flex;
	flex-direction: column;
}

/* No appearance of its own: the global button style is meant to show through. */
.aio-occ__trigger {
	cursor: pointer;
}

/*
 * The <dialog> itself, stretched to the viewport so the panel inside it can be
 * centred with margin:auto. No align-items/justify-content on purpose: centring
 * a flex item taller than the viewport clips its top off, and the top of this
 * one is the heading.
 *
 * z-index is set for the fallback path only. A dialog opened with showModal()
 * is in the top layer, where z-index does not apply and nothing on the page can
 * paint over it.
 */
.aio-occ__overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	padding: 1rem;
	border: 0;
	background: transparent;
	overflow-y: auto;
}

.aio-occ__overlay:not([open]) {
	display: none;
}

.aio-occ__overlay[open] {
	display: flex;
}

/*
 * The fallback value matters: ::backdrop only inherits custom properties from
 * its own element in browsers from 2024 onwards, so older ones take this.
 */
.aio-occ__overlay::backdrop {
	background: var(--aio-occ-overlay, rgba(0, 0, 0, 0.6));
}

.aio-occ__dialog {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 26rem;
	margin: auto;
	padding: 2rem 1.75rem 1.5rem;
	border-radius: 6px;
	background: var(--aio-occ-surface);
	color: var(--aio-occ-ink);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	font-size: 1rem;
	line-height: 1.5;
	text-align: left;
}

/* Room to spare on a desktop: wider, so the popup is shorter. */
@media (min-width: 768px) {
	.aio-occ__dialog {
		max-width: 34rem;
		padding: 2.25rem 2.25rem 1.75rem;
	}
}

.aio-occ__close {
	position: absolute;
	top: 0.35rem;
	right: 0.6rem;
	padding: 0.2rem 0.4rem;
	border: 0;
	background: none;
	color: var(--aio-occ-muted);
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.aio-occ__heading {
	margin: 0 0 0.75rem;
	font-size: 1.35rem;
	line-height: 1.25;
}

.aio-occ .aio-occ__course {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.35;
}

.aio-occ .aio-occ__price {
	margin: 0.15rem 0 0.75rem;
	color: var(--aio-occ-accent);
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.2;
}

.aio-occ .aio-occ__intro {
	margin: 0 0 1rem;
	color: var(--aio-occ-muted);
	font-size: 0.95rem;
	line-height: 1.5;
}

/* A rule between what is being bought and what the buyer has to do about it. */
.aio-occ__form {
	padding-top: 1rem;
	border-top: 1px solid var(--aio-occ-line);
}

.aio-occ__field {
	display: block;
	margin-bottom: 0.85rem;
}

.aio-occ__label {
	display: block;
	margin-bottom: 0.25rem;
	font-size: 0.85rem;
	font-weight: 600;
}

.aio-occ__field input {
	box-sizing: border-box;
	width: 100%;
	padding: 0.6rem 0.7rem;
	border: 1px solid var(--aio-occ-line);
	border-radius: 4px;
	font: inherit;
	line-height: 1.3;
}

.aio-occ__field input:focus {
	border-color: var(--aio-occ-accent);
	outline: 2px solid var(--aio-occ-accent);
	outline-offset: 1px;
}

.aio-occ__field--invalid input {
	border-color: var(--aio-occ-error);
}

/*
 * D-085: the buyer-chosen amount. Slightly larger than the contact fields —
 * it is the number the buyer is agreeing to pay — with the allowed range
 * (or, when the amount is wrong, the reason Pay is off) straight beneath it.
 */
.aio-occ__field--amount {
	margin-bottom: 0.3rem;
}

.aio-occ__field--amount input {
	font-size: 1.15rem;
	font-weight: 600;
}

.aio-occ .aio-occ__amount-hint {
	margin: 0 0 0.85rem;
	color: var(--aio-occ-muted);
	font-size: 0.85rem;
	line-height: 1.45;
}

.aio-occ .aio-occ__amount-hint--invalid {
	color: var(--aio-occ-error);
}

/*
 * A field's help line (this project's D-004), straight under its box — or,
 * on the amount, under the range hint. The negative top margin collapses with
 * the 0.85rem below the box or hint, leaving a small gap above the help and
 * the usual space before the next box.
 */
.aio-occ .aio-occ__help {
	margin: -0.6rem 0 0.85rem;
	color: var(--aio-occ-muted);
	font-size: 0.85rem;
	line-height: 1.45;
}

/* Off-screen rather than display:none — some bots skip hidden inputs. */
.aio-occ__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.aio-occ .aio-occ__error {
	margin: 0 0 0.75rem;
	color: var(--aio-occ-error);
	font-size: 0.9rem;
	line-height: 1.45;
}

.aio-occ__error[hidden] {
	display: none;
}

.aio-occ__submit {
	width: 100%;
	cursor: pointer;
}

.aio-occ__submit[disabled] {
	opacity: 0.6;
	cursor: progress;
}

/*
 * What the popup says once the form has done its job: the duplicate-purchase
 * warning (D-011), the wait while a payment is confirmed, and the result
 * message that carries Kajabi's answer before the thank-you page loads (D-006).
 *
 * A boxed callout, so it reads as the popup speaking rather than as one more
 * line of the course description above it.
 */
.aio-occ__status {
	padding: 1rem 1.1rem;
	border: 1px solid var(--aio-occ-line);
	border-left: 4px solid var(--aio-occ-accent);
	border-radius: 4px;
	background: #f6f7f9;
}

.aio-occ__status[hidden] {
	display: none;
}

.aio-occ .aio-occ__status-message {
	margin: 0;
	color: var(--aio-occ-ink);
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.5;
}

.aio-occ__status-actions {
	margin-top: 1rem;
}

.aio-occ__status-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.aio-occ__status-action {
	flex: 1 1 auto;
	padding: 0.6rem 1rem;
	border: 1px solid var(--aio-occ-line);
	border-radius: 4px;
	background: var(--aio-occ-surface);
	color: inherit;
	font: inherit;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.aio-occ__status-action--primary {
	border-color: var(--aio-occ-accent);
	color: var(--aio-occ-accent);
	font-weight: 600;
}

.aio-occ__form[hidden] {
	display: none;
}

.aio-occ .aio-occ__footnote {
	margin: 1.25rem 0 0;
	padding-top: 0.9rem;
	border-top: 1px solid var(--aio-occ-line);
	color: var(--aio-occ-muted);
	font-size: 0.8rem;
	line-height: 1.45;
}

/*
 * D-009's second signpost: a button in test mode is unmistakable on the live
 * page, not only in the editor. Deliberately loud and deliberately not themed —
 * an editor's Elementor style controls reach the button and the popup, never
 * this, so a test button cannot be styled back into looking like a real one.
 *
 * Colours are literal rather than custom properties for the same reason.
 */
.aio-occ .aio-occ__test-flag,
.aio-occ .aio-occ__test-banner {
	display: block;
	box-sizing: border-box;
	margin: 0 0 0.6rem;
	padding: 0.55rem 0.7rem;
	border: 2px solid #8a5a00;
	border-radius: 4px;
	background: repeating-linear-gradient(
		135deg,
		#fff4d6,
		#fff4d6 10px,
		#ffe9b3 10px,
		#ffe9b3 20px
	);
	color: #5a3c00;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.45;
	text-align: left;
}

.aio-occ .aio-occ__test-banner {
	margin: 0 0 1rem;
}

.aio-occ__test-tag {
	display: inline-block;
	margin-right: 0.45rem;
	padding: 0.1rem 0.4rem;
	border-radius: 3px;
	background: #8a5a00;
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	vertical-align: baseline;
}

.aio-occ__placeholder,
.aio-occ__editor-warning {
	padding: 1rem;
	border: 1px dashed var(--aio-occ-line, #d8d8d8);
	border-radius: 4px;
	color: #6b6b6b;
	font-size: 0.9rem;
}

/* Editor only: a payment button missing a required field (D-087). */
.aio-occ__placeholder--error {
	border: 2px solid #b32d2e;
	background: #fcf0f1;
	color: #8a1f1f;
}

.aio-occ__placeholder--error ul {
	margin: 0.5rem 0 0 1.2rem;
	padding: 0;
}

.aio-occ--open-lock {
	overflow: hidden;
}

@media (max-width: 480px) {
	.aio-occ__dialog {
		padding: 1.75rem 1.1rem 1.25rem;
	}
}
