/**
 * Work gallery — template-parts/section-gallery.php.
 *
 * Images and videos are siblings under the same slide selector, so every slide rule has to
 * hold for both element types. `.theme-nav` is injected at runtime by gallery.js and only
 * when a card carries two or more slides.
 */

.ons3-gallery__note {
	margin: 0;
	font-size: 14px;
	color: var(--muted-cream-1);
}

.ons3-gallery__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 22px 0 clamp(36px, 4vw, 56px);
}

/* The chips are the category filter. Same pill as the design; the active one fills in. */
.ons3-gallery__cats button {
	min-height: 44px;
	padding: 10px 16px;
	border: 1px solid rgba(20, 35, 44, .2);
	border-radius: var(--r-pill);
	background: rgba(255, 255, 255, .28);
	color: var(--ons-ink);
	font-family: inherit;
	font-weight: 700;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
	transition: background .25s, color .25s, border-color .25s;
}

.ons3-gallery__cats button:hover {
	border-color: var(--ons-accent-on-cream);
}

.ons3-gallery__cats button.is-active {
	background: var(--ons-ink);
	border-color: var(--ons-ink);
	color: var(--ons-cream);
}

/* A filtered-out card. The attribute alone is overridden by the grid display. */
.ons3-card[data-theme-card][hidden] {
	display: none;
}

.ons3-gallery__grid[data-theme-grid] {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(22px, 3vw, 42px);
}

/* Set by gallery.js on the last visible card when the count is odd. */
.ons3-card[data-theme-card].is-wide {
	grid-column: 1 / -1;
}

.ons3-card[data-theme-card] {
	position: relative;
	margin: 0;
	min-height: clamp(380px, 52vw, 650px);
	overflow: hidden;
	border-radius: var(--r-media);
	background: var(--ons-card-base);
	box-shadow: var(--sh-card);
	isolation: isolate;
	outline: none;
}

.ons3-card[data-theme-card]:focus-visible {
	box-shadow: var(--sh-card-focus);
}

/* Bottom scrim — painted above the slides, below the meter/caption/controls. */
.ons3-card[data-theme-card]::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	background: linear-gradient(180deg, transparent 42%, rgba(8, 22, 30, .88) 100%);
	pointer-events: none;
}

.ons3-card__media {
	position: absolute;
	inset: 0;
}

.ons3-card__slide[data-theme-slide] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transform: scale(1.06);
	transition: opacity .65s ease, transform 1.1s var(--ease-ons);
	pointer-events: none;
}

.ons3-card__slide[data-theme-slide].is-active {
	opacity: 1;
	transform: scale(1);
}

.ons3-card__slide[data-theme-slide].is-leaving {
	opacity: 0;
	transform: scale(.98);
}

.ons3-card__meter {
	position: absolute;
	inset-block-start: 18px;
	inset-inline: 18px;
	z-index: 4;
	height: 2px;
	overflow: hidden;
	background: var(--cream-24);
}

/* Grows from the inline start: right in RTL, left in the LTR variant. */
.ons3-card__meter i {
	display: block;
	width: 100%;
	height: 100%;
	background: var(--accent);
	transform: scaleX(.15);
	transform-origin: left center;
	transition: transform .4s ease;
}

[dir="rtl"] .ons3-card__meter i {
	transform-origin: right center;
}

/* Top corner on the inline start: right in RTL — the side the design counts from. */
.ons3-card__index {
	position: absolute;
	inset-block-start: 28px;
	inset-inline-start: 18px;
	z-index: 4;
	color: var(--ons-cream);
	font-size: 12px;
}

.ons3-card__caption {
	position: absolute;
	inset-block-end: 22px;
	inset-inline: 24px;
	z-index: 4;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 18px;
	color: var(--ons-cream);
	/* Captions are owner-written now, so they can be any length. Reserve the corner the
	   injected arrows occupy (2 x 44px + 9px gap + 20px inset) so a long title wraps instead
	   of running underneath them. */
	padding-inline-end: 117px;
}

/* Once the grid is a single column the caption sits clear above the arrows, so the
   reservation only narrows the title for no reason. */
@media (max-width: 760px) {
	.ons3-card__caption {
		padding-inline-end: 0;
	}
}

.ons3-card__caption strong {
	font-family: var(--font-display);
	font-size: var(--fs-caption);
	font-weight: 500;
	line-height: 1.1;
}

.ons3-card__caption small {
	display: block;
	margin-top: 8px;
	font-size: 12px;
	color: var(--cream-70);
}

/* Opposite corner from the caption text: left in RTL, mirrored for the LTR variant. */
.ons3-card .theme-nav {
	position: absolute;
	inset-inline-end: 20px;
	inset-block-end: 20px;
	z-index: 5;
	display: flex;
	gap: 9px;
}

.ons3-card .theme-nav button {
	width: 44px;
	height: 44px;
	border: 1px solid var(--cream-55);
	border-radius: 50%;
	background: rgba(12, 28, 38, .48);
	-webkit-backdrop-filter: blur(9px);
	backdrop-filter: blur(9px);
	color: var(--ons-cream);
	font-family: inherit;
	font-weight: 600;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background .25s, border-color .25s, transform .25s;
}

.ons3-card .theme-nav button:hover,
.ons3-card .theme-nav button:focus-visible {
	border-color: var(--accent);
	background: var(--accent);
	color: var(--ons-deep);
	transform: translateY(-2px);
}

@media (max-width: 760px) {
	.ons3-gallery__grid[data-theme-grid] {
		grid-template-columns: 1fr;
	}

	.ons3-card[data-theme-card] {
		min-height: 520px;
	}

	/* Lift the caption clear of the 44px controls, which overlap it below ~470px. */
	.ons3-card__caption {
		inset-block-end: 76px;
		inset-inline: 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ons3-card__slide[data-theme-slide],
	.ons3-card__meter i,
	.ons3-card .theme-nav button {
		transition: none !important;
		animation: none !important;
	}
}
