/* DCW Gallery
 * Year and category pickers above a justified mosaic.
 *
 * The mosaic is laid out entirely by flexbox and aspect-ratio - the row
 * groupings are decided in PHP, and each row carries the total aspect ratio of
 * the images on it. A row's height is therefore always its own width divided by
 * that total, whatever the screen size, so the layout stays justified as it
 * scales and nothing jumps once the images load.
 */
.dcw-gallery {
	width: 100%;
}

.dcw-gallery *,
.dcw-gallery *:before,
.dcw-gallery *:after {
	box-sizing: border-box;
}

/* # Pickers
---------------------------------------------------------------------------- */
.dcw-gallery-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	margin-bottom: 25px;
}

.dcw-gallery-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 0 1 260px;
	margin: 0;
}

/* The two pickers on the left choose which photos; this one only changes how
 * many, so it sits apart from them at the other end of the row */
.dcw-gallery-field-per-page {
	flex: 0 0 auto;
	margin-left: auto;
}

.dcw-gallery-field-per-page .dcw-gallery-select {
	min-width: 150px;
}

.dcw-gallery-label {
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.dcw-gallery-select {
	width: 100%;
	padding: 11px 14px;
	border: 2px solid transparent;
	border-radius: 8px;
	background-color: #fff;
	color: #333;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 18px;
	line-height: 1.3;
}

.dcw-gallery-select:focus {
	border-color: #f2d492;
	outline: none;
}

/* # Mosaic
---------------------------------------------------------------------------- */
.dcw-gallery-mosaic {
	--dcw-gallery-gap: 6px;
	width: 100%;
}

.dcw-gallery-row {
	display: flex;
	width: 100%;
}

/* The gutter is padding inside each item rather than a flex gap. A gap would
 * eat into the width the row's aspect ratio is calculated from and leave the
 * rows fractionally too tall; padding comes out of the item instead, and the
 * images are cropped to fill so nothing distorts. */
.dcw-gallery-link {
	display: block;
	position: relative;
	min-width: 0;
	padding: calc(var(--dcw-gallery-gap) / 2);
	overflow: hidden;
	text-decoration: none;
}

.dcw-gallery-link:hover,
.dcw-gallery-link:focus {
	text-decoration: none;
}

.dcw-gallery-link img,
.dcw-gallery-link .dcw-gallery-image {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border-radius: 3px;
	object-fit: cover;
	transition: opacity .2s ease;
}

.dcw-gallery-link:hover img,
.dcw-gallery-link:focus img {
	opacity: .82;
}

.dcw-gallery-empty {
	margin: 0;
	padding: 40px 0;
	text-align: center;
}

/* Only editors see this one, under the message above */
.dcw-gallery-hint {
	padding: 0 0 40px;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 17px;
	opacity: .85;
}

.dcw-gallery-empty + .dcw-gallery-hint {
	padding-top: 0;
}

/* # Pagination
---------------------------------------------------------------------------- */
.dcw-gallery-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 15px;
	margin-top: 25px;
}

.dcw-gallery-count {
	margin: 0;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 16px;
	opacity: .85;
}

.dcw-gallery-pages {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-left: auto;
}

.dcw-gallery-page {
	min-width: 42px;
	padding: 9px 13px;
	/* The page content button - see .dcw-button in the theme */
	border: 3px solid #fff;
	border-radius: 8px;
	background-color: rgba(255, 255, 255, .14);
	color: #fff;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}

.dcw-gallery-page:hover,
.dcw-gallery-page:focus {
	background-color: rgba(255, 255, 255, .28);
	color: #fff;
}

/* The page you are on is filled in rather than outlined, so it reads as the
 * one that is not a link */
.dcw-gallery-page.is-current {
	background-color: #fff;
	color: #522c3e;
	cursor: default;
}

.dcw-gallery-page[disabled] {
	opacity: .4;
	cursor: default;
}

.dcw-gallery-page[disabled]:hover,
.dcw-gallery-page[disabled]:focus {
	background-color: rgba(255, 255, 255, .14);
	color: #fff;
}

.dcw-gallery-page-ellipsis {
	padding: 0 2px;
	opacity: .7;
}

/* # Loading
---------------------------------------------------------------------------- */
.dcw-gallery-stage {
	position: relative;
	min-height: 60px;
}

.dcw-gallery-stage.is-loading {
	opacity: .35;
}

/* # Lightbox
---------------------------------------------------------------------------- */
/* Magnific ships with Beaver Builder and is styled for a white page. These are
 * only the pieces that need to sit on this site's darker overlay. */
.dcw-gallery-lightbox .mfp-bg {
	background: #2b1a24;
	opacity: .94;
}

/* Each arrow is two stacked triangles - a dark one behind a light one, so it
 * reads over a pale photo as well as a dark one. Only the backing triangle is
 * recoloured; blanking both is what made the arrows invisible. */
.dcw-gallery-lightbox .mfp-arrow {
	opacity: .85;
}

.dcw-gallery-lightbox .mfp-arrow:hover,
.dcw-gallery-lightbox .mfp-arrow:focus {
	opacity: 1;
}

.dcw-gallery-lightbox .mfp-arrow-left:before {
	border-right-color: #2b1a24;
}

.dcw-gallery-lightbox .mfp-arrow-right:before {
	border-left-color: #2b1a24;
}

.dcw-gallery-lightbox .mfp-counter {
	color: #f2d492;
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 15px;
}

.dcw-gallery-lightbox .mfp-figure:after {
	box-shadow: none;
	background: transparent;
}

/* No caption is rendered, so the space the figure reserves for one is removed */
.dcw-gallery-lightbox .mfp-bottom-bar {
	margin-top: -30px;
}

.dcw-gallery-lightbox .mfp-title {
	display: none;
}

/* # Medium devices
---------------------------------------------------------------------------- */
@media only screen and (max-width: 860px) {

	.dcw-gallery-filters {
		gap: 14px;
		margin-bottom: 20px;
	}

	.dcw-gallery-field {
		flex: 1 1 180px;
	}

	.dcw-gallery-field-per-page {
		flex: 0 0 auto;
	}

}

/* # Phone devices
---------------------------------------------------------------------------- */
/* Rows of four or five photos are unreadable on a phone, so the rows dissolve
 * and each photo takes the full width at its own shape. --dcw-ar is written
 * onto every item for exactly this. */
@media only screen and (max-width: 600px) {

	.dcw-gallery-row {
		display: block;
		aspect-ratio: auto !important;
	}

	.dcw-gallery-link {
		width: 100% !important;
		flex: none !important;
		/* Margin rather than padding - aspect-ratio sizes the border box, so
		 * padding here would eat into the photo instead of separating them */
		padding: 0;
		margin-bottom: var(--dcw-gallery-gap);
		aspect-ratio: var(--dcw-ar, 1.5);
	}

	.dcw-gallery-field {
		flex: 1 1 100%;
	}

	.dcw-gallery-field-per-page {
		flex: 1 1 100%;
		margin-left: 0;
	}

	.dcw-gallery-pagination {
		justify-content: center;
		text-align: center;
	}

	.dcw-gallery-pages {
		justify-content: center;
		margin-left: 0;
	}

	.dcw-gallery-count {
		flex: 1 1 100%;
		order: 2;
	}

}
