/* Lightbox accessibile per core/gallery su elemento nativo <dialog> */

.wp-block-gallery .pi-gallery-trigger {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: zoom-in;
}

/* Scope display solo su [open] per non rompere lo stato chiuso nativo di <dialog> */
dialog.pi-lightbox {
	padding: 0;
	margin: auto;
	border: 0;
	width: min(100vw, 100%);
	max-width: 100vw;
	height: min(100dvh, 100vh);
	max-height: 100dvh;
	background: transparent;
	color: #ffffff;
}

dialog.pi-lightbox[open] {
	display: grid;
}

dialog.pi-lightbox:modal {
	overscroll-behavior: contain;
}

dialog.pi-lightbox::backdrop {
	background: rgba(10, 10, 10, 0.94);
	backdrop-filter: blur(8px);
	overflow: hidden;
	overscroll-behavior: contain;
}

.pi-lightbox-shell {
	display: grid;
	grid-template-rows: 64px minmax(0, 1fr) 68px;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	padding: 8px 16px;
}

.pi-lightbox-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.pi-lightbox-counter {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.75rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #d4d4d8;
}

.pi-lightbox-stage {
	display: grid;
	grid-template-columns: 52px minmax(0, 1fr) 52px;
	align-items: center;
	gap: 12px;
	min-height: 0;
}

.pi-lightbox-figure {
	margin: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.pi-lightbox-img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
}

.pi-lightbox-btn {
	min-width: 44px;
	min-height: 44px;
	border-radius: 9999px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	background: rgba(17, 17, 17, 0.85);
	color: #ffffff;
	font-size: 1.5rem;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pi-lightbox-btn:hover {
	background: #ffffff;
	color: #0a0a0a;
	border-color: #ffffff;
}

.pi-lightbox-btn:focus-visible {
	outline: 3px solid #38bdf8;
	outline-offset: 3px;
}

.pi-lightbox-footer {
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 0 12px;
}

.pi-lightbox-caption {
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.75rem;
	letter-spacing: 0.06em;
	color: #e4e4e7;
	max-width: 72ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media (max-width: 639px) {
	.pi-lightbox-stage {
		grid-template-columns: 44px minmax(0, 1fr) 44px;
		gap: 6px;
	}
	.pi-lightbox-shell {
		padding: 6px 8px;
	}
}
