/* ═══════════════════════════════════════════════════════════════════════════
   LEAD MAGNET MODAL
   Popup form for gated PDF downloads.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Overlay ── */
.cs-lm-overlay {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	z-index: 9999;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease-out;
	box-sizing: border-box;
}

.cs-lm-overlay.is-open {
	opacity: 1;
	pointer-events: auto;
}

/* Prevent body scroll when modal open */
.cs-lm-body-lock {
	overflow: hidden;
}

/* ── Modal box ── */
.cs-lm-modal {
	position: relative;
	background-color: var(--ci-color-white, #fff);
	border-radius: 1.25rem;
	padding: 2.5rem;
	width: 100%;
	max-width: 640px;
	max-height: calc(100vh - 3rem);
	overflow-y: auto;
	/* Matched to .mae-video-modal__container and .ce-ofsted-modal__panel so the
	   three popups open the same way. Scale as well as translate, and a strong
	   ease-out in place of symmetric `ease` — see the note in maestro.css. */
	opacity: 0;
	transform: scale(0.96) translateY(12px);
	transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1),
	            opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
	box-sizing: border-box;
}

.cs-lm-overlay.is-open .cs-lm-modal {
	opacity: 1;
	transform: scale(1) translateY(0);
}

/* ── Close button ── */
.cs-lm-close {
	position: absolute;
	/* 2.5rem matches the modal's padding, which puts this 2.25rem button's
	   centre on the heading's optical centre — it was sitting 20px above it,
	   aligned to nothing. Kept at 1.25rem from the right: pulling it in to the
	   content edge as well would force the heading to wrap earlier, and the
	   vertical offset is the one the eye catches. */
	top: 2.5rem;
	right: 1.25rem;
	width: 2.25rem;
	height: 2.25rem;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f0f0f4;
	border: none;
	border-radius: 50%;
	font-size: 1.25rem;
	line-height: 1;
	color: var(--ci-color-navy, #1e2d3d);
	cursor: pointer;
	padding: 0;
	transition: background-color 0.15s ease;
}

.cs-lm-close:hover {
	background-color: #e0e0e8;
}

/* ── Heading ── */
.cs-lm-heading {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	/* 1rem, so the intro paragraph sits comfortably under a 2rem heading. */
	font-size: var(--ci-text-h2);
	font-weight: 700;
	line-height: 1.15;
	color: var(--ci-color-navy, #1e2d3d);
	margin: 0 2.5rem 1rem 0;
}

/* ── Intro ── */
.cs-lm-intro {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-body);
	line-height: 1.65;
	color: #4a5568;
	margin: 0 0 1.5rem;
}

.cs-lm-intro:empty {
	display: none;
}

/* ── Form ── */
.cs-lm-form {
	display: flex;
	flex-direction: column;
	gap: 1.1rem;
	/* The gap belongs here rather than under the heading, because a magnet
	   with no intro paragraph would otherwise leave only the heading's own
	   margin between a 2rem title and the first field label — 12px, which is
	   less than the 17.6px the form uses between its own rows, so the title
	   read as crammed onto the form. This works with or without an intro. */
	margin-top: 2rem;
}

.cs-lm-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
}

/* School names run long and wrap badly in half a modal, so that one field gets
   the full row while the short fields pair up around it. Below 560px every row
   collapses to one column anyway — see the media query at the end. */
.cs-lm-row--single {
	grid-template-columns: 1fr;
}

/* ── Individual field ── */
.cs-lm-field {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.cs-lm-field__label {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--ci-color-navy, #1e2d3d);
}

.cs-lm-field__input {
	width: 100%;
	padding: 0.8rem 1rem;
	border: 1.5px solid #d2d2d7;
	border-radius: 12px;
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	color: var(--ci-color-text, #1a1a2e);
	background-color: #fff;
	appearance: none;
	-webkit-appearance: none;
	outline: none;
	box-sizing: border-box;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.cs-lm-field__input::placeholder {
	color: #b0b0b8;
}

.cs-lm-field__input:hover {
	border-color: #a8a8b3;
}

.cs-lm-field__input:focus {
	border-color: #538eaa;
	box-shadow: 0 0 0 4px rgba(83, 142, 170, 0.12);
}

/* ── Permissions checkbox ── */
/* Consent sits apart from the fields. At the form's own 1.1rem rhythm it read
   as one more cramped input rather than a separate thing being asked, and the
   button was then stranded 39px below it. Even air on both sides. */
.cs-lm-field--consent {
	margin-top: 0.65rem;
}

.cs-lm-field__checkbox-label {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	cursor: pointer;
}

.cs-lm-field__checkbox {
	flex-shrink: 0;
	width: 1.1rem;
	height: 1.1rem;
	margin-top: 0.15rem;
	cursor: pointer;
	accent-color: var(--ci-color-navy, #1e2d3d);
}

.cs-lm-permissions-text {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	line-height: 1.55;
	color: #5a6270;
}

/* ── Status / error message ── */
.cs-lm-status {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	min-height: 0;
}

.cs-lm-status.is-error {
	color: #c0392b;
}

/* ── Submit button ── */
.cs-lm-submit {
	align-self: flex-start;
	/* Matches the space above the checkbox, so consent is evenly framed. */
	margin-top: 0.65rem;
}

/* ── Success state ── */
/* The [hidden] attribute only sets display:none, so the display below used to
   win and the panel showed through underneath an unsubmitted form — which is
   what put a green tick under the fields. Any element given a display value
   needs its hidden state restating. */
.cs-lm-success[hidden] {
	display: none;
}

.cs-lm-success {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 0.5rem 0;
	gap: 0;
}

.cs-lm-success__heading {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--ci-color-navy, #1e2d3d);
	margin: 0 0 0.5rem;
	line-height: 1.25;
	/* Clears the close button, which is absolutely positioned and overlaps the
	   content box by 16px on desktop and 32px on mobile. Padding on BOTH sides
	   rather than the right alone: this heading is centred, so padding one edge
	   would shift the text off-centre by half the amount. The form view's own
	   heading is short enough never to reach the button, but this one carries a
	   full sentence of the resource's own copy and wraps across the top line. */
	padding: 0 2.75rem;
}

.cs-lm-success__message {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-body);
	line-height: 1.6;
	color: var(--ci-color-text-muted, #6b6b6c);
	margin: 0 0 1.5rem;
}

/* Left-aligned inside a centred panel on purpose: a filename and its format
   are read, not admired, and centred text sets a ragged left edge against the
   thumbnail. */
.cs-lm-success__resource {
	display: flex;
	align-items: center;
	gap: 1rem;
	text-align: left;
	width: 100%;
	background: #f9f9f9;
	border-radius: 14px;
	padding: 1rem 1.15rem;
	margin: 0 0 1.5rem;
}

/* A suggestion of a document rather than a file-type icon set — one shape that
   works for every format, and nothing to add when a resource ships as
   something other than a PDF. */
.cs-lm-success__thumb {
	flex: none;
	width: 3rem;
	height: 3.75rem;
	border-radius: 5px;
	background:
		linear-gradient(var(--ci-color-develop, #af4d76) 0 0) 0.5rem 0.7rem / 1.4rem 0.25rem no-repeat,
		linear-gradient(#dfe4e8 0 0) 0.5rem 1.3rem / 2rem 0.2rem no-repeat,
		linear-gradient(#dfe4e8 0 0) 0.5rem 1.85rem / 2rem 0.2rem no-repeat,
		linear-gradient(#dfe4e8 0 0) 0.5rem 2.4rem / 1.3rem 0.2rem no-repeat,
		#ffffff;
	border: 1px solid var(--ci-color-border, #d3d3d3);
}

.cs-lm-success__resource-text {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
}

.cs-lm-success__resource-name {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-weight: 700;
	color: var(--ci-color-navy, #1e2d3d);
}

.cs-lm-success__resource-meta {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	color: var(--ci-color-text-muted, #6b6b6c);
}

/* Empty when the file has no extension worth naming — collapsed rather than
   left as a gap under the title. */
.cs-lm-success__resource-meta:empty {
	display: none;
}

.cs-lm-success__download {
	width: 100%;
}

.cs-lm-success__note {
	font-family: var(--ci-font-primary, 'Lato', sans-serif);
	font-size: var(--ci-text-utility);
	line-height: 1.55;
	color: var(--ci-color-text-muted, #6b6b6c);
	margin: 1rem 0 0;
}

/* ── Responsive ── */
@media (max-width: 520px) {
	.cs-lm-modal {
		padding: 2rem 1.5rem;
	}

	.cs-lm-row {
		grid-template-columns: 1fr;
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRIGGER BUTTON IN POST CONTENT

   The [cs-lead-magnet] shortcode drops this into the body of a blog post.
   Centred by default, with its own vertical rhythm so it does not sit tight
   against the paragraphs either side.
   ═══════════════════════════════════════════════════════════════════════════ */

.cs-lm-trigger-wrap {
	display: flex;
	justify-content: center;
	margin: 2.5rem 0;
}

@media (max-width: 600px) {
	.cs-lm-trigger-wrap {
		margin: 2rem 0;
	}

	/* Long trigger wording would otherwise overflow a narrow screen. */
	.cs-lm-trigger-wrap .cs-lm-trigger {
		max-width: 100%;
	}
}
