/**
 * Nyumbani Gallery — layouts, cards, lightbox.
 * No hardcoded brand colors: everything derives from three custom properties
 * set from the active theme by colors.js (overridable on :root):
 *   --nyg-accent (theme link color), --nyg-ink (text), --nyg-bg (background).
 * Neutral fallbacks keep the plugin usable even with scripts disabled.
 * Lines/surfaces are mixed from ink+bg so they fit light AND dark themes.
 */

.nyg-gallery,
.nyg-galleries {
	--nyg-line: color-mix(in srgb, var(--nyg-ink, #222) 16%, transparent);
	--nyg-soft: color-mix(in srgb, var(--nyg-ink, #222) 62%, var(--nyg-bg, #fff));
}

/* ---------- Single gallery: masonry ---------- */
.nyg-gallery--masonry {
	columns: var(--nyg-cols, 3);
	column-gap: 14px;
}

.nyg-gallery--masonry .nyg-tile {
	display: block;
	break-inside: avoid;
	margin: 0 0 14px;
}

/* ---------- Single gallery: classic ---------- */
.nyg-gallery--classic {
	display: grid;
	grid-template-columns: repeat(var(--nyg-cols, 3), 1fr);
	gap: 14px;
}

.nyg-gallery--classic .nyg-tile {
	aspect-ratio: 4 / 3;
}

.nyg-gallery--classic .nyg-tile img,
.nyg-gallery--classic .nyg-tile video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ---------- Tiles ---------- */
.nyg-tile {
	position: relative;
	display: block;
	border-radius: 8px;
	overflow: hidden;
	background: color-mix(in srgb, var(--nyg-ink, #222) 8%, var(--nyg-bg, #fff));
	line-height: 0;
}

.nyg-tile img,
.nyg-tile video {
	width: 100%;
	display: block;
	border-radius: 8px;
}

.nyg-tile:hover img,
.nyg-tile:hover video {
	filter: brightness(1.06);
}

.nyg-tile:focus-visible {
	outline: 3px solid var(--nyg-accent, #444);
	outline-offset: 2px;
}

.nyg-play {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 18px;
	color: var(--nyg-bg, #fff);
	background: rgba(0, 0, 0, 0.25);
	z-index: 1;
}

.nyg-play::before {
	content: "";
	position: absolute;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--nyg-accent, #444);
	opacity: 0.92;
	z-index: -1;
}

/* ---------- Galleries overview grid ---------- */
.nyg-galleries {
	display: grid;
	grid-template-columns: repeat(var(--nyg-cols, 3), 1fr);
	gap: 22px;
}

.nyg-card {
	display: flex;
	flex-direction: column;
	background: var(--nyg-bg, #fff);
	border: 1px solid var(--nyg-line);
	border-top: 4px solid var(--nyg-accent, #444);
	border-radius: 10px;
	overflow: hidden;
	text-decoration: none;
	color: var(--nyg-ink, #222);
	box-shadow: 0 2px 10px color-mix(in srgb, var(--nyg-ink, #222) 8%, transparent);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.nyg-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--nyg-ink, #222) 35%, transparent);
}

.nyg-card:focus-visible {
	outline: 3px solid var(--nyg-accent, #444);
	outline-offset: 2px;
}

.nyg-card img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	display: block;
}

.nyg-card-placeholder {
	aspect-ratio: 4 / 3;
	display: grid;
	place-items: center;
	background: color-mix(in srgb, var(--nyg-ink, #222) 82%, var(--nyg-bg, #fff));
	color: var(--nyg-accent, #999);
	font-size: 28px;
}

.nyg-card:hover img {
	filter: brightness(1.06);
}

.nyg-card-body {
	padding: 16px 18px 18px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.nyg-card-body strong {
	font-size: 1.05em;
	font-weight: 700;
	color: var(--nyg-ink, #222);
}

.nyg-card-body span {
	font-size: 0.82em;
	color: var(--nyg-soft);
}

/* ---------- Lightbox ---------- */
.nyg-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(12, 12, 14, 0.95);
	display: flex;
	flex-direction: column;
	color: #f2f2f2;
}

.nyg-lb[hidden] {
	display: none; /* author display:flex would otherwise beat the UA [hidden] rule */
}

@media (prefers-reduced-motion: no-preference) {
	.nyg-lb {
		animation: nyg-lb-in 0.22s ease;
	}

	@keyframes nyg-lb-in {
		from { opacity: 0; }
		to { opacity: 1; }
	}
}

.nyg-lb-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 14px 20px;
	flex: none;
}

.nyg-lb-counter {
	font-size: 14px;
	letter-spacing: 0.08em;
	opacity: 0.75;
	font-variant-numeric: tabular-nums;
}

.nyg-lb-close {
	background: none;
	border: 0;
	color: #f2f2f2;
	font-size: 34px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 10px;
}

.nyg-lb-close:hover {
	color: var(--nyg-accent, #bbb);
}

.nyg-lb-stage {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 0;
	padding: 0 12px;
}

.nyg-lb-figure {
	margin: 0;
	max-width: min(1100px, 86vw);
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.nyg-lb-media {
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.nyg-lb-media img,
.nyg-lb-media video {
	max-width: 100%;
	max-height: calc(100vh - 220px);
	border-radius: 6px;
	box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

.nyg-lb-caption {
	font-size: 14px;
	opacity: 0.8;
	padding: 12px 6px 0;
	text-align: center;
	min-height: 20px;
}

.nyg-lb-prev,
.nyg-lb-next {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 1.5px solid rgba(242, 242, 242, 0.35);
	background: rgba(0, 0, 0, 0.45);
	color: #f2f2f2;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.nyg-lb-prev:hover,
.nyg-lb-next:hover {
	background: var(--nyg-accent, #666);
	border-color: var(--nyg-accent, #666);
}

.nyg-lb-close:focus-visible,
.nyg-lb-prev:focus-visible,
.nyg-lb-next:focus-visible,
.nyg-lb-thumb:focus-visible {
	outline: 3px solid var(--nyg-accent, #bbb);
	outline-offset: 2px;
}

.nyg-lb-thumbs {
	flex: none;
	display: flex;
	gap: 8px;
	padding: 14px 20px 18px;
	overflow-x: auto;
	justify-content: safe center;
}

.nyg-lb-thumb {
	flex: none;
	width: 68px;
	height: 52px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	background: #2a2a2e;
	opacity: 0.55;
}

.nyg-lb-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.nyg-lb-thumb-play {
	color: var(--nyg-accent, #bbb);
	font-size: 16px;
	display: grid;
	place-items: center;
	height: 100%;
}

.nyg-lb-thumb.is-active,
.nyg-lb-thumb:hover {
	opacity: 1;
	border-color: var(--nyg-accent, #bbb);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.nyg-gallery--masonry {
		columns: 2;
	}

	.nyg-gallery--classic,
	.nyg-galleries {
		grid-template-columns: 1fr 1fr;
	}
}

@media (max-width: 560px) {
	.nyg-gallery--masonry {
		columns: 1;
	}

	.nyg-gallery--classic,
	.nyg-galleries {
		grid-template-columns: 1fr;
	}

	.nyg-lb-prev,
	.nyg-lb-next {
		width: 40px;
		height: 40px;
		font-size: 20px;
	}

	.nyg-lb-media img,
	.nyg-lb-media video {
		max-height: calc(100vh - 190px);
	}
}
