/*
 * Galerie a samostatné fotky v článcích. Selektory :where() mají nulovou specifičnost,
 * takže jakékoli pravidlo šablony má přednost. Výjimkou jsou rozměry obrázků (viz níže).
 * Poměr stran fotky přichází v proměnné --he-gallery-ratio. Fotky v řádku dostanou šířku
 * podle poměru stran, a tím i stejnou výšku.
 */
:where( .he-gallery ) {
	display: flex;
	flex-direction: column;
	gap: 10px;
	clear: both;
	width: 100%;
	margin: 2.5rem 0;
}

:where( .he-gallery__row ) {
	display: flex;
	gap: 10px;
	width: 100%;
}

:where( .he-gallery__item, .he-gallery__link ) {
	display: block;
	overflow: hidden;
	border-radius: 4px;
	line-height: 0;
}

:where( .he-gallery__item ) {
	flex: var( --he-gallery-ratio, 1 ) 1 0%;
	min-width: 0;
	aspect-ratio: var( --he-gallery-ratio, 1 );
}

/* Obrázek zarovnaný vlevo nebo vpravo zůstane, jak je, odkaz jen otevře lightbox. */
:where( .he-gallery__link--aligned ) {
	display: contents;
}

/*
 * Rozměry obrázků mají vyšší specifičnost: šablony a Elementor nastavují obrázkům
 * height: auto (img, .elementor img) a fotka by pak nevyplnila svůj díl řádku.
 */
.he-gallery__item .he-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
}

.he-gallery__link .he-gallery__image {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
}

:where( .he-gallery__image ) {
	border: 0;
	object-fit: cover;
	transition: transform .35s ease, filter .35s ease;
}

:where( .he-gallery__item:hover, .he-gallery__link:hover ) :where( .he-gallery__image ) {
	transform: scale( 1.02 );
}

:where( .he-gallery__item:focus-visible, .he-gallery__link:focus-visible ) {
	outline: 3px solid currentColor;
	outline-offset: -3px;
}

/* Na mobilu jdou fotky pod sebe přes celou šířku. */
@media ( max-width: 576px ) {
	:where( .he-gallery__row ) {
		flex-direction: column;
	}

	:where( .he-gallery__item ) {
		flex: none;
		width: 100%;
	}
}
