/*
 * Shared gallery archive filters (image + video results).
 * Mobile: swipeable family slides. Desktop: compact family cards.
 * Theme tokens: primary #015C92, secondary #D4AF37, Almarai on page content.
 */

.chromatic-gallery-filters {
	--gallery-filter-bg: #f8fafc;
	--gallery-filter-card: #ffffff;
	--gallery-filter-line: #e2e8f0;
}

.dark .chromatic-gallery-filters {
	--gallery-filter-bg: #0b1120;
	--gallery-filter-card: #1e293b;
	--gallery-filter-line: #334155;
}

.chromatic-gallery-filters__toolbar {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 1.15rem;
}

.chromatic-gallery-filters__label,
.chromatic-gallery-filters__family-label {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #94a3b8;
	line-height: 1.4;
}

.dark .chromatic-gallery-filters__label,
.dark .chromatic-gallery-filters__family-label {
	color: #64748b;
}

.chromatic-gallery-filters__cluster--methods,
.chromatic-gallery-filters__cluster--colors {
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	min-width: 0;
}

.chromatic-gallery-filters__cluster-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 2rem;
}

.chromatic-gallery-filters__chips {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	justify-items: stretch;
	align-items: stretch;
	gap: 0.45rem;
}

.chromatic-gallery-filter,
.chromatic-ba-filter,
.chromatic-vg-filter {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-height: 2.75rem;
	padding: 0.45rem 1rem;
	border-radius: 9999px;
	border: 1px solid #e2e8f0;
	background: #fff;
	color: #475569;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.dark .chromatic-gallery-filter,
.dark .chromatic-ba-filter,
.dark .chromatic-vg-filter {
	background: #1e293b;
	border-color: #334155;
	color: #94a3b8;
}

.dark .chromatic-gallery-filters__chips > .chromatic-gallery-filter--color {
	background: #0f172a;
	border-color: #334155;
}

.chromatic-gallery-filter:hover,
.chromatic-ba-filter:hover,
.chromatic-vg-filter:hover {
	border-color: rgba(1, 92, 146, 0.45);
}

.chromatic-gallery-filter:focus-visible,
.chromatic-ba-filter:focus-visible,
.chromatic-vg-filter:focus-visible {
	outline: 2px solid #015c92;
	outline-offset: 2px;
}

.chromatic-gallery-filter:disabled,
.chromatic-ba-filter:disabled,
.chromatic-vg-filter:disabled {
	opacity: 0.55;
	cursor: wait;
}

.chromatic-gallery-filter.is-active,
.chromatic-ba-filter.is-active,
.chromatic-vg-filter.is-active,
.chromatic-gallery-filters__chips > .chromatic-gallery-filter--color.is-active {
	background-color: #015c92;
	color: #fff;
	border-color: transparent;
	box-shadow: 0 4px 6px -1px rgba(1, 92, 146, 0.25);
}

.chromatic-gallery-filters__chips > .chromatic-gallery-filter--color {
	display: flex;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	min-height: 2.75rem;
	height: 2.75rem;
	padding: 0.35rem 0.6rem;
	justify-content: flex-start;
	justify-self: stretch;
	align-self: stretch;
	white-space: nowrap;
	box-sizing: border-box;
	border-radius: 0.75rem;
	background: #f8fafc;
}

.chromatic-gallery-filter--color .chromatic-gallery-filter__text {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chromatic-gallery-filter--all {
	position: sticky;
	inset-inline-start: 0;
	z-index: 2;
	background: var(--gallery-filter-card);
	box-shadow: 0 0 0 6px var(--gallery-filter-bg);
}

.chromatic-gallery-filter__swatch {
	width: 0.75rem;
	height: 0.75rem;
	border-radius: 9999px;
	flex-shrink: 0;
	box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.18);
}

.chromatic-gallery-filter.is-active .chromatic-gallery-filter__swatch {
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Primary method rail — swipe when chips overflow. */
.chromatic-gallery-filters__rail {
	position: relative;
	min-width: 0;
}

.chromatic-gallery-filters__scroller {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 0.5rem;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
	touch-action: pan-x;
	padding-block: 0.15rem;
}

.chromatic-gallery-filters__scroller::-webkit-scrollbar {
	display: none;
}

.chromatic-gallery-filters__rail::before,
.chromatic-gallery-filters__rail::after,
.chromatic-gallery-filters__carousel::before,
.chromatic-gallery-filters__carousel::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	width: 1.75rem;
	z-index: 1;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.chromatic-gallery-filters__rail::before,
.chromatic-gallery-filters__carousel::before {
	inset-inline-start: 0;
	background: linear-gradient(to left, var(--gallery-filter-bg), transparent);
}

.chromatic-gallery-filters__rail::after,
.chromatic-gallery-filters__carousel::after {
	inset-inline-end: 0;
	background: linear-gradient(to right, var(--gallery-filter-bg), transparent);
}

[dir='rtl'] .chromatic-gallery-filters__rail::before,
[dir='rtl'] .chromatic-gallery-filters__carousel::before {
	background: linear-gradient(to right, var(--gallery-filter-bg), transparent);
}

[dir='rtl'] .chromatic-gallery-filters__rail::after,
[dir='rtl'] .chromatic-gallery-filters__carousel::after {
	background: linear-gradient(to left, var(--gallery-filter-bg), transparent);
}

.chromatic-gallery-filters__rail--primary::before {
	display: none;
}

.chromatic-gallery-filters__rail:not(.is-at-end)::after,
.chromatic-gallery-filters__carousel:not(.is-at-start)::before,
.chromatic-gallery-filters__carousel:not(.is-at-end)::after {
	opacity: 1;
}

.chromatic-gallery-filters__carousel {
	position: relative;
	min-width: 0;
}

.chromatic-gallery-filters__viewport {
	min-width: 0;
}

.chromatic-gallery-filters__slides {
	display: flex;
	align-items: stretch;
	gap: 0.75rem;
}

.chromatic-gallery-filters__slide {
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	min-width: 0;
	padding: 0.85rem 0.95rem 1rem;
	border-radius: 1rem;
	border: 1px solid var(--gallery-filter-line);
	background: var(--gallery-filter-card);
	box-shadow: inset 0 3px 0 var(--family-accent, #015c92);
}

.chromatic-gallery-filters__slide[data-family='blue'] {
	--family-accent: #3b82c4;
}

.chromatic-gallery-filters__slide[data-family='green'] {
	--family-accent: #2f8f4e;
}

.chromatic-gallery-filters__slide[data-family='honey'] {
	--family-accent: #d4af37;
}

.chromatic-gallery-filters__slide[data-family='grey'] {
	--family-accent: #8b95a7;
}

.chromatic-gallery-filters__family-label {
	margin: 0;
}

.chromatic-gallery-filters__pager {
	display: none;
	align-items: center;
	gap: 0.35rem;
}

.chromatic-gallery-filters__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border-radius: 9999px;
	border: 1px solid var(--gallery-filter-line);
	background: var(--gallery-filter-card);
	color: #475569;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.dark .chromatic-gallery-filters__arrow {
	color: #94a3b8;
}

.chromatic-gallery-filters__arrow:hover {
	border-color: rgba(1, 92, 146, 0.45);
	color: #015c92;
}

.chromatic-gallery-filters__arrow:focus-visible {
	outline: 2px solid #015c92;
	outline-offset: 2px;
}

.chromatic-gallery-filters__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.chromatic-gallery-filters__arrow-icon {
	width: 1rem;
	height: 1rem;
	display: block;
}

.chromatic-gallery-filters__dots {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	padding-inline: 0.15rem;
}

.chromatic-gallery-filters__dot {
	width: 0.4rem;
	height: 0.4rem;
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: #cbd5e1;
	cursor: pointer;
	transition: width 0.2s ease, background-color 0.2s ease;
}

.dark .chromatic-gallery-filters__dot {
	background: #475569;
}

.chromatic-gallery-filters__dot.is-active {
	width: 1rem;
	background: #015c92;
}

.chromatic-gallery-filters__dot:focus-visible {
	outline: 2px solid #015c92;
	outline-offset: 2px;
}

@media (max-width: 767.98px) {
	.chromatic-gallery-filters__pager {
		display: flex;
	}

	.chromatic-gallery-filters__viewport {
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: 0;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		overscroll-behavior-x: contain;
		touch-action: pan-x;
		padding-bottom: 0.15rem;
	}

	.chromatic-gallery-filters__viewport::-webkit-scrollbar {
		display: none;
	}

	.chromatic-gallery-filters__viewport:focus-visible {
		outline: 2px solid #015c92;
		outline-offset: 3px;
		border-radius: 1rem;
	}

	.chromatic-gallery-filters__slide {
		flex: 0 0 82%;
		scroll-snap-align: start;
		scroll-snap-stop: always;
	}

	.chromatic-gallery-filter,
	.chromatic-ba-filter,
	.chromatic-vg-filter {
		flex: 0 0 auto;
		font-size: 0.75rem;
		min-height: 2.375rem;
		padding: 0.35rem 0.85rem;
	}

	.chromatic-gallery-filters__chips .chromatic-gallery-filter--color {
		flex: none;
		width: 100%;
		min-height: 2.5rem;
		height: 2.5rem;
		padding: 0.3rem 0.55rem;
	}
}

@media (min-width: 768px) {
	.chromatic-gallery-filter--all {
		position: static;
		box-shadow: none;
	}

	.chromatic-gallery-filters__rail--primary .chromatic-gallery-filters__scroller {
		flex-wrap: wrap;
		overflow: visible;
	}

	.chromatic-gallery-filters__rail--primary::before,
	.chromatic-gallery-filters__rail--primary::after {
		display: none;
	}

	.chromatic-gallery-filters__carousel::before,
	.chromatic-gallery-filters__carousel::after {
		display: none;
	}

	.chromatic-gallery-filters__viewport {
		overflow: visible;
	}

	.chromatic-gallery-filters__slides {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.85rem;
	}

	.chromatic-gallery-filters__slide {
		height: 100%;
	}
}

@media (min-width: 1024px) {
	.chromatic-gallery-filters__slides {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 1rem;
	}

	.chromatic-gallery-filters__slide {
		padding: 1rem 1.05rem 1.1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.chromatic-gallery-filter,
	.chromatic-ba-filter,
	.chromatic-vg-filter,
	.chromatic-gallery-filters__arrow,
	.chromatic-gallery-filters__dot,
	.chromatic-gallery-filters__rail::before,
	.chromatic-gallery-filters__rail::after,
	.chromatic-gallery-filters__carousel::before,
	.chromatic-gallery-filters__carousel::after {
		transition: none;
	}

	.chromatic-gallery-filters__viewport,
	.chromatic-gallery-filters__scroller {
		scroll-behavior: auto;
	}
}
