/**
 * Steel Mobile Lightbox — overlay styles.
 * Active only at viewport <= 768px. Desktop never sees any of these rules.
 */

.steel-mlb-overlay { display: none; }

@media (max-width: 768px) {

	.steel-mlb-overlay.is-open {
		position: fixed;
		inset: 0;
		z-index: 999999;
		display: flex;
		flex-direction: column;
		background: #000;
		animation: steel-mlb-fade-in 180ms ease-out;
	}

	.steel-mlb-track {
		flex: 1 1 auto;
		display: flex;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		scroll-behavior: auto;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.steel-mlb-track::-webkit-scrollbar { display: none; }

	.steel-mlb-slide {
		flex: 0 0 100%;
		scroll-snap-align: center;
		scroll-snap-stop: always;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0;
		padding: 0;
		/* pan-x lets horizontal swipe propagate to the track's scroll-snap;
		   pinch-zoom keeps native pinch on the image. Without pan-x, the
		   browser blocks the swipe gesture on the slide element. */
		touch-action: pan-x pinch-zoom;
	}

	.steel-mlb-slide img {
		display: block;
		max-width: 100%;
		max-height: 100%;
		width: auto;
		height: auto;
		object-fit: contain;
		user-select: none;
		-webkit-user-select: none;
		-webkit-touch-callout: none;
	}

	.steel-mlb-close {
		position: absolute;
		top: calc(env(safe-area-inset-top, 0px) + 12px);
		right: 12px;
		width: 44px;
		height: 44px;
		padding: 0;
		margin: 0;
		background: rgba(0, 0, 0, 0.55);
		border: 0;
		border-radius: 50%;
		color: #fff;
		font-size: 28px;
		line-height: 1;
		cursor: pointer;
		z-index: 2;
		/* Tap-only: tells iOS not to analyse touches on this button for
		   pan/scroll/zoom/double-tap. Without this, small finger drift on a
		   tap was being interpreted as a gesture, which routed through the
		   adjacent track's scroll-snap and advanced the slide instead of
		   firing a synthetic click on the button. */
		touch-action: manipulation;
	}
	.steel-mlb-close::before {
		/* Invisible tap-area expansion: 44x44 visual button becomes 76x76 hit
		   target without changing how the button looks. Catches near-misses
		   when reaching for the small icon on a phone screen. */
		content: '';
		position: absolute;
		inset: -16px;
	}
	.steel-mlb-close:focus-visible {
		outline: 2px solid #fff;
		outline-offset: 2px;
	}

	.steel-mlb-counter {
		position: absolute;
		bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
		left: 50%;
		transform: translateX(-50%);
		padding: 6px 14px;
		background: rgba(0, 0, 0, 0.55);
		border-radius: 999px;
		color: #fff;
		font: 600 14px/1 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
		white-space: nowrap;
		z-index: 2;
		pointer-events: none;
	}

	body.steel-mlb-lock { overflow: hidden; }

	/* Close cooldown: for 600ms after close(), make all gallery lightbox
	   links and their children non-interactive at the hit-test layer.
	   This is the only reliable defense against the synthetic click that
	   iOS/Android dispatch after touchend — it can land on a .fusion-lightbox
	   in the underlying page and trigger either Avada's iLightbox or our
	   own handleTap to open a NEW overlay at the clicked image's index
	   (typically index 0 if that image is first in the gallery), which
	   manifests as "tap X resets to first image". Disabling pointer-events
	   on link AND descendants makes the hit-test pass straight through. */
	body.steel-mlb-closing a.fusion-lightbox,
	body.steel-mlb-closing a.fusion-lightbox * {
		pointer-events: none !important;
	}
}

@keyframes steel-mlb-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}
