/**
 * Reel Portfolio — front end.
 *
 * Desktop mode = a mouse or trackpad on a window at least 768px wide (the width is
 * a setting): (min-width: 768px) and (hover: hover) and (pointer: fine)
 * Everything else (phones, tablets) is mobile mode. The rules that depend on it are in
 * frontend-breakpoint.css, which is printed inline with the width from the settings.
 *
 * Easy overrides from the theme's Additional CSS:
 *   .rpf          { --rpf-gap: 6px; }
 *   .rpf .rpf-filter { text-transform: uppercase; }
 *   .rpf-lb       { --rpf-lb-bg: #000; }
 */

/* ------------------------------------------------------------------ Grid */

.rpf {
	--rpf-row: 280px;
	--rpf-row-m: 160px;
	--rpf-gap: 8px;
	--rpf-row-now: var(--rpf-row-m);
	position: relative;
}

/* Justified rows. Before the script runs (and without it), every item grows in
   proportion to its aspect ratio, so all items of a row end up the same height.
   Flexbox can only stretch a row, never shrink it, so items start at 80% of the
   target size; the script then picks the row breaks that land closest to the
   target height and gives each item its share of its row (--share). */
.rpf-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--rpf-gap);
	transition: opacity 0.2s ease;
}

/* Soaks up the free space of the last row so it keeps the target height. */
.rpf-grid::after {
	content: "";
	flex: 999999 1 0px;
}

.rpf-grid.is-filtering {
	opacity: 0;
}

.rpf .rpf-item {
	--ar: 1.7778;
	position: relative;
	display: flex;
	flex-direction: column;
	flex: var(--ar) 1 calc(var(--rpf-row-now) * var(--ar) * 0.8);
	min-width: 0;
	margin: 0;
	padding: 0;
	color: inherit;
	text-decoration: none;
	border: 0;
	box-shadow: none;
	outline-offset: 3px;
	/* Themes often animate every property of links, which would animate the layout. */
	transition: none;
}

/* A share of the row's width less its gaps (--gaps), so every row scales with the
   page while the window is resized; the script redoes the rows once it settles. */
.rpf .rpf-grid.is-justified .rpf-item {
	flex: 0 0 calc((100% - var(--gaps)) * var(--share));
}

/* The script lays out the last row itself. */
.rpf-grid.is-justified::after {
	display: none;
}

.rpf .rpf-item[hidden] {
	display: none;
}

.rpf-item__media {
	position: relative;
	display: block;
	aspect-ratio: var(--ar);
	overflow: hidden;
	background: rgba(127, 127, 127, 0.12);
}

.rpf .rpf-item__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
	object-fit: cover;
}

.rpf-item__img--empty {
	background: rgba(127, 127, 127, 0.2);
}

.rpf-item__hover {
	position: absolute;
	inset: 0;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.rpf-item__hover.is-active.is-loaded {
	opacity: 1;
}

.rpf .rpf-item__hover > img,
.rpf .rpf-item__hover > video {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

/* Caption: below the image by default (the "Classic" look). */
.rpf-item__caption {
	display: block;
	padding: 0.6em 0 0.2em;
	line-height: 1.3;
}

.rpf-item__title {
	display: block;
	font-weight: 600;
}

.rpf-item__meta {
	display: block;
	margin-top: 0.15em;
	font-size: 0.85em;
	opacity: 0.65;
}

/* Desktop and phone caption styles: frontend-breakpoint.css. */

/* --------------------------------------------------------------- Filters */

.rpf-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25em 1.4em;
	margin: 0 0 1.25em;
}

/* Covers every state (hover, focus, a right-click) on its own, so a theme's button
   styles stay out while custom CSS written for .rpf .rpf-filter still wins. */
.rpf .rpf-filter {
	appearance: none;
	min-height: 0;
	margin: 0;
	padding: 0.25em 0;
	font: inherit;
	line-height: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	color: inherit;
	background: none;
	border: 0;
	border-bottom: 1px solid transparent;
	border-radius: 0;
	box-shadow: none;
	text-shadow: none;
	cursor: pointer;
	/* No word highlight when a filter is right-clicked. */
	-webkit-user-select: none;
	user-select: none;
	opacity: 0.55;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.rpf .rpf-filter:hover,
.rpf .rpf-filter:focus-visible,
.rpf .rpf-filter.is-active {
	opacity: 1;
}

/* Themes often outline any focused button; keep that for keyboard focus only. */
.rpf .rpf-filter:focus:not(:focus-visible),
.rpf-lb button:focus:not(:focus-visible) {
	outline: none;
}

.rpf .rpf-filter.is-active {
	border-bottom-color: currentColor;
}

/* -------------------------------------------------------- Cursor caption */

.rpf-cursor {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 99990;
	pointer-events: none;
	will-change: transform;
}

.rpf-cursor__inner {
	display: block;
	max-width: 320px;
	padding: 0.55em 0.85em;
	font-size: 14px;
	line-height: 1.3;
	color: var(--rpf-cursor-text, #111);
	background: var(--rpf-cursor-bg, #fff);
	opacity: 0;
	transform: scale(0.85);
	transform-origin: 0 0;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.rpf-cursor.is-flipped .rpf-cursor__inner {
	transform-origin: 100% 0;
}

.rpf-cursor.is-visible .rpf-cursor__inner {
	opacity: 1;
	transform: none;
}

.rpf-cursor__title {
	display: block;
	font-weight: 600;
}

.rpf-cursor__meta {
	display: block;
	margin-top: 0.1em;
	font-size: 0.85em;
	opacity: 0.7;
}

.rpf-cursor__meta:empty {
	display: none;
}

/* -------------------------------------------------------------- Lightbox */

html.rpf-lb-open {
	overflow: hidden;
}

html.rpf-lb-open.rpf-lb-gutter {
	scrollbar-gutter: stable;
}

.rpf-lb {
	--pad: clamp(12px, 2.5vw, 32px);
	--bar: 56px;
	--rail: clamp(200px, 21vw, 340px);
	--col-gap: clamp(12px, 1.4vw, 22px);
	--ratio: 1.7778;
	--vh: 100vh;
	/* Room left under the player so the project title peeks in. */
	--reserve: 64px;
	--stage-w: calc((var(--vh) - var(--bar) - var(--reserve)) * var(--ratio));

	position: fixed;
	inset: 0;
	z-index: 99999;
	color: #f1f1f1;
	line-height: 1.55;
	background: var(--rpf-lb-bg, #0b0b0b);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

@supports (height: 100dvh) {
	.rpf-lb {
		--vh: 100dvh;
	}
}

.rpf-lb[hidden] {
	display: none;
}

.rpf-lb.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.25s ease;
}

.rpf-lb *,
.rpf-lb *::before,
.rpf-lb *::after {
	box-sizing: border-box;
}

.rpf-lb__scroll {
	position: absolute;
	inset: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Top bar. */
.rpf-lb__bar {
	position: sticky;
	top: 0;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 2px;
	height: var(--bar);
	padding: 0 calc(var(--pad) - 8px);
	background: var(--rpf-lb-bg, #0b0b0b);
}

.rpf-lb__count {
	margin-right: auto;
	padding-left: 8px;
	font-size: 12px;
	letter-spacing: 0.12em;
	font-variant-numeric: tabular-nums;
	opacity: 0.5;
}

.rpf-lb .rpf-lb__btn,
.rpf-lb .rpf-lb__arrow,
.rpf-lb .rpf-lb__thumb {
	appearance: none;
	min-height: 0;
	margin: 0;
	padding: 0;
	font: inherit;
	text-transform: none;
	color: inherit;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	text-shadow: none;
	cursor: pointer;
}

.rpf-lb .rpf-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	background: transparent;
	border-radius: 50%;
	opacity: 0.7;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.rpf-lb .rpf-lb__btn:hover,
.rpf-lb .rpf-lb__btn:focus-visible {
	background: rgba(255, 255, 255, 0.1);
	opacity: 1;
}

.rpf-lb .rpf-lb__btn[hidden] {
	display: none;
}

.rpf-lb svg {
	display: block;
	width: 22px;
	height: 22px;
}

/* Body: player, gallery rail, caption. */
.rpf-lb__body {
	display: grid;
	grid-template-columns: minmax(0, var(--stage-w));
	grid-template-areas:
		"stage"
		"rail"
		"caption";
	justify-content: center;
	gap: var(--col-gap);
	padding: 0 var(--pad) calc(var(--pad) * 2);
}

.rpf-lb:not(.rpf-lb--has-rail) .rpf-lb__body {
	grid-template-areas:
		"stage"
		"caption";
}

.rpf-lb__body.is-in {
	animation: rpf-fade-in 0.3s ease;
}

@keyframes rpf-fade-in {
	from {
		opacity: 0;
	}
}

@media (min-width: 900px) {
	.rpf-lb--has-rail .rpf-lb__body {
		grid-template-columns: minmax(0, var(--stage-w)) var(--rail);
		grid-template-areas:
			"stage rail"
			"caption caption";
	}
}

/* Stage: the video, or a still in its place. */
.rpf-lb__stage {
	position: relative;
	grid-area: stage;
	width: 100%;
	aspect-ratio: var(--ratio);
	overflow: hidden;
	background: #000;
}

.rpf-lb__video,
.rpf-lb__still {
	position: absolute;
	inset: 0;
	margin: 0;
}

.rpf-lb__video[hidden],
.rpf-lb__still[hidden] {
	display: none;
}

.rpf-lb .rpf-lb__video iframe,
.rpf-lb .rpf-lb__video video {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	background: #000;
	border: 0;
}

.rpf-lb .rpf-lb__still img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: contain;
	transition: opacity 0.25s ease;
}

.rpf-lb__still.is-loading img {
	opacity: 0;
}

.rpf-lb__still.is-loading::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border: 2px solid rgba(255, 255, 255, 0.2);
	border-top-color: rgba(255, 255, 255, 0.8);
	border-radius: 50%;
	animation: rpf-spin 0.8s linear infinite;
}

@keyframes rpf-spin {
	to {
		transform: rotate(360deg);
	}
}

.rpf-lb__still-caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	padding: 2.5em 14px 10px;
	font-size: 12px;
	line-height: 1.4;
	background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.65));
}

.rpf-lb__still-caption[hidden] {
	display: none;
}

.rpf-lb__still-caption a {
	color: inherit;
}

.rpf-lb__stage-count {
	position: absolute;
	top: 10px;
	left: 12px;
	padding: 2px 8px;
	font-size: 11px;
	letter-spacing: 0.1em;
	font-variant-numeric: tabular-nums;
	background: rgba(0, 0, 0, 0.45);
	pointer-events: none;
}

.rpf-lb__stage-count:empty {
	display: none;
}

.rpf-lb .rpf-lb__arrow {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 72px;
	color: #fff;
	background: rgba(0, 0, 0, 0.35);
	opacity: 0;
	transform: translateY(-50%);
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.rpf-lb .rpf-lb__arrow[hidden] {
	display: none;
}

.rpf-lb__arrow--prev {
	left: 0;
}

.rpf-lb__arrow--next {
	right: 0;
}

.rpf-lb__stage:hover .rpf-lb__arrow,
.rpf-lb .rpf-lb__arrow:focus-visible {
	opacity: 1;
}

.rpf-lb .rpf-lb__arrow:hover {
	background: rgba(0, 0, 0, 0.6);
}

@media (hover: none) {
	.rpf-lb .rpf-lb__arrow {
		opacity: 0.85;
	}
}

/* Gallery rail. */
.rpf-lb__rail {
	position: relative;
	grid-area: rail;
	min-width: 0;
}

.rpf-lb__rail[hidden] {
	display: none;
}

.rpf-lb__section + .rpf-lb__section {
	margin-top: 18px;
}

.rpf-lb .rpf-lb__section-title {
	margin: 0 0 8px;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: inherit;
	opacity: 0.55;
}

.rpf-lb__thumbs {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px;
}

.rpf-lb .rpf-lb__thumb {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	background: #1c1c1c;
	opacity: 0.6;
	transition: opacity 0.2s ease;
}

.rpf-lb .rpf-lb__thumb:hover,
.rpf-lb .rpf-lb__thumb:focus-visible,
.rpf-lb .rpf-lb__thumb.is-active {
	opacity: 1;
}

.rpf-lb .rpf-lb__thumb.is-active::after {
	content: "";
	position: absolute;
	inset: 0;
	box-shadow: inset 0 0 0 2px #fff;
}

.rpf-lb .rpf-lb__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

.rpf-lb .rpf-lb__thumb--video {
	aspect-ratio: var(--ratio);
	margin-bottom: 18px;
}

.rpf-lb__play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 0 10px;
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #fff;
	background: rgba(0, 0, 0, 0.3);
}

/* A dark disc behind the play icon, so it reads on any poster. */
.rpf-lb .rpf-lb__play svg {
	flex: none;
	box-sizing: content-box;
	width: 26px;
	height: 26px;
	padding: 12px 11px 12px 13px;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 50%;
}

.rpf-lb__play span {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rpf-lb__badge {
	position: absolute;
	top: 4px;
	left: 4px;
	display: none;
	padding: 1px 5px;
	font-size: 9px;
	letter-spacing: 0.1em;
	color: #fff;
	background: rgba(0, 0, 0, 0.6);
}

/* Desktop: the rail sits beside the player, exactly as tall, and scrolls on its own. */
@media (min-width: 900px) {
	.rpf-lb--has-rail .rpf-lb__rail-inner {
		position: absolute;
		inset: 0;
		padding-right: 4px;
		overflow-y: auto;
		scrollbar-width: thin;
		scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
	}
}

/* Narrow screens: one swipeable strip under the player. */
@media (max-width: 899px) {
	.rpf-lb__rail-inner {
		display: flex;
		gap: 6px;
		overflow-x: auto;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
	}

	.rpf-lb__rail-inner::-webkit-scrollbar {
		display: none;
	}

	.rpf-lb__section,
	.rpf-lb__thumbs {
		display: contents;
	}

	.rpf-lb .rpf-lb__section-title {
		display: none;
	}

	.rpf-lb .rpf-lb__thumb,
	.rpf-lb .rpf-lb__thumb--video {
		flex: 0 0 auto;
		width: 120px;
		aspect-ratio: 3 / 2;
		margin: 0;
		scroll-snap-align: start;
	}

	.rpf-lb__play {
		gap: 6px;
		padding: 0 6px;
		font-size: 11px;
	}

	.rpf-lb .rpf-lb__play svg {
		width: 22px;
		height: 22px;
		padding: 9px 8px 9px 10px;
	}

	.rpf-lb__badge {
		display: block;
	}
}

/* Caption. */
.rpf-lb__caption {
	grid-area: caption;
	max-width: 72ch;
	padding-top: 4px;
}

.rpf-lb .rpf-lb__title {
	margin: 0;
	padding: 0;
	font-size: clamp(20px, 2.1vw, 28px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	color: inherit;
}

.rpf-lb .rpf-lb__meta {
	margin: 6px 0 0;
	opacity: 0.6;
}

.rpf-lb__meta[hidden],
.rpf-lb__text[hidden] {
	display: none;
}

.rpf-lb__text {
	margin-top: 18px;
	font-size: 15px;
}

.rpf-lb__text > :first-child {
	margin-top: 0;
}

.rpf-lb__text > :last-child {
	margin-bottom: 0;
}

.rpf-lb .rpf-lb__text p,
.rpf-lb .rpf-lb__text ul,
.rpf-lb .rpf-lb__text ol {
	margin: 0 0 1em;
	color: inherit;
}

.rpf-lb .rpf-lb__text a {
	color: inherit;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.rpf-lb .rpf-lb__text a:hover {
	opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
	.rpf-grid,
	.rpf-lb,
	.rpf-lb__body.is-in,
	.rpf-cursor__inner,
	.rpf-item__hover {
		transition: none;
		animation: none;
	}
}
