/*
 * Listing photo gallery: full-screen grid and photo viewer.
 *
 * Theme-neutral. A theme sets its look with these custom properties on :root
 * (or any ancestor of body):
 *
 *   --urba-gallery-bg            page colour behind the grid and viewer
 *   --urba-gallery-surface       buttons and bars on that background
 *   --urba-gallery-text          primary text and icons
 *   --urba-gallery-muted         secondary text
 *   --urba-gallery-accent        primary action (defaults to --urba-accent-color)
 *   --urba-gallery-accent-text   text on the primary action
 *   --urba-gallery-font          font family (inherits the page font)
 *   --urba-gallery-radius        corner radius for photos and buttons
 */

:root {
	--urba-gallery-bg: #0e0f11;
	--urba-gallery-surface: rgba(255, 255, 255, 0.1);
	--urba-gallery-surface-hover: rgba(255, 255, 255, 0.18);
	--urba-gallery-text: #f6f4f1;
	--urba-gallery-muted: rgba(246, 244, 241, 0.68);
	--urba-gallery-accent: var(--urba-accent-color, #d20038);
	--urba-gallery-accent-text: #fff;
	--urba-gallery-font: inherit;
	--urba-gallery-radius: 6px;
	--urba-gallery-ease: cubic-bezier(0.23, 1, 0.32, 1);
}

html.urba-listing-gallery-open {
	overflow: hidden;
}

/* Hero photos: every tile opens the viewer. */
.urba-ssr-listing__image .asset-image {
	position: relative;
}

.urba-gallery-open {
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 0;
	cursor: zoom-in;
	display: block;
	inset: 0;
	margin: 0;
	padding: 0;
	position: absolute;
	z-index: 1;
}

.urba-gallery-open:hover,
.urba-gallery-open:focus {
	background: transparent;
}

.urba-gallery-open::after {
	background: rgba(0, 0, 0, 0);
	content: "";
	inset: 0;
	position: absolute;
	transition: background-color 160ms ease;
}

.urba-gallery-open:hover::after {
	background: rgba(0, 0, 0, 0.08);
}

.urba-gallery-open:focus-visible {
	outline: 3px solid var(--urba-gallery-text);
	outline-offset: -6px;
}

.urba-mobile-gallery__track {
	cursor: zoom-in;
}

.asset__media-actions {
	z-index: 2;
}

/* Grid. */
.urba-listing-gallery,
.urba-listing-gallery *,
.urba-photo-viewer,
.urba-photo-viewer * {
	color: var(--urba-gallery-text);
}

.urba-listing-gallery {
	background: var(--urba-gallery-bg);
	border: 0;
	color: var(--urba-gallery-text);
	font-family: var(--urba-gallery-font);
	height: 100%;
	inset: 0;
	margin: 0;
	max-height: none;
	max-width: none;
	overflow: auto;
	overscroll-behavior: contain;
	padding: 0;
	position: fixed;
	width: 100%;
}

.urba-listing-gallery[open] {
	animation: urba-gallery-in 220ms var(--urba-gallery-ease);
}

.urba-listing-gallery::backdrop {
	background: var(--urba-gallery-bg);
}

@keyframes urba-gallery-in {
	from {
		opacity: 0;
	}
}

.urba-listing-gallery__bar {
	align-items: center;
	backdrop-filter: blur(12px);
	background: color-mix(in srgb, var(--urba-gallery-bg) 88%, transparent);
	display: grid;
	gap: 12px 24px;
	grid-template-columns: minmax(0, 1fr) auto auto;
	padding: 16px max(24px, calc((100% - 1280px) / 2 + 24px));
	position: sticky;
	top: 0;
	z-index: 1;
}

.urba-listing-gallery__summary {
	min-width: 0;
}

.urba-listing-gallery .urba-listing-gallery__title {
	color: inherit;
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1.25;
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.urba-listing-gallery .urba-listing-gallery__meta {
	color: var(--urba-gallery-muted);
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	line-height: 1.4;
	margin: 2px 0 0;
}

.urba-listing-gallery .urba-listing-gallery__actions,
.urba-photo-viewer .pswp__listing-actions {
	display: flex;
	gap: 8px;
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action {
	align-items: center;
	appearance: none;
	background: var(--urba-gallery-surface);
	border: 0;
	border-radius: var(--urba-gallery-radius);
	color: var(--urba-gallery-text);
	cursor: pointer;
	display: inline-flex;
	font-family: var(--urba-gallery-font);
	font-size: 14px;
	font-weight: 700;
	justify-content: center;
	line-height: 1;
	min-height: 44px;
	padding: 0 18px;
	transition: background-color 160ms ease, transform 120ms var(--urba-gallery-ease);
	white-space: nowrap;
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action:hover {
	background: var(--urba-gallery-surface-hover);
	color: var(--urba-gallery-text);
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action--primary,
:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action--primary:hover {
	background: var(--urba-gallery-accent);
	color: var(--urba-gallery-accent-text);
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action--primary:hover {
	filter: brightness(0.92);
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action:active,
.urba-listing-gallery .urba-listing-gallery__close:active,
.urba-listing-gallery .urba-listing-gallery__tile:active {
	transform: scale(0.97);
}

.urba-listing-gallery .urba-listing-gallery__close {
	align-items: center;
	appearance: none;
	background: var(--urba-gallery-surface);
	border: 0;
	border-radius: 999px;
	color: var(--urba-gallery-text);
	cursor: pointer;
	display: inline-flex;
	height: 44px;
	justify-content: center;
	padding: 0;
	transition: background-color 160ms ease, transform 120ms var(--urba-gallery-ease);
	width: 44px;
}

.urba-listing-gallery .urba-listing-gallery__close:hover {
	background: var(--urba-gallery-surface-hover);
	color: var(--urba-gallery-text);
}

.urba-listing-gallery svg,
.urba-photo-viewer .pswp__button svg {
	color: inherit;
	fill: none;
	height: 22px;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.8;
	width: 22px;
}

.urba-listing-gallery .urba-listing-gallery__grid {
	display: grid;
	gap: 8px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	list-style: none;
	margin: 8px auto 48px;
	max-width: 1280px;
	padding: 0 24px;
}

.urba-listing-gallery .urba-listing-gallery__grid > li {
	margin: 0;
	padding: 0;
}

.urba-listing-gallery .urba-listing-gallery__grid > li:nth-child(3n + 1) {
	grid-column: 1 / -1;
}

.urba-listing-gallery .urba-listing-gallery__tile {
	appearance: none;
	aspect-ratio: 3 / 2;
	background: var(--urba-gallery-surface);
	border: 0;
	border-radius: var(--urba-gallery-radius);
	cursor: zoom-in;
	display: block;
	overflow: hidden;
	padding: 0;
	transition: transform 160ms var(--urba-gallery-ease);
	width: 100%;
}

.urba-listing-gallery .urba-listing-gallery__grid > li:nth-child(3n + 1) .urba-listing-gallery__tile {
	aspect-ratio: 16 / 9;
}

.urba-listing-gallery .urba-listing-gallery__tile img {
	display: block;
	height: 100%;
	object-fit: cover;
	transition: opacity 160ms ease;
	width: 100%;
}

.urba-listing-gallery .urba-listing-gallery__tile:hover img {
	opacity: 0.9;
}

:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action:focus-visible,
.urba-listing-gallery .urba-listing-gallery__close:focus-visible,
.urba-listing-gallery .urba-listing-gallery__tile:focus-visible,
.urba-photo-viewer .pswp__button:focus-visible,
.urba-photo-viewer .urba-listing-gallery__action:focus-visible {
	outline: 2px solid var(--urba-gallery-text);
	outline-offset: 2px;
}

/* Viewer (PhotoSwipe). */
.urba-photo-viewer {
	--pswp-bg: var(--urba-gallery-bg);
	--pswp-placeholder-bg: var(--urba-gallery-surface);
	--pswp-icon-color: var(--urba-gallery-text);
	--pswp-icon-color-secondary: var(--urba-gallery-bg);
	--pswp-error-text-color: var(--urba-gallery-muted);
	font-family: var(--urba-gallery-font);
}

.urba-photo-viewer .pswp__top-bar {
	align-items: center;
	height: 72px;
	padding: 0 16px;
}

.urba-photo-viewer .pswp__counter {
	color: var(--urba-gallery-text);
	font-size: 15px;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	height: auto;
	line-height: 1;
	margin: 0 auto 0 8px;
	opacity: 1;
	text-shadow: none;
}

.urba-photo-viewer .pswp__button {
	align-items: center;
	background: var(--urba-gallery-surface);
	border: 0;
	color: var(--urba-gallery-text);
	border-radius: 999px;
	display: inline-flex;
	height: 44px;
	justify-content: center;
	margin-left: 8px;
	opacity: 1;
	transition: background-color 160ms ease, transform 120ms var(--urba-gallery-ease);
	width: 44px;
}

.urba-photo-viewer .pswp__button:hover {
	background: var(--urba-gallery-surface-hover);
	color: var(--urba-gallery-text);
}

.urba-photo-viewer .pswp__button:active {
	transform: scale(0.95);
}

.urba-photo-viewer .pswp__button--zoom {
	display: none !important;
}

.urba-photo-viewer .pswp__button--arrow {
	height: 64px;
	margin: -32px 0 0;
	top: 50%;
	width: 64px;
}

.urba-photo-viewer .pswp__button--arrow svg {
	height: 28px;
	width: 28px;
}

.urba-photo-viewer .pswp__button--arrow--prev {
	left: 24px;
}

.urba-photo-viewer .pswp__button--arrow--next {
	right: 24px;
}

.urba-photo-viewer .pswp__listing-actions {
	bottom: 20px;
	left: 50%;
	position: absolute;
	transform: translateX(-50%);
	transition: opacity 160ms ease;
	z-index: 10;
}

.urba-photo-viewer.pswp--ui-visible .pswp__listing-actions {
	opacity: 1;
}

.urba-photo-viewer:not(.pswp--ui-visible) .pswp__listing-actions {
	opacity: 0;
	pointer-events: none;
}

.urba-photo-viewer .pswp__img {
	border-radius: 2px;
}

@media (max-width: 768px) {
	.urba-listing-gallery__bar {
		backdrop-filter: none;
		background: var(--urba-gallery-bg);
		grid-template-columns: minmax(0, 1fr) auto;
		padding: 12px 16px;
	}

	.urba-listing-gallery .urba-listing-gallery__actions {
		bottom: 0;
		background: color-mix(in srgb, var(--urba-gallery-bg) 92%, transparent);
		display: grid;
		gap: 8px;
		grid-template-columns: 1fr 1fr;
		left: 0;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
		position: fixed;
		right: 0;
	}

	.urba-listing-gallery .urba-listing-gallery__actions:has(> :only-child) {
		grid-template-columns: 1fr;
	}

	.urba-listing-gallery .urba-listing-gallery__grid {
		gap: 4px;
		grid-template-columns: 1fr;
		margin-bottom: 96px;
		padding: 0;
	}

	.urba-listing-gallery .urba-listing-gallery__tile,
	.urba-listing-gallery .urba-listing-gallery__grid > li:nth-child(3n + 1) .urba-listing-gallery__tile {
		aspect-ratio: 3 / 2;
		border-radius: 0;
	}

	.urba-photo-viewer .pswp__top-bar {
		height: 60px;
		padding: 0 8px;
	}

	.urba-photo-viewer .pswp__button--arrow {
		display: none;
	}

	.urba-photo-viewer .pswp__listing-actions {
		bottom: 0;
		display: grid;
		grid-template-columns: 1fr 1fr;
		left: 0;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
		right: 0;
		transform: none;
	}

	.urba-photo-viewer .pswp__listing-actions:has(> :only-child) {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.urba-listing-gallery[open] {
		animation: none;
	}

	.urba-listing-gallery .urba-listing-gallery__tile,
	:is(.urba-listing-gallery, .urba-photo-viewer) .urba-listing-gallery__action,
	.urba-listing-gallery .urba-listing-gallery__close,
	.urba-photo-viewer .pswp__button {
		transition: none;
	}
}
