/* Atomware Toolkit – Hoeksfontein: species gallery. Every class is prefixed atk-. */

/*
 * Theme hooks: set any of these on :root, body or a wrapper to restyle, e.g.
 *   :root { --atk-accent: #CC9933; --atk-radius: 0; }
 * --atk-accent (#CC9933)  active thumb outline / focus ring
 * --atk-radius (2px)      main image + card corners (keep 0-2px)
 * --atk-bg (#F1F1F1)      main image box background (existing site colour; no new hex)
 * --atk-max-height (600px)
 * --atk-object-position (center) crop focus of gallery photos, e.g. "center 30%"
 * --atk-featured-fit (contain) / --atk-featured-bg (transparent): no-gallery featured image
 */

.atk-sg {
	--atk-thumb-w: 80px;
	--atk-thumb-h: 60px;
	--atk-gap: 8px;
	position: relative;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.atk-sg *,
.atk-sg *::before,
.atk-sg *::after {
	box-sizing: border-box;
}

/* Main image box: 4:3 reserved up front, so no layout shift. */
.atk-sg__stage {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	max-height: var(--atk-max-height, 600px);
	overflow: hidden;
	border-radius: var(--atk-radius, 2px);
	background: var(--atk-bg, #F1F1F1);
	touch-action: pan-y;
	-webkit-user-select: none;
	user-select: none;
}

@supports not (aspect-ratio: 4 / 3) {
	.atk-sg__stage {
		height: 0;
		padding-top: 75%;
	}
}

.atk-sg__stage:focus {
	outline: none;
}

.atk-sg__stage:focus-visible {
	outline: 2px solid var(--atk-accent, #CC9933);
	outline-offset: 2px;
}

.atk-sg__slides {
	position: absolute;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}

.atk-sg__slide {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: none;
}

.atk-sg__slide.atk-is-active {
	display: block;
	animation: atk-sg-fade 0.25s ease-out;
}

@keyframes atk-sg-fade {
	from { opacity: 0.35; }
	to { opacity: 1; }
}

.atk-sg .atk-sg__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: cover;
	object-position: var(--atk-object-position, center);
	-webkit-user-drag: none;
}

/* No gallery: the featured image alone, uncropped (species cut-outs). */
.atk-sg--featured .atk-sg__stage {
	background: var(--atk-featured-bg, transparent);
}

.atk-sg--featured .atk-sg__img {
	object-fit: var(--atk-featured-fit, contain);
}

/* Thumbnail strip: one row, scrolls sideways, never wraps. */
.atk-sg__thumbs {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--atk-gap);
	margin: var(--atk-gap) 0 0;
	padding: 3px;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.atk-sg__thumbs::-webkit-scrollbar {
	height: 6px;
}

.atk-sg__thumbs::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.25);
	border-radius: 2px;
}

.atk-sg__thumb-item {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	list-style: none;
	scroll-snap-align: center;
}

.atk-sg__thumb-item::before,
.atk-sg__thumb-item::marker {
	content: none;
}

.atk-sg button.atk-sg__thumb {
	display: block;
	width: var(--atk-thumb-w);
	height: var(--atk-thumb-h);
	min-height: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: var(--atk-radius, 2px);
	background: var(--atk-bg, #F1F1F1);
	cursor: pointer;
	opacity: 0.7;
	box-shadow: none;
	transition: opacity 0.15s ease;
}

.atk-sg button.atk-sg__thumb:hover,
.atk-sg button.atk-sg__thumb:focus {
	background: var(--atk-bg, #F1F1F1);
	opacity: 1;
}

.atk-sg button.atk-sg__thumb:focus {
	outline: none;
}

.atk-sg button.atk-sg__thumb:focus-visible {
	outline: 2px dashed var(--atk-accent, #CC9933);
	outline-offset: 1px;
}

.atk-sg button.atk-sg__thumb.atk-is-active {
	opacity: 1;
	outline: 2px solid var(--atk-accent, #CC9933);
	outline-offset: 1px;
}

.atk-sg .atk-sg__thumb-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	-webkit-user-drag: none;
}

/* Exactly one image: no strip (also not output by PHP). */
.atk-sg--single .atk-sg__thumbs {
	display: none;
}

@media (max-width: 767px) {
	.atk-sg {
		--atk-thumb-w: 64px;
		--atk-thumb-h: 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.atk-sg__slide.atk-is-active {
		animation: none;
	}
}

/* [atk_species_featured_small]: card-sized featured image. */
.atk-sf {
	display: block;
	width: 100%;
	max-width: 300px;
	overflow: hidden;
	border-radius: var(--atk-radius, 2px);
	line-height: 0;
}

.atk-sf .atk-sf__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
}
