/**
 * Moon Magic Diary — Checkout styling
 * File: assets/css/mmd-checkout.css
 *
 * Uses the same Moon Magic Design System tokens as mmd-diary.css (Bricks
 * global CSS variables with hex fallbacks), scoped to .mmd-purchase.
 *
 * Now designed to live inside a Bricks modal/off-canvas element rather
 * than embedded directly in the page, so sizing here is deliberately in
 * absolute px rather than rem: a modal can end up nested somewhere with a
 * root font-size this component has no control over, and px sizing keeps
 * it predictable regardless of that context.
 *
 * CRITICAL: every text/email/password input's font-size MUST be 16px or
 * larger. iOS Safari auto-zooms the whole page on focus for any input
 * below that, which is exactly what's being avoided here, don't shrink
 * these below 16px even if a future tweak wants things more compact.
 */

.mmd-purchase {
	--mmd-font-display: 'Montserrat', sans-serif;
	--mmd-font-body: 'Jost', sans-serif;
	font-family: var(--mmd-font-body);
	font-size: 16px;
	max-width: 480px;
	margin: 0 auto;
	color: var(--deep-indigo, #2E2A6E);
}

.mmd-purchase--error p,
.mmd-purchase--owned .mmd-purchase__notice {
	padding: 18px 20px;
	background: var(--lavender-mist, #F0EEF8);
	border-radius: 12px;
	color: var(--deep-indigo, #2E2A6E);
	font-size: 17px;
	line-height: 1.5;
}
.mmd-purchase--owned .mmd-purchase__notice a {
	color: var(--soft-violet, #7B5AAC);
	font-weight: 600;
}

/* ---------------- cards ---------------- */

.mmd-purchase__card {
	background: var(--white, #FFFFFF);
	border: 1px solid var(--panel-border, rgba(46, 42, 110, 0.15));
	border-radius: 14px;
	padding: 24px;
	margin-bottom: 16px;
}

.mmd-purchase__label {
	font-family: var(--mmd-font-display);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--soft-violet, #7B5AAC);
	margin: 0 0 16px;
}

/* ---------------- order summary ---------------- */

.mmd-purchase__row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	font-size: 18px;
}
.mmd-purchase__row span:last-child {
	font-family: var(--mmd-font-display);
	font-weight: 700;
	font-size: 28px;
}

.mmd-purchase__link {
	display: inline-block;
	background: none;
	border: none;
	padding: 0;
	margin-top: 10px;
	font-family: var(--mmd-font-body);
	font-size: 15px;
	font-weight: 500;
	color: var(--soft-violet, #7B5AAC);
	text-decoration: underline;
	cursor: pointer;
}

.mmd-purchase__voucher {
	display: flex;
	gap: 10px;
	margin-top: 14px;
}
/* Author stylesheets always beat the browser's own [hidden] rule, even
   at equal specificity, so setting display:flex above silently defeats
   the hidden attribute unless it's restored explicitly here. This is
   why the voucher fields were showing by default instead of staying
   hidden until "Have a code?" is clicked. */
.mmd-purchase__voucher[hidden] {
	display: none;
}
.mmd-purchase__voucher input[type="text"] {
	flex: 1;
	min-width: 0;
}
.mmd-purchase__voucher-msg {
	font-size: 15px;
	margin: 8px 0 0;
	min-height: 1.2em;
}
.mmd-purchase__voucher-msg.is-success {
	color: var(--teal, #3E8F8A);
}
.mmd-purchase__voucher-msg.is-error {
	color: var(--warning, #e24b4a);
}
.mmd-purchase__voucher-msg a {
	color: inherit;
	text-decoration: underline;
	font-weight: 600;
}

/* ---------------- form fields ---------------- */

.mmd-purchase__fields {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-bottom: 18px;
}
.mmd-purchase__field--full {
	grid-column: 1 / -1;
}
.mmd-purchase__field label {
	display: block;
	font-size: 15px;
	font-weight: 500;
	color: var(--deep-indigo-75, #625F92);
	margin-bottom: 6px;
}

.mmd-purchase input[type="text"],
.mmd-purchase input[type="email"],
.mmd-purchase input[type="password"] {
	width: 100%;
	box-sizing: border-box;
	font-family: var(--mmd-font-body);
	font-size: 17px; /* iOS zoom threshold is 16px, staying a point above it on purpose */
	line-height: 1.4;
	padding: 14px 16px;
	border: 1px solid var(--panel-border, rgba(46, 42, 110, 0.15));
	border-radius: 10px;
	background: var(--page-background, #FAFAFD);
	color: var(--deep-indigo, #2E2A6E);
}
.mmd-purchase input:focus {
	outline: none;
	border-color: var(--soft-violet, #7B5AAC);
	border-width: 2px;
	padding: 13px 15px; /* compensate for the thicker border so focus doesn't shift layout */
}

.mmd-purchase input.is-error {
	border-color: var(--warning, #e24b4a);
	border-width: 2px;
	padding: 13px 15px; /* same compensation as :focus, so the red outline doesn't shift layout either */
}

.mmd-purchase__checkbox {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--deep-indigo-75, #625F92);
	margin-bottom: 14px;
	cursor: pointer;
}
.mmd-purchase__checkbox input {
	width: 20px;
	height: 20px;
	margin-top: 1px;
	flex-shrink: 0;
	accent-color: var(--soft-violet, #7B5AAC);
}
.mmd-purchase__checkbox a {
	color: var(--soft-violet, #7B5AAC);
}
.mmd-purchase__checkbox.is-error {
	color: var(--warning, #e24b4a);
}

/* Billing-name note above the PayPal buttons, so buyers recognise the
   company name on their card/bank statement. */
.mmd-purchase__statement-note {
	margin: 0 0 18px;
	padding: 12px 14px;
	background: var(--lavender-mist, #F0EEF8);
	border-radius: 8px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--deep-indigo, #2E2A6E);
}
.mmd-purchase__statement-note strong {
	font-weight: 600;
}

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

.mmd-purchase__btn {
	font-family: var(--mmd-font-body);
	font-weight: 600;
	font-size: 17px;
	border-radius: 24px;
	padding: 15px 28px;
	border: 1px solid var(--panel-border, rgba(46, 42, 110, 0.15));
	background: transparent;
	color: var(--deep-indigo, #2E2A6E);
	cursor: pointer;
	transition: all 0.15s ease;
}
.mmd-purchase__btn--primary {
	background: var(--teal, #3E8F8A);
	border-color: var(--teal, #3E8F8A);
	color: var(--white, #FFFFFF);
}
.mmd-purchase__btn--primary:hover {
	background: color-mix(in srgb, var(--teal, #3E8F8A) 85%, black);
}
.mmd-purchase__btn--ghost {
	border-color: transparent;
	background: var(--lavender-mist, #F0EEF8);
	color: var(--deep-indigo, #2E2A6E);
	padding: 15px 20px;
}
.mmd-purchase__btn--ghost:hover {
	background: var(--soft-violet-50, #BDACD5);
}
.mmd-purchase__btn--full {
	display: block;
	width: 100%;
	text-align: center;
	text-decoration: none;
	box-sizing: border-box;
}
.mmd-purchase__btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ---------------- success state ---------------- */

.mmd-purchase__card--success {
	text-align: center;
	background: var(--lavender-mist, #F0EEF8);
	border-color: transparent;
}
.mmd-purchase__success-title {
	font-family: var(--mmd-font-display);
	font-size: 26px;
	font-weight: 700;
	color: var(--deep-indigo, #2E2A6E);
	margin: 0 0 8px;
}
.mmd-purchase__card--success p {
	font-size: 17px;
	line-height: 1.5;
	margin: 0 0 18px;
	color: var(--deep-indigo-75, #625F92);
}

/* ---------------- messages ---------------- */

.mmd-purchase__message {
	font-size: 15px;
	text-align: center;
	min-height: 1.3em;
	margin-top: 6px;
	line-height: 1.5;
}
.mmd-purchase__message a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
}
#mmd-register-message {
	margin-top: 14px;
}
.mmd-purchase__message.is-error {
	color: var(--warning, #e24b4a);
}
.mmd-purchase__message.is-success {
	color: var(--teal, #3E8F8A);
}
.mmd-purchase__message.is-info {
	color: var(--deep-indigo-75, #625F92);
}

/* Payment-stage message (#mmd-purchase-message). It sits inside the white
   payment card, under the PayPal buttons, so it is always on white rather than
   on whatever the page background happens to be. Errors are a proper alert
   box (dark red text on a pale red fill, well past the contrast needed for
   small text) instead of thin red text. The id selector deliberately beats
   the generic .mmd-purchase__message rules above, which the registration
   message inside the details card still uses unchanged. */
#mmd-purchase-message {
	margin: 18px 0 0;
	min-height: 0;
	text-align: left;
	font-size: 16px;
	line-height: 1.5;
	border-radius: 10px;
}
#mmd-purchase-message:empty {
	display: none;
}
#mmd-purchase-message.is-error,
#mmd-purchase-message.is-info,
#mmd-purchase-message.is-success {
	padding: 14px 16px;
}
#mmd-purchase-message.is-error {
	background: #FDECEA;
	border: 1px solid #E8B9B5;
	border-left: 4px solid #B3261E;
	color: #7A1712;
	font-weight: 500;
}
#mmd-purchase-message.is-info {
	background: var(--lavender-mist, #F0EEF8);
	color: var(--deep-indigo, #2E2A6E);
}
#mmd-purchase-message.is-success {
	background: #E8F4F3;
	color: #1F5E5A;
}
.mmd-purchase__ref {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	font-weight: 400;
	letter-spacing: 0.01em;
}

/* ---------------- responsive ---------------- */

@media (max-width: 480px) {
	.mmd-purchase__fields {
		grid-template-columns: 1fr;
	}
	.mmd-purchase__card {
		padding: 20px;
	}
}
