/* Comparing listings on Explore: the floating bar and the pop-up. See inc/mr-compare.php. */

/* The bar: a frosted pill, clear of the bottom menu and the Map button */
#c27-explore-listings .compare-bar.mr-cbar,
.compare-bar.mr-cbar {
	position: fixed;
	right: auto;
	bottom: calc(20px + env(safe-area-inset-bottom));
	left: 50%;
	z-index: 870;
	display: flex;
	align-items: center;
	gap: 6px;
	width: max-content;
	max-width: calc(100% - 24px);
	height: auto;
	margin: 0;
	padding: 6px 6px 6px 18px;
	border: 1px solid rgba(255, 255, 255, .7);
	border-radius: 999px;
	background: rgba(255, 255, 255, .86);
	-webkit-backdrop-filter: blur(18px) saturate(170%);
	backdrop-filter: blur(18px) saturate(170%);
	box-shadow: 0 10px 30px rgba(16, 40, 26, .22);
	transform: translateX(-50%);
	animation: mr-cbar-in .25s ease-out;
}
body.modal-open .compare-bar.mr-cbar { visibility: hidden; } /* not over the comparison */
@keyframes mr-cbar-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (max-width: 1200px) {
	#c27-explore-listings .compare-bar.mr-cbar,
	.compare-bar.mr-cbar { bottom: calc(80px + env(safe-area-inset-bottom)); } /* above the Map button */
}
@media (max-width: 767px), (pointer: coarse) and (max-width: 1366px) { /* where the bottom menu shows (MR_PWA_MQ) */
	body.mr-tabbar-on #c27-explore-listings .compare-bar.mr-cbar,
	body.mr-tabbar-on .compare-bar.mr-cbar { bottom: calc(var(--mr-tab-space, 80px) + 72px); } /* above the Map button, itself above the menu */
}
.mr-cbar .mr-cbar-text { flex: 1 1 auto; min-width: 0; margin: 0 6px 0 0; overflow: hidden; color: #141a16; font-size: 14px; font-weight: 500; line-height: 1.2; white-space: nowrap; text-overflow: ellipsis; }
.mr-cbar .mr-cbar-text b { font-weight: 700; }
.mr-cbar .mr-cbar-clear,
.mr-cbar .mr-cbar-go {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 7px;
	min-height: 44px;
	margin: 0;
	padding: 0 16px;
	border: 0;
	border-radius: 999px;
	box-shadow: none;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}
.mr-cbar .mr-cbar-clear { background: transparent; color: #4c5851; }
.mr-cbar .mr-cbar-clear:hover { background: rgba(20, 26, 22, .06); }
.mr-cbar .mr-cbar-go { background: #0b823e; color: #fff; }
.mr-cbar .mr-cbar-go:hover { background: #096d34; }
.mr-cbar .mr-cbar-go[disabled] { background: #c9d6ce; color: #fff; cursor: default; }
.mr-cbar button:focus-visible { outline: 2px solid #0b823e; outline-offset: 2px; }

/* The pop-up */
#comparison-view .modal-dialog:has(.mrcmp) {
	width: fit-content; /* as wide as the columns need, up to the screen */
	max-width: calc(100% - 48px);
	max-width: none;
	margin: 24px auto;
}
#comparison-view .modal-content:has(.mrcmp) {
	max-height: none; /* the theme's 70vh cut the summary short */
	overflow: hidden;
	padding: 0;
	border: 0;
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(10, 20, 14, .3);
}
.mrcmp { display: flex; flex-direction: column; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); color: #141a16; }
.mrcmp-head {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 16px 14px 22px;
	border-bottom: 1px solid #edf1ee;
}
.mrcmp-head h2 { margin: 0; color: #141a16; font-size: 19px; font-weight: 600; line-height: 1.25; }
.mrcmp .mrcmp-close {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f1f4f2;
	box-shadow: none;
	color: #141a16;
	cursor: pointer;
}
.mrcmp .mrcmp-close:hover { background: #e4eae6; }
.mrcmp-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.mrcmp-grid {
	display: grid;
	grid-template-columns: repeat(var(--mrcmp-n, 2), minmax(250px, 400px));
	column-gap: 18px;
	min-width: min-content;
	padding: 18px 22px 22px;
}
.mrcmp-label {
	position: sticky;
	left: 22px; /* stays in view when swiping across more than two */
	grid-column: 1 / -1;
	width: max-content;
	margin: 18px 0 8px;
	color: #66716b;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.mrcmp-cell { min-width: 0; padding-bottom: 14px; border-bottom: 1px solid #edf1ee; font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; }
.mrcmp-cell.mrcmp-top,
.mrcmp-cell.mrcmp-actions { border-bottom: 0; }
.mrcmp-none { color: #a3ada7; }

/* Photos */
.mrcmp-photos { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 16px; background: #eef2ef; }
.mrcmp-track {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}
.mrcmp-track::-webkit-scrollbar { display: none; }
.mrcmp-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; scroll-snap-stop: always; }
.mrcmp .mrcmp-arrow {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: -18px 0 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, .55);
	border-radius: 50%;
	background: rgba(255, 255, 255, .78);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	box-shadow: 0 4px 14px rgba(10, 20, 14, .22);
	color: #141a16;
	cursor: pointer;
}
.mrcmp .mrcmp-arrow[hidden] { display: none; }
.mrcmp .mrcmp-prev { left: 10px; }
.mrcmp .mrcmp-next { right: 10px; }
.mrcmp-count {
	position: absolute;
	right: 10px;
	bottom: 10px;
	padding: 3px 10px;
	border-radius: 999px;
	background: rgba(20, 26, 22, .7);
	color: #fff;
	font-size: 12px;
	font-weight: 500;
}
.mrcmp-nophoto { display: flex; align-items: center; justify-content: center; height: 100%; color: #66716b; font-size: 13.5px; }
@media (hover: none) {
	.mrcmp .mrcmp-arrow { display: none; } /* swipe instead */
}

.mrcmp .mrcmp-title {
	display: -webkit-box;
	margin: 12px 0 2px;
	overflow: hidden;
	color: #141a16;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}
.mrcmp .mrcmp-title:hover { color: #0b823e; }
.mrcmp-kicker { margin: 0; color: #66716b; font-size: 13px; line-height: 1.4; }

.mrcmp-price { display: block; color: #141a16; font-size: 18px; font-weight: 700; line-height: 1.3; }
.mrcmp-best { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 999px; background: #e6f4ec; color: #0b823e; font-size: 12px; font-weight: 600; }

.mrcmp-facts,
.mrcmp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.mrcmp-facts li {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	border-radius: 10px;
	background: #f3f6f4;
	font-size: 13.5px;
	line-height: 1.3;
}
.mrcmp-facts li svg,
.mrcmp-facts li i { flex: none; width: 17px; height: 17px; color: #0b823e; font-size: 16px; }
.mrcmp-tags li { padding: 4px 10px; border: 1px solid #e1e8e3; border-radius: 999px; font-size: 13px; line-height: 1.3; }
.mrcmp-tags li.mrcmp-more { border-color: transparent; background: #f3f6f4; color: #4c5851; }

.mrcmp .mrcmp-view {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	margin-top: 4px;
	border-radius: 999px;
	background: #0b823e;
	color: #fff;
	font-size: 14.5px;
	font-weight: 600;
	text-decoration: none;
}
.mrcmp .mrcmp-view:hover { background: #096d34; color: #fff; }

.mrcmp-empty { align-items: center; gap: 14px; padding: 28px; text-align: center; }
.mrcmp-empty p { margin: 0; }
.mrcmp .mrcmp-done { min-height: 42px; padding: 0 22px; border: 0; border-radius: 999px; background: #0b823e; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }

/* Phones: a sheet filling the screen, two properties side by side, more by swiping */
@media (max-width: 767px) {
	#comparison-view .modal-dialog:has(.mrcmp) { width: 100%; max-width: none; height: 100%; margin: 0; }
	#comparison-view .modal-content:has(.mrcmp) { height: 100%; border-radius: 0; }
	.mrcmp { height: 100%; max-height: none; padding-bottom: env(safe-area-inset-bottom); }
	.mrcmp-head { padding: calc(12px + env(safe-area-inset-top)) 12px 12px 16px; }
	.mrcmp-head h2 { font-size: 17px; }
	.mrcmp-grid {
		grid-template-columns: repeat(var(--mrcmp-n, 2), calc((100vw - 42px) / 2));
		column-gap: 10px;
		padding: 14px 16px 18px;
	}
	.mrcmp-label { left: 16px; }
	.mrcmp-photos { border-radius: 12px; }
	.mrcmp .mrcmp-title { font-size: 14.5px; }
	.mrcmp-kicker { font-size: 12px; }
	.mrcmp-price { font-size: 15.5px; }
	.mrcmp-cell { font-size: 13.5px; }
	.mrcmp-facts li { padding: 4px 8px; font-size: 12.5px; }
	.mrcmp-tags li { font-size: 12px; }
	.mrcmp .mrcmp-view { min-height: 42px; font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
	.compare-bar.mr-cbar { animation: none; }
}
