/*
 * Enquiry form section (sections/enquiry-form.php): heading, intro, a Contact Form 7
 * form in a cream card, small print. Not in Figma: built from the design system
 * (cards, pill buttons, beige borders, the aqua focus ring).
 *
 * --details ("Show contact details beside the form", Contact): the form card on the
 * left and a light aqua "Other ways to reach us" card on the right; stacked under 1024.
 *
 * The form markup (pe-form__grid, pe-form__field …) is written in the CF7 form itself
 * (Contact > Contact Forms > Enquiry). CF7's own stylesheet also loads; the rules here are specific
 * enough to win over it.
 */
.pe-enquiry-form {
	/* Warm red for validation errors. Not one of the palette colours in theme.json,
	   so it is kept here, in the one section that needs it. */
	--pe-enquiry-error: #a8492f; /* 5.1:1 on cream, passes WCAG AA */
	--pe-enquiry-field-height: 3.5rem; /* 56px */

	text-align: center;
}

.pe-enquiry-form__heading {
	margin: 0;
}

.pe-enquiry-form__intro {
	max-width: 40rem;
	margin: 1rem auto 0;
}

/* ---------- The card ---------- */

/* 48px padding at desktop, 24px on phones; about 800px wide, centred. */
.pe-enquiry-form__card {
	max-width: 50rem;
	margin: clamp(2rem, 3.5vw, 3rem) auto 0;
	padding: clamp(1.5rem, 3.34vw, 3rem);
	text-align: left;
}

/* The form card and the details card don't lift on hover like other cards (a form
   shouldn't move while you type): they are left out of the hover rule in motion.css. */

.pe-enquiry-form__note {
	max-width: 50rem;
	margin: 1.5rem auto 0;
	color: var(--pe-muted);
	font-size: 1rem;
}

/* ---------- With contact details: form left (about 2/3), details card right ---------- */

/* The card is 384px wide at 1440 (27vw, at most 24rem) and the form takes the rest.
   At least 312px, so the email address and the hours fit on one line at 1024. */
.pe-enquiry-form--details .pe-enquiry-form__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) clamp(19.5rem, 27vw, 24rem);
	align-items: start;
	gap: clamp(1.5rem, 2.8vw, 2.5rem);
	margin-top: clamp(2rem, 3.5vw, 3rem);
	text-align: left;
}

.pe-enquiry-form--details .pe-enquiry-form__card {
	max-width: none;
	margin: 0;
}

.pe-enquiry-form--details .pe-enquiry-form__note {
	max-width: none;
	text-align: center;
}

.pe-enquiry-form__aside {
	padding: clamp(1.5rem, 2.5vw, 2.25rem);
}

.pe-enquiry-form__aside-title {
	margin: 0 0 1.5rem;
	font-size: clamp(1.5rem, 2.2vw, 1.875rem);
	line-height: 1.2;
	text-wrap: balance; /* no lone "us" on the second line */
}

/* Small bold label, the value under it (like the Find us contact card). */
.pe-enquiry-form__details {
	display: grid;
	gap: 1.25rem;
	margin: 0;
}

.pe-enquiry-form__details dt {
	margin: 0 0 0.25rem;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.4;
}

.pe-enquiry-form__details dd {
	margin: 0;
	font-size: 1.125rem;
	line-height: 1.5;
	overflow-wrap: anywhere; /* a long email address never pushes the card wider */
}

.pe-enquiry-form__details a {
	text-decoration: none;
}

.pe-enquiry-form__details a:hover {
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* Quick links under a thin divider, each with an arrow. */
.pe-enquiry-form__links {
	display: grid;
	gap: 0.75rem;
	margin: 1.75rem 0 0;
	padding: 1.5rem 0 0;
	border-top: 1.5px solid rgb(32 61 54 / 0.2); /* ink at 20% */
	list-style: none;
}

/* The details list is optional: without it the links need no divider. */
.pe-enquiry-form__aside-title + .pe-enquiry-form__links {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.pe-enquiry-form__link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.4;
	text-decoration: none;
}

.pe-enquiry-form__link:hover > span:first-child {
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* The arrow (pe_arrow()), a little smaller than the text, sitting on its middle. */
.pe-enquiry-form__arrow {
	flex: none;
	width: 0.85em;
	height: auto;
}

@media (prefers-reduced-motion: no-preference) {
	.pe-enquiry-form__arrow {
		transition: transform 0.15s ease;
	}

	.pe-enquiry-form__link:hover .pe-enquiry-form__arrow {
		transform: translateX(0.25rem);
	}
}

/* Under 1024: one column, the details card under the form. */
@media (max-width: 1023px) {
	.pe-enquiry-form--details .pe-enquiry-form__layout {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Tablets: the card is wide now, so the details sit side by side (each as wide as its
   text; one that doesn't fit goes to the next line) and the quick links in one row.
   Phones keep everything one per line. */
@media (min-width: 768px) and (max-width: 1023px) {
	.pe-enquiry-form__details,
	.pe-enquiry-form__links {
		display: flex;
		flex-wrap: wrap;
		gap: 1.25rem 3rem;
	}

	.pe-enquiry-form__links {
		row-gap: 0.75rem;
	}
}

/* ---------- Layout: two fields per row, the message full width ---------- */

.pe-enquiry-form .pe-form__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.5rem;
}

.pe-enquiry-form .pe-form__field--wide {
	grid-column: 1 / -1;
}

/* The party fields while a general question is chosen (assets/js/enquiry-form.js).
   display: none takes them out of the grid, so the message moves up with no gap. */
.pe-enquiry-form .pe-form__field[hidden] {
	display: none;
}

.pe-enquiry-form .pe-form__field label {
	display: block;
	margin-bottom: 0.5rem;
	color: var(--pe-ink);
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.3;
}

.pe-enquiry-form .pe-form__required {
	color: var(--pe-muted);
}

.pe-enquiry-form .wpcf7-form-control-wrap {
	position: relative;
	display: block;
}

/* ---------- Fields: pill-shaped single lines, a rounded box for the message ---------- */

.pe-enquiry-form :is(input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="number"], select, textarea) {
	display: block;
	width: 100%;
	min-height: var(--pe-enquiry-field-height);
	margin: 0;
	padding: 0 1.5rem;
	border: 1.5px solid var(--pe-beige);
	border-radius: var(--pe-radius-pill);
	background: var(--pe-cream);
	color: var(--pe-ink);
	font-family: var(--pe-font-body);
	font-size: 1.1rem; /* over 16px, so phones don't zoom in on focus */
	line-height: 1.4;
	transition: border-color 0.15s ease;
}

/* Hints in the empty fields: ink at 75%, 5:1 on cream (the browser's grey is too pale). */
.pe-enquiry-form :is(input, textarea)::placeholder {
	color: color-mix(in srgb, var(--pe-ink) 75%, var(--pe-cream));
	opacity: 1;
}

/* ".pe-form__field" makes these beat the :is() rule above (it counts as input[type]).
   The height comes from the form's 6 rows (x6 in the CF7 tag); this is a floor. */
.pe-enquiry-form .pe-form__field textarea {
	min-height: 9rem;
	padding-block: 1rem;
	border-radius: 1rem;
	resize: vertical;
}

/* Our own arrow on the dropdown (the browser's one is hidden), drawn in CSS so it
   takes the ink colour. It sits in the middle of the 56px field. */
.pe-enquiry-form .pe-form__field select {
	padding-right: 3.25rem;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}

.pe-enquiry-form .wpcf7-form-control-wrap:has(> select)::after {
	content: "";
	position: absolute;
	top: calc(var(--pe-enquiry-field-height) / 2);
	right: 1.5rem;
	width: 0.55rem;
	height: 0.55rem;
	border-right: 2px solid var(--pe-ink);
	border-bottom: 2px solid var(--pe-ink);
	transform: translateY(-70%) rotate(45deg);
	pointer-events: none;
}

.pe-enquiry-form :is(input, select, textarea):hover {
	border-color: color-mix(in srgb, var(--pe-beige) 60%, var(--pe-ink));
}

/* The same aqua ring as .pe-button. */
.pe-enquiry-form :is(input, select, textarea):focus {
	border-color: var(--pe-ink);
	outline: 3px solid var(--pe-aqua);
	outline-offset: 2px;
}

/* ---------- Send button: the .pe-button--primary look on CF7's <input> ---------- */

.pe-enquiry-form .pe-form__submit {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
	margin-top: 2rem;
}

.pe-enquiry-form .wpcf7-submit {
	min-height: 3.625rem;
	padding: 0.5rem 1.75rem;
	border: 1.36px solid var(--pe-ink);
	border-radius: var(--pe-radius-pill);
	background: var(--pe-ink);
	color: var(--pe-cream);
	font-family: var(--pe-font-body);
	font-size: var(--pe-text-button);
	font-weight: 700;
	line-height: 1.25;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.pe-enquiry-form .wpcf7-submit:hover {
	border-color: color-mix(in srgb, var(--pe-ink) 85%, var(--pe-cream));
	background: color-mix(in srgb, var(--pe-ink) 85%, var(--pe-cream));
	box-shadow: 0 6px 14px rgb(32 61 54 / 0.18);
	transform: translateY(-2px);
}

.pe-enquiry-form .wpcf7-submit:active {
	box-shadow: none;
	transform: translateY(0);
}

.pe-enquiry-form .wpcf7-submit:focus-visible {
	outline: 3px solid var(--pe-aqua);
	outline-offset: 3px;
}

/* While sending, CF7 disables the button. */
.pe-enquiry-form .wpcf7-submit:disabled {
	cursor: wait;
	opacity: 0.7;
}

/* CF7's spinner (shown while sending) sits beside the button. */
.pe-enquiry-form .wpcf7-spinner {
	margin: 0;
}

/* "We only use your details to reply to you. Read our Privacy Policy." */
.pe-enquiry-form .pe-form__privacy {
	margin: 1rem 0 0;
	color: var(--pe-muted);
	font-size: 0.9375rem;
	line-height: 1.5;
}

.pe-enquiry-form .pe-form__privacy a {
	color: inherit;
	text-underline-offset: 0.15em;
}

/* ---------- Validation and the reply message ---------- */

/* A field that needs fixing: deep peach border, a faint peach fill. */
.pe-enquiry-form .pe-form__field .wpcf7-not-valid {
	border-color: var(--pe-enquiry-error);
	background: color-mix(in srgb, var(--pe-peach-light) 45%, var(--pe-cream));
}

/* "Please fill this in." under the field, lined up with the text inside it. */
.pe-enquiry-form .wpcf7-not-valid-tip {
	margin-top: 0.375rem;
	padding-left: 1.5rem;
	color: var(--pe-enquiry-error);
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.4;
}

/* The message under the button ("Thanks! …" or "A few details are missing …"): a
   rounded box with a small round icon, ink text, no border. Peach for problems, sage
   once sent (ink on peach 8:1, on sage 6:1). Specific enough to beat CF7's own
   coloured-border rules. CF7 hides the box before the first send and while sending. */
.pe-enquiry-form .wpcf7 form.wpcf7-form .wpcf7-response-output {
	margin: 1.5rem 0 0;
	padding: 0.875rem 1.25rem;
	border: 0;
	border-radius: 1rem;
	background: var(--pe-peach);
	color: var(--pe-ink);
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.45;
}

.pe-enquiry-form .wpcf7 form.wpcf7-form.sent .wpcf7-response-output {
	background: var(--pe-sage);
}

/* The states that show a message: icon on the left, the text beside it. */
.pe-enquiry-form .wpcf7 form.wpcf7-form:is(.sent, .invalid, .unaccepted, .payment-required, .failed, .aborted, .spam) .wpcf7-response-output {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
}

/* The icon: "!" in an ink circle ("✓" once sent). The "/ ''" part stops screen
   readers reading it out; browsers that don't know it use the line above. */
.pe-enquiry-form .wpcf7 form.wpcf7-form:is(.sent, .invalid, .unaccepted, .payment-required, .failed, .aborted, .spam) .wpcf7-response-output::before {
	content: "!";
	content: "!" / "";
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 50%;
	background: var(--pe-ink);
	color: var(--pe-cream);
	font-size: 0.9375rem;
	line-height: 1;
}

.pe-enquiry-form .wpcf7 form.wpcf7-form.sent .wpcf7-response-output::before {
	content: "✓";
	content: "✓" / "";
}

/* ---------- Phones: one column ---------- */

@media (max-width: 767px) {
	.pe-enquiry-form .pe-form__grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.25rem;
	}

	/* A full-width button; the spinner overlaps its right end instead of wrapping
	   onto a line of its own. */
	.pe-enquiry-form .pe-form__submit {
		position: relative;
	}

	.pe-enquiry-form .wpcf7-submit {
		width: 100%;
	}

	.pe-enquiry-form .pe-form__submit .wpcf7-spinner {
		position: absolute;
		top: 50%;
		right: 1rem;
		transform: translateY(-50%);
	}
}
