/* ==========================================================================
   Photos & Videos page (page-templates/template-media-gallery.php).
   The video boxes reuse components/video-row.css; everything here is the
   filter buttons, the photo grid and the photo viewer.
   ========================================================================== */

/* The banner photo. Each page's own stylesheet has to hand the picture in
   template-media-gallery.php (--hero-bg) to the background, the same way
   the category pages do. */
.hero--media {
	background-image: var(--hero-bg);
	background-size: cover;
	background-position: center 58%;
	min-height: 460px;
}

.mg-section { padding-top: 40px; }

/* ---- The buttons that show only one kind ---- */
.mg-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	margin-bottom: 36px;
}
.mg-filter {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	border: 1px solid var(--color-border);
	border-radius: 999px;
	background: var(--color-surface);
	color: var(--color-text);
	font-size: 0.92rem;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--transition), color var(--transition),
		border-color var(--transition), transform var(--transition);
}
.mg-filter:hover { transform: translateY(-2px); border-color: var(--color-primary); }
.mg-filter.is-current {
	background: var(--color-primary);
	border-color: var(--color-primary);
	color: #fff;
}
.mg-count {
	display: inline-grid;
	place-items: center;
	min-width: 24px;
	height: 22px;
	padding: 0 7px;
	border-radius: 999px;
	background: var(--color-bg-alt);
	color: var(--color-text-light);
	font-size: 0.74rem;
}
.mg-filter.is-current .mg-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

/* ---- Headings above each part ---- */
.mg-block + .mg-block { margin-top: 56px; }
.mg-block[hidden] { display: none; }
.mg-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 1.3rem;
	margin: 0 0 22px;
	color: var(--color-primary-dark);
}
.mg-heading svg { width: 22px; height: 22px; color: var(--color-secondary); }

.mg-videos { margin-bottom: 0; }

/* ---- The photo grid ---- */
.mg-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 18px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.mg-photo {
	border-radius: var(--radius-md);
	overflow: hidden;
	box-shadow: var(--shadow-sm);
	background: var(--color-bg-alt);
	transition: transform 320ms ease, box-shadow 320ms ease;
}
.mg-photo:hover,
.mg-photo:focus-within {
	transform: translateY(-5px);
	box-shadow: 0 18px 36px rgba(43, 38, 32, 0.18);
}
.mg-photo-open {
	display: block;
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	color: #fff;
}
.mg-photo-open img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 500ms ease;
}
.mg-photo:hover .mg-photo-open img { transform: scale(1.06); }
.mg-photo-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 26px 14px 12px;
	text-align: left;
	font-size: 0.86rem;
	font-weight: 600;
	line-height: 1.35;
	background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.72) 100%);
	opacity: 0;
	transition: opacity var(--transition);
}
.mg-photo:hover .mg-photo-caption,
.mg-photo:focus-within .mg-photo-caption { opacity: 1; }

.mg-item[hidden] { display: none; }
.mg-empty { text-align: center; color: var(--color-text-light); margin: 26px 0 0; }

/* ---- The big photo viewer ---- */
.mg-viewer {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: none;
	place-items: center;
	padding: 24px;
	background: rgba(20, 17, 14, 0.94);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}
.mg-viewer.is-open { display: grid; }
.mg-viewer img {
	max-width: min(1100px, 94vw);
	max-height: 78vh;
	max-height: 78dvh;
	border-radius: var(--radius-md);
	box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}
.mg-viewer-caption {
	color: #fff;
	text-align: center;
	margin: 16px 0 0;
	font-weight: 600;
}
.mg-viewer-close,
.mg-viewer-prev,
.mg-viewer-next {
	position: absolute;
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	cursor: pointer;
	transition: background var(--transition);
}
.mg-viewer-close:hover,
.mg-viewer-prev:hover,
.mg-viewer-next:hover { background: rgba(255, 255, 255, 0.3); }
.mg-viewer-close { top: 20px; right: 20px; }
.mg-viewer-prev  { top: 50%; left: 20px; margin-top: -24px; }
.mg-viewer-next  { top: 50%; right: 20px; margin-top: -24px; }
.mg-viewer-close svg,
.mg-viewer-prev svg,
.mg-viewer-next svg { width: 22px; height: 22px; }
html.mg-lock { overflow: hidden; }

/* ---- Phones ---- */
@media (max-width: 640px) {
	.mg-section { padding-top: 28px; }
	.mg-filters { gap: 8px; margin-bottom: 26px; }
	.mg-filter { padding: 9px 14px; font-size: 0.85rem; }
	.mg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
	.mg-photo-caption { opacity: 1; font-size: 0.74rem; padding: 20px 10px 9px; }
	.mg-viewer { padding: 14px; }
	.mg-viewer-prev { top: auto; bottom: 20px; left: calc(50% - 62px); margin-top: 0; }
	.mg-viewer-next { top: auto; bottom: 20px; right: calc(50% - 62px); margin-top: 0; }
	.mg-viewer-caption { margin-bottom: 74px; }
}
