/*
 * Strengthen our community — a copy of One column, for that campaign alone.
 *
 * Loaded after the plugin's `donations.css`, only while this template draws
 * the page. The site theme's look (JHLC), as on the events' Light Custom
 * page: a light grey page, white square cards with no frame, Tilda Sans, the
 * title centred over a short green mark, a teal pill for the button. Two
 * cards, one column at every width: the campaign — its name and its call to
 * action — then the form, no wider than 640px in the middle of its card.
 *
 * Contents
 *   1. Tokens    3. The campaign   5. Where the form would be
 *   2. The page  4. The form       6. Phones
 *                                   7. Labels in the field
 */

/* -- 1. Tokens --------------------------------------------------------------- */

/* Everything a site is likely to change, in one place — the theme's own presets first. */
.donations-single--jhlc {
	--jhlc-font: var(--wp--preset--font-family--tilda-sans, 'Tilda Sans', TildaSans, Arial, sans-serif);

	--jhlc-page: var(--wp--preset--color--ground, #f9f9f9);
	--jhlc-card: var(--wp--preset--color--surface, #fff);
	--jhlc-ink: var(--wp--preset--color--ink, #000);
	--jhlc-copy: var(--wp--preset--color--copy, #333);
	--jhlc-soft: rgb(0 0 0 / 0.6);
	--jhlc-line: #e6e6e6;
	--jhlc-accent: var(--wp--preset--color--teal, #179fa7);
	--jhlc-mark: var(--wp--preset--color--green, #40d86f);

	--jhlc-width: 1040px;
	--jhlc-gap: 20px;
	--jhlc-pad: clamp(20px, 4vw, 40px);

	/* The plugin's own pieces (the notices) in the same colours. */
	--donations-ink: var(--jhlc-ink);
	--donations-muted: var(--jhlc-soft);
	--donations-accent: var(--jhlc-accent);
	--donations-line: var(--jhlc-line);
}

/* -- 2. The page ------------------------------------------------------------- */

body:has(.donations-single--jhlc) {
	background: var(--jhlc-page, #f9f9f9);
}

.donations-single--jhlc {
	max-width: none;
	margin: 0;
	padding: clamp(16px, 3vw, 40px) var(--wp--preset--spacing--gutter, 20px) clamp(40px, 6vw, 80px);
	background: var(--jhlc-page);
	color: var(--jhlc-ink);
	font-family: var(--jhlc-font);
	font-size: 18px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.donations-single--jhlc *,
.donations-single--jhlc *::before,
.donations-single--jhlc *::after {
	box-sizing: border-box;
}

.donations-single__column {
	display: grid;
	gap: var(--jhlc-gap);
	max-width: var(--jhlc-width);
	margin: 0 auto;
}

/* A white square card: no frame, no shadow, no corners. */
.donations-single__card {
	min-width: 0;
	margin: 0;
	padding: var(--jhlc-pad);
	border: 0;
	border-radius: 0;
	background: var(--jhlc-card);
	box-shadow: none;
}

/* -- 3. The campaign --------------------------------------------------------- */

.donations-single__intro {
	text-align: center;
}

.donations-single__title {
	max-width: 22em;
	margin: 0 auto;
	color: var(--jhlc-ink);
	font-family: inherit;
	font-size: clamp(30px, 4.2vw, 46px);
	font-weight: 600;
	line-height: 1.23;
	text-wrap: balance;
}

.donations-single__title::after {
	content: '';
	display: block;
	width: 40px;
	height: 3px;
	margin: 18px auto 0;
	background: var(--jhlc-mark);
}

/* The call to action: the author's words, at a reading measure. */
.donations-single--jhlc .donations-cta {
	max-width: 720px;
	margin: 24px auto 0;
	color: var(--jhlc-copy);
	font-size: 18px;
	line-height: 1.6;
	text-align: center;
}

.donations-single--jhlc .donations-cta :is(h2, h3, h4) {
	margin: 1.5em 0 0.4em;
	color: var(--jhlc-ink);
	font-family: inherit;
	font-size: 20px;
	font-weight: 600;
}

.donations-single--jhlc .donations-cta a {
	color: var(--jhlc-accent);
}

/* -- 4. The form ------------------------------------------------------------- */

/* No form and nothing to say in its place: no empty card. */
.donations-single__form:not(:has(*)) {
	display: none;
}

.donations-single__form > .form-wrap {
	max-width: 640px;
	margin: 0 auto;
}

/*
 * The form keeps Forms' own house look; only its tokens are set here — Forms'
 * documented way for a page to give a form its accent — so on this page it is
 * teal, black on white, in the page's type, with square boxes.
 * `.donations-single--jhlc` outranks Forms' `.form-wrap`. Anything the
 * campaign's form wants different is still its own (Forms → the form → CSS).
 */
.donations-single--jhlc .form-wrap {
	--font: 16px;
	--radius: 0px;
	--radius-sm: 0px;
	--radius-lg: 0px;
	--ink: #000;
	--muted: #6b6b6b;
	--line: #e6e6e6;
	--line-strong: #d2d2d2;
	--surface-sunk: #f9f9f9;
	--accent: #179fa7;
	--accent-soft: rgb(23 159 167 / 0.08);
	--accent-wash: rgb(23 159 167 / 0.08);
	--accent-line: rgb(23 159 167 / 0.25);
	--accent-hover: rgb(23 159 167 / 0.4);
	--button: #179fa7;
	--button-hover: #127f86;
	--ring: 0 0 0 3px rgb(23 159 167 / 0.2);

	font-family: inherit;
}

/* The button stays the theme's pill, whatever the form's corners. */
.donations-single--jhlc .form-wrap .form__submit {
	border-radius: 30px;
	font-weight: 600;
}

/* -- 5. Where the form would be ---------------------------------------------- */

/* Before it opens, once it has closed: a line in the middle of the card. */
.donations-single--jhlc .donations-closed {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--jhlc-copy);
	font-size: 18px;
}

.donations-single--jhlc .donations-notice {
	border-radius: 0;
}

/* -- 6. Phones --------------------------------------------------------------- */

@media (max-width: 782px) {
	.donations-single--jhlc {
		--jhlc-gap: 12px;

		padding-inline: 16px;
		font-size: 16px;
	}

	.donations-single--jhlc .donations-cta {
		font-size: 16px;
	}
}

/* -- 7. Labels in the field -------------------------------------------------- */

/*
 * A question you type into (`light-float`, set by template.js) shows its label
 * inside the empty box, where a placeholder would be. On focus, or once the box
 * holds an answer, the label shrinks and slides up ABOVE the box, and stays
 * there while there is an answer. The box's own placeholder is not shown: the
 * label is the placeholder.
 *
 * The first row is always kept for the label above, so nothing moves when it
 * slides; the label and the box share the second row, and the hint and the
 * error come after it. The resting label is centred on `--light-h`, the box's
 * height (template.js); 2.6em, Forms' own box, until it is known.
 */
.donations-single--jhlc .field.light-float {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: 1.5em auto;
	gap: 0;
}

.donations-single--jhlc .field.light-float > :is(input, textarea) {
	grid-row: 2;
	grid-column: 1;
}

.donations-single--jhlc .field.light-float > .field__hint {
	grid-row: 3;
	margin-top: 0.25em;
}

.donations-single--jhlc .field.light-float > .field__error {
	grid-row: 4;
	margin-top: 0.25em;
}

.donations-single--jhlc .field.light-float > :is(input, textarea)::placeholder {
	color: transparent;
}

/* Resting: in the box, in the box's own size, grey — a placeholder. */
.donations-single--jhlc .field.light-float > .field__label {
	z-index: 1;
	grid-row: 2;
	grid-column: 1;
	align-self: start;
	max-width: 100%;
	overflow: hidden;
	color: var(--muted);
	font-size: 1em;
	font-weight: 400;
	line-height: 1.35;
	white-space: nowrap;
	text-overflow: ellipsis;
	pointer-events: none;
	transform: translate(0, calc((var(--light-h, 2.6em) - 1.35em) / 2)) scale(1);
	transform-origin: 0 0;
	transition: transform 0.24s cubic-bezier(0.2, 0.7, 0.2, 1), color 0.16s ease;
}

/* A text area is a box: its label rests at the top left, inside the frame. */
.donations-single--jhlc .field.light-float:has(> textarea) > .field__label {
	transform: translate(0.85em, calc(0.6em + 1px)) scale(1);
}

/* Above the box: on focus, or with an answer. */
.donations-single--jhlc .field.light-float:has(> :focus) > .field__label,
.donations-single--jhlc .field.light-float:has(> :is(input, textarea):not(:placeholder-shown)) > .field__label {
	transform: translate(0, -1.3em) scale(0.8);
}

/* …or one the browser filled in — a rule of its own, as a browser that does not know `:autofill` drops the whole rule. */
.donations-single--jhlc .field.light-float:has(> :autofill) > .field__label {
	transform: translate(0, -1.3em) scale(0.8);
}

.donations-single--jhlc .field.light-float:has(> :focus) > .field__label {
	color: var(--accent);
}

.donations-single--jhlc .field.light-float.field--invalid > .field__label {
	color: var(--error);
}
