/* Replacements for the Cargo web components (column-set, media-item, gallery-*, marquee-set, text-icon, digital-clock) */

html.js-on body { opacity: 0; }
html.js-on.ready body { opacity: 1; transition: opacity .3s ease; }

/* ---------- column-set: 12-col grid, equal columns unless span is given ---------- */
.column-set {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: var(--gutter, 1rem);
	width: 100%;
	position: relative;
	clear: both;
	contain: layout;
}
.column-unit {
	display: block;
	grid-column: span var(--span, 6);
	min-width: 0;
	max-width: 100%;
	position: relative;
	word-wrap: break-word;
}
.column-set + .column-set { margin-top: var(--gutter, 1rem); }
.mobile .column-set:not([data-stack="false"]) { display: block; }
.mobile .column-set[data-hide-empty="true"]:not([data-stack="false"]) > .column-unit.is-empty { display: none; }

/* ---------- text-icon ---------- */
.text-icon {
	display: inline-block;
	aspect-ratio: 1;
	height: 1.2em;
	width: auto;
	margin-top: -1em;
	margin-bottom: -.25em;
	vertical-align: baseline;
	position: relative;
	contain: layout;
}
.text-icon svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; fill: currentColor; }

/* ---------- blink ---------- */
.blink {
	display: inline-block;
	position: relative;
	animation: 1.25s infinite steps(1) blink !important;
}
@keyframes blink { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- digital clock ---------- */
.digital-clock { display: inline-block; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- media-item ---------- */
.media-item {
	display: inline-flex;
	flex-direction: column;
	vertical-align: bottom;
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
.media-item .mi-link { display: block; width: 100%; cursor: pointer; color: inherit; }
.media-item.linked { cursor: pointer; }
.mi-frame {
	display: block;
	width: 100%;
	height: 0;
	position: relative;
	isolation: isolate;
	filter: blur(5px);
	transform: scale(.992);
	transition: filter .5s cubic-bezier(.4, 0, .2, 1), transform .5s cubic-bezier(.4, 0, .2, 1);
	backface-visibility: hidden;
}
.media-item.in-view .mi-frame,
html:not(.js-on) .mi-frame { filter: none; transform: none; }
.mi-frame img,
.mi-frame video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	margin: 0;
}
.media-item .caption { margin-top: 1rem; }
.media-item figcaption { width: 100%; user-select: text; }
.gallery-grid .media-item .caption { margin-bottom: 2em; }
.gallery-slideshow .caption { margin-top: 1em; }

/* ---------- gallery-grid: N columns, 1rem gutter, items span k columns ---------- */
.gallery-grid {
	display: grid;
	grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
	gap: 1rem;
	align-items: start;
	width: 100%;
	max-width: 100%;
	position: relative;
}
.gallery-grid > .grid-item {
	display: flex;
	grid-column: span var(--span, 1);
	min-width: 0;
	max-width: 100%;
}
.mobile .gallery-grid { grid-template-columns: repeat(var(--mcols, 1), minmax(0, 1fr)); }
.mobile .gallery-grid > .grid-item { grid-column: auto; }

/* ---------- gallery-slideshow (frames cross-fade in place) ---------- */
.gallery-slideshow { display: grid; width: 100%; max-width: 100%; position: relative; }
.gallery-slideshow > .slide {
	grid-area: 1 / 1;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--fade, .01s) cubic-bezier(.24, 0, .29, 1);
	max-width: none;
}
.gallery-slideshow > .slide.prev { opacity: 1; visibility: visible; z-index: 1; transition: none; }
.gallery-slideshow > .slide.active { opacity: 1; visibility: visible; z-index: 2; }
.gallery-slideshow > .slide .mi-frame { height: 0; padding-bottom: var(--pb, 0); }
.gallery-slideshow.has-h > .slide .mi-frame { height: var(--slide-h); padding-bottom: 0; }
.gallery-slideshow > .slide .mi-frame img,
.gallery-slideshow > .slide .mi-frame video { object-fit: contain; object-position: center var(--ss-pos, center); }

/* ---------- marquee ---------- */
.marquee-h {
	display: block;
	position: relative;
	contain: layout;
	min-height: .5em;
	width: 100%;
	cursor: default;
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
}
.marquee-h .marquee-clip { margin: -2rem 0; padding: 2rem 0; overflow: hidden; pointer-events: none; }
.marquee-h .marquee-track { display: flex; width: max-content; will-change: transform; white-space: nowrap; pointer-events: auto; }
.marquee-h .marquee-copy { display: inline-block; min-width: var(--w, 100%); white-space: nowrap; flex: 0 0 auto; }

.marquee-bounce {
	display: block;
	position: relative;
	width: 100%;
	height: calc(var(--fit-height, 50vh) * var(--vh, .7));
	min-height: .5em;
	contain: layout;
	touch-action: pan-y;
	cursor: grab;
	-webkit-user-select: none;
	user-select: none;
}
.marquee-bounce:active { cursor: grabbing; }
.marquee-bounce .marquee-item {
	position: absolute;
	top: 0;
	left: 0;
	will-change: transform;
	width: 100%;
	max-width: 20rem;
}
.marquee-bounce .marquee-item .media-item { max-width: 20rem; width: 20rem; }
.marquee-bounce .marquee-item .caption { text-align: left; }

/* ---------- page bits ---------- */
.desktop-only { }
.mobile .desktop-only { display: none !important; }
.overlay-content[hidden] { display: none !important; }
a { cursor: pointer; }

/* ---------- draggable text (uses="drag") ---------- */
.drag {
	display: inline-block;
	position: relative;
	cursor: grab;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	transform: var(--drag-transform, translate(0));
}
.drag.dragging { cursor: grabbing; }

/* ---------- hero image behind the first screen of a case (same picture as its home card) ---------- */
.hero-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.hero-bg { background: var(--hero-bg, transparent); }
.hero-bg img, .hero-bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--hero-pos, 50% 50%); display: block; }
.mobile .hero-bg img { object-fit: var(--hero-fit-m, cover); }
/* soft shade under the headline so white type stays readable on any frame */
.hero-bg.scrim::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, .25) 28%, rgba(0, 0, 0, 0) 55%); }
.mobile .hero-bg.scrim::after { background: linear-gradient(to top, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, .35) 35%, rgba(0, 0, 0, 0) 65%); }

/* ---------- page backdrop: image fixed to the viewport, visible only inside its page (clipScroll) ---------- */
.backdrop.clip { position: absolute; inset: 0; z-index: -1; clip-path: inset(0); pointer-events: none; }
.backdrop.clip .backdrop-contents { position: fixed; inset: 0; }
.backdrop.clip .backdrop-contents img {
	position: absolute;
	inset: var(--m, 0);
	width: calc(100% - 2 * var(--m, 0px));
	height: calc(100% - 2 * var(--m, 0px));
	object-fit: contain;
}

/* the bus footage is a screen recording: scale it up from the top so the player controls
   along its bottom and right edges fall outside the frame */
.crop-ui { transform: scale(1.14); transform-origin: 50% 0; }
.mi-frame:has(> .crop-ui) { overflow: hidden; }
