/* acf/gallery — Tucson overrides. Loaded with the block.
   Grid layout is the Instagram strip on every page: four 270x359 portrait
   tiles 24 apart across the 1152 container, square corners, then the
   Follow button centred 47px below. The "Logo row" style is the homepage
   sponsor strip. */

body .lp-gallery .block-contents {
	max-width: var(--content-max-width);
}

body .lp-gallery__intro {
	max-width: 760px;
	text-align: center;
}

body .lp-gallery__intro:not(:has(*)) {
	display: none;
}

body .lp-gallery__header {
	font-family: var(--font-family-heading);
	font-size: var(--tr-heading-size);
	font-weight: 400;
	line-height: 1.2;
	color: var(--text-primary);
}

.is-dark .lp-gallery__header,
:is(.is-style-tr-band, .is-style-tr-band-flat-top) .lp-gallery__header {
	font-weight: 700;
}

body .lp-gallery__sub-header {
	font-family: var(--font-family-body);
	font-size: var(--font-size-small);
	font-weight: 400;
	line-height: 1.5;
	color: var(--text-primary);
	margin-top: 4px;
}

body .lp-gallery__header:not(:has(+ .lp-gallery__sub-header))::after,
body .lp-gallery__sub-header::after {
	content: "";
	display: block;
	width: min(528px, 100%);
	height: 17px;
	margin: 20px auto 0;
	background-color: var(--tr-rule-color);
	-webkit-mask: url("../../assets/img/barbed-wire.svg") center / contain no-repeat;
	mask: url("../../assets/img/barbed-wire.svg") center / contain no-repeat;
}

body .lp-gallery__gallery {
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 24px;
	margin-block: 0 47px;
}

body .lp-gallery__intro:has(*) + .lp-gallery__gallery {
	margin-top: 40px;
}

body .lp-gallery__img-wrapper {
	height: auto;
	aspect-ratio: 270 / 359;
}

body .lp-gallery__img-wrapper img {
	border-radius: 0;
}

@media (max-width: 767px) {
	body .lp-gallery__gallery {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Live Instagram carousel in place of the grid (Smash Balloon posts,
   field "Instagram feed"; functions.php). card-grid.js row mode: it rests
   on the Figma row, four 270:359 tiles 24 apart (two across under 768),
   and slides one tile at a time. It sets --slide-w from the stage and each
   post's --x (its centre's offset from the first tile's centre); --drag
   follows the pointer. Before the script runs it is a plain row. */
body .tr-gallery-instagram {
	--slides-visible: 4;
	--slide-gap: 24;
	--slide-dur: 600;
	--slide-ease: cubic-bezier(.45, .05, .2, 1);
	position: relative;
	overflow: hidden;
	margin-block: 0 47px;
}

body .lp-gallery__intro:has(*) + .tr-gallery-instagram {
	margin-top: 40px;
}

.tr-gallery-instagram:not(.is-ready) {
	display: grid;
	grid-template-columns: repeat(var(--slides-visible), minmax(0, 1fr));
	gap: calc(var(--slide-gap) * 1px);
}

.tr-gallery-instagram:not(.is-ready) > :nth-child(n + 5) {
	display: none;
}

.tr-gallery-instagram__post {
	position: relative;
	display: block;
	aspect-ratio: 270 / 359;
	overflow: hidden;
	-webkit-user-drag: none;
}

.tr-gallery-instagram__post img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}

.tr-gallery-instagram__type {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 20px;
	height: 20px;
	color: #fff;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
}

.tr-gallery-instagram.is-ready {
	height: calc(var(--slide-w) * 359 / 270 * 1px);
	touch-action: pan-y;
	cursor: grab;
	-webkit-user-select: none;
	user-select: none;
}

.tr-gallery-instagram.is-ready:focus-visible {
	outline: 2px solid var(--secondary-300);
	outline-offset: 6px;
}

.tr-gallery-instagram.is-dragging {
	cursor: grabbing;
}

.tr-gallery-instagram .tr-card-grid__track {
	position: absolute;
	inset: 0;
	--drag: 0px;
}

.tr-gallery-instagram .tr-card-grid__track > .tr-gallery-instagram__post {
	position: absolute;
	top: 0;
	left: calc(var(--slide-w) * .5px);
	width: calc(var(--slide-w) * 1px);
	height: 100%;
	transform: translateX(-50%) translateX(calc(var(--x, 0) * 1px + var(--drag)));
	transition: transform calc(var(--slide-dur) * 1ms) var(--slide-ease);
	will-change: transform;
}

.tr-gallery-instagram.is-dragging .tr-gallery-instagram__post {
	transition: none;
}

@media (max-width: 767px) {
	body .tr-gallery-instagram {
		--slides-visible: 2;
	}

	.tr-gallery-instagram:not(.is-ready) > :nth-child(n + 3) {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	body .tr-gallery-instagram {
		--slide-dur: 1;
	}
}

/* Logo row: mono logos on the dark band (homepage sponsors). In the
   marquee layout the parent's gallery.js scrolls them; tiles are the
   Figma 271px logo boxes. */
body .is-style-tr-logos .lp-gallery__marquee {
	margin-block: 40px;
}

body .is-style-tr-logos .lp-gallery__marquee .lp-gallery__img-wrapper {
	height: clamp(120px, 18.8vw, 271px);
	aspect-ratio: auto;
}

body .is-style-tr-logos .lp-gallery__marquee .lp-gallery__img-wrapper img {
	width: auto;
	height: 100%;
	object-fit: contain;
}

/* Logo row, grid layout: sized by height. */
body .is-style-tr-logos .lp-gallery__gallery {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: clamp(24px, 3vw, 40px);
}

body .is-style-tr-logos .lp-gallery__img-wrapper {
	aspect-ratio: auto;
	height: clamp(70px, 9vw, 130px);
}

body .is-style-tr-logos .lp-gallery__img-wrapper img {
	width: auto;
	object-fit: contain;
}

/* ---- Text items (child field group "Gallery: Text items") ------------
   Rodeo 101 "Speak Rodeo": term + definition cards scrolled by the
   parent's marquee script, one track per row. Figma: 367-wide cards ~25
   apart, term Unbounded 500 17/24 caps, definition 16/20; row 2 starts
   85px further right and 30px lower; first row 51px under the intro rule.
   The rows run the full band width and fade out towards the edges. */
.tr-gallery-text {
	--tr-gt-inset: max(24px, calc(50vw - 576px));
	margin: 51px calc(50% - 50vw) 0;
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 max(18%, calc(50% - 420px)), #000 min(82%, calc(50% + 420px)), transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 max(18%, calc(50% - 420px)), #000 min(82%, calc(50% + 420px)), transparent 100%);
}

body .tr-gallery-text .lp-gallery__marquee {
	--marquee-speed: 35;
	margin: 0;
}

body .tr-gallery-text .lp-gallery__marquee + .lp-gallery__marquee {
	margin-top: 30px;
}

body .tr-gallery-text .lp-gallery__marquee-track {
	gap: 25px;
	margin: 0;
	padding-left: var(--tr-gt-inset);
	align-items: flex-start;
}

body .tr-gallery-text .lp-gallery__marquee + .lp-gallery__marquee .lp-gallery__marquee-track {
	padding-left: calc(var(--tr-gt-inset) + 85px);
}

/* Top row scrolls left to right, the bottom row right to left. The
   parent's gallery.js only moves a track leftward, so the top row is
   mirrored and each card mirrored back: its track still runs left
   inside the row, which reads as rightward on screen. One row keeps
   the parent's direction. */
@media (prefers-reduced-motion: no-preference) {
	body .tr-gallery-text .lp-gallery__marquee:first-child:not(:last-child),
	body .tr-gallery-text .lp-gallery__marquee:first-child:not(:last-child) .tr-gallery-text__item {
		transform: scaleX(-1);
	}
}

.tr-gallery-text__item {
	flex: 0 0 367px;
	margin: 0;
}

.tr-gallery-text__term {
	font-family: var(--font-family-heading);
	font-size: var(--font-size-h4);
	font-weight: 500;
	line-height: 24px;
	text-transform: uppercase;
	color: var(--text-primary);
}

.tr-gallery-text__def {
	margin: 0;
	font-size: 16px;
	line-height: 20px;
	color: var(--text-primary);
}

/* No motion: every card, wrapped in the container. */
@media (prefers-reduced-motion: reduce) {
	.tr-gallery-text {
		margin-inline: 0;
		-webkit-mask-image: none;
		mask-image: none;
	}

	body .tr-gallery-text .lp-gallery__marquee-track,
	body .tr-gallery-text .lp-gallery__marquee + .lp-gallery__marquee .lp-gallery__marquee-track {
		width: auto;
		flex-wrap: wrap;
		padding-left: 0;
		row-gap: 30px;
	}
}

@media (max-width: 767px) {
	.tr-gallery-text__item {
		flex-basis: 280px;
	}
}
