/*
 * TradeKit Gallery block styles.
 */

.tk-gallery {
	--tk-gallery-bg: var(--wp--preset--color--light);
	--tk-gallery-heading: var(--wp--preset--color--dark);
	--tk-gallery-body: var(--wp--preset--color--neutral-600);
	--tk-gallery-accent: var(--wp--preset--color--accent);
	--tk-gallery-card-bg: #fff;
	--tk-gallery-card-text: var(--wp--preset--color--dark);
	--tk-gallery-overlay: #0f172a;
	--tk-gallery-overlay-opacity: 0.52;
	--tk-gallery-radius: var(--tk-radius-default);
	--tk-features-carousel-arrow-color: var(--tk-gallery-heading);
	--tk-features-carousel-arrow-bg: color-mix(in srgb, var(--tk-gallery-card-bg) 90%, transparent);
	--tk-features-carousel-arrow-border: color-mix(in srgb, var(--tk-gallery-heading) 20%, transparent);
	--tk-features-carousel-dot-color: color-mix(in srgb, var(--tk-gallery-heading) 26%, transparent);
	--tk-features-carousel-dot-active-color: var(--tk-gallery-accent);
	--tk-features-per-view: 1;
	--tk-gallery-gap: clamp(18px, 2.2vw, 32px);
	--tk-gallery-columns: 3;
	--tk-gallery-ratio: 1.333333;
	background: var(--tk-gallery-bg);
	color: var(--tk-gallery-heading);
}

.wp-block-tradekit-gallery,
.tk-gallery {
	max-inline-size: 100%;
	width: 100%;
}

.wp-block-tradekit-gallery.alignfull,
.tk-gallery.alignfull {
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	max-width: none;
	width: auto;
}

.tk-gallery .tk-section-block__background-overlay {
	background-color: var(--tk-gallery-overlay);
	opacity: var(--tk-gallery-overlay-opacity);
}

.tk-gallery :where(.tk-section-intro__eyebrow) {
	--tk-section-accent: var(--tk-gallery-accent);
}

.tk-gallery :where(.tk-section-intro__headline) {
	--tk-section-heading: var(--tk-gallery-heading);
}

.tk-gallery :where(.tk-section-intro__copy) {
	--tk-section-body: var(--tk-gallery-body);
}

.tk-gallery__grid {
	display: grid;
	gap: var(--tk-gallery-gap);
	grid-template-columns: repeat(var(--tk-gallery-columns), minmax(0, 1fr));
	align-items: start;
}

.tk-gallery--columns-2 {
	--tk-gallery-columns: 2;
}

.tk-gallery--columns-3 {
	--tk-gallery-columns: 3;
}

.tk-gallery--columns-4 {
	--tk-gallery-columns: 4;
}

.tk-gallery__item {
	background: var(--tk-gallery-card-bg);
	border: 1px solid color-mix(in srgb, var(--tk-gallery-heading) 12%, transparent);
	border-radius: var(--tk-gallery-radius);
	display: grid;
	grid-template-rows: auto 1fr;
	min-width: 0;
	overflow: hidden;
	position: relative;
	transition: transform 300ms ease, box-shadow 300ms ease;
}

.tk-gallery__media {
	aspect-ratio: var(--tk-gallery-ratio);
	margin: 0;
	min-width: 0;
	overflow: hidden;
	position: relative;
}

.tk-gallery--ratio-landscape {
	--tk-gallery-ratio: 1.333333;
}

.tk-gallery--ratio-widescreen {
	--tk-gallery-ratio: 1.777778;
}

.tk-gallery--ratio-square {
	--tk-gallery-ratio: 1;
}

.tk-gallery--ratio-portrait {
	--tk-gallery-ratio: 0.75;
}

.tk-gallery--ratio-original {
	--tk-gallery-ratio: auto;
}

.tk-gallery__media-link {
	display: block;
	height: 100%;
	position: relative;
	width: 100%;
}

.tk-gallery__media-link:focus-visible {
	outline: 3px solid var(--tk-gallery-accent);
	outline-offset: -5px;
}

.tk-gallery__image {
	display: block;
	height: 100%;
	object-fit: cover;
	transition: transform 360ms cubic-bezier(0.2, 0.65, 0.3, 1);
	width: 100%;
}

.tk-gallery--ratio-original .tk-gallery__image {
	height: auto;
}

.tk-gallery__content {
	align-content: start;
	display: grid;
	gap: 8px;
	padding: clamp(18px, 2vw, 26px);
	overflow-wrap: anywhere;
}

.tk-gallery__title {
	color: var(--tk-gallery-card-text);
	font-size: clamp(1.1rem, 1.4vw, 1.4rem);
	line-height: 1.3;
	margin: 0;
}

.tk-gallery__caption {
	color: color-mix(in srgb, var(--tk-gallery-card-text) 80%, transparent);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
}

.tk-gallery__caption p {
	margin: 0;
}

.tk-gallery__content:empty {
	display: none;
}

.tk-gallery--captions-modal .tk-gallery__content,
.tk-gallery--captions-hidden .tk-gallery__content {
	display: none;
}

@media (hover: hover) and (pointer: fine) {

	.tk-gallery--hover-zoom .tk-gallery__item:hover .tk-gallery__image,
	.tk-gallery--hover-zoom .tk-gallery__item:focus-within .tk-gallery__image {
		transform: scale(1.035);
	}

	.tk-gallery--hover-lift .tk-gallery__item:hover,
	.tk-gallery--hover-lift .tk-gallery__item:focus-within {
		box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
		transform: translateY(-4px);
	}

	.tk-gallery--hover-reveal .tk-gallery__media::after {
		background: linear-gradient(180deg, transparent 40%, rgba(15, 23, 42, 0.3));
		content: "";
		inset: 0;
		opacity: 0;
		pointer-events: none;
		position: absolute;
		transition: opacity 280ms ease;
	}

	.tk-gallery--hover-reveal .tk-gallery__item:hover .tk-gallery__media::after,
	.tk-gallery--hover-reveal .tk-gallery__item:focus-within .tk-gallery__media::after {
		opacity: 1;
	}

	.tk-gallery--captions-hover .tk-gallery__content {
		background: color-mix(in srgb, var(--tk-gallery-card-bg) 96%, transparent);
		bottom: 0;
		left: 0;
		max-height: 70%;
		opacity: 0;
		overflow-y: auto;
		position: absolute;
		right: 0;
		transform: translateY(8px);
		transition: opacity 240ms ease, transform 240ms ease;
		z-index: 1;
	}

	.editor-styles-wrapper .tk-gallery--captions-hover .tk-gallery__content,
	.tk-gallery--captions-hover .tk-gallery__item:hover .tk-gallery__content,
	.tk-gallery--captions-hover .tk-gallery__item:focus-within .tk-gallery__content {
		opacity: 1;
		transform: none;
	}
}

.tk-gallery--card-outline-none .tk-gallery__item {
	border: 0;
}

.tk-gallery--geometry-cut .tk-gallery__item {
	clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

/* Compositions apply to stacked galleries, not the shared moving track. */

/* Layout and carousel states are mutually exclusive. */
/* stylelint-disable no-descending-specificity */
.tk-gallery--layout-masonry .tk-gallery__grid:not(.tk-features__items--carousel),
.tk-gallery--layout-masonry .tk-features--carousel-static .tk-gallery__grid {
	column-count: var(--tk-gallery-columns);
	column-gap: var(--tk-gallery-gap);
	display: block;
}

.tk-gallery--layout-masonry .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item,
.tk-gallery--layout-masonry .tk-features--carousel-static .tk-gallery__item {
	break-inside: avoid;
	display: inline-grid;
	margin-bottom: var(--tk-gallery-gap);
	vertical-align: top;
	width: 100%;
}

.tk-gallery--layout-masonry:not(.tk-gallery--ratio-original) .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:nth-child(3n + 2) .tk-gallery__media,
.tk-gallery--layout-masonry:not(.tk-gallery--ratio-original) .tk-features--carousel-static .tk-gallery__item:nth-child(3n + 2) .tk-gallery__media {
	aspect-ratio: calc(var(--tk-gallery-ratio) * 0.72);
}

.tk-gallery--layout-masonry .tk-gallery__item:has(.tk-gallery__media)::before {
	background: var(--tk-gallery-card-bg);
	color: var(--tk-gallery-card-text);
	content: attr(data-tk-gallery-number);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	left: 14px;
	letter-spacing: 0.08em;
	padding: 6px 9px;
	pointer-events: none;
	position: absolute;
	top: 14px;
	z-index: 1;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel),
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__grid {
	grid-template-columns: repeat(3, minmax(0, 1fr));
	align-items: stretch;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:first-child,
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:first-child {
	grid-column: span 2;
	grid-row: span 2;
	grid-template-rows: minmax(0, 1fr) auto;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:first-child .tk-gallery__media,
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:first-child .tk-gallery__media {
	aspect-ratio: auto;
	min-height: 200px;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:first-child .tk-gallery__image,
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:first-child .tk-gallery__image {
	height: 100%;
	inset: 0;
	position: absolute;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:only-child,
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:only-child {
	grid-column: 1 / -1;
}

.tk-gallery--layout-spotlight .tk-gallery__grid:has(> .tk-gallery__item:nth-child(2):last-child) > .tk-gallery__item:first-child {
	grid-row: auto;
}

.tk-gallery--layout-spotlight .tk-gallery__item:first-child .tk-gallery__title {
	font-size: clamp(1.25rem, 2vw, 1.9rem);
}

.tk-gallery--surface-dark {
	--tk-gallery-bg: var(--wp--preset--color--dark);
	--tk-gallery-heading: var(--wp--preset--color--light);
	--tk-gallery-body: var(--wp--preset--color--neutral-100);
	--tk-gallery-card-bg: color-mix(in srgb, var(--wp--preset--color--dark) 80%, #1e293b 20%);
	--tk-gallery-card-text: var(--wp--preset--color--light);
}

.tk-gallery--surface-brand {
	--tk-gallery-bg: var(--wp--preset--color--primary);
	--tk-gallery-heading: var(--wp--preset--color--light);
	--tk-gallery-body: var(--wp--preset--color--neutral-100);
	--tk-gallery-accent: var(--wp--preset--color--light);
	--tk-gallery-card-bg: color-mix(in srgb, var(--wp--preset--color--light) 94%, var(--wp--preset--color--primary) 6%);
	--tk-gallery-card-text: var(--wp--preset--color--dark);
}

.tk-gallery--geometry-clean {
	--tk-gallery-radius: var(--tk-radius-clean);
}

.tk-gallery--geometry-soft {
	--tk-gallery-radius: var(--tk-radius-soft);
}

.tk-gallery--geometry-cut {
	--tk-gallery-radius: var(--tk-radius-cut);
}

.tk-gallery--intro-center .tk-section-intro {
	justify-items: center;
	margin-inline: auto;
	text-align: center;
}

.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__carousel {
	padding-inline: clamp(52px, 5.5vw, 76px);
	position: relative;
}

.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__viewport {
	margin-inline: auto;
	overflow: hidden;
	width: 100%;
}

.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__carousel:not(.tk-features--carousel-static) .tk-features__items--carousel {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--tk-gallery-gap);
	justify-content: flex-start;
	min-width: 0;
	overflow: visible;
	padding: 6px 0;
	transform: translate3d(0, 0, 0);
	will-change: transform;
}

.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__slide {
	flex: 0 0 calc((100% - (var(--tk-gallery-gap) * (var(--tk-features-per-view) - 1))) / var(--tk-features-per-view));
	max-width: calc((100% - (var(--tk-gallery-gap) * (var(--tk-features-per-view) - 1))) / var(--tk-features-per-view));
}

.tk-gallery .tk-features__carousel.tk-features--carousel-static {
	padding-inline: 0;
}

.tk-gallery .tk-features__carousel.tk-features--carousel-static .tk-features__viewport {
	overflow: visible;
}

.tk-gallery .tk-features__carousel.tk-features--carousel-static .tk-features__items--carousel {
	transform: none !important;
	will-change: auto;
}

.tk-gallery .tk-features__carousel.tk-features--carousel-static .tk-features__slide {
	max-width: none;
}

.tk-gallery .tk-features__carousel.tk-features--carousel-static .tk-features__carousel-controls {
	display: none;
}

.tk-gallery .tk-features__carousel-arrow {
	align-items: center;
	background: var(--tk-features-carousel-arrow-bg);
	border: 1px solid var(--tk-features-carousel-arrow-border);
	border-radius: 999px;
	color: var(--tk-features-carousel-arrow-color);
	display: inline-flex;
	height: 48px;
	justify-content: center;
	width: 48px;
}

.tk-gallery .tk-features__carousel-dots {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.tk-gallery .tk-features__carousel-dot {
	background: var(--tk-features-carousel-dot-color);
	border: 0;
	border-radius: 999px;
	height: 8px;
	padding: 0;
	width: 8px;
}

.tk-gallery .tk-features__carousel-dot.is-active {
	background: var(--tk-features-carousel-dot-active-color);
}

.tk-gallery--editor {
	--tk-features-per-view: var(--tk-gallery-configured-columns, 3);
}

.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:only-child .tk-gallery__media,
.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:only-child .tk-gallery__media {
	aspect-ratio: 16 / 9;
}

@media (max-width: 1023px) {

	.tk-gallery {
		--tk-gallery-columns: 2;
	}

	.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel),
	.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:first-child,
	.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:first-child {
		grid-column: 1 / -1;
		grid-row: auto;
	}

	.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel) > .tk-gallery__item:first-child .tk-gallery__media,
	.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__item:first-child .tk-gallery__media {
		aspect-ratio: 16 / 9;
	}

	.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__carousel {
		padding-inline: clamp(44px, 5vw, 58px);
	}

	.tk-gallery--editor {
		--tk-features-per-view: min(2, var(--tk-gallery-configured-columns, 3));
	}
}

@media (max-width: 699px) {

	.tk-gallery--editor {
		--tk-features-per-view: 1;
	}
}

@media (max-width: 600px) {

	.tk-gallery {
		--tk-gallery-columns: 1;
	}

	.tk-gallery--layout-spotlight .tk-gallery__grid:not(.tk-features__items--carousel),
	.tk-gallery--layout-spotlight .tk-features--carousel-static .tk-gallery__grid {
		grid-template-columns: 1fr;
	}

	.tk-gallery:is(.tk-gallery--overflow-carousel, .tk-gallery--overflow-stack-mobile-carousel).tk-gallery--carousel-active .tk-features__carousel {
		padding-inline: clamp(10px, 4.2vw, 16px);
	}

	.tk-gallery .tk-features__carousel-controls--pos-outside .tk-features__carousel-arrow {
		top: 40%;
	}
}

.tk-gallery.tk-gallery--images-only .tk-gallery__item {
	background: transparent;
	border: 0;
	box-shadow: none;
	padding: 0;
}

.tk-gallery.tk-gallery--images-only .tk-gallery__content,
.tk-gallery.tk-gallery--images-only .tk-gallery__item::before {
	display: none;
}

/* stylelint-enable no-descending-specificity */

.tk-gallery-lightbox {
	background: #10141c;
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 16px;
	box-shadow: 0 24px 100px rgba(0, 0, 0, 0.4);
	color: #f8fafc;
	height: min(960px, calc(100dvh - 32px));
	margin: auto;
	max-height: calc(100dvh - 32px);
	max-width: 1600px;
	overflow: hidden;
	padding: clamp(16px, 2vw, 28px);
	width: calc(100vw - 48px);
}

.tk-gallery-lightbox[open] {
	animation: tk-gallery-viewer-in 220ms ease-out;
	display: grid;
	gap: 12px;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.tk-gallery-lightbox::backdrop {
	background: rgba(5, 9, 16, 0.92);
	backdrop-filter: blur(8px);
}

.tk-gallery-lightbox [hidden] {
	display: none !important;
}

.tk-gallery-lightbox__toolbar {
	align-items: center;
	display: flex;
	gap: 16px;
}

.tk-gallery-lightbox__label,
.tk-gallery-lightbox__count {
	font-size: 14px;
	margin: 0;
}

.tk-gallery-lightbox__label {
	margin-right: auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tk-gallery-lightbox__count {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.tk-gallery-lightbox__button {
	align-items: center;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	flex-shrink: 0;
	font: inherit;
	font-size: 30px;
	height: 48px;
	justify-content: center;
	line-height: 1;
	padding: 0;
	width: 48px;
}

.tk-gallery-lightbox__button:hover {
	background: rgba(255, 255, 255, 0.18);
}

.tk-gallery-lightbox :is(button, a):focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.tk-gallery-lightbox__canvas {
	align-items: center;
	display: grid;
	gap: 12px;
	grid-template-columns: 48px minmax(0, 1fr) 48px;
	min-height: 0;
	position: relative;
}

.tk-gallery-lightbox__stage {
	grid-column: 2;
	grid-row: 1;
	height: 100%;
	min-height: 0;
	touch-action: pan-y pinch-zoom;
}

.tk-gallery-lightbox__previous {
	grid-column: 1;
	grid-row: 1;
}

.tk-gallery-lightbox__next {
	grid-column: 3;
	grid-row: 1;
}

.tk-gallery-lightbox__image {
	display: block;
	height: 100%;
	object-fit: contain;
	opacity: 0;
	transition: opacity 220ms ease;
	width: 100%;
}

.tk-gallery-lightbox__image.is-loaded {
	opacity: 1;
}

.tk-gallery-lightbox__details {
	margin-inline: auto;
	max-height: 18dvh;
	max-width: 72ch;
	overflow-y: auto;
	text-align: center;
	width: 100%;
}

.tk-gallery-lightbox__title {
	color: #fff;
	font-size: clamp(1rem, 1.5vw, 1.3rem);
	margin: 0;
}

.tk-gallery-lightbox__caption,
.tk-gallery-lightbox__status {
	color: #cbd5e1;
	font-size: 14px;
	line-height: 1.5;
	margin: 6px 0 0;
	white-space: pre-line;
}

.tk-gallery-lightbox__status:empty {
	display: none;
}

.tk-gallery-lightbox__project,
.tk-gallery-lightbox__original {
	color: #fff;
	display: inline-flex;
	font-size: 14px;
	padding: 8px;
	text-underline-offset: 4px;
}

.tk-gallery-lightbox__thumbnails {
	display: flex;
	gap: 10px;
	margin-inline: auto;
	max-width: 100%;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	padding: 6px 4px;
	position: relative;
	scrollbar-width: thin;
}

.tk-gallery-lightbox__thumbnail {
	background: #1e293b;
	border: 2px solid transparent;
	border-radius: 6px;
	cursor: pointer;
	flex: 0 0 80px;
	height: 64px;
	opacity: 0.65;
	overflow: hidden;
	padding: 0;
	transition: opacity 200ms ease, border-color 200ms ease;
}

.tk-gallery-lightbox__thumbnail[aria-current="true"] {
	border-color: var(--tk-gallery-viewer-accent, #fff);
	box-shadow: 0 0 0 1px #fff;
	opacity: 1;
}

.tk-gallery-lightbox__thumbnail-image {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

@keyframes tk-gallery-viewer-in {

	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (max-width: 782px) {

	.tk-gallery-lightbox {
		border-radius: 10px;
		height: calc(100dvh - 16px);
		max-height: calc(100dvh - 16px);
		padding: 12px;
		width: calc(100vw - 16px);
	}

	.tk-gallery-lightbox__canvas {
		display: block;
	}

	.tk-gallery-lightbox__previous,
	.tk-gallery-lightbox__next {
		background: rgba(15, 23, 42, 0.85);
		bottom: 10px;
		position: absolute;
		z-index: 1;
	}

	.tk-gallery-lightbox__previous {
		left: 6px;
	}

	.tk-gallery-lightbox__next {
		right: 6px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.tk-gallery .tk-gallery__item,
	.tk-gallery .tk-gallery__image,
	.tk-gallery .tk-gallery__content,
	.tk-gallery .tk-gallery__media::after,
	.tk-gallery-lightbox[open],
	.tk-gallery-lightbox * {
		animation: none;
		transition: none;
	}

	.tk-gallery .tk-gallery__item:hover,
	.tk-gallery .tk-gallery__item:focus-within,
	.tk-gallery .tk-gallery__item:hover .tk-gallery__image,
	.tk-gallery .tk-gallery__item:focus-within .tk-gallery__image {
		transform: none;
	}
}
