/*
 * nmbox: photo viewer (nmbox.js), article pictures (a.nmz from mambots/content/hsimage.php)
 * and article galleries (.nmz-gal from mambots/content/plugin_jw_sig.php).
 */

/* ---------- pictures in articles ---------- */

a.nmz {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: 0;
	vertical-align: top;
	cursor: zoom-in;
	text-decoration: none;
	background: none;
}

a.nmz img {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	background: #eef2f7;
	outline: 1px solid rgba(15, 23, 42, .08);
	outline-offset: -1px;
	transition: filter .2s ease;
}

a.nmz:hover img,
a.nmz:focus-visible img {
	filter: brightness(.9);
}

a.nmz:focus-visible {
	outline: 2px solid #385C88;
	outline-offset: 2px;
}

/* magnifier badge in the corner */
a.nmz::after {
	content: "";
	position: absolute;
	right: 6px;
	bottom: 6px;
	width: 28px;
	height: 28px;
	background: rgba(15, 23, 42, .62) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='square'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='M15 15l5 5M10.5 8v5M8 10.5h5'/%3E%3C/svg%3E") center / 18px no-repeat;
	opacity: 0;
	transition: opacity .2s ease;
	pointer-events: none;
}

a.nmz:hover::after,
a.nmz:focus-visible::after {
	opacity: 1;
}

/* small list thumbnails: no badge */
a.nmz-list::after {
	display: none;
}

.nmz-left {
	float: left;
	margin: 4px 18px 10px 0;
}

.nmz-right {
	float: right;
	margin: 4px 0 10px 18px;
}

a.nmz.nmz-center {
	display: block;
	width: -moz-fit-content;
	width: fit-content;
	margin: 8px auto 14px;
}

a.nmz-list.nmz-left {
	margin: 2px 14px 6px 0;
}

/* ---------- galleries ---------- */

.nmz-gal {
	clear: both;
	margin: 20px 0 10px;
}

.nmz-gal-head {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin: 0 0 8px;
	padding: 0;
	font: 600 16px/1.3 Inter, verdana, arial, sans-serif;
	color: #1e293b;
}

.nmz-gal-head span {
	font: 13px/1.3 verdana, arial, sans-serif;
	color: #64748b;
}

.nmz-gal-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 6px;
}

.nmz-gal a.nmz {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #eef2f7;
}

.nmz-gal a.nmz img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .35s ease, filter .2s ease;
}

.nmz-gal a.nmz:hover img {
	transform: scale(1.04);
}

/* ---------- touch screens and phones ---------- */

@media (hover: none) {
	a.nmz-full::after {
		opacity: .85;
	}
}

@media (max-width: 700px) {
	/* the article picture runs across the column */
	a.nmz.nmz-full {
		float: none;
		display: block;
		width: 100%;
		margin: 6px 0 14px;
	}

	a.nmz-full img {
		width: 100%;
		max-height: 75vh;
		object-fit: cover;
	}

	/* list thumbnails stay beside the text, at most a third of the line */
	.contentpaneopen a.nmz-list {
		max-width: 36%;
		margin: 4px 12px 4px 0;
	}

	.nmz-gal-grid {
		grid-template-columns: repeat(3, 1fr);
		gap: 4px;
	}
}

@media (max-width: 340px) {
	.nmz-gal-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ---------- the viewer ---------- */

html.nmbox-lock {
	overflow: hidden;
}

.nmbox {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: rgba(10, 14, 22, calc(.95 * var(--nmbox-fade, 1)));
	color: #fff;
	font: 13px/1.4 verdana, arial, sans-serif;
	opacity: 0;
	transition: opacity .2s ease;
	-webkit-tap-highlight-color: transparent;
}

.nmbox[hidden] {
	display: none;
}

.nmbox.is-open {
	opacity: 1;
}

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

.nmbox-stage {
	position: absolute;
	inset: 60px 80px 76px;
	overflow: hidden;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
}

.nmbox-stage.is-zoomed {
	inset: 0;
	z-index: 1;
	overflow: auto;
	touch-action: auto;
	cursor: zoom-out;
}

.nmbox-img {
	position: absolute;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: #1c2330;
	box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
	transform-origin: 50% 50%;
	-webkit-user-drag: none;
}

.nmbox-img.can-zoom {
	cursor: zoom-in;
}

.nmbox-stage.is-zoomed .nmbox-img {
	cursor: zoom-out;
	box-shadow: none;
}

.nmbox.is-error .nmbox-img {
	opacity: .25;
}

/* loading: a turning square bracket of light */
.nmbox-spin {
	display: none;
	position: absolute;
	left: 50%;
	top: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, .2);
	border-top-color: #fff;
	animation: nmbox-turn .8s linear infinite;
}

.nmbox.is-loading .nmbox-spin {
	display: block;
}

@keyframes nmbox-turn {
	to { transform: rotate(360deg); }
}

/* top bar: counter on the left, original and close on the right */
.nmbox-top {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 4px;
	height: 60px;
	padding: 0 8px 0 18px;
	background: linear-gradient(rgba(10, 14, 22, .7), rgba(10, 14, 22, 0));
}

.nmbox-count {
	margin-right: auto;
	font: 600 14px/1 Inter, verdana, arial, sans-serif;
	font-variant-numeric: tabular-nums;
	color: rgba(255, 255, 255, .85);
}

.nmbox-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	opacity: .85;
	cursor: pointer;
	text-decoration: none;
	transition: background-color .15s ease, opacity .15s ease;
}

.nmbox-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, .14);
	color: #fff;
}

.nmbox-btn:focus-visible {
	opacity: 1;
	outline: 2px solid #8fb3e0;
	outline-offset: -2px;
}

.nmbox-btn[hidden] {
	display: none;
}

.nmbox-btn svg {
	display: block;
}

.nmbox-prev,
.nmbox-next {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 56px;
	height: 56px;
	margin-top: -28px;
	background: rgba(255, 255, 255, .07);
}

.nmbox-prev {
	left: 12px;
}

.nmbox-next {
	right: 12px;
}

.nmbox-prev svg,
.nmbox-next svg {
	width: 28px;
	height: 28px;
}

.nmbox-cap {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 76px;
	padding: 12px 80px 16px;
	font: 500 15px/1.4 Inter, verdana, arial, sans-serif;
	text-align: center;
	color: #e6ebf2;
}

.nmbox-cap[hidden] {
	display: none;
}

/* at full size the photo has the whole screen; the bar stays */
.nmbox:has(.is-zoomed) .nmbox-cap,
.nmbox:has(.is-zoomed) .nmbox-prev,
.nmbox:has(.is-zoomed) .nmbox-next {
	display: none;
}

@media (max-width: 700px) {
	.nmbox-stage {
		inset: 56px 0 84px;
	}

	.nmbox-top {
		height: 56px;
		padding-left: 14px;
	}

	/* arrows sit in the bottom corners, beside the caption */
	.nmbox-prev,
	.nmbox-next {
		top: auto;
		bottom: 20px;
		width: 44px;
		height: 44px;
		margin: 0;
		background: transparent;
	}

	.nmbox-prev {
		left: 4px;
	}

	.nmbox-next {
		right: 4px;
	}

	.nmbox-cap {
		min-height: 84px;
		padding: 10px 52px 14px;
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.nmbox,
	.nmbox-btn,
	a.nmz img,
	a.nmz::after {
		transition: none;
	}

	.nmz-gal a.nmz:hover img {
		transform: none;
	}
}
