/**
 * Framed Minds Pact - Frontend Styles
 *
 * Tokens, palette, and accessibility per Framed Minds Course Creation
 * Constitution v1.3, Appendix A (palette) and Appendix B (accessibility).
 *
 * - WCAG AA contrast (#151515 body text on light surfaces)
 * - Touch targets >= 44x44px
 * - Mobile readability at 390px width
 * - No body text on #96CA42 (active accent only)
 */

:root {
	--fm-text:         #151515;
	--fm-bg:           #FFFFFF;
	--fm-warm-surface: #F4F1E8;
	--fm-border:       #E7EAED;
	--fm-cta:          #BCCF97;
	--fm-cta-hover:    #A8BC85;
	--fm-cta-active:   #96CA42;
	--fm-deep:         #0E1A27;
	--fm-muted:        #6B6B6B;
	--fm-error-bg:     #FEF2F2;
	--fm-error-border: #FCA5A5;
	--fm-error-text:   #991B1B;
}

body.fm-pact-body {
	margin: 0;
	padding: 0;
	background: var(--fm-warm-surface);
	color: var(--fm-text);
	font-family: 'Avenir', 'Avenir Next', 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 17px;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	-webkit-tap-highlight-color: transparent;
	-webkit-text-size-adjust: 100%;
}

.fm-pact-stage {
	min-height: 100vh;
	min-height: 100dvh; /* iOS app WebView - account for dynamic viewport */
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 48px 20px 80px;
	box-sizing: border-box;
}

.fm-pact-container {
	width: 100%;
	max-width: 640px;
	background: var(--fm-bg);
	border: 1px solid var(--fm-border);
	border-radius: 4px;
	padding: 56px 48px;
	box-sizing: border-box;
	box-shadow: 0 4px 24px rgba(14, 26, 39, 0.04);
}

/* Header */

.fm-pact-header {
	text-align: center;
	margin-bottom: 40px;
}

.fm-pact-logo {
	max-width: 140px;
	height: auto;
	display: inline-block;
}

/* Article body */

.fm-pact-article {
	margin-bottom: 40px;
}

.fm-pact-title {
	font-family: 'Avenir', 'Avenir Next', 'Work Sans', sans-serif;
	font-weight: 600;
	font-size: 32px;
	line-height: 1.2;
	color: var(--fm-deep);
	margin: 0 0 8px;
	text-align: center;
	letter-spacing: -0.01em;
}

.fm-pact-subtitle {
	text-align: center;
	color: var(--fm-muted);
	font-size: 16px;
	margin: 0 0 32px;
	font-style: italic;
}

.fm-pact-intro {
	font-size: 18px;
	color: var(--fm-text);
	margin: 0 0 32px;
	line-height: 1.6;
}

.fm-pact-section {
	margin: 0 0 28px;
}

.fm-pact-section h2 {
	font-family: 'Avenir', 'Avenir Next', 'Work Sans', sans-serif;
	font-weight: 600;
	font-size: 17px;
	line-height: 1.4;
	color: var(--fm-deep);
	margin: 0 0 8px;
}

.fm-pact-section p {
	margin: 0;
	color: var(--fm-text);
	font-size: 16px;
	line-height: 1.65;
}

.fm-pact-closing {
	font-size: 17px;
	line-height: 1.6;
	margin: 32px 0 0;
	padding-top: 24px;
	border-top: 1px solid var(--fm-border);
	color: var(--fm-text);
}

/* Form */

.fm-pact-form {
	margin: 0 0 24px;
}

.fm-pact-checkbox {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 24px;
	cursor: pointer;
	user-select: none;
	padding: 16px;
	background: var(--fm-warm-surface);
	border: 1px solid var(--fm-border);
	border-radius: 4px;
	transition: border-color 0.2s ease;
	min-height: 44px; /* WCAG touch target */
	box-sizing: border-box;
}

.fm-pact-checkbox:hover,
.fm-pact-checkbox:focus-within {
	border-color: var(--fm-cta);
}

.fm-pact-checkbox input[type="checkbox"] {
	width: 20px;
	height: 20px;
	margin: 2px 0 0;
	flex-shrink: 0;
	accent-color: var(--fm-cta-active);
	cursor: pointer;
}

.fm-pact-checkbox span {
	font-size: 16px;
	color: var(--fm-text);
	line-height: 1.5;
	font-weight: 500;
}

.fm-pact-button {
	width: 100%;
	padding: 16px 24px;
	background: var(--fm-cta);
	color: var(--fm-deep);
	border: none;
	border-radius: 4px;
	font-family: inherit;
	font-size: 17px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.1s ease;
	letter-spacing: 0.01em;
	min-height: 48px; /* WCAG touch target */
	-webkit-appearance: none;
	appearance: none;
}

.fm-pact-button:hover:not(:disabled):not(.is-loading) {
	background: var(--fm-cta-hover);
}

.fm-pact-button:active:not(:disabled):not(.is-loading) {
	transform: translateY(1px);
}

.fm-pact-button:focus-visible {
	outline: 2px solid var(--fm-deep);
	outline-offset: 2px;
}

.fm-pact-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.fm-pact-button.is-loading {
	opacity: 0.7;
	cursor: wait;
}

/* Anchor variants: JS swaps the submit buttons for real links so the app
   WebView routes them as genuine link taps. They must look identical. */
a.fm-pact-button {
	display: block;
	box-sizing: border-box;
	text-align: center;
	text-decoration: none;
	line-height: 1.2;
}
a.fm-pact-button[aria-disabled="true"] {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}
a.fm-pact-decline {
	display: inline-block;
	text-decoration: underline;
}

.fm-pact-error {
	margin: 16px 0 0;
	padding: 12px 16px;
	background: var(--fm-error-bg);
	border: 1px solid var(--fm-error-border);
	border-radius: 4px;
	color: var(--fm-error-text);
	font-size: 15px;
	line-height: 1.5;
}

/* Decline path — deliberately subdued. Compliance requirement, but visually
   recedes so it doesn't compete with the primary CTA. */

.fm-pact-decline-row {
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--fm-border);
	text-align: center;
}

.fm-pact-decline {
	background: transparent;
	border: none;
	color: var(--fm-muted);
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	padding: 8px 16px;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--fm-border);
	border-radius: 2px;
	transition: color 0.2s ease, text-decoration-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
	min-height: 32px;
}

.fm-pact-decline:hover:not(:disabled):not(.is-loading) {
	color: var(--fm-deep);
	text-decoration-color: var(--fm-muted);
}

.fm-pact-decline:focus-visible {
	outline: 2px solid var(--fm-muted);
	outline-offset: 2px;
}

.fm-pact-decline:disabled,
.fm-pact-decline.is-loading {
	opacity: 0.5;
	cursor: wait;
}

.fm-pact-decline-note {
	margin: 8px 0 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--fm-muted);
	max-width: 420px;
	margin-left: auto;
	margin-right: auto;
}

/* Footer */

.fm-pact-footer {
	text-align: center;
	color: var(--fm-muted);
	margin-top: 24px;
}

.fm-pact-footer small {
	font-size: 12px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

/* Logged-out fallback */

.fm-pact-loggedout {
	text-align: center;
	padding: 48px 24px;
}

.fm-pact-loggedout .fm-pact-button {
	display: inline-block;
	width: auto;
	padding: 12px 32px;
	text-decoration: none;
	color: var(--fm-deep);
}

/* Mobile (Constitution Appendix B: 390px reference width) */

@media (max-width: 640px) {
	.fm-pact-stage {
		padding: 24px 16px 60px;
	}
	.fm-pact-container {
		padding: 32px 24px;
		border-radius: 0;
		border-left: none;
		border-right: none;
	}
	.fm-pact-title {
		font-size: 26px;
	}
	.fm-pact-section h2 {
		font-size: 16px;
	}
	.fm-pact-section p,
	.fm-pact-intro {
		font-size: 16px;
	}
}
