/**
 * Legacy Jet Blocks for WordPress - Lightbox Styles
 *
 * Provides a lightweight, accessible, zero-dependency individual lightbox
 * for legacy Jetpack and Legacy Mosaic Galleries. Supports CSS custom
 * properties for dynamic styling from the WordPress settings page.
 *
 * Version: 1.1.0
 * Author: Legacy Jet Blocks Team
 * License: GNU General Public License v2.0 or later (GPL-2.0-or-later)
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

/* ==========================================================================
   1. Gallery Items Trigger State
   ========================================================================== */

.wp-block-jetpack-tiled-gallery .tiled-gallery__item img,
.wp-block-legacy-jet-blocks-mosaic-gallery .tiled-gallery__item img {
	cursor: zoom-in;
	transition: opacity 0.15s ease;
}

.wp-block-jetpack-tiled-gallery .tiled-gallery__item img:hover,
.wp-block-legacy-jet-blocks-mosaic-gallery .tiled-gallery__item img:hover {
	opacity: 0.95;
}

/* Accessible focus indicator for keyboard navigation while lightbox is closed */
.wp-block-jetpack-tiled-gallery .tiled-gallery__item img:focus-visible,
.wp-block-legacy-jet-blocks-mosaic-gallery .tiled-gallery__item img:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* Suppress blue focus outline on thumbnail strictly while the lightbox dialog is open */
body.ljb-scroll-locked .wp-block-jetpack-tiled-gallery .tiled-gallery__item img:focus-visible,
body.ljb-scroll-locked .wp-block-legacy-jet-blocks-mosaic-gallery .tiled-gallery__item img:focus-visible {
	outline: none;
}

/* ==========================================================================
   2. Lightbox Base & Overlay
   ========================================================================== */

.ljb-lightbox {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s ease;
	box-sizing: border-box;
}

.ljb-lightbox[hidden] {
	display: none;
}

.ljb-lightbox *,
.ljb-lightbox *::before,
.ljb-lightbox *::after {
	box-sizing: inherit;
}

.ljb-lightbox.ljb-is-open {
	opacity: 1;
	visibility: visible;
}

/* Backdrop / Scrim with customizable color and opacity */
.ljb-lightbox__backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: var(--ljb-overlay-color, #000000);
	opacity: var(--ljb-overlay-opacity, 0.88);
	cursor: pointer;
}

/* Main Container (passes clicks through unless on content) */
.ljb-lightbox__container {
	position: relative;
	z-index: 2;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	pointer-events: none;
}

/* Content wrapper */
.ljb-lightbox__content {
	position: relative;
	max-width: 90vw;
	max-height: 85vh;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
}

/* Enlarged Image with customizable border radius */
.ljb-lightbox__img {
	display: block;
	max-width: 90vw;
	max-height: 85vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--ljb-lightbox-radius, 8px);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
	user-select: none;
	-webkit-user-select: none;
	transform: scale(0.96);
	transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ljb-lightbox.ljb-is-open .ljb-lightbox__img {
	transform: scale(1);
}

/* ==========================================================================
   3. Close Button (Guaranteed minimum 44x44px interactive target)
   ========================================================================== */

.ljb-lightbox__close {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 10;
	width: 44px;
	height: 44px;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(30, 30, 30, 0.75);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	color: var(--ljb-close-color, #ffffff);
	cursor: pointer;
	padding: 0;
	margin: 0;
	line-height: 1;
	transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
	pointer-events: auto;
}

.ljb-lightbox__close:hover {
	background: rgba(60, 60, 60, 0.95);
	border-color: rgba(255, 255, 255, 0.6);
	transform: scale(1.06);
}

.ljb-lightbox__close:focus-visible {
	outline: 2px solid var(--ljb-close-color, #ffffff);
	outline-offset: 3px;
}

.ljb-lightbox__close svg,
.ljb-lightbox__close line {
	width: 20px;
	height: 20px;
	stroke: currentColor;
	stroke-width: 2.2;
	pointer-events: none;
}

/* ==========================================================================
   4. Loading Indicator (Minimal, pure CSS)
   ========================================================================== */

.ljb-lightbox__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 38px;
	height: 38px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: ljb-spin 0.7s linear infinite;
	display: none;
	pointer-events: none;
}

.ljb-lightbox.ljb-is-loading .ljb-lightbox__spinner {
	display: block;
}

@keyframes ljb-spin {
	0% {
		transform: translate(-50%, -50%) rotate(0deg);
	}
	100% {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}

/* ==========================================================================
   5. Background Page Scroll Lock
   ========================================================================== */

body.ljb-scroll-locked {
	overflow: hidden !important;
}

/* ==========================================================================
   6. Mobile adjustments (Maintains WCAG 44x44px target)
   ========================================================================== */

@media (max-width: 600px) {
	.ljb-lightbox__container {
		padding: 12px;
	}

	.ljb-lightbox__close {
		top: 14px;
		right: 14px;
		width: 44px;
		height: 44px;
		min-width: 44px;
		min-height: 44px;
	}

	.ljb-lightbox__content,
	.ljb-lightbox__img {
		max-width: 95vw;
		max-height: 80vh;
	}
}
