/* Media Gallery: grid, masonry and endless carousel, with lightbox and video tiles. */

.vsk-gallery {
	position: relative;
}

.vsk-gallery__items {
	--vsk-columns: 3;
	--vsk-gap: 1rem;
	display: grid;
	grid-template-columns: repeat(var(--vsk-columns), minmax(0, 1fr));
	gap: var(--vsk-gap);
}

.vsk-gallery__item {
	position: relative;
	margin: 0;
	overflow: hidden;
	border-radius: var(--vsk-radius-sm);
	background: var(--vsk-surface-muted);
	transition: transform var(--vsk-duration) var(--vsk-ease), box-shadow var(--vsk-duration) var(--vsk-ease), border-color var(--vsk-duration) var(--vsk-ease);
}

.vsk-gallery__link {
	position: relative;
	display: block;
	overflow: hidden;
	line-height: 0;
	color: inherit;
}

.vsk .vsk-gallery__img {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: cover;
	transition: transform 600ms var(--vsk-ease);
}

.vsk-gallery--zoom .vsk-gallery__link:hover .vsk-gallery__img {
	transform: scale(1.05);
}

button.vsk-gallery__link {
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	cursor: pointer;
}

.vsk-gallery__link:focus-visible {
	outline: 2px solid var(--vsk-color-accent);
	outline-offset: -2px;
}

/* Tile shapes (grid and carousel). */
.vsk-ratio--1-1 .vsk-gallery__link { aspect-ratio: 1; }
.vsk-ratio--4-3 .vsk-gallery__link { aspect-ratio: 4 / 3; }
.vsk-ratio--3-2 .vsk-gallery__link { aspect-ratio: 3 / 2; }
.vsk-ratio--16-9 .vsk-gallery__link { aspect-ratio: 16 / 9; }
.vsk-ratio--3-4 .vsk-gallery__link { aspect-ratio: 3 / 4; }

/* Masonry: columns keep each image's own height. */
.vsk-gallery--masonry .vsk-gallery__items {
	display: block;
	column-count: var(--vsk-columns);
	column-gap: var(--vsk-gap);
}

.vsk.vsk-gallery.vsk-gallery--masonry .vsk-gallery__items > .vsk-gallery__item {
	margin-bottom: var(--vsk-gap);
	break-inside: avoid;
}

.vsk-gallery--masonry .vsk-gallery__link {
	aspect-ratio: auto;
}

.vsk.vsk-gallery--masonry .vsk-gallery__img {
	height: auto;
}

/* Carousel: native scroll-snap row; the script makes it endless. */
.vsk-gallery--carousel .vsk-gallery__items {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.vsk-gallery--carousel .vsk-gallery__items::-webkit-scrollbar {
	display: none;
}

.vsk-gallery--carousel .vsk-gallery__item {
	flex: 0 0 calc((100% - (var(--vsk-columns) - 1) * var(--vsk-gap)) / var(--vsk-columns));
	scroll-snap-align: start;
}

.vsk-gallery__arrow {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid rgb(255 255 255 / 45%);
	border-radius: 50%;
	background: rgb(0 0 0 / 40%);
	color: #fff;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	transform: translateY(-50%);
	transition: background-color var(--vsk-duration) var(--vsk-ease);
}

.vsk-gallery__arrow:hover {
	background: rgb(0 0 0 / 65%);
}

.vsk-gallery__arrow:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.vsk-gallery__arrow--prev { left: var(--vsk-space-3); }
.vsk-gallery__arrow--next { right: var(--vsk-space-3); }

.vsk-gallery--static .vsk-gallery__arrow {
	display: none;
}

/* Captions. */
.vsk-gallery__caption {
	font-size: 0.9rem;
	font-style: normal;
	line-height: 1.4;
}

.vsk-gallery--captions-overlay .vsk-gallery__caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	padding: 2.5rem var(--vsk-space-4) var(--vsk-space-3);
	background: linear-gradient(180deg, rgb(0 0 0 / 0%), rgb(0 0 0 / 70%));
	color: #fff;
	pointer-events: none;
}

.vsk-gallery--captions-below .vsk-gallery__caption {
	padding: var(--vsk-space-3) var(--vsk-space-1) 0;
	color: var(--vsk-color-text);
}

.vsk-gallery--captions-below .vsk-gallery__item {
	overflow: visible;
	background: transparent;
}

.vsk-gallery--captions-below .vsk-gallery__link {
	border-radius: var(--vsk-radius-sm);
}

/* Video tiles. */
.vsk-gallery__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	background: rgb(0 0 0 / 55%);
	color: #fff;
	transform: translate(-50%, -50%);
	transition: transform var(--vsk-duration) var(--vsk-ease), background-color var(--vsk-duration) var(--vsk-ease);
}

.vsk-gallery__play::after {
	content: "";
	position: absolute;
	inset: 0;
	background: currentcolor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z'/%3E%3C/svg%3E") center / 60% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z'/%3E%3C/svg%3E") center / 60% no-repeat;
}

.vsk-gallery__link:hover .vsk-gallery__play {
	background: var(--vsk-color-accent);
	transform: translate(-50%, -50%) scale(1.08);
}

/* Presets. */
.vsk-gallery.vsk-preset--outline .vsk-gallery__item {
	border: 1px solid var(--vsk-border);
}

.vsk-gallery.vsk-preset--elevated .vsk-gallery__item {
	box-shadow: var(--vsk-shadow-sm);
}

.vsk-gallery.vsk-preset--elevated .vsk-gallery__item:hover {
	box-shadow: var(--vsk-shadow-md);
	transform: translateY(-3px);
}

.vsk-gallery.vsk-preset--tinted.vsk-gallery--captions-below .vsk-gallery__item {
	background: var(--vsk-surface-muted);
}

.vsk-gallery.vsk-preset--tinted.vsk-gallery--captions-below .vsk-gallery__caption {
	padding: var(--vsk-space-3) var(--vsk-space-4) var(--vsk-space-4);
}

.vsk-gallery.vsk-preset--tinted.vsk-gallery--captions-below .vsk-gallery__item {
	overflow: hidden;
}

/* Category filter buttons. Hidden until the script runs, so there is never a dead control. */
.vsk-gallery__filter {
	display: none;
	flex-wrap: wrap;
	gap: var(--vsk-space-2);
	margin-bottom: var(--vsk-space-5);
}

.vsk-gallery--filterable .vsk-gallery__filter {
	display: flex;
}

.vsk-gallery__filter-btn {
	padding: 0.5em 1.1em;
	border: 1px solid var(--vsk-border);
	border-radius: var(--vsk-radius-pill);
	background: transparent;
	color: var(--vsk-color-primary);
	font-family: var(--vsk-font-button);
	font-size: 0.9rem;
	font-weight: var(--vsk-weight-button);
	line-height: 1.2;
	cursor: pointer;
	transition: background-color var(--vsk-duration) var(--vsk-ease), color var(--vsk-duration) var(--vsk-ease), border-color var(--vsk-duration) var(--vsk-ease);
}

.vsk-gallery__filter-btn:hover {
	border-color: var(--vsk-color-accent);
	color: var(--vsk-color-accent);
}

.vsk-gallery__filter-btn.is-active {
	border-color: var(--vsk-color-accent);
	background: var(--vsk-color-accent);
	color: var(--vsk-color-on-accent);
}

.vsk-gallery__filter-btn:focus-visible {
	outline: 2px solid var(--vsk-color-accent);
	outline-offset: 2px;
}

.vsk-gallery.vsk-preset--editorial .vsk-gallery__filter-btn {
	border-radius: 0;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-size: 0.75rem;
}

/* "Show more": the button sits under the grid and takes the shared button look from tokens.css. */
.vsk-gallery__more {
	display: flex;
	justify-content: center;
	margin-top: var(--vsk-space-6, 2rem);
}

.vsk-gallery__more[hidden] {
	display: none;
}

/* The editorial preset makes buttons small capitals; "Show more" keeps the
   standard button look so it matches the header and hero buttons. */
.vsk-gallery.vsk-preset--editorial .vsk-gallery__more .vsk-gallery__button {
	padding: 0.7em 1.25em;
	border-radius: 8px;
	font-size: 0.95rem;
	letter-spacing: normal;
	text-transform: none;
}

/* hidden tiles must really go, whatever display the layout gives them. */
.vsk-gallery__item[hidden] {
	display: none !important;
}

/* Before/after tile. The "before" photo is clipped from the right; the range input sits on top. */
.vsk-compare {
	--vsk-pos: 50%;
	cursor: ew-resize;
	touch-action: pan-y;
}

.vsk-gallery .vsk-compare {
	aspect-ratio: 4 / 3;
}

.vsk-ratio--1-1 .vsk-compare { aspect-ratio: 1; }
.vsk-ratio--3-2 .vsk-compare { aspect-ratio: 3 / 2; }
.vsk-ratio--16-9 .vsk-compare { aspect-ratio: 16 / 9; }
.vsk-ratio--3-4 .vsk-compare { aspect-ratio: 3 / 4; }

.vsk .vsk-compare__after,
.vsk .vsk-compare__before {
	position: absolute;
	inset: 0;
}

.vsk .vsk-compare__before {
	clip-path: inset(0 calc(100% - var(--vsk-pos)) 0 0);
}

.vsk-gallery--zoom .vsk-compare:hover .vsk-gallery__img {
	transform: none;
}

.vsk-compare__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--vsk-pos);
	width: 2px;
	margin-left: -1px;
	background: var(--vsk-color-on-accent);
	box-shadow: 0 0 0 1px rgb(0 0 0 / 25%);
	pointer-events: none;
}

.vsk-compare__handle::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 2.5rem;
	height: 2.5rem;
	margin: -1.25rem 0 0 -1.25rem;
	border: 2px solid var(--vsk-color-on-accent);
	border-radius: 50%;
	background: var(--vsk-color-accent);
	box-shadow: var(--vsk-shadow-sm);
}

.vsk-compare__handle::before {
	content: "\2039\00a0\203a";
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 1;
	transform: translate(-50%, -52%);
	color: var(--vsk-color-on-accent);
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1;
	white-space: nowrap;
}

.vsk-compare__tag {
	position: absolute;
	top: var(--vsk-space-3);
	padding: 0.25em 0.7em;
	border-radius: var(--vsk-radius-pill);
	background: rgb(0 0 0 / 55%);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1.4;
	pointer-events: none;
}

.vsk-compare__tag--before {
	left: var(--vsk-space-3);
}

.vsk-compare__tag--after {
	right: var(--vsk-space-3);
}

/* The native range is invisible but fills the tile, so mouse, touch and keyboard all work. */
.vsk-compare__range {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: ew-resize;
	-webkit-appearance: none;
	appearance: none;
}

.vsk-compare:has(.vsk-compare__range:focus-visible) {
	outline: 2px solid var(--vsk-color-accent);
	outline-offset: -2px;
}

.vsk-gallery--masonry .vsk-compare {
	aspect-ratio: 4 / 3;
}
