/*
 * Project Grid block (template-parts/blocks/section_project-grid.php, js/blocks_js/block_project-grid.js).
 * Loaded by abefactors_acf_block_enqueue_assets() only on pages that contain the block (and in the editor).
 *
 * Design, at 1728px:
 *   Projects page ("Projects")   two columns 678px, 20px gap; photo 678 x 490; name ExtraBold 22px 26px under it;
 *                                gold arrow 28px; 67px between rows; light grey section 122px above, 161px under
 *   Home ("Featured Projects")   line across, "FEATURED PROJECTS" 36px under it, title Bold 32px; three columns
 *                                445px, 21px gap; photo 444 x 550; name ExtraBold 18px and summary Regular 18px
 *                                28px under the photo; button about 80px under the cards
 *   Popup ("Projects_popup")     1239px wide; photo 1239 x 702; light grey text area, 64px side padding;
 *                                title ExtraBold 32px; facts 18/24 with Bold labels; white close icon top right
 *                                The design has no previous / next yet (Kristy's comment): round buttons on the
 *                                photo and a counter, in the style of the close icon.
 */

/* ------------------------------------------------------------------
 * Section
 * ------------------------------------------------------------------ */
.section_project_grid {
	position: relative;
	--project-line: var(--wp--preset--color--steel);
}

.section_project_grid.global-block-ptb {
	padding-top: clamp(48px, 7.06vw, 122px);
	padding-bottom: clamp(60px, 9.3vw, 161px);
}

/* Background Image (Settings): a 70% Charcoal overlay; set the text colour to White. */
.section_project_grid.has_bg::before {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--wp--preset--color--secondary);
	opacity: 0.7;
	pointer-events: none; /* decorative */
}

.section_project_grid.has_bg > .container {
	position: relative;
}

.section_project_grid.has_bg_color {
	--project-line: currentColor;
}

/* ------------------------------------------------------------------
 * Head (same columns as Split Content)
 * ------------------------------------------------------------------ */
.project_grid_head {
	display: grid;
	grid-template-columns: minmax(0, 504fr) minmax(0, 855fr);
	column-gap: 19px;
	align-items: start;
	margin-bottom: clamp(36px, 3.9vw, 68px);
}

.top-line-one .project_grid_head {
	padding-top: 36px;
	border-top: 1px solid var(--project-line);
}

.top-line-two .project_grid_head_title,
.top-line-two .project_grid_head_text {
	padding-top: 36px;
	border-top: 1px solid var(--project-line);
}

.project_grid_head .section_title_above {
	margin: 0 0 12px;
}

.project_grid_title {
	max-width: 14em; /* "From concept design to / operations, we work across / the full lifecycle of a project." */
	margin: 0;
	font-weight: 700;
	letter-spacing: 0;
}

.project_grid_title:not([class*="fontsize-"]) {
	font-size: var(--wp--preset--font-size--medium-32);
	line-height: 1.3;
}

.project_grid_description {
	max-width: 735px;
	font-weight: 500;
}

.project_grid_description:not([class*="fontsize-"]) {
	font-size: var(--wp--preset--font-size--body);
	line-height: 30px;
}

.project_grid_description p {
	margin: 0 0 30px;
}

.project_grid_description > :last-child {
	margin-bottom: 0;
}

.project_grid_description a:not(.button) {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------ */
.section_project_grid .project_grid_list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 20px;
	row-gap: clamp(36px, 3.9vw, 67px);
	margin: 0;
	padding: 0;
	list-style: none;
}

.section_project_grid.project-columns-3 .project_grid_list {
	grid-template-columns: repeat(3, minmax(0, 1fr));
	column-gap: 21px;
}

.section_project_grid .project_grid_list > li {
	margin: 0;
	padding: 0;
}

.section_project_grid .project_grid_list > li::before {
	content: none; /* no list dash from the theme */
}

.project_card {
	position: relative; /* the stretched link covers the card */
}

.project_card_photo {
	aspect-ratio: 678 / 490;
	overflow: hidden;
	background-color: var(--wp--preset--color--silver); /* until the photo loads, or without a photo */
}

.project-columns-3 .project_card_photo {
	aspect-ratio: 444 / 550;
}

.project_card_img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s ease;
}

.project_card_text {
	padding-top: 26px;
	font-size: var(--wp--preset--font-size--body);
	line-height: 25px;
}

.project-columns-3 .project_card_text {
	padding-top: 28px;
}

.project_card_name {
	margin: 0;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small-22);
	font-weight: 800;
	line-height: 1.3;
	letter-spacing: 0;
}

.project-columns-3 .project_card_name {
	font-size: var(--wp--preset--font-size--body);
	line-height: 25px;
}

.project_card_link {
	color: inherit;
	text-decoration: none;
}

/* The link's click area covers the whole card (photo included). */
.project_card_link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.project_card_summary {
	max-width: 420px;
	margin: 0;
	font-weight: 400;
}

.project_card_arrow {
	display: inline-block;
	margin-top: 16px;
	color: var(--wp--preset--color--gold);
	font-size: 28px;
	line-height: 1;
	transition: transform 0.2s ease;
}

/* Hover: photo zooms a little, the name is underlined, the arrow moves towards its direction. */
.project_card:hover .project_card_img {
	transform: scale(1.03);
}

.project_card:hover .project_card_link {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.project_card:hover .project_card_arrow,
.project_card:focus-within .project_card_arrow {
	transform: translate(3px, -3px);
}

/* Keyboard focus: the outline goes around the whole card (WCAG 2.4.7, 2.4.11). */
.project_card_link:focus {
	outline: none;
}

.project_card_link:focus-visible::after {
	outline: 3px solid var(--wp--preset--color--secondary);
	outline-offset: 6px;
}

/* Safari may retain :focus-visible when the dialog returns focus after a click.
 * Keep focus restoration accessible, but show the card ring only for keyboard input. */
html[data-input="pointer"] .project_card_link:focus::after {
	outline: none;
}

.has_bg .project_card_link:focus-visible::after {
	outline-color: currentColor;
}

/* ------------------------------------------------------------------
 * Button
 * ------------------------------------------------------------------ */
.project_grid_button {
	display: flex;
	justify-content: center;
	margin-top: clamp(48px, 5.5vw, 95px);
}

/* ------------------------------------------------------------------
 * Popup
 * ------------------------------------------------------------------ */
html.has-open-dialog {
	overflow: hidden; /* the page behind does not scroll */
}

.project_dialog {
	--dialog-w: min(calc(100vw - 40px), 1239px);
	--media-h: min(calc(var(--dialog-w) * 702 / 1239), 58vh);
	width: var(--dialog-w);
	max-width: none;
	max-height: calc(100dvh - 40px);
	margin: auto;
	padding: 0;
	border: 0;
	background: var(--wp--preset--color--lightgrey);
	color: var(--wp--preset--color--black);
	overflow: auto;
	overscroll-behavior: contain;
}

.project_dialog::backdrop {
	background: rgba(36, 31, 33, 0.85);
}

.project_dialog[open] {
	animation: abe-dialog-in 0.25s ease both;
}

@keyframes abe-dialog-in {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
}

.project_dialog_box {
	position: relative;
}

.project_dialog_stage {
	overflow: hidden; /* the slide never shows outside the box */
}

.project_dialog_item {
	transition: transform 0.35s ease, opacity 0.35s ease;
}

.project_dialog_item.is-from-right,
.project_dialog_item.is-from-left {
	opacity: 0;
	transition: none;
}

.project_dialog_item.is-from-right {
	transform: translateX(48px);
}

.project_dialog_item.is-from-left {
	transform: translateX(-48px);
}

.project_dialog_media {
	height: var(--media-h);
	background-color: var(--wp--preset--color--secondary);
}

.project_dialog_img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.project_dialog_text {
	padding: clamp(28px, 2.5vw, 43px) clamp(20px, 3.7vw, 64px) clamp(40px, 4.6vw, 80px);
}

.project_dialog_title {
	margin: 0 0 17px;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium-32);
	font-weight: 800;
	line-height: 1.3;
	letter-spacing: 0;
}

.project_dialog_facts {
	margin: 0;
	font-size: var(--wp--preset--font-size--body);
	line-height: 24px;
}

.project_dialog_facts dt,
.project_dialog_facts dd {
	display: inline;
	margin: 0;
}

.project_dialog_facts dt {
	font-weight: 700;
}

.project_dialog_description {
	max-width: 790px;
	margin-top: 24px;
	font-size: var(--wp--preset--font-size--body);
	line-height: 30px;
}

.project_dialog_description p {
	margin: 0 0 20px;
}

.project_dialog_description > :last-child {
	margin-bottom: 0;
}

/* Close, previous, next: white icons on a dark round backing, so they show on any photo (WCAG 1.4.11). */
.project_dialog .project_dialog_close,
.project_dialog .project_dialog_nav {
	position: absolute;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 50%;
	background-color: rgba(36, 31, 33, 0.6);
	color: var(--wp--preset--color--white);
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.project_dialog .project_dialog_close::after,
.project_dialog .project_dialog_nav::after {
	content: none; /* no button arrow from the theme */
}

.project_dialog .project_dialog_close:hover,
.project_dialog .project_dialog_nav:hover {
	background-color: var(--wp--preset--color--secondary);
}

.project_dialog .project_dialog_close:focus-visible,
.project_dialog .project_dialog_nav:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.project_dialog .project_dialog_close {
	top: 20px;
	right: 20px;
	font-size: 22px;
}

/* Previous / next: on the middle of the photo, at its edges. */
.project_dialog_controls {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	height: var(--media-h);
	pointer-events: none; /* only the buttons take clicks; the photo can be swiped */
}

.project_dialog .project_dialog_nav {
	top: 50%;
	font-size: 26px;
	transform: translateY(-50%);
	pointer-events: auto;
}

.project_dialog_prev {
	left: 20px;
}

.project_dialog_next {
	right: 20px;
}

/* Counter "3 / 12" at the bottom of the photo (screen readers hear the live region instead). */
.project_dialog_count {
	position: absolute;
	bottom: 16px;
	left: 50%;
	margin: 0;
	padding: 4px 12px;
	border-radius: 20px;
	background-color: rgba(36, 31, 33, 0.6);
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--small-16);
	font-weight: 600;
	line-height: 1.5;
	transform: translateX(-50%);
}

@media (forced-colors: active) {
	 .project_dialog .project_dialog_close,
	.project_dialog .project_dialog_nav,
	.project_dialog_count {
		border-color: ButtonText;
	}

	.project_card_link:focus-visible::after {
		outline-color: Highlight;
	}
}

@media (prefers-reduced-motion: reduce) {
	.project_card_img,
	.project_card_arrow,
	.project_dialog_item {
		transition: none;
	}

	.project_card:hover .project_card_img,
	.project_card:hover .project_card_arrow,
	.project_card:focus-within .project_card_arrow {
		transform: none;
	}

	.project_dialog[open] {
		animation: none;
	}
}

/* ------------------------------------------------------------------
 * Smaller screens
 * ------------------------------------------------------------------ */
@media screen and (max-width: 900px) {
	.project_grid_head {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 16px;
	}

	.top-line-two .project_grid_head_text {
		padding-top: 0;
		border-top: 0;
	}

	.section_project_grid.project-columns-3 .project_grid_list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media screen and (max-width: 600px) {
	.project_card_arrow {
		font-size: 20px;
	}

	.section_project_grid .project_grid_list,
	.section_project_grid.project-columns-3 .project_grid_list {
		grid-template-columns: minmax(0, 1fr);
	}

	.project_dialog {
		--dialog-w: calc(100vw - 24px);
		max-height: calc(100dvh - 24px);
	}

	 .project_dialog .project_dialog_close,
	.project_dialog .project_dialog_nav {
		width: 44px;
		height: 44px;
	}

	 .project_dialog .project_dialog_close {
		top: 12px;
		right: 12px;
	}

	.project_dialog_prev {
		left: 12px;
	}

	.project_dialog_next {
		right: 12px;
	}
}

/* Empty block in the editor. */
.project_grid_empty {
	margin: 0;
	padding: 40px 20px;
	border: 1px dashed var(--wp--preset--color--mediumgrey);
	border-radius: 24px;
	text-align: center;
}
