/*
 * Registration form styling.
 *
 * Deliberately unopinionated: colours and typography come from the active
 * theme, so this file only does layout and the couple of things a theme cannot
 * know about (hiding the honeypot, spacing the checkbox grid).
 */

.mer-rego__form {
	margin: 0 0 1.5rem;
}

.mer-rego__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
	gap: 0 1.25rem;
}

.mer-rego__field {
	display: flex;
	flex-direction: column;
	margin: 0 0 1rem;
}

/*
 * The reveal. The form embedded in a CPD activity box leads with four fields
 * and opens over the rest the moment the reader starts filling it in — a
 * thirteen-field form under an article is a form nobody starts.
 *
 * `grid-template-rows: 0fr -> 1fr` is the one way to animate to a height
 * nothing has measured; `height: auto` is not interpolable and a hard-coded
 * max-height either clips a long form or animates thin air. The inner element
 * needs `min-height: 0` or the grid refuses to shrink it below its content.
 *
 * ⚠ NOT `display: none` AND NOT THE `hidden` ATTRIBUTE. The fields inside are
 * real, required inputs: a browser that is asked to report an invalid field it
 * cannot display refuses the submit and says nothing, so a reader would be left
 * pressing a button that does nothing. Collapsed-but-rendered keeps them
 * focusable, which is also what makes :focus-within a real fallback.
 */
.mer-rego__more {
	display: grid;
	grid-template-rows: 0fr;
	overflow: hidden;
	transition: grid-template-rows 0.35s ease;
}

.mer-rego__more-inner {
	min-height: 0;
}

/*
 * Two ways open. `:focus-within` is the one that needs no JavaScript — tab into
 * any lead field and the rest is there — and the class is what keeps it open
 * after the reader tabs back out, which only src/js/mer-rego.ts can decide.
 */
.mer-rego__form.is-expanded .mer-rego__more,
.mer-rego__form[data-mer-rego-expand]:focus-within .mer-rego__more {
	grid-template-rows: 1fr;
}

@media ( prefers-reduced-motion: reduce ) {

	.mer-rego__more {
		transition: none;
	}
}

.mer-rego__field input {
	width: 100%;
}

.mer-rego__label {
	font-weight: 600;
}

.mer-rego__required {
	opacity: 0.6;
}

.mer-rego__hint {
	font-size: 0.85em;
	opacity: 0.75;
	margin-top: 0.25rem;
}

/*
 * The honeypot. Off-screen rather than display:none — some bots skip fields
 * that are display:none, and this one is meant to be tempting.
 */
.mer-rego__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.mer-rego__newsletters {
	border: 1px solid currentColor;
	border-radius: 4px;
	padding: 1rem 1.25rem;
	margin: 0 0 1.5rem;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: 0.4rem 1.25rem;
}

.mer-rego__newsletters legend {
	font-weight: 600;
	padding: 0 0.4rem;
}

/* Spans the checkbox grid: a sentence, not another column. */
.mer-rego__newsletters-note {
	grid-column: 1 / -1;
	margin: 0.25rem 0 0;
}

.mer-rego__check {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.mer-rego__check--all {
	grid-column: 1 / -1;
	font-weight: 600;
	padding-bottom: 0.4rem;
	border-bottom: 1px solid currentColor;
}

.mer-rego__readonly {
	margin: 0 0 1.5rem;
}

/*
 * "Contact support", under the hint that tells a member to contact us. Inline
 * by default (it is an <a>), so it needs the gap the hint's own margin cannot
 * give it. Spacing only — the theme owns how a button looks.
 */
.mer-rego__button--support {
	display: inline-block;
	margin-top: 0.5rem;
}

.mer-rego__field--readonly {
	flex-direction: row;
	gap: 0.5rem;
	margin-bottom: 0.35rem;
}

.mer-rego__notice {
	padding: 0.75rem 1rem;
	border-left: 4px solid currentColor;
	margin: 0 0 1.5rem;
}

.mer-rego__notice--error {
	border-left-color: #b32d2e;
}

.mer-rego__notice--success {
	border-left-color: #007017;
}

/* Account-page outcomes read from further away than form hints do. */
.mer-rego--account .mer-rego__notice {
	font-size: calc( 1em + 5px );
}

.mer-rego__consent {
	font-size: 0.9em;
	opacity: 0.8;
}

/* The way back to the activity a member arrived from. */
.mer-rego__back {
	margin: 0 0 1rem;
}

/* The member's CPD, above the profile form on the account page. */
.mer-rego__cpd {
	margin: 0 0 2rem;
}

.mer-rego__cpd-title {
	font-size: 1.25em;
	margin: 0 0 0.75rem;
}

.mer-rego__cpd-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mer-rego__cpd-item {
	border-top: 1px solid currentColor;
	display: grid;
	gap: 0.25rem 1rem;
	grid-template-columns: 1fr auto;
	padding: 0.75rem 0;
}

.mer-rego__cpd-activity {
	font-weight: 600;
}

.mer-rego__cpd-meta {
	font-size: 0.85em;
	font-weight: 400;
	opacity: 0.75;
}

/*
 * `align-self: start` is the fix for a badge that looked off-centre: a grid
 * item stretches to the row's height by default, so a theme that draws this as
 * a pill got a pill as tall as the title-plus-meta cell beside it.
 */
.mer-rego__cpd-status {
	align-self: start;
	font-size: 0.9em;
	line-height: 0.8rem;
	text-align: right;
}

.mer-rego__cpd-date {
	display: block;
	font-size: 0.8125rem;
	opacity: 0.75;
}

.mer-rego__cpd-links {
	display: flex;
	font-size: 0.9em;
	gap: 1rem;
	grid-column: 1 / -1;
}
