/*
 * ROVERHAUL Gallery — album pages and lightbox.
 * Colors and type come from the child theme's --rh-* tokens and theme.json presets, so the
 * gallery follows the site; fallbacks only matter if the theme changes.
 */

.rhg {
	--rhg-gap: 12px;
	--rhg-ink: var(--rh-ink, #2c2a26);
	--rhg-brown: var(--rh-brown, #5a4e3c);
	--rhg-tan: #7a6140; /* the theme's tan is 4.1:1 on its cream, short of 4.5:1 for small text */
	--rhg-cream: var(--rh-cream, #f5efe4);
	--rhg-border: var(--rh-border, #b8a890);
	--rhg-border-light: var(--rh-border-light, #d4c7b0);
	--rhg-serif: var(--rh-serif, Georgia, serif);
	--rhg-sans: var(--rh-sans, system-ui, sans-serif);
	margin-block: 0 3rem;
}

@media (min-width: 900px) {
	.rhg {
		--rhg-gap: 20px;
	}
}

/* The theme's page title sits in the 720px content column; on gallery pages line it up with
   the wide (1080px) gallery below it. */
.rhg-page .wp-block-post-title {
	max-width: var(--wp--style--global--wide-size, 1080px);
}

/* Heard by screen readers, not shown. */
.rhg-sr,
.rhg .rhg-sr {
	position: absolute;
	width: 1px;
	min-width: 0;
	height: 1px;
	min-height: 0;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* Breadcrumbs: the theme's small-caps label style. */
.rhg-crumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: .25rem .5rem;
	margin: 0 0 1.5rem;
	padding: 0;
	list-style: none;
	font-family: var(--rhg-sans);
	font-size: 11px;
	letter-spacing: .15em;
	line-height: 1.6;
	text-transform: uppercase;
}

.rhg-crumbs li + li::before {
	content: "/";
	margin-inline-end: .5rem;
	color: var(--rhg-border);
}

/* The padding makes a 24px target without moving anything. */
.rhg-crumbs a {
	display: inline-block;
	margin-block: -4px;
	padding-block: 4px;
	color: var(--rhg-tan);
	text-decoration: none;
}

.rhg-crumbs a:hover,
.rhg-crumbs a:focus-visible {
	color: var(--rhg-ink);
}

.rhg-crumbs a:focus-visible,
.rhg-pages a:focus-visible {
	outline: 2px solid var(--rhg-ink);
	outline-offset: 2px;
}

.rhg-crumbs [aria-current] {
	color: var(--rhg-ink);
}

.rhg-updated {
	margin: -.75rem 0 1.5rem;
	font-family: var(--rhg-sans);
	font-size: 11px;
	letter-spacing: .15em;
	line-height: 1.6;
	text-transform: uppercase;
	color: var(--rhg-tan);
}

.rhg-description {
	max-width: var(--wp--style--global--content-size, 720px);
	margin-block-end: 2rem;
	font-family: var(--rhg-serif);
	color: var(--rhg-brown);
}

.rhg-description a {
	color: var(--rhg-ink);
	text-decoration: underline;
}

.rhg-description a:hover {
	color: var(--rhg-tan);
}

.rhg-description a:focus-visible {
	outline: 2px solid var(--rhg-ink);
	outline-offset: 2px;
}

/* Sub-albums and photos share one grid: 2 columns, 3 from 600px, 4 from 900px. */
.rhg-cards,
.rhg-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--rhg-gap);
	margin: 0 0 2.5rem;
	padding: 0;
	list-style: none;
}

@media (min-width: 600px) {
	.rhg-cards,
	.rhg-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 900px) {
	.rhg-cards,
	.rhg-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.rhg-cards li,
.rhg-grid li {
	margin: 0;
}

.rhg-frame {
	display: block;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--rhg-border-light);
}

.rhg-frame picture {
	display: contents;
}

.rhg-frame img,
.rhg-card-blank {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .4s ease;
}

.rhg-card a,
.rhg-photo {
	display: block;
	color: inherit;
	text-decoration: none;
}

.rhg-card a:hover img,
.rhg-photo:hover img {
	transform: scale(1.03);
}

.rhg-card a:focus-visible,
.rhg-photo:focus-visible {
	outline: 2px solid var(--rhg-ink);
	outline-offset: 3px;
}

.rhg-card-title {
	display: block;
	margin-top: .6rem;
	font-family: var(--rhg-serif);
	font-size: 1rem;
	line-height: 1.3;
	color: var(--rhg-ink);
}

.rhg-card a:hover .rhg-card-title {
	color: var(--rhg-tan);
}

.rhg-card-count {
	display: block;
	margin-top: .25rem;
	font-family: var(--rhg-sans);
	font-size: 11px;
	letter-spacing: .15em;
	text-transform: uppercase;
	color: var(--rhg-tan);
}

/* An ad's tile: its label and line of text on the image, so it's the same size as a photo. */
.rhg-ad {
	margin: 0;
}

.rhg-ad a {
	position: relative;
	display: block;
	color: #fff;
	text-decoration: none;
}

.rhg-ad .rhg-frame {
	position: relative;
}

.rhg-ad .rhg-frame::after {
	content: "";
	position: absolute;
	inset: 25% 0 0;
	background: linear-gradient(to top, rgb(0 0 0 / .85), rgb(0 0 0 / .55) 55%, rgb(0 0 0 / 0));
	pointer-events: none;
}

.rhg-ad-copy {
	position: absolute;
	left: 10px;
	right: 10px;
	bottom: 8px;
	z-index: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.rhg-ad-label {
	font-family: var(--rhg-sans);
	font-size: 10px;
	letter-spacing: .12em;
	line-height: 1.3;
	text-transform: uppercase;
	color: #f5efe4;
}

.rhg-ad-text {
	display: -webkit-box;
	overflow: hidden;
	font-family: var(--rhg-serif);
	font-size: .95rem;
	line-height: 1.25;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.rhg-ad a:hover img {
	transform: scale(1.03);
}

.rhg-ad a:hover .rhg-ad-text {
	text-decoration: underline;
}

.rhg-ad a:focus-visible {
	outline: 2px solid var(--rhg-ink);
	outline-offset: 3px;
}

/* Pagination */
.rhg-pages {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	font-family: var(--rhg-sans);
	font-size: 14px;
}

.rhg-pages a,
.rhg-pages span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 .75rem;
	border: 1px solid var(--rhg-border);
	color: var(--rhg-brown);
	text-decoration: none;
}

.rhg-pages a:hover,
.rhg-pages a:focus-visible {
	border-color: var(--rhg-ink);
	color: var(--rhg-ink);
}

.rhg-pages .rhg-page-current {
	border-color: var(--rhg-ink);
	background: var(--rhg-ink);
	color: var(--rhg-cream);
}

.rhg-pages .rhg-page-prev,
.rhg-pages .rhg-page-next {
	letter-spacing: .1em;
	text-transform: uppercase;
	font-size: 12px;
}

@media (max-width: 599px) {
	/* Phones: Previous / Next only, plus where you are. */
	.rhg-pages a:not(.rhg-page-prev):not(.rhg-page-next) {
		display: none;
	}
}

/* Lightbox */
.rhg-lightbox {
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgb(20 18 15 / .97);
	color: var(--rh-cream, #f5efe4);
	overscroll-behavior: contain;
}

.rhg-lightbox::backdrop {
	background: rgb(20 18 15 / .97);
}

.rhg-lightbox[open] {
	display: grid;
	grid-template-rows: 1fr auto;
}

.rhg-lb-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	overflow: hidden;
	touch-action: pan-y pinch-zoom;
}

.rhg-lb-stage img {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity .2s ease;
}

.rhg-lb-stage img.is-loading {
	opacity: .35;
}

.rhg-lb-bar {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
	font-family: var(--rh-sans, system-ui, sans-serif);
	font-size: 14px;
	line-height: 1.4;
}

.rhg-lb-text {
	flex: 1;
	min-width: 0;
}

.rhg-lb-caption {
	margin: 0;
	font-family: var(--rh-serif, Georgia, serif);
	font-size: 15px;
}

.rhg-lb-credit,
.rhg-lb-count {
	margin: .2rem 0 0;
	font-size: 11px;
	letter-spacing: .15em;
	text-transform: uppercase;
	color: var(--rh-border, #b8a890);
}

.rhg-lb-count {
	flex-shrink: 0;
	margin: 0;
}

.rhg-lightbox button {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgb(20 18 15 / .55);
	color: inherit;
	font: 400 28px/1 var(--rh-sans, system-ui, sans-serif);
	cursor: pointer;
}

.rhg-lightbox button:hover,
.rhg-lightbox button:focus-visible {
	background: rgb(245 239 228 / .18);
	outline: none;
}

/* The transparent outline shows in Windows high-contrast mode, where the shadow doesn't. */
.rhg-lightbox button:focus-visible {
	box-shadow: 0 0 0 2px var(--rh-cream, #f5efe4);
	outline: 2px solid transparent;
}

.rhg-lb-close {
	top: max(8px, env(safe-area-inset-top));
	right: 8px;
	z-index: 2;
}

.rhg-lb-prev,
.rhg-lb-next {
	top: 50%;
	transform: translateY(-50%);
}

.rhg-lb-prev {
	left: 8px;
}

.rhg-lb-next {
	right: 8px;
}

.rhg-lb-prev[hidden],
.rhg-lb-next[hidden] {
	display: none;
}

@media (hover: none) {
	/* Touch: swipe instead of arrows. They stay for screen readers, which can't swipe the photo. */
	.rhg-lb-prev:not(:focus-visible),
	.rhg-lb-next:not(:focus-visible) {
		clip-path: inset(50%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.rhg-frame img,
	.rhg-lb-stage img {
		transition: none;
	}
}
