
/* --- media viewer ---------------------------------------------------------
   Progressive enhancement only: every trigger is a real link, and this layer
   just intercepts the click. Palette and type come from the template.
   ------------------------------------------------------------------------- */

/* Wrappers that turn an existing image into a link without moving it. */
.fig-open,
.contents-open {
	display: block;
	width: 100%;
	height: 100%;
}

.contact-open {
	display: block;
	width: max-content;
}

.viewer {
	--viewer-gutter: 68px;
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-height: 100dvh;
	margin: 0;
	padding: var(--viewer-gutter) 16px 20px;
	box-sizing: border-box;
	border: 0;
	background: rgba(8, 8, 8, 0.96);
	color: var(--paper);
	overflow: auto;
}

.viewer[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.viewer::backdrop {
	background: rgba(8, 8, 8, 0.96);
}

.viewer-close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--paper);
	color: var(--black);
	transition:
		background 0.25s ease,
		color 0.25s ease;
}

@media (hover: hover) {
	.viewer-close:hover {
		background: var(--hot-red);
		color: var(--white);
	}
}

.viewer-close svg {
	width: 18px;
	height: 18px;
	display: block;
}

/* Sized by its content, so the bar lines up with the media edges. */
.viewer-inner {
	display: flex;
	flex-direction: column;
	max-width: 100%;
	min-width: 0;
}

.viewer-body {
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 0;
}

.viewer-img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100dvh - var(--viewer-gutter) - 20px - 72px);
	object-fit: contain;
	border: 1px solid var(--border-dark);
	background: var(--card-dark);
}

.viewer-frame {
	display: block;
	width: min(90vw, 960px, calc((100dvh - var(--viewer-gutter) - 20px - 72px) * 16 / 9));
	aspect-ratio: 16 / 9;
	height: auto;
	border: 1px solid var(--border-dark);
	background: var(--card-dark);
}

/* Caption bar: the template's mono editorial voice, as in .cover-foot. */
.viewer-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 12px;
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid rgba(242, 240, 235, 0.28);
}

.viewer-nav {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.viewer-step {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	color: var(--paper);
	transition:
		background 0.25s ease,
		color 0.25s ease;
}

@media (hover: hover) {
	.viewer-step:hover {
		background: var(--paper);
		color: var(--black);
	}
}

/* The global focus ring has a 3px offset; on these round controls it would
   overlap the counter, so hug the button instead. */
.viewer-step:focus-visible,
.viewer-close:focus-visible {
	outline-offset: 0;
}

.viewer-step svg {
	width: 18px;
	height: 18px;
	display: block;
}

.viewer-count {
	margin: 0;
	min-width: 4.4em;
	text-align: center;
	font-family: var(--mono);
	font-size: 0.72rem;
	letter-spacing: 0.06em;
	color: var(--paper);
	opacity: 0.82;
	font-variant-numeric: tabular-nums;
}

.viewer-title {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	font-family: var(--mono);
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	color: var(--paper);
}

.viewer-title:empty {
	display: none;
}

.viewer-external {
	flex-shrink: 0;
	font-family: var(--mono);
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--paper);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.viewer-external[hidden] {
	display: none;
}

@media (hover: hover) {
	.viewer-external:hover {
		color: var(--hot-red);
	}
}

.viewer-step[hidden],
.viewer-count[hidden] {
	display: none;
}

/* Visually hidden announcement for the item change. */
.viewer-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

body.viewer-open {
	overflow: hidden;
}

@media (min-width: 768px) {
	.viewer {
		--viewer-gutter: 76px;
	}
	.viewer-close {
		top: 22px;
		right: 22px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.viewer[open] .viewer-inner {
		animation: viewer-in 0.22s ease-out;
	}

	@keyframes viewer-in {
		from {
			opacity: 0;
			transform: translateY(8px);
		}
		to {
			opacity: 1;
			transform: none;
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition: none;
		scroll-behavior: auto;
	}
	.page {
		opacity: 1;
		transform: none;
	}
	.viewer[open] .viewer-inner {
		animation: none;
	}
}

