/* Jays Gallery — front-end styles */

.jaysgallery-single-gallery-wrap,
.jays-gallery-category-wrap {
	margin-top: 40px;
	margin-bottom: 40px;
}

.jays-gallery-wrap {
	--jg-gap: 10px;
}

.jays-gallery {
	--jg-gap: 10px;
	box-sizing: border-box;
}

.jays-gallery * {
	box-sizing: border-box;
}

.jays-gallery-item {
	margin: 0;
	position: relative;
}

.jays-gallery-link {
	display: block;
	line-height: 0;
	outline-offset: 2px;
}

.jays-gallery-img {
	display: block;
	width: 100%;
	height: auto;
}

.jays-gallery-caption {
	font-size: 0.85em;
	padding: 6px 2px;
	color: inherit;
	opacity: 0.8;
}

/* Grid layout: even CSS grid. */
.jaysgallery-layout-grid {
	display: grid;
	grid-template-columns: repeat( var( --jg-columns, 3 ), 1fr );
	gap: var( --jg-gap );
}

.jaysgallery-layout-grid .jays-gallery-img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
	height: 100%;
}

/* Masonry layout: CSS multi-column, images keep their natural ratio. */
.jaysgallery-layout-masonry {
	column-count: var( --jg-columns, 3 );
	column-gap: var( --jg-gap );
}

.jaysgallery-layout-masonry .jays-gallery-item {
	break-inside: avoid;
	margin-bottom: var( --jg-gap );
}

/* Justified layout: rows are computed by gallery.js, which sets inline
   flex-basis/width on each item. This is the CSS fallback before JS runs
   and for no-JS contexts. */
.jaysgallery-layout-justified {
	display: flex;
	flex-wrap: wrap;
	gap: var( --jg-gap );
}

.jaysgallery-layout-justified .jays-gallery-item {
	flex: 1 1 260px;
}

.jaysgallery-layout-justified.jaysgallery-justified-ready {
	align-items: flex-start;
}

.jaysgallery-layout-justified.jaysgallery-justified-ready .jays-gallery-item {
	flex-grow: 0;
	flex-shrink: 0;
}

/* Toolbar + favorites */
.jays-gallery-toolbar {
	margin-bottom: var( --jg-gap );
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

.jaysgallery-zip-download,
.jaysgallery-favorites-toggle {
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 999px;
	padding: 0.4em 1em;
	font-size: 0.85em;
	cursor: pointer;
}

.jaysgallery-zip-download {
	text-decoration: none;
	color: inherit;
	display: inline-block;
}

.jaysgallery-zip-download:hover {
	border-color: #4f9cff;
	color: #4f9cff;
}

.jaysgallery-favorites-toggle.is-active {
	background: #fdeef0;
	border-color: #d9534f;
	color: #d9534f;
}

.jaysgallery-favorite-btn {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 0;
	background: rgba( 0, 0, 0, 0.45 );
	color: #fff;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jaysgallery-favorite-btn.is-favorited {
	color: #ff5a5f;
	background: rgba( 255, 255, 255, 0.85 );
}

.jays-gallery.jaysgallery-favorites-only .jays-gallery-item:not( .is-favorited ) {
	display: none;
}

/* Access gates */
.jays-gallery-gate {
	max-width: 420px;
	padding: 1.5em;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	background: #f9f9f9;
}

.jays-gallery-gate input[type="password"] {
	width: 100%;
	padding: 0.5em;
	margin-bottom: 0.75em;
}

.jaysgallery-gate-error {
	color: #d63638;
}

/* Gallery category grid (cards linking to whole galleries) */
.jaysgallery-category-link {
	display: block;
	position: relative;
	line-height: 0;
	outline-offset: 2px;
	color: inherit;
	text-decoration: none;
}

.jaysgallery-category-item-title {
	position: absolute;
	inset: auto 0 0 0;
	padding: 10px 12px;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.7 ), rgba( 0, 0, 0, 0 ) );
	color: #fff;
	font-size: 1em;
	line-height: 1.3;
}

.jaysgallery-category-lock {
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba( 0, 0, 0, 0.55 );
	color: #fff;
	border-radius: 50%;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.9rem;
}

.jaysgallery-single-gallery-title,
.jays-gallery-category-title {
	margin-bottom: 0.6em;
}

.jays-gallery-category-description {
	margin-bottom: 1.5em;
}

@media ( max-width: 600px ) {
	.jaysgallery-layout-grid {
		grid-template-columns: repeat( min( 2, var( --jg-columns, 3 ) ), 1fr );
	}
	.jaysgallery-layout-masonry {
		column-count: min( 2, var( --jg-columns, 3 ) );
	}
}

/* Lightbox */
.jaysgallery-lightbox {
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.92 );
	display: flex;
	flex-direction: column;
	z-index: 100000;
	touch-action: pan-y;
}

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

.jaysgallery-lightbox-main {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jaysgallery-lightbox-figure {
	max-width: 92vw;
	height: 100%;
	max-height: 100%;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.jaysgallery-lightbox-img {
	flex: 0 1 auto;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	box-sizing: border-box;
	border: 12px solid #fff;
	object-fit: contain;
	user-select: none;
}

.jaysgallery-lightbox-caption {
	flex: 0 0 auto;
	color: #f0f0f1;
	margin-top: 10px;
	font-size: 0.95em;
	text-align: center;
}

.jaysgallery-lightbox-close,
.jaysgallery-lightbox-prev,
.jaysgallery-lightbox-next {
	position: absolute;
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
	padding: 0.5em;
	z-index: 1;
}

.jaysgallery-lightbox-close {
	top: 10px;
	right: 10px;
	z-index: 2;
}

.jaysgallery-lightbox-prev {
	left: 10px;
	top: 50%;
	transform: translateY( -50% );
}

.jaysgallery-lightbox-next {
	right: 10px;
	top: 50%;
	transform: translateY( -50% );
}

.jaysgallery-lightbox-close:focus-visible,
.jaysgallery-lightbox-prev:focus-visible,
.jaysgallery-lightbox-next:focus-visible,
.jays-gallery-link:focus-visible {
	outline: 2px solid #4f9cff;
}

/* Lightbox filmstrip */
.jaysgallery-lightbox-strip {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 10px 16px;
	overflow-x: auto;
	background: rgba( 0, 0, 0, 0.5 );
	scrollbar-width: thin;
}

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

.jaysgallery-lightbox-strip-item {
	flex: 0 0 auto;
	width: 72px;
	height: 52px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 3px;
	background: none;
	cursor: pointer;
	opacity: 0.55;
	overflow: hidden;
}

.jaysgallery-lightbox-strip-item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.jaysgallery-lightbox-strip-item.is-active {
	opacity: 1;
	border-color: #4f9cff;
}

.jaysgallery-lightbox-strip-item:hover {
	opacity: 0.85;
}

.jaysgallery-lightbox-strip-item:focus-visible {
	outline: 2px solid #4f9cff;
}

@media ( max-width: 600px ) {
	.jaysgallery-lightbox-strip-item {
		width: 52px;
		height: 40px;
	}
}
