/* MaxGallery - front end. The font always comes from the theme (no font-family set here). */

/* ------------------------------------------------------------------ gallery */

.mxg-gallery {
	--mxg-gap: 12px;
	margin: 1.5em 0;
	font-family: inherit;
}

.mxg-gallery .mxg-items {
	display: grid;
	grid-template-columns: repeat(var(--mxg-cols, 3), minmax(0, 1fr));
	gap: var(--mxg-gap);
	margin: 0;
	padding: 0;
}

/* Themes often set margins, paddings and widths on figures and images. */
.mxg-gallery .mxg-items > .mxg-item {
	margin: 0;
	padding: 0;
	min-width: 0;
	max-width: none;
	width: auto;
	float: none;
}

.mxg-gallery .mxg-link {
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
	text-decoration: none;
}

.mxg-gallery .mxg-img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto !important;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

.mxg-gallery[data-mxg-link="lightbox"] .mxg-link {
	cursor: zoom-in;
}

.mxg-gallery .mxg-caption {
	margin: 6px 0 0;
	padding: 0;
	font-family: inherit;
	font-size: 0.875em;
	line-height: 1.4;
	text-align: start;
}

.mxg-notice {
	font-family: inherit;
	font-style: italic;
}

/* ---------------------------------------------------------------- documents */

.mxg-docs {
	--mxg-gap: 12px;
	margin: 1.5em 0;
	font-family: inherit;
}

.mxg-docs .mxg-docs-items {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--mxg-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mxg-docs-grid .mxg-docs-items {
	grid-template-columns: repeat(var(--mxg-cols, 3), minmax(0, 1fr));
}

/* Themes often set margins, list markers and link styles. */
.mxg-docs .mxg-docs-items > .mxg-doc {
	margin: 0;
	padding: 0;
	min-width: 0;
	list-style: none;
}

.mxg-docs .mxg-doc::before,
.mxg-docs .mxg-doc::marker {
	content: none;
}

.mxg-docs .mxg-doc-link {
	display: flex;
	align-items: center;
	gap: 12px;
	height: 100%;
	box-sizing: border-box;
	padding: 10px;
	border: 1px solid rgba(128, 128, 128, 0.35);
	border-radius: 4px;
	box-shadow: none;
	color: inherit;
	text-decoration: none;
}

.mxg-docs .mxg-doc-link:hover,
.mxg-docs .mxg-doc-link:focus-visible {
	border-color: currentcolor;
}

.mxg-docs .mxg-doc-link:hover .mxg-doc-title,
.mxg-docs .mxg-doc-link:focus-visible .mxg-doc-title {
	text-decoration: underline;
}

.mxg-docs .mxg-doc-thumb {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 56px;
	margin: 0;
}

.mxg-docs .mxg-doc-img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	border: 1px solid rgba(128, 128, 128, 0.35);
}

/* File type symbol (no image file needed): a sheet with the type in it. */
.mxg-docs .mxg-doc-icon {
	display: flex;
	align-items: flex-end;
	justify-content: center;
	box-sizing: border-box;
	width: 100%;
	aspect-ratio: 3 / 4;
	padding-bottom: 6px;
	border: 1px solid rgba(128, 128, 128, 0.6);
	border-radius: 3px;
	font-size: 0.7em;
	font-weight: 700;
	letter-spacing: 0.03em;
	line-height: 1;
}

.mxg-docs .mxg-doc-icon::after {
	content: attr(data-ext);
}

.mxg-docs .mxg-doc-body {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	overflow-wrap: anywhere;
}

.mxg-docs .mxg-doc-title {
	font-weight: 600;
}

.mxg-docs .mxg-doc-caption,
.mxg-docs .mxg-doc-description,
.mxg-docs .mxg-doc-meta {
	font-size: 0.875em;
	line-height: 1.4;
}

.mxg-docs .mxg-doc-meta {
	opacity: 0.7;
}

/* Grid: the preview is on top and larger. */
.mxg-docs-grid .mxg-doc-link {
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
}

.mxg-docs-grid .mxg-doc-thumb {
	width: auto;
}

.mxg-docs-grid .mxg-doc-icon {
	width: 40%;
	margin: 0 auto;
	font-size: 0.85em;
}

.mxg-docs-grid .mxg-doc-img {
	width: auto;
	margin: 0 auto;
}

@media (max-width: 782px) {
	.mxg-docs-grid .mxg-docs-items {
		grid-template-columns: repeat(min(var(--mxg-cols, 3), 2), minmax(0, 1fr));
	}
}

@media (max-width: 480px) {
	.mxg-docs-grid .mxg-docs-items {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Text for screen readers only. */
.mxg-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Masonry: the script sets "mxg-masonry-on" and the row spans. Without it the
   gallery stays a regular grid. */
.mxg-gallery.mxg-masonry-on .mxg-items {
	grid-auto-rows: 4px;
	row-gap: 0;
}

.mxg-gallery.mxg-masonry-on .mxg-items > .mxg-item {
	align-self: start;
	padding-bottom: var(--mxg-gap);
	box-sizing: border-box;
}

@media (max-width: 600px) {
	.mxg-gallery .mxg-items {
		grid-template-columns: repeat(min(var(--mxg-cols, 3), 2), minmax(0, 1fr));
	}
}

@media (max-width: 380px) {
	.mxg-gallery .mxg-items {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Widget: smaller gaps. */
.mxg-gallery.mxg-widget-gallery {
	--mxg-gap: 8px;
	margin: 0;
}

/* ----------------------------------------------------------------- lightbox */

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

.mxg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 12px;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	color: #f0f0f0;
}

.mxg-lightbox[hidden] {
	display: none;
}

.mxg-lightbox *,
.mxg-lightbox *::before,
.mxg-lightbox *::after {
	box-sizing: border-box;
}

.mxg-lb-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.88);
}

.mxg-lb-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	max-width: 100%;
	max-height: calc(100vh - 24px);
	max-height: calc(100dvh - 24px);
	min-height: 0;
	outline: 0;
}

.mxg-lb-stage {
	/* A strip above the image for counter, arrows and close button, so the controls never cover the image. */
	--mxg-lb-bar: 60px;
	position: relative;
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 0;
	padding-top: var(--mxg-lb-bar);
}

.mxg-lb-img {
	display: block;
	width: auto;
	height: auto;
	max-width: calc(100vw - 24px);
	max-height: calc(100vh - 24px - var(--mxg-lb-bar));
	max-height: calc(100dvh - 24px - var(--mxg-lb-bar));
	margin: 0;
	padding: 0;
	border: 0;
	object-fit: contain;
	background: #1a1a1a;
}

.mxg-lb-stage.is-loading .mxg-lb-img {
	opacity: 0.35;
}

.mxg-lb-info {
	flex: 0 0 auto;
	min-height: 0;
	overflow: auto;
	padding: 12px 16px;
	background: #151515;
	color: #f0f0f0;
	overscroll-behavior: contain;
}

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

.mxg-lb-info .mxg-detail-caption {
	margin: 0 0 0.5em;
	font-weight: 600;
}

.mxg-lb-info .mxg-detail-desc {
	margin: 0 0 0.75em;
}

.mxg-lb-info .mxg-detail-desc > :first-child {
	margin-top: 0;
}

.mxg-lb-info .mxg-detail-desc > :last-child {
	margin-bottom: 0;
}

.mxg-lb-info .mxg-detail-desc ul,
.mxg-lb-info .mxg-detail-desc ol {
	padding-inline-start: 1.25em;
}

.mxg-lb-info .mxg-fields {
	margin: 0;
	padding: 0;
}

.mxg-lb-info .mxg-field {
	margin: 0 0 0.5em;
	padding: 0;
}

.mxg-lb-info dt {
	margin: 0;
	padding: 0;
	font-size: 0.8125em;
	opacity: 0.7;
}

.mxg-lb-info dd {
	margin: 0;
	padding: 0;
	overflow-wrap: anywhere;
}

.mxg-lb-info dd p {
	margin: 0 0 0.5em;
}

.mxg-lb-info a {
	color: #fff;
	text-decoration: underline;
}

.mxg-lb-btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.mxg-lb-btn[hidden],
.mxg-lb-count[hidden] {
	display: none;
}

.mxg-lb-btn:hover {
	background: rgba(0, 0, 0, 0.85);
}

.mxg-lb-btn:focus-visible,
.mxg-lb-panel:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.mxg-lb-close {
	top: 8px;
	right: 8px;
}

.mxg-lb-bar {
	position: absolute;
	z-index: 2;
	top: 8px;
	left: 8px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.mxg-lb-bar .mxg-lb-btn {
	position: static;
}

.mxg-lb-next {
	top: 8px;
	/* Leaves room for the close button, which sits on the image in this layout. */
	right: 60px;
}

.mxg-lb-count {
	padding: 2px 10px;
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 0.8125em;
	line-height: 24px;
}

/* Narrow: image on top, fields below. The fields use the space the image leaves
   (scrolling when there is more); the image keeps at least 140px free for them. */
.mxg-lb-panel.has-info .mxg-lb-img {
	max-height: calc(100vh - 24px - 140px - var(--mxg-lb-bar));
	max-height: calc(100dvh - 24px - 140px - var(--mxg-lb-bar));
}

.mxg-lb-panel.has-info .mxg-lb-info {
	flex: 1 1 auto;
	min-height: 0;
}

/* Wide: fields next to the image. */
@media (min-width: 900px) and (min-height: 480px) {
	.mxg-lb-panel.has-info {
		flex-direction: row;
		align-items: stretch;
	}

	.mxg-lb-panel.has-info .mxg-lb-img {
		max-width: calc(100vw - 24px - 320px);
		max-height: calc(100vh - 24px - var(--mxg-lb-bar));
		max-height: calc(100dvh - 24px - var(--mxg-lb-bar));
	}

	/* The close button sits on the field panel here, so the next arrow takes the
	   same distance to the image edge as the counter has on the left. */
	.mxg-lb-panel.has-info .mxg-lb-next {
		right: 8px;
	}

	.mxg-lb-panel.has-info .mxg-lb-info {
		flex: 0 0 320px;
		width: 320px;
		padding: 56px 16px 16px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.mxg-lb-img {
		transition: opacity 0.15s;
	}
}
