/**
 * Pet Gallery Block Styles
 */

/* Placeholder (editor) */
.pet-gallery--placeholder {
	min-height: 150px;
}

.pet-gallery__placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 24px;
	background: #f0f0f0;
	border: 1px dashed #ccc;
	border-radius: 4px;
	text-align: center;
	color: #666;
}

.pet-gallery__placeholder p {
	margin: 0;
	font-weight: 600;
}

.pet-gallery__placeholder small {
	color: #888;
}

.pet-gallery__placeholder svg {
	opacity: 0.5;
}

/* Featured image hero */
.pet-gallery__featured {
	position: relative;
	margin: 0 0 var(--wp--preset--spacing--20, 0.5rem);
	border-radius: var(--wp--custom--border-radius, 4px);
	overflow: hidden;
}

.pet-gallery__featured-image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

/* Grid */
.pet-gallery__grid {
	display: grid;
	grid-template-columns: repeat(var(--pet-gallery-columns, 3), 1fr);
	gap: var(--wp--preset--spacing--20, 0.5rem);
	list-style: none;
	margin: 0;
	padding: 0;
}

.pet-gallery__item {
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: var(--wp--custom--border-radius, 4px);
}

.pet-gallery__trigger {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
}

.pet-gallery__trigger img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.pet-gallery__trigger:hover img {
	transform: scale(1.05);
}

.pet-gallery__trigger:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary, #007cba);
	outline-offset: 2px;
}

/* Status bar — rendered above the featured image, not overlaid on it.
 * Keeps the photo clean while giving the status badge clear visibility.
 * Sets --pet-gallery-status-offset for sibling blocks (pet-actions overlay)
 * that need to position below the status bar. */
.pet-gallery__status-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: var(--wp--preset--spacing--10, 0.375rem);
}

/* When a status bar is present, offset the sibling pet-actions overlay
 * so the buttons land on the image, not above it. The offset is set on
 * the column (shared parent) via :has() so it cascades to the actions. */
.pet-details__gallery-col:has(.pet-gallery__status-bar) {
	--pet-actions-top-offset: 2.25rem;
}

.pet-gallery__badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--small, 0.8125rem);
	font-weight: 600;
	line-height: 1.4;
	white-space: nowrap;
	color: #fff;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

/* "New" — white-on-dark translucent, distinct from "Available" green */
.pet-gallery__badge--new {
	background: rgba(255, 255, 255, 0.85);
	color: #1e1e1e;
}

.pet-gallery__badge--bonded {
	background: rgba(155, 81, 224, 0.75);
}

.pet-gallery__badge--special-needs {
	background: rgba(252, 185, 0, 0.8);
	color: #1e1e1e;
}

.pet-gallery__badge--status-available {
	background: rgba(0, 208, 132, 0.75);
}

.pet-gallery__badge--status-pending {
	background: rgba(255, 105, 0, 0.8);
}

.pet-gallery__badge--status-adopted {
	background: rgba(6, 147, 227, 0.75);
}

.pet-gallery__badge--age {
	background: rgba(0, 0, 0, 0.5);
}

/* Below-image badge strip — secondary badges (new, bonded, special needs, age)
 * rendered as pills beneath the featured image, keeping the photo clean. */
.pet-gallery__badges-below {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: var(--wp--preset--spacing--20, 0.5rem);
}

/* Videos */
.pet-gallery__videos {
	margin-top: var(--wp--preset--spacing--30, 1rem);
}

.pet-gallery__videos-heading {
	margin: 0 0 var(--wp--preset--spacing--20, 0.5rem);
	font-size: var(--wp--preset--font-size--medium, 1rem);
	font-weight: 600;
}

.pet-gallery__videos-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: var(--wp--preset--spacing--20, 0.5rem);
}

.pet-gallery__video-wrapper {
	position: relative;
	aspect-ratio: 16 / 9;
	border-radius: var(--wp--custom--border-radius, 4px);
	overflow: hidden;
	background: #000;
}

.pet-gallery__video-iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/*
 * Lightbox — a native <dialog> opened with showModal().
 *
 * No z-index here on purpose. showModal() puts the element in the browser's top
 * layer, which is painted above every stacking context regardless of z-index, so
 * a value would be inert and misleading. It also cannot be trapped: the previous
 * `z-index: 10000` was scoped inside .pet-details__gallery-col, which is
 * position:sticky and so always creates a stacking context.
 */
.pet-gallery__lightbox {
	position: fixed;
	inset: 0;

	/* Reset the UA dialog box, which is fit-content sized with auto margins,
	   a solid border, 1em padding and an opaque background. */
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: hidden;
}

/*
 * Scoped to [open] deliberately. Unscoped, this `display: flex` would override
 * the UA's `dialog:not([open]) { display: none }` and leave the lightbox on
 * screen permanently.
 */
.pet-gallery__lightbox[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

/*
 * The visible scrim is .pet-gallery__lightbox-backdrop, which is a real element
 * because it also handles click-to-close. Left alone, the UA ::backdrop would
 * darken on top of that one.
 */
.pet-gallery__lightbox::backdrop {
	background: transparent;
}

.pet-gallery__lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.9);
}

.pet-gallery__lightbox-content {
	position: relative;
	z-index: 1;
	max-width: 90vw;
	max-height: 90vh;
	margin: 0;
}

.pet-gallery__lightbox-image {
	max-width: 100%;
	max-height: 90vh;
	object-fit: contain;
}

.pet-gallery__lightbox-nav,
.pet-gallery__lightbox-close {
	position: absolute;
	z-index: 2;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	color: #000;
	font-size: 24px;
	cursor: pointer;
}

.pet-gallery__lightbox-nav:hover,
.pet-gallery__lightbox-close:hover {
	background: #fff;
}

.pet-gallery__lightbox-nav:focus-visible,
.pet-gallery__lightbox-close:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary, #007cba);
	outline-offset: 2px;
}

.pet-gallery__lightbox-nav--prev {
	left: var(--wp--preset--spacing--40, 1.5rem);
	top: 50%;
	transform: translateY(-50%);
}

.pet-gallery__lightbox-nav--next {
	right: var(--wp--preset--spacing--40, 1.5rem);
	top: 50%;
	transform: translateY(-50%);
}

.pet-gallery__lightbox-close {
	top: var(--wp--preset--spacing--40, 1.5rem);
	right: var(--wp--preset--spacing--40, 1.5rem);
}

.pet-gallery__lightbox-counter {
	position: absolute;
	bottom: var(--wp--preset--spacing--40, 1.5rem);
	left: 50%;
	transform: translateX(-50%);
	padding: var(--wp--preset--spacing--10, 0.25rem) var(--wp--preset--spacing--20, 0.5rem);
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	border-radius: var(--wp--custom--border-radius, 4px);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

@media (max-width: 600px) {

	.pet-gallery__grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.pet-gallery__lightbox-nav--prev {
		left: var(--wp--preset--spacing--20, 0.5rem);
	}

	.pet-gallery__lightbox-nav--next {
		right: var(--wp--preset--spacing--20, 0.5rem);
	}
}

@media (prefers-reduced-motion: reduce) {

	.pet-gallery__trigger img {
		transition: none;
	}

	.pet-gallery__trigger:hover img {
		transform: none;
	}
}

/* Featured image as lightbox trigger — reset button chrome, full coverage */
.pet-gallery__featured-trigger {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
	text-align: left;
}

.pet-gallery__featured-trigger:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary, #2271b1);
	outline-offset: 2px;
	border-radius: var(--pet-gallery-radius, 12px);
}
