/*
 * Default styling of the newsletter forms.
 *
 * Deliberately plain: colours, fonts and spacing are expected to come from the
 * project. What this file does provide is the layout - one shared left edge for every
 * row, so field, privacy notice and captcha line up instead of each sitting somewhere
 * else.
 */

.tx-newslettersubscription form {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 1rem;
	/* Only ever narrows: in a column that is already tighter this has no effect. A
	 * single e-mail field running the full width of a wide section reads as a mistake,
	 * not as a form. Centred, so the leftover space is shared instead of piling up on
	 * one side. */
	max-width: 48rem;
	margin-inline: auto;
}

/* Fluid wraps the form's hidden fields in a div of its own. It carries no content but
 * would still take part in the layout and add a gap above the first field. */
.tx-newslettersubscription form > div:not([class]) {
	display: contents;
}

/* Two columns where there is room. A field that is alone in the grid spans the full
 * width instead of sitting centred in one half - which is what made a form with only
 * an e-mail address look lost. */
.tx-newslettersubscription .twocol {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem 2rem;
}

.tx-newslettersubscription .twocol > div:only-child {
	grid-column: 1 / -1;
}

.tx-newslettersubscription .newsletterformpart > label {
	display: block;
}

.tx-newslettersubscription .newsletterformpart input[type="text"],
.tx-newslettersubscription .newsletterformpart input[type="email"],
.tx-newslettersubscription .newsletterformpart select {
	width: 100%;
	box-sizing: border-box;
}

/* Checkbox and text as two columns, so wrapped lines keep clear of the box instead of
 * running underneath it. The text needs its own element: a link inside it would
 * otherwise become a flex item of its own and tear the sentence apart. */
.tx-newslettersubscription .privacypart > label {
	display: flex;
	align-items: flex-start;
	gap: .5em;
}

.tx-newslettersubscription .privacytext {
	flex: 1 1 auto;
}

.tx-newslettersubscription .privacypart input[type="checkbox"] {
	flex: 0 0 auto;
	margin-top: .25em;
}

.tx-newslettersubscription input[type="submit"] {
	align-self: flex-end;
}

@media screen and (max-width: 40rem) {
	.tx-newslettersubscription .twocol {
		grid-template-columns: minmax(0, 1fr);
	}

	.tx-newslettersubscription input[type="submit"] {
		align-self: stretch;
	}
}

/* Inline validation messages added by validation.js */
.tx-newslettersubscription .newsletterformerror {
	display: block;
	margin-top: .25em;
	font-size: .875em;
	color: #a4001e;
}

.tx-newslettersubscription .newsletterformerror:empty {
	display: none;
}

.tx-newslettersubscription .is-invalid {
	border-color: #a4001e;
	outline-color: #a4001e;
}

/* Link to the other form, below the submit button */
.tx-newslettersubscription .newsletterformswitch {
	max-width: 48rem;
	margin: .5rem auto 0;
	font-size: .875em;
}
