/*
 * Terra Nova Gallery — neutral public styles. The theme owns the visual design and
 * may override anything here; these rules only provide working layout and behaviour.
 * Theme hooks: --tn-slideshow-height, --tn-transition, --tn-gallery-gap, --tn-gallery-min.
 */

/* ---------- Grid ---------- */
.tn-gallery__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--tn-gallery-min, 280px), 1fr));
	gap: var(--tn-gallery-gap, 1rem);
	margin: 0;
	padding: 0;
	list-style: none;
}
.tn-gallery__figure { margin: 0; }
.tn-gallery__figure img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: auto;
}
.tn-gallery__caption { margin-top: .5rem; font-size: .9em; }

/* ---------- Slideshow ---------- */
.tn-slideshow {
	position: relative;
	height: var(--tn-slideshow-height, 100vh);
	height: var(--tn-slideshow-height, 100svh);
	min-height: 320px;
	overflow: hidden;
	background: #1b1b1b;
	isolation: isolate;
}
.tn-slideshow__track { position: absolute; inset: 0; }
.tn-slideshow__slide {
	position: absolute;
	inset: 0;
	margin: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--tn-transition, 1200ms) ease-in-out, visibility 0s linear var(--tn-transition, 1200ms);
}
.tn-slideshow__slide.is-active {
	opacity: 1;
	visibility: visible;
	transition: opacity var(--tn-transition, 1200ms) ease-in-out, visibility 0s;
	z-index: 1;
}
.tn-slideshow__slide picture,
.tn-slideshow__slide img {
	display: block;
	width: 100%;
	height: 100%;
}
.tn-slideshow__slide img {
	object-fit: cover;
	object-position: var(--tn-pos, 50% 50%);
}
@media (max-width: 767px) {
	.tn-slideshow__slide img { object-position: var(--tn-pos-mobile, var(--tn-pos, 50% 50%)); }
}
.tn-slideshow__caption {
	position: absolute;
	left: 1rem;
	bottom: 1rem;
	max-width: min(40rem, calc(100% - 9rem));
	padding: .4rem .75rem;
	color: #fff;
	background: rgba(0, 0, 0, .45);
	font-size: .875rem;
}
.tn-slideshow__controls {
	position: absolute;
	right: 1rem;
	bottom: 1rem;
	z-index: 3;
	display: flex;
	gap: .5rem;
}
.tn-slideshow__controls button {
	display: inline-grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, .7);
	border-radius: 50%;
	color: #fff;
	background: rgba(0, 0, 0, .35);
	font: inherit;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}
.tn-slideshow__controls button:hover { background: rgba(0, 0, 0, .55); }
.tn-slideshow__controls button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.tn-slideshow__pause { font-size: .8rem !important; letter-spacing: -.1em; }
.tn-slideshow__pause[aria-pressed="true"] { font-size: 1rem !important; }

@media (prefers-reduced-motion: reduce) {
	.tn-slideshow__slide,
	.tn-slideshow__slide.is-active { transition: none; }
}

/* ---------- Carousel (several photos that slide together) ----------
 * Theme hooks: --tn-per-view (set per gallery), --tn-carousel-gap, --tn-carousel-ratio.
 */
.tn-carousel { position: relative; }
.tn-carousel__track {
	--tn-gap: var(--tn-carousel-gap, 1rem);
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (var(--tn-visible) - 1) * var(--tn-gap)) / var(--tn-visible));
	gap: var(--tn-gap);
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	--tn-visible: min(1.15, var(--tn-per-view, 4)); /* phones: a peek at the next photo, unless one at a time */
}
.tn-carousel__track::-webkit-scrollbar { display: none; }
.tn-carousel__track:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }
@media (min-width: 700px) { .tn-carousel__track { --tn-visible: min(2, var(--tn-per-view, 4)); } }
@media (min-width: 1100px) { .tn-carousel__track { --tn-visible: var(--tn-per-view, 4); } }
.tn-carousel__item { scroll-snap-align: start; min-width: 0; }
.tn-carousel__figure { margin: 0; }
.tn-carousel__figure img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--tn-carousel-ratio, 4 / 3);
	object-fit: cover;
	object-position: var(--tn-pos, 50% 50%);
}
.tn-carousel__caption { margin-top: .5rem; font-size: .9em; }
.tn-carousel__controls { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; margin-top: .75rem; }
.tn-carousel__controls[hidden] { display: none; }
.tn-carousel__controls button {
	display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0;
	border: 1px solid currentColor; border-radius: 50%; background: transparent; color: inherit;
	font: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.tn-carousel__controls button[disabled] { opacity: .35; cursor: default; }
.tn-carousel__controls button:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.tn-carousel__status { font-size: .875rem; min-width: 5.5em; text-align: center; }
@media (prefers-reduced-motion: reduce) { .tn-carousel__track { scroll-behavior: auto; } }
