/**
 * ARMLS IDX — listing photo gallery (Phase 2).
 *
 * Loaded only on single idx_listing pages. See ARMLS_Shortcodes::enqueue_gallery_assets().
 *
 * Layout intent: large hero photo with a horizontally scrolling thumbnail
 * strip beneath, matching what buyers already expect from Zillow/Redfin.
 *
 * The hero keeps a fixed 4/3 aspect-ratio box so the space is reserved before
 * the image loads — without that the price and details jump down the page as
 * photos arrive (cumulative layout shift, which Google penalises).
 */

/* ---------- hero ---------- */

.armls-idx-gallery {
	margin: 0 0 1.25rem;
}

.armls-idx-photo {
	position: relative;
	margin: 0;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 6px;
	background: #eee;
}

.armls-idx-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.armls-idx-gallery-main-link {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.armls-idx-gallery-count {
	position: absolute;
	right: 0.75rem;
	bottom: 0.75rem;
	padding: 0.25rem 0.6rem;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 0.8rem;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

/* ---------- thumbnail strip ---------- */

.armls-idx-gallery-thumbs {
	display: flex;
	gap: 0.5rem;
	list-style: none;
	margin: 0.5rem 0 0;
	padding: 0 0 0.25rem;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.armls-idx-gallery-thumbs li {
	flex: 0 0 auto;
	scroll-snap-align: start;
}

.armls-idx-gallery-thumb {
	display: block;
	width: 96px;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 4px;
	background: #eee;
	opacity: 0.65;
	transition: opacity 0.15s ease, box-shadow 0.15s ease;
}

.armls-idx-gallery-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.armls-idx-gallery-thumb:hover,
.armls-idx-gallery-thumb:focus-visible {
	opacity: 1;
}

.armls-idx-gallery-thumb.is-active {
	opacity: 1;
	box-shadow: 0 0 0 2px #b01e28;
}

/* ---------- lightbox ---------- */

/* Hidden until the script adds .is-open, so with JS disabled it never shows
   and the thumbnails stay ordinary links to the full-size image. */
.armls-idx-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
}

.armls-idx-lightbox.is-open {
	display: flex;
}

.armls-idx-lightbox img {
	max-width: 94vw;
	max-height: 88vh;
	object-fit: contain;
	display: block;
}

.armls-idx-lightbox-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}

.armls-idx-lightbox-btn:hover,
.armls-idx-lightbox-btn:focus-visible {
	background: rgba(255, 255, 255, 0.3);
}

.armls-idx-lightbox-prev { left: 1rem; }
.armls-idx-lightbox-next { right: 1rem; }

.armls-idx-lightbox-close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	transform: none;
}

.armls-idx-lightbox-counter {
	position: absolute;
	bottom: 1.25rem;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}

/* ---------- responsive ---------- */

@media (max-width: 600px) {
	.armls-idx-gallery-thumb { width: 72px; }
	.armls-idx-lightbox-btn { width: 40px; height: 40px; }
}

/* Respect users who have asked for reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.armls-idx-gallery-thumb { transition: none; }
}
