/**
 * Single Project page (single-td_project.php, template-parts/project/*).
 *
 * Mobile (390 frame): Back, title, type/location, image 350:200, overview,
 * button; details stacked; galleries two per row; viewer with the arrows on
 * the image. Tablet (600px): details and galleries in more columns. Desktop
 * (1440 frame, from 1024px): text column 427 beside the image 765:520, details
 * in three columns under the image, galleries four per row (314:220).
 */

.td-project-page {
	background-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--ivory);
}

.td-project-hero,
.td-project-galleries,
.td-project-renovation {
	box-sizing: border-box;
	max-width: var(--td-frame);
	margin-inline: auto;
	padding-inline: var(--td-gutter);
}

.td-project-page :where(h1, h2, p, dl, dd, figure, ul) {
	margin: 0;
}

/* Hero --------------------------------------------------------------------- */

/* The design frames include the 80px header: 104px − 80px = 24px. */
.td-project-hero {
	display: grid;
	gap: 32px;
	padding-top: 24px;
	padding-bottom: 48px;
}

.td-project-hero__overview {
	display: grid;
	grid-template-areas:
		"header"
		"media"
		"description"
		"button";
	gap: 24px;
}

/* Desktop column wrappers (text | image + details). Below 1024px their
   children are laid out by the grid above, in the mobile order. */
.td-project-hero__primary,
.td-project-hero__aside {
	display: contents;
}

/* Mobile: the details come last, 32px below the text as without an image
   (24px row gap + 8px). */
.td-project-hero__aside > .td-project-details {
	grid-row: -1;
	margin-top: 8px;
}

.td-project-hero__header {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 16px;
	grid-area: header;
}

.td-project-hero__back {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding-block: 4px;
	color: var(--wp--preset--color--ivory);
	text-decoration: none;
}

.td-project-hero__back .td-icon {
	flex: none;
	width: 12px;
	height: 12px;
}

.td-project-hero__back:hover span,
.td-project-hero__back:focus-visible span {
	text-decoration: underline;
	text-underline-offset: 4px;
}

.td-project-hero__back:focus-visible,
.td-project-hero__button:focus-visible {
	outline: 2px solid var(--wp--preset--color--ivory);
	outline-offset: 2px;
}

.td-project-hero__title {
	font-family: var(--wp--preset--font-family--serif);
	font-size: 40px;
	font-weight: 400;
	line-height: 48px;
	color: var(--wp--preset--color--ivory);
	text-wrap: balance;
}

.td-project-hero__info {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 32px;
	margin-top: 8px;
}

.td-project-hero__fact dt,
.td-project-hero__label,
.td-project-details__item dt {
	color: var(--wp--preset--color--stone);
}

.td-project-hero__fact dd {
	font-size: 14px;
	font-weight: 700;
	line-height: 22px;
}

.td-project-hero__media {
	grid-area: media;
}

.td-project-hero__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 350 / 200;
	object-fit: cover;
}

.td-project-hero__description {
	display: flex;
	flex-direction: column;
	gap: 4px;
	grid-area: description;
}

.td-project-hero__text {
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-size: 14px;
	line-height: 22px;
}

.td-project-hero__button {
	grid-area: button;
	justify-self: start;
	max-width: 100%;
	white-space: normal;
}

/* Project details ---------------------------------------------------------- */

.td-project-details {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.td-project-details__title {
	font-family: var(--wp--preset--font-family--sans);
	font-size: 16px;
	font-weight: 700;
	line-height: 28px;
	text-transform: uppercase;
	color: var(--wp--preset--color--ivory);
}

.td-project-details__list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 24px;
}

.td-project-details__item {
	min-width: 0;
	padding-top: 8px;
	border-top: 1px solid var(--wp--preset--color--slate);
}

.td-project-details__item dd {
	font-size: 16px;
	font-weight: 700;
	line-height: 25px;
	overflow-wrap: anywhere;
}

/* Galleries ---------------------------------------------------------------- */

.td-project-galleries {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding-bottom: 80px;
}

.td-project-gallery {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.td-project-gallery__title {
	font-family: var(--wp--preset--font-family--sans);
	font-size: 20px;
	font-weight: 800;
	line-height: 28px;
	color: var(--wp--preset--color--ivory);
}

.td-project-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	padding: 0;
	list-style: none;
}

.td-project-gallery__open {
	display: block;
	overflow: hidden;
	background-color: var(--wp--preset--color--slate);
}

.td-project-gallery__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 314 / 220;
	object-fit: cover;
	transition: transform 0.4s var(--td-ease), opacity 0.2s var(--td-ease);
}

.td-project-gallery__open:hover .td-project-gallery__image {
	transform: scale(1.03);
}

.td-project-gallery__open:focus-visible {
	outline: 2px solid var(--wp--preset--color--ivory);
	outline-offset: 2px;
}

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

	.td-project-gallery__image {
		transition: none;
	}

	.td-project-gallery__open:hover .td-project-gallery__image {
		transform: none;
	}
}

/* Renovation (optional): sections with Before / During / After galleries. A
   phase has an image grid (the gallery grid above) and, below it, its own
   video grid. */

.td-project-renovation {
	display: flex;
	flex-direction: column;
	gap: 48px;
	padding-bottom: 80px;
}

.td-project-renovation__section {
	display: flex;
	flex-direction: column;
	gap: 32px;
}

.td-project-renovation__title {
	font-family: var(--wp--preset--font-family--sans);
	font-size: 24px;
	font-weight: 800;
	line-height: 32px;
	color: var(--wp--preset--color--ivory);
}

/* Videos of a phase: their own grid below the images, never in the image
   grid. */
.td-project-videos {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	padding: 0;
	list-style: none;
}

.td-project-videos__item {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.td-project-gallery__badge {
	align-self: flex-start;
	padding: 2px 10px;
	border: 1px solid currentcolor;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
	line-height: 20px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--ivory);
}

.td-project-videos__player {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	background-color: var(--wp--preset--color--slate);
}

video.td-project-videos__player {
	object-fit: contain;
}

.td-project-videos__caption {
	font-size: 14px;
	line-height: 22px;
}

/* Full-screen viewer ("Gallery Zoom") -------------------------------------- */

html.td-project-viewer-open {
	overflow: hidden;
}

.td-project-viewer {
	box-sizing: border-box;
	width: 100vw;
	max-width: none;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0 20px;
	border: 0;
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--ivory);

	/* Swipes change the image: the browser must not also scroll or go back.
	   Pinch zoom stays. */
	overscroll-behavior: contain;
	touch-action: pinch-zoom;
}

.td-project-viewer[open] {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	animation: td-project-viewer-in 0.25s var(--td-ease);
}

.td-project-viewer::backdrop {
	background: transparent;
}

@keyframes td-project-viewer-in {

	from {
		opacity: 0;
	}
}

.td-project-viewer button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--ivory);
	cursor: pointer;
}

.td-project-viewer button:focus-visible {
	outline: 2px solid var(--wp--preset--color--ivory);
	outline-offset: 2px;
}

.td-project-viewer__close {
	position: absolute;
	top: max(16px, calc(50dvh - 352px));
	right: 20px;
	width: 40px;
	height: 40px;
}

.td-project-viewer__close .td-icon {
	width: 40px;
	height: 40px;
	stroke-width: 1.5;
}

.td-project-viewer__stage {
	position: relative;
	display: flex;
	align-items: center;
	gap: 24px;
	width: 100%;
	max-width: 1328px;
}

.td-project-viewer__figure {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	min-width: 0;
	height: min(704px, calc(100dvh - 300px), calc((100vw - 40px) * 0.5772));
}

.td-project-viewer__image {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

/* Phones: the arrows sit on the image, 20px inside its edges. */
.td-project-viewer__step {
	position: absolute;
	z-index: 1;
	width: 30px;
	height: 30px;
}

.td-project-viewer__step.is-prev {
	left: 20px;
}

.td-project-viewer__step.is-next {
	right: 20px;
}

.td-project-viewer__step .td-icon {
	width: 30px;
	height: 30px;
	stroke-width: 2;
	filter: drop-shadow(0 0 2px rgba(10, 16, 31, 0.6));
}

.td-project-viewer__thumbs {
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	max-width: 1328px;
	height: 102px;
}

.td-project-viewer__scroll {
	flex: none;
	width: 30px;
	height: 30px;
}

.td-project-viewer__scroll .td-icon {
	width: 30px;
	height: 30px;
}

.td-project-viewer__scroll:disabled {
	color: var(--wp--preset--color--stone);
	cursor: default;
}

.td-project-viewer__strip {
	display: flex;
	flex: 1;
	gap: 8px;
	min-width: 0;
	padding: 4px 2px;
	overflow-x: auto;
	list-style: none;
	scroll-behavior: smooth;
	scrollbar-width: none;

	/* The strip scrolls sideways by touch; its ends never pass the gesture on. */
	overscroll-behavior: contain;
	touch-action: pan-x;
}

.td-project-viewer__strip::-webkit-scrollbar {
	display: none;
}

.td-project-viewer__strip li {
	flex: none;
}

.td-project-viewer__thumb {
	width: 72px;
	height: 60px;
	opacity: 0.55;
	transition: opacity 0.2s var(--td-ease);
}

.td-project-viewer__thumb:hover,
.td-project-viewer__thumb[aria-current="true"] {
	opacity: 1;
}

.td-project-viewer__thumb[aria-current="true"] {
	outline: 1px solid var(--wp--preset--color--ivory);
	outline-offset: 2px;
}

.td-project-viewer__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.td-project-viewer.is-single .td-project-viewer__step,
.td-project-viewer.is-single .td-project-viewer__thumbs {
	display: none;
}

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

	.td-project-viewer[open] {
		animation: none;
	}

	.td-project-viewer__strip {
		scroll-behavior: auto;
	}
}

/* Tablet ------------------------------------------------------------------- */

@media (min-width: 600px) {

	.td-project-videos {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px;
	}

	.td-project-details__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.td-project-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 24px;
	}

	.td-project-galleries,
	.td-project-gallery {
		gap: 24px;
	}
}

/* Desktop ------------------------------------------------------------------ */

@media (min-width: 1024px) {

	.td-project-hero {
		gap: 80px;
		padding-bottom: 64px;
	}

	/* Text column 427 beside the image column 765 (gap up to 136). Without an
	   image, the details row below lines up with the same two columns. */
	.td-project-hero__overview,
	.td-project-hero > .td-project-details {
		display: grid;
		grid-template-columns: minmax(0, 427fr) minmax(0, 765fr);
		column-gap: clamp(48px, 9.45vw, 136px);
	}

	/* The two columns are independent: a long overview no longer pushes the
	   details below the image down. */
	.td-project-hero__overview {
		grid-template-areas: "primary aside";
		align-items: start;
	}

	.td-project-hero__overview.has-no-image {
		grid-template-areas: "primary primary";
	}

	/* Header at the top, button at the bottom, overview in between, like the
	   design. The column is at least as tall as the image beside it (765:520
	   at 765/427 of this column's width) and grows with a longer overview. */
	.td-project-hero__primary {
		display: grid;
		grid-area: primary;
		grid-template-areas:
			"header"
			"description"
			"button";
		grid-template-rows: auto 1fr auto;
		row-gap: 32px;
		aspect-ratio: 427 / 520;
	}

	.has-no-image > .td-project-hero__primary {
		aspect-ratio: auto;
	}

	/* Image, then the project details directly below it (80px, the spacing of
	   the details row in the design). */
	.td-project-hero__aside {
		display: flex;
		flex-direction: column;
		gap: 80px;
		grid-area: aside;
	}

	.td-project-hero__aside > .td-project-details {
		margin-top: 0;
	}

	.td-project-hero__header {
		gap: 24px;
	}

	.td-project-hero__info {
		gap: 8px 48px;
		margin-top: 0;
	}

	.td-project-hero__title {
		font-size: 48px;
		line-height: 56px;
	}

	.td-project-hero__fact dd {
		font-size: 16px;
		line-height: 25px;
	}

	.td-project-hero__image {
		aspect-ratio: 765 / 520;
	}

	.td-project-hero__description {
		align-self: center;
		gap: 8px;
	}

	.td-project-hero__text {
		font-size: 16px;
		line-height: 25px;
	}

	.td-project-hero > .td-project-details {
		align-items: start;
	}

	.td-project-details__title {
		font-size: 18px;
		line-height: 27px;
	}

	.td-project-details__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.td-project-galleries,
	.td-project-renovation {
		padding-bottom: 150px;
	}

	.td-project-renovation__section {
		gap: 40px;
	}

	.td-project-renovation__title {
		font-size: 32px;
		line-height: 40px;
	}

	.td-project-gallery__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	/* Viewer: arrows beside the image, thumbnails strip in a 1128px column. */
	.td-project-viewer {
		padding: 0 56px;
	}

	.td-project-viewer__close {
		right: 26px;
	}

	.td-project-viewer__step {
		position: static;
		flex: none;
	}

	.td-project-viewer__step .td-icon {
		filter: none;
	}

	.td-project-viewer__figure {
		height: min(704px, calc(100dvh - 300px));
	}

	.td-project-viewer__thumbs {
		justify-content: center;
		padding-inline: 54px;
	}

	.td-project-viewer__strip {
		max-width: 1128px;
	}
}
