/*
 * Shared components: paint-wipe buttons, text links, project/service cards, the project strip,
 * the enquiry section and its form. Values from the Framer build (see wordpress-build-spec.md).
 */

/* On body, not :root: theme.json's --wp--custom--* values are defined on body. */
body {
	--fh-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--fh-wipe: cubic-bezier(0.6, 0.05, 0.25, 1);
	--fh-content-w: min(var(--wp--style--global--content-size, 1280px), 100vw - 2 * var(--wp--custom--outer));
}

/* ---------- Buttons: ink fill; hover wipes a Paper fill in from the left with a brush edge ---------- */

.wp-block-button__link,
.fh-btn {
	--fh-btn-bg: var(--wp--preset--color--ink);
	--fh-btn-fg: var(--wp--preset--color--paper);
	--fh-btn-line: var(--wp--preset--color--ink);
	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 48px;
	padding: 0 30px;
	overflow: hidden;
	border: 1px solid var(--fh-btn-line);
	border-radius: var(--wp--custom--radius);
	background: var(--fh-btn-bg);
	color: var(--fh-btn-fg);
	font-family: var(--wp--preset--font-family--helvetica-neue);
	font-size: var(--wp--preset--font-size--body);
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

/* The label is repeated (data-label) on a Paper layer revealed through the brush mask. */
.wp-block-button__link[data-label]::after,
.fh-btn[data-label]::after {
	content: attr(data-label);
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--fh-btn-fg);
	color: var(--fh-btn-bg);
	mask-image: url(../img/brush-mask.png);
	mask-repeat: no-repeat;
	mask-size: 300% 100%;
	mask-position: 100% 0;
	transition: mask-position 0.8s var(--fh-wipe);
	pointer-events: none;
}

@media (hover: hover) {
	.wp-block-button__link[data-label]:hover::after,
	.fh-btn[data-label]:hover::after {
		mask-position: 0 0;
	}
}

/* Light button, for use on dark photos. */
.is-on-dark .wp-block-button__link,
.fh-btn--light {
	--fh-btn-bg: var(--wp--preset--color--paper);
	--fh-btn-fg: var(--wp--preset--color--ink);
	--fh-btn-line: var(--wp--preset--color--paper);
}

.wp-block-buttons {
	gap: 0;
}

/* ---------- Text link: underline wipes in from the left, out to the right ---------- */

.fh-link a,
a.fh-link {
	color: inherit;
	text-decoration: none;
	padding-bottom: 3px;
	background-image: linear-gradient(currentColor, currentColor);
	background-repeat: no-repeat;
	background-size: 0% 1px;
	background-position: 100% 100%;
	transition: background-size 0.45s var(--fh-ease), opacity 0.3s ease;
}

@media (hover: hover) {
	.fh-link a:hover,
	a.fh-link:hover {
		opacity: 0.4;
		background-size: 100% 1px;
		background-position: 0 100%;
	}
}

/* ---------- Cards ---------- */

.fh-cards {
	margin: 0;
	padding: 0;
	list-style: none;
}

.fh-card__link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.fh-card__media {
	display: block;
	height: var(--wp--custom--card--image-height);
	overflow: hidden;
}

.fh-card__img,
.fh-card__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

/* Only an empty card shows the grey; behind a photo there's nothing, so the hover shrink
   doesn't uncover a grey edge. */
.fh-card__placeholder {
	background: var(--wp--preset--color--image-placeholder);
}

@media (hover: hover) {
	.fh-card__link:hover .fh-card__img,
	.fh-card__link:hover .fh-card__placeholder {
		transform: scale(0.95);
	}
}

.fh-card .fh-card__title {
	margin: 6px 0 0;
	font-family: var(--wp--preset--font-family--helvetica-neue);
	font-size: var(--wp--preset--font-size--subheading);
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: -0.01em;
}

.fh-card__line {
	margin: 4px 0 0;
	color: var(--wp--preset--color--muted);
}

/* Desktop: case study cards keep the 4:5 crop at whatever width they are (566 tall at 1440). */
@media (min-width: 1200px) {
	.fh-project-list .fh-card__media {
		height: auto;
		aspect-ratio: 4 / 5;
	}
}

/* Card grid (case study archive, service "View selected works"): 1 / 2 / 3 columns. */
.fh-project-list:not(.is-strip) .fh-cards {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--custom--grid-row-gap) var(--wp--custom--gutter);
}

@media (min-width: 810px) {
	.fh-project-list:not(.is-strip) .fh-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1200px) {
	.fh-project-list:not(.is-strip) .fh-cards {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ---------- Project strip (LoopScroller): 1.12 / 2.1 / 3 cards across the content width ---------- */

.fh-strip {
	position: relative;
	--fh-cards-in-view: 1.12;
	--fh-card-w: calc((var(--fh-content-w) - var(--wp--custom--gutter) * (var(--fh-cards-in-view) - 1)) / var(--fh-cards-in-view));
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	cursor: grab;
}

.fh-strip::-webkit-scrollbar {
	display: none;
}

.fh-strip.is-dragging {
	cursor: grabbing;
	user-select: none;
}

.fh-strip.is-dragging .fh-card__link {
	pointer-events: none;
}

@media (min-width: 810px) {
	.fh-strip {
		--fh-cards-in-view: 2.1;
	}
}

@media (min-width: 1200px) {
	.fh-strip {
		--fh-cards-in-view: 3;
	}
}

.fh-strip .fh-cards {
	display: flex;
	gap: var(--wp--custom--gutter);
	width: max-content;
	padding-inline: calc((100vw - var(--fh-content-w)) / 2 - var(--wp--custom--frame));
}

.fh-strip .fh-card {
	flex: 0 0 var(--fh-card-w);
}

.fh-strip img {
	-webkit-user-drag: none;
}

/* ---------- Enquiry section: form left, image right (desktop); image below the form under 1200px ---------- */

.fh-enquiry.wp-block-cover {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	min-height: 0;
	padding: 0;
	color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--paper);
}

.fh-enquiry .wp-block-cover__background {
	display: none;
}

.fh-enquiry > .wp-block-cover__inner-container {
	order: 1;
	box-sizing: border-box;
	width: 100%;
	padding: 56px calc(var(--wp--custom--outer) - var(--wp--custom--frame));
	color: inherit;
}

.fh-enquiry > .wp-block-cover__inner-container > * {
	max-width: var(--fh-content-w);
	margin-inline: auto;
}

.wp-block-cover.fh-enquiry .wp-block-cover__image-background,
.fh-enquiry::after {
	order: 2;
	position: static;
	width: 100%;
	height: 360px;
}

/* No image chosen yet: a Stone placeholder where the image goes. */
.fh-enquiry:not(:has(.wp-block-cover__image-background))::after {
	content: "";
	display: block;
	background: var(--wp--preset--color--stone);
}

@media (min-width: 810px) {
	.wp-block-cover.fh-enquiry .wp-block-cover__image-background,
	.fh-enquiry::after {
		height: 460px;
	}
}

@media (min-width: 1200px) {
	/* Two squares: form half and image half (690 x 690 at 1440). The photo starts 10px past the
	   centre line, so beside another half-width photo (Home's commissions) there's a 20px gap,
	   the same as the frame. */
	.fh-enquiry.wp-block-cover {
		flex-direction: row;
		justify-content: flex-start;
		min-height: calc(50vw - 1.5 * var(--wp--custom--frame));
	}

	.fh-enquiry > .wp-block-cover__inner-container {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 50%;
		padding: 40px 0;
	}

	.fh-enquiry > .wp-block-cover__inner-container > * {
		width: 70%;
		max-width: none;
	}

	/* The photo fills the right half exactly, whatever its own shape. */
	.wp-block-cover.fh-enquiry .wp-block-cover__image-background,
	.fh-enquiry::after {
		position: absolute;
		top: 0;
		right: 0;
		left: auto;
		width: calc(50% - var(--wp--custom--frame) / 2);
		height: 100%;
		min-height: 0;
	}
}

.fh-enquiry__form > * + * {
	margin-block-start: 40px;
}

.fh-enquiry h2,
.fh-enquiry h1 {
	margin: 0;
}

/* Contact: the section heading is the page's h1, at Heading 2 size; a phone field and a taller message box. */
.fh-enquiry--contact h1 {
	font-size: var(--wp--preset--font-size--heading-2);
	line-height: 1.12;
	letter-spacing: -0.025em;
}

.fh-enquiry--contact .fh-form__field textarea {
	height: 129px;
}

/* Phones: Contact is just the form, filling the screen below the header; no photo. */
@media (max-width: 809.98px) {
	.wp-block-cover.fh-enquiry--contact .wp-block-cover__image-background,
	.fh-enquiry--contact::after {
		display: none;
	}

	.fh-enquiry--contact > .wp-block-cover__inner-container {
		display: flex;
		flex-direction: column;
		justify-content: center;
		min-height: calc(100svh - var(--wp--custom--header-height));
	}

	.fh-enquiry--contact > .wp-block-cover__inner-container > * {
		width: 100%;
	}
}

/* Its form is taller (phone field), so a little less space above and below keeps it square. */
@media (min-width: 1200px) {
	.fh-enquiry--contact > .wp-block-cover__inner-container {
		padding-block: 36px;
	}
}

.fh-page--contact main.wp-block-group > * {
	margin-block: 0;
}

/* ---------- Enquiry form ---------- */

.fh-form {
	display: grid;
	gap: 6px;
}

.fh-form__field {
	position: relative;
	display: block;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.fh-form__field input,
.fh-form__field select,
.fh-form__field textarea {
	box-sizing: border-box;
	display: block;
	width: 100%;
	margin: 0;
	padding: 12px 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--helvetica-neue);
	font-size: var(--wp--preset--font-size--field);
	line-height: 1.3;
	letter-spacing: 0.06em;
	appearance: none;
}

/* Field heights include the 1px underline: 44 per field, 110 for the message (130 on Contact). */
.fh-form__field input,
.fh-form__field select {
	height: 43px;
}

.fh-form__field textarea {
	height: 109px;
	resize: vertical;
}

.fh-form__field ::placeholder {
	color: var(--wp--preset--color--placeholder);
	text-transform: uppercase;
	opacity: 1;
}

.fh-form__field select {
	padding-right: 24px;
	color: var(--wp--preset--color--placeholder);
	text-transform: uppercase;
	cursor: pointer;
}

.fh-form__field select.has-value {
	color: var(--wp--preset--color--ink);
}

.fh-form__field select option {
	color: var(--wp--preset--color--ink);
	text-transform: none;
}

.fh-form__chevron {
	position: absolute;
	right: 2px;
	top: 50%;
	color: var(--wp--preset--color--muted);
	transform: translateY(-50%);
	pointer-events: none;
}

.fh-form__field:focus-within {
	border-bottom-color: var(--wp--preset--color--ink);
}

.fh-form__field :focus-visible {
	outline: none;
}

.fh-form__field:has(:focus-visible) {
	outline: 2px solid var(--wp--preset--color--ink);
	outline-offset: 2px;
}

.fh-form__field.is-invalid {
	border-bottom-color: var(--wp--preset--color--ink);
}

.fh-form__error {
	margin: 4px 0 0;
	color: var(--wp--preset--color--ink);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

.fh-form__trap {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.fh-form__actions {
	margin-top: 26px;
	display: grid;
	gap: 6px;
}

.fh-btn--block {
	width: 100%;
	min-height: 44px;
	padding: 12px 24px;
	line-height: 1.2;
}

.fh-btn[disabled] {
	cursor: progress;
}

.fh-form__note,
.fh-form__status {
	margin: 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

.fh-form__status:empty {
	display: none;
}

.fh-form__status {
	color: var(--wp--preset--color--ink);
}

/* ---------- Lead paragraph: Body Large, Muted, half the content width from 810 ---------- */

.is-layout-constrained > .fh-lead {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--body-large);
	line-height: 1.55;
	letter-spacing: -0.005em;
}

@media (min-width: 810px) {
	.is-layout-constrained > .fh-lead {
		box-sizing: border-box;
		max-width: calc(var(--fh-content-w) / 2) !important;
		margin-left: calc((100% - var(--fh-content-w)) / 2) !important;
	}
}

/* ---------- Arrow (assets/img/arrow.svg) ----------
 * Plain and geometric: a straight shaft and a 90° open head, one even stroke the weight of the
 * Helvetica stems, flat ends. Drawn as a mask so it takes the text colour and scales with the
 * type. --left flips it. It nudges 4px its way on hover.
 */

.fh-arrow {
	display: inline-block;
	flex: none;
	width: 1em;
	height: 0.75em;
	background-color: currentColor;
	-webkit-mask: url(../img/arrow.svg) center / contain no-repeat;
	mask: url(../img/arrow.svg) center / contain no-repeat;
	transition: transform 0.45s var(--fh-ease);
}

.fh-arrow--left {
	transform: scaleX(-1);
}

/* ---------- Arrow links: "← Back", "← Previous project", "Next project →" ----------
 * Fade and an underline that draws in from the left on hover, like the menu and footer links;
 * the underline runs under the words only, not the arrow.
 */

.fh-back {
	line-height: 1.3;
}

/* Text links get a taller tap area (44px) without moving anything. Arrow links: padding out,
   margin back (their underline is on the label). Plain text links draw their underline on
   themselves, so an invisible layer takes the taps instead. */
.fh-arrow-link {
	padding-block: 11px;
	margin-block: -11px;
}

.fh-link a,
a.fh-link {
	position: relative;
}

.fh-link a::before,
a.fh-link::before {
	content: "";
	position: absolute;
	inset: -11px 0;
}

.fh-arrow-link {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	color: inherit;
	text-decoration: none;
	transition: opacity 0.3s ease;
}

.fh-arrow-link__label {
	padding-bottom: 3px;
	background-image: linear-gradient(currentColor, currentColor);
	background-repeat: no-repeat;
	background-size: 0% 1px;
	background-position: 100% 100%;
	transition: background-size 0.45s var(--fh-ease);
}

@media (hover: hover) {
	.fh-arrow-link:hover {
		opacity: 0.4;
	}

	.fh-arrow-link:hover .fh-arrow-link__label {
		background-size: 100% 1px;
		background-position: 0 100%;
	}

	.fh-arrow-link:hover .fh-arrow--right {
		transform: translateX(4px);
	}

	.fh-arrow-link:hover .fh-arrow--left {
		transform: scaleX(-1) translateX(4px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.fh-arrow,
	.fh-arrow-link__label {
		transition: none;
	}
}

/* ---------- Closing enquiry prompt (heading + Enquire today) ---------- */

.fh-cta {
	padding-block: var(--wp--preset--spacing--section-120);
}

.fh-cta > * {
	margin-block: 0;
}

.is-layout-constrained.fh-cta > h2 {
	max-width: min(760px, var(--fh-content-w));
	margin-left: calc((100% - var(--fh-content-w)) / 2) !important;
}

.fh-cta > * + * {
	margin-block-start: 32px;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-button__link::after,
	.fh-btn::after,
	.fh-card__img,
	.fh-card__placeholder {
		transition: none;
	}
}
