/*
 * The House page (page-the-house.php).
 * Ported from the-house.uk theme. Everything is scoped to .th-page so it
 * can't leak into, or be overridden by, Divi and the child theme.
 */

.th-page {
	--th-paper: #faf8f4;
	--th-paper-warm: #f3efe7;
	--th-ink: #2b2a26;
	--th-ink-soft: #5f5c54;
	--th-brick: #9c5a3c;
	--th-font: "BernhardModernW01-Roman", Georgia, "Times New Roman", serif;
	--th-measure: 42rem;
	--th-space-sm: 1rem;
	--th-space-md: 2rem;
	--th-space-lg: 3.5rem;
	--th-space-xl: 5.5rem;

	background: var(--th-paper);
	color: var(--th-ink);
	font-family: var(--th-font);
	font-size: 1.0625rem;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
}

.th-page *,
.th-page *::before,
.th-page *::after {
	box-sizing: border-box;
}

/* Undo Divi's heading/paragraph padding and colours. */
.th-page h1,
.th-page h2,
.th-page p {
	margin: 0;
	padding: 0;
	font-family: var(--th-font);
	font-weight: 400;
	overflow-wrap: break-word;
}

.th-page h1,
.th-page h2 {
	line-height: 1.15;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.th-page img {
	display: block;
	max-width: 100%;
	height: auto;
}

.th-narrow {
	width: min(100% - 2.5rem, var(--th-measure));
	margin-inline: auto;
}

.th-section {
	padding-block: var(--th-space-lg);
}

@media (min-width: 48rem) {
	.th-section {
		padding-block: var(--th-space-xl);
	}
}

/* ---- Buttons: outline, filling on hover; solid for the closing CTA ---- */
.th-page .th-btn {
	display: inline-block;
	padding: 0.85em 1.8em;
	border: 1px solid var(--th-ink);
	border-radius: 2px;
	background: transparent;
	color: var(--th-ink);
	font-family: var(--th-font);
	font-size: 0.95rem;
	line-height: 1.4;
	letter-spacing: 0.04em;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.th-page .th-btn:hover,
.th-page .th-btn:focus-visible {
	background: var(--th-ink);
	color: var(--th-paper);
}

.th-page .th-btn--solid {
	background: var(--th-ink);
	color: var(--th-paper);
}

.th-page .th-btn--solid:hover,
.th-page .th-btn--solid:focus-visible {
	background: transparent;
	color: var(--th-ink);
}

.th-page :focus-visible {
	outline: 2px solid var(--th-brick);
	outline-offset: 3px;
}

/* ---- Hero ---- */
.th-hero {
	/* Compact on phones, taller on big screens */
	--th-hero-h: min(78vh, 110vw, max(44rem, 52vw));
	/* Rendered photo height: 122.67vw = 1488 / 1213 */
	--th-hero-img-h: max(var(--th-hero-h), 122.67vw);
	position: relative;
	height: var(--th-hero-h);
	overflow: hidden;
	background: var(--th-ink);
}

.th-page .th-hero__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.th-hero__scrim {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to bottom,
		rgb(0 0 0 / 0.25) 0%,
		rgb(0 0 0 / 0.05) 35%,
		rgb(0 0 0 / 0.55) 100%
	);
}

.th-hero__content {
	/* Title on the lawn: offsets measured from this photo */
	position: absolute;
	top: min(
		calc(var(--th-hero-h) / 2 + 0.145 * var(--th-hero-img-h)),
		calc(0.75 * var(--th-hero-h) + 0.039 * var(--th-hero-img-h)),
		calc(var(--th-hero-h) - 3.5rem)
	);
	left: 0;
	right: 0;
	transform: translateY(-50%);
	text-align: center;
	text-shadow:
		0 1px 3px rgb(0 0 0 / 0.55),
		0 2px 12px rgb(0 0 0 / 0.5),
		0 1px 24px rgb(0 0 0 / 0.35);
}

.th-page .th-hero__title {
	color: #fff;
	font-size: clamp(2.4rem, 10vw, 4.8rem);
}

/* ---- Intro ---- */
.th-intro {
	text-align: center;
	padding-bottom: 0; /* Paper-on-paper with the gallery below. */
}

.th-page .th-intro__title {
	margin-bottom: var(--th-space-md);
	color: var(--th-ink);
	font-size: clamp(1.9rem, 4vw, 2.75rem);
}

.th-page .th-intro p {
	font-size: clamp(1.2rem, 2.4vw, 1.5rem);
	line-height: 1.5;
	color: var(--th-ink-soft);
	text-wrap: pretty;
}

.th-page .th-intro p:not(:last-child) {
	margin-bottom: 1em;
}

.th-page .th-intro a:not(.th-btn) {
	color: var(--th-brick);
	text-underline-offset: 0.18em;
}

.th-page .th-actions {
	margin-top: var(--th-space-md);
}

/* ---- Gallery: edge to edge, uncropped, 2 cols then 3 (as core Gallery) ---- */
.th-page .th-gallery {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.th-page .th-gallery__item {
	display: flex;
	flex-direction: column;
	justify-content: center;
	flex-grow: 1;
	width: calc(50% - 0.25rem);
	margin: 0;
	padding: 0;
	border-radius: 2px;
	overflow: hidden;
}

@media (min-width: 600px) {
	.th-page .th-gallery__item {
		width: calc(33.333% - 0.334rem);
	}
}

.th-gallery__link {
	display: block;
	cursor: zoom-in;
	touch-action: manipulation; /* iOS: no double-tap zoom. */
}

.th-page .th-gallery__link img {
	width: 100%;
	transition: transform 0.4s ease, filter 0.4s ease;
}

.th-gallery__link:hover img {
	transform: scale(1.02);
	filter: brightness(1.04);
}

/* ---- Closing CTA ---- */
.th-book {
	text-align: center;
	background: var(--th-paper-warm);
}

/* ---- Lightbox (<dialog>, top layer, so Divi's fixed header can't cover it) ---- */
.th-lightbox {
	width: 100vw;
	max-width: none;
	height: 100vh;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: hidden;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.th-lightbox[open] {
	display: grid;
	place-items: center;
}

.th-lightbox::backdrop {
	background: rgb(0 0 0 / 0.5);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}

.th-lightbox__img {
	max-width: calc(100vw - 2rem);
	max-height: calc(100dvh - 7rem);
	width: auto;
	height: auto;
	border-radius: 2px;
	box-shadow: 0 6px 30px rgb(0 0 0 / 0.35);
	user-select: none;
	-webkit-user-select: none;
}

.th-lightbox__count {
	position: absolute;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-family: var(--th-font);
	font-size: 1rem;
	text-shadow: 0 1px 4px rgb(0 0 0 / 0.6);
}

/* White pills, large enough to hit on a phone. */
.th-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 0;
	border-radius: 50px;
	background: #fff;
	color: #2b2a26;
	box-shadow: 0 2px 10px rgb(0 0 0 / 0.25);
	cursor: pointer;
	touch-action: manipulation;
}

.th-lightbox__btn:hover,
.th-lightbox__btn:focus-visible {
	color: #9c5a3c;
}

.th-lightbox__btn svg {
	width: 1.5rem;
	height: 1.5rem;
	fill: currentColor;
}

.th-lightbox__close {
	top: 1rem;
	right: 1rem;
}

.th-lightbox__prev,
.th-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.th-lightbox__prev {
	left: 1rem;
}

.th-lightbox__next {
	right: 1rem;
}

@media (max-width: 48rem) {
	.th-lightbox__btn {
		width: 3.5rem;
		height: 3.5rem;
	}

	/* Arrows drop to the bottom corners so they don't sit on the photo. */
	.th-lightbox__prev,
	.th-lightbox__next {
		top: auto;
		bottom: 0.75rem;
		transform: none;
	}

	.th-lightbox__prev {
		left: 0.75rem;
	}

	.th-lightbox__next {
		right: 0.75rem;
	}

	.th-lightbox__count {
		bottom: 1.75rem;
	}
}

/* Stop the page scrolling behind the open lightbox. */
html.th-lock {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.th-page .th-btn,
	.th-page .th-gallery__link img {
		transition: none;
	}

	.th-gallery__link:hover img {
		transform: none;
	}
}
