/**
 * Vibrant Hero - Frontend Styles
 *
 * Mobile first. The desktop layout kicks in at 900px.
 *
 * @author  Accent - https://accentinteractive.nl
 * @package Vibrant
 * @since   1.0.0
 */

/* ==========================================================================
   Section
   ========================================================================== */

.wp-block-vibrant-hero {
	/* Colors – theme presets with the design system as fallback. */
	--vb-hero-gradient-start: var(--wp--preset--color--green-100, #E5ECE6);
	--vb-hero-gradient-end: var(--wp--preset--color--cream-50, #FBF9F3);
	--vb-hero-text: var(--wp--preset--color--green-900, #1D261F);
	--vb-hero-text-muted: var(--wp--preset--color--green-700, #525F55);
	--vb-hero-accent: var(--wp--preset--color--rose-200, #F2E5E6);
	--vb-hero-action: var(--wp--preset--color--terracotta, #A23E2B);
	--vb-hero-action-hover: var(--wp--preset--color--green-800, #2B4231);
	--vb-hero-action-text: var(--wp--preset--color--white, #FFFFFF);
	--vb-hero-field-bg: var(--wp--preset--color--white, #FFFFFF);
	/*
	 * WCAG 1.4.11 asks 3:1 for the boundary of a form control. The design's
	 * #C6D5CA reaches 1.5:1 on white, so this is a darker sage that clears it.
	 */
	--vb-hero-field-border: var(--wp--preset--color--green-500, #808E84);

	/* Typography */
	--vb-hero-font-display: var(--wp--preset--font-family--fraunces, "Fraunces", Georgia, serif);
	--vb-hero-font-body: var(--wp--preset--font-family--sora, "Sora", sans-serif);

	/* Layout */
	--vb-hero-max-width: 1280px;
	--vb-hero-content-width: 680px;
	--vb-hero-media-size: 520px;
	--vb-hero-gap: 24px;
	--vb-hero-content-gap: 24px;
	--vb-hero-radius-field: 16px;

	box-sizing: border-box;
	padding: 32px 20px 48px;
	background: linear-gradient(
		180deg,
		var(--vb-hero-gradient-start) 0%,
		var(--vb-hero-gradient-end) 100%
	);
	color: var(--vb-hero-text);
}

.wp-block-vibrant-hero *,
.wp-block-vibrant-hero *::before,
.wp-block-vibrant-hero *::after {
	box-sizing: border-box;
}

.vb-hero__inner {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--vb-hero-gap);
	max-width: var(--vb-hero-max-width);
	margin-inline: auto;
}

/* ==========================================================================
   Content
   ========================================================================== */

.vb-hero__content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--vb-hero-content-gap);
	width: 100%;
	min-width: 0;
}

.vb-hero__headline {
	margin: 0;
	max-width: var(--vb-hero-content-width);
	font-family: var(--vb-hero-font-display);
	font-weight: 900;
	font-size: clamp(2.375rem, 1.5rem + 3.5vw, 4rem);
	line-height: 1.15;
	letter-spacing: 0;
	text-transform: none;
	color: var(--vb-hero-text);
	text-wrap: balance;
}

.vb-hero__subtitle {
	margin: 0 !important;
	max-width: var(--vb-hero-content-width);
	font-family: var(--vb-hero-font-body);
	font-weight: 400;
	font-size: clamp(0.9375rem, 0.85rem + 0.35vw, 1.125rem);
	line-height: 1.6;
	color: var(--vb-hero-text-muted);
}

/* ==========================================================================
   Search
   ========================================================================== */

.vb-hero__search {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 20px;
	width: 100%;
	max-width: var(--vb-hero-content-width);
	margin: 0;
	padding: 18px 12px 12px;
	background: var(--vb-hero-field-bg);
	border: 1.5px solid var(--vb-hero-field-border);
	border-radius: var(--vb-hero-radius-field);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.vb-hero__search:focus-within {
	border-color: var(--vb-hero-action);
	box-shadow: 0 0 0 3px rgba(162, 62, 43, 0.15);
}

/*
 * In modal mode the field is a way into the search panel rather than a place
 * to type, so the whole thing reads as one control.
 */
.vb-hero__search[data-vb-hero-search-modal],
.vb-hero__search[data-vb-hero-search-modal] .vb-hero__search-input {
	cursor: pointer;
}

.vb-hero__search-field {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.vb-hero__search-icon {
	display: flex;
	flex: 0 0 20px;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	color: var(--vb-hero-text-muted);
}

.vb-hero__search-icon svg {
	display: block;
	width: 20px;
	height: 20px;
}

.vb-hero__search-input {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font-family: var(--vb-hero-font-body);
	font-weight: 400;
	/*
	 * 16px is a floor, not a design choice. Below it, iOS and Android zoom the
	 * page in the moment the field takes focus. The design asks for 14px here
	 * on mobile, but a zooming viewport costs more than two pixels.
	 */
	font-size: 1rem;
	line-height: 1.3;
	color: var(--vb-hero-text);
	-webkit-appearance: none;
	appearance: none;
}

.vb-hero__search-input:focus {
	outline: none;
	box-shadow: none;
}

.vb-hero__search-input::placeholder {
	color: var(--vb-hero-text-muted);
	opacity: 1;
}

.vb-hero__search-input::-webkit-search-cancel-button,
.vb-hero__search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.vb-hero__search-button {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	padding: 12px 24px;
	background: var(--vb-hero-action);
	border: 0;
	border-radius: 100px;
	font-family: var(--vb-hero-font-body);
	font-weight: 700;
	font-size: 0.875rem;
	line-height: 1.3;
	color: var(--vb-hero-field-bg);
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.vb-hero__search-button:hover,
.vb-hero__search-button:focus-visible {
	background: var(--vb-hero-action-hover);
	color: var(--vb-hero-field-bg);
}

.vb-hero__search-button:focus-visible {
	outline: 2px solid var(--vb-hero-text);
	outline-offset: 2px;
}

/* Local copy so the block does not depend on the theme for this helper. */
.vb-hero__search .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* ==========================================================================
   Calls to action
   ========================================================================== */

.vb-hero__ctas {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	width: 100%;
}

.vb-hero__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 14px 24px;
	border: 1.5px solid transparent;
	border-radius: 100px;
	font-family: var(--vb-hero-font-body);
	font-weight: 700;
	font-size: 0.9375rem;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.vb-hero__cta.is-style-primary {
	background: var(--vb-hero-action);
	border-color: var(--vb-hero-action);
	color: var(--vb-hero-action-text);
}

.vb-hero__cta.is-style-primary:hover,
.vb-hero__cta.is-style-primary:focus-visible {
	background: var(--vb-hero-action-hover);
	border-color: var(--vb-hero-action-hover);
	color: var(--vb-hero-action-text);
}

.vb-hero__cta.is-style-secondary {
	background: transparent;
	border-color: var(--vb-hero-action);
	color: var(--vb-hero-action);
}

.vb-hero__cta.is-style-secondary:hover,
.vb-hero__cta.is-style-secondary:focus-visible {
	background: var(--vb-hero-action);
	color: var(--vb-hero-action-text);
}

.vb-hero__cta:focus-visible {
	outline: 2px solid var(--vb-hero-text);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {

	.vb-hero__cta {
		transition: none;
	}
}

/* ==========================================================================
   Media
   ========================================================================== */

.vb-hero__media {
	position: relative;
	flex: 0 0 auto;
	align-self: center;
	width: 100%;
	max-width: var(--vb-hero-media-size);
	aspect-ratio: 1 / 1;
	isolation: isolate;
}

.vb-hero__accent {
	position: absolute;
	top: 3.85%;
	left: 3.85%;
	z-index: 0;
	width: 73.08%;
	height: 73.08%;
	background: var(--vb-hero-accent);
	border-radius: 50%;
}

.vb-hero__figure {
	position: absolute;
	top: 7.7%;
	left: 7.7%;
	z-index: 1;
	width: 84.62%;
	height: 84.62%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: 50% 50% 50% 9.1%;
}

.vb-hero__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	border-radius: inherit;
}

/* ==========================================================================
   Search bar as a pill
   ==========================================================================
   Independent of the two column layout below. In the stacked layout the
   content is full width, where the pill reads better than a stacked field. */

@media (min-width: 600px) {

	.vb-hero__search {
		flex-direction: row;
		align-items: center;
		gap: 12px;
		padding: 8px;
		border-radius: 100px;
	}

	.vb-hero__search-field {
		gap: 12px;
		padding-left: 16px;
	}

	.vb-hero__search-button {
		padding: 14px 24px;
		font-size: 0.9375rem;
		line-height: 1.25;
	}
}

/* ==========================================================================
   Desktop
   ==========================================================================
   Two columns from 1024px. Below that there is not enough room for a
   readable text column next to the image: at 900px the fixed 520px image
   plus an 80px gap left about 140px for the text.

   From there on the gap and the image scale with the viewport instead of
   being fixed, so the row layout is never cramped. At 1440px this lands back
   on the design: 680px of text, an 80px gap and a 520px image. */

@media (min-width: 1024px) {

	.wp-block-vibrant-hero {
		--vb-hero-gap: clamp(32px, 5.6vw, 80px);
		--vb-hero-content-gap: 32px;

		padding: 80px clamp(24px, 5.5vw, 80px) 48px;
	}

	.vb-hero__inner {
		flex-direction: row;
		align-items: center;
	}

	.wp-block-vibrant-hero.has-media-left .vb-hero__inner {
		flex-direction: row-reverse;
	}

	.vb-hero__content {
		flex: 1 1 auto;
		min-width: 360px;
		max-width: var(--vb-hero-content-width);
	}

	.vb-hero__headline {
		line-height: 1.1;
	}

	.vb-hero__media {
		/* Shrinks with the viewport, and may give way if space runs out. */
		flex: 0 1 auto;
		width: clamp(320px, 38vw, var(--vb-hero-media-size));
		align-self: center;
	}

	.wp-block-vibrant-hero.has-no-media .vb-hero__content {
		min-width: 0;
		max-width: 860px;
	}
}
