/*
 * Newsletter popup: white on black, floating at the bottom of the viewport.
 * The dark twin of the nav bar (same 90% tint). One row on desktop,
 * a card on phones where the text has to wrap. Never blocks the page.
 */

.nl-popup {
	position: fixed;
	inset: auto 0 var(--page-gutter, 18px);
	z-index: 950; /* Above the logo, below the header and open menu. */
	box-sizing: border-box;
	width: calc(100% - 2 * var(--page-gutter, 18px));
	max-width: none;
	margin: 0 auto;
	padding: 0;
	color: #fff;
	background: rgba(0, 0, 0, 0.9);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
}

.nl-popup[open] {
	animation: nl-popup-in 0.6s cubic-bezier(0, 0, 0, 1);
}

@keyframes nl-popup-in {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.nl-popup[open] {
		animation: none;
	}
}

html.nav-open .nl-popup {
	display: none;
}

.nl-popup__inner {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 12px 16px;
	align-items: center;
	padding: 16px 14px 16px 20px;
}

.nl-popup .nl-popup__heading { /* Doubled class: out-ranks .home h2. */
	margin: 0;
	font: 300 18px/1.25 var(--font-display, "Items", serif);
	text-wrap: balance;
}

.nl-popup__heading i {
	white-space: nowrap;
}

.nl-popup__form {
	grid-column: 1 / -1;
	grid-row: 2;
	margin: 0;
}

.nl-popup__field {
	display: flex;
	align-items: stretch;
	border-bottom: 1px solid rgba(255, 255, 255, 0.6);
	transition: border-color 0.2s;
}

.nl-popup__field:focus-within {
	border-color: #fff;
}

.nl-popup input[type=email] {
	flex: 1 1 auto;
	min-width: 0;
	padding: 6px 0;
	color: #fff;
	font: 400 15px/22px var(--font-text, "Inter", sans-serif);
	background: none;
	border: 0;
	border-radius: 0;
	outline: none;
	-webkit-appearance: none;
}

.nl-popup input[type=email]::placeholder {
	color: rgba(255, 255, 255, 0.6);
}

.nl-popup__submit {
	flex: 0 0 32px; /* Just wider than the arrow, so its tip ends near the line end. */
	padding: 0;
	border: 0;
	border-radius: 0;
	background: url(../images/rarr.svg) left center / 30px no-repeat;
	filter: brightness(0) invert(1);
	cursor: pointer;
	transform: scaleX(0.9);
	transform-origin: left center; /* Grows to the right, like the other arrows. */
	transition: transform 0.3s;
}

.nl-popup__submit:hover,
.nl-popup__submit:focus-visible {
	transform: scaleX(1);
}

.nl-popup__submit:disabled {
	opacity: 0.5;
	pointer-events: none;
}

.nl-popup__status {
	margin: 8px 0 0;
	font: 400 13px/1.4 var(--font-text, "Inter", sans-serif);
}

.nl-popup__status:empty {
	display: none;
}

.nl-popup__status[data-state=error] {
	color: #ffb4ab;
}

.nl-popup__close {
	grid-column: 2;
	grid-row: 1;
	align-self: start;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: url(../images/close.svg) center / 14px no-repeat;
	filter: brightness(0) invert(1);
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.2s;
}

.nl-popup__close:hover,
.nl-popup__close:focus-visible {
	opacity: 1;
}

/* Desktop: one row, heading | email + arrow | close. */
@media (min-width: 900px) {
	.nl-popup {
		bottom: 24px;
		width: fit-content;
		max-width: calc(100% - 2 * var(--page-gutter, 30px));
		border-radius: 8px; /* Same corners as the black Keep up button. */
	}

	/* Top-aligned, with the heading and close nudged to sit level with the field. */
	.nl-popup__inner {
		grid-template-columns: auto 300px auto;
		gap: 0 28px;
		align-items: start;
		padding: 10px 12px 10px 32px;
	}

	.nl-popup .nl-popup__heading {
		max-width: 34em;
		margin-top: 6px;
		font-size: 19px;
	}

	.nl-popup__form {
		grid-column: 2;
		grid-row: 1;
	}

	/* A message adds lines under the field. The bar is pinned by its bottom edge,
	   so it grows upwards to fit and drops back when the message clears. */
	.nl-popup__status {
		margin-top: 6px;
		font-size: 12px;
		line-height: 16px;
	}

	.nl-popup__close {
		grid-column: 3;
		align-self: start;
		width: 36px;
		height: 36px;
	}
}

/* Site-wide heading and input colours out-rank the rules above on some pages: keep it all white. */
.nl-popup .nl-popup__heading,
.nl-popup .nl-popup__heading i,
.nl-popup .nl-popup__status:not([data-state=error]) {
	color: #fff !important;
}

.nl-popup .nl-popup__field input[type=email] {
	color: #fff !important;
	-webkit-text-fill-color: #fff;
	caret-color: #fff;
}

.nl-popup .nl-popup__field input[type=email]::placeholder {
	color: rgba(255, 255, 255, 0.6) !important;
	-webkit-text-fill-color: rgba(255, 255, 255, 0.6);
	opacity: 1;
}

/* Browser autofill paints its own pale background and dark text. */
.nl-popup .nl-popup__field input[type=email]:-webkit-autofill {
	-webkit-text-fill-color: #fff;
	-webkit-box-shadow: 0 0 0 100px #000 inset;
	transition: background-color 9999s;
}
