@charset "UTF-8";

/* =====================================================================
   ART VIEWER  (art.html; js/art-viewer.js builds the stage)
   Each body of work is an entry: the text block, then a short strip of
   plate thumbnails along the bottom. Selecting a plate opens a "light
   table" in the page, above the strip: the plate flies up from its
   thumbnail into a drafting mount (rulers, brackets), and a side panel
   carries the plate number, a loupe that magnifies wherever the pointer
   is on the work (with its X / Y in the original's pixels), the caption
   and the controls. Changing plate scans the new one in left to right.
   No overlay, no new page: the module just opens and closes in place.

   Colours follow the video frame (--hair / --ink / --text), so the
   viewer follows the theme the same way. All strokes are a true 1px.
   ===================================================================== */

.apv {
	--apv-hair: #CFCFCF;
	--apv-ink: #6B6B6B;
	--apv-text: #1A1A1A;
	--apv-px: calc(1px / var(--ui-scale, 1));
	--apv-ruler: 10px;
	--apv-ease: cubic-bezier(.65, 0, .35, 1);
	position: relative;
}

html[data-theme="dark"] .apv {
	--apv-hair: #3A3A3A;
	--apv-ink: #9A9A9A;
	--apv-text: #F0F0F0;
}

/* shared monospace labels */
.apv__label,
.apv__head,
.apv__count,
.apv__read,
.apv__meta,
.apv__no {
	font-family: Consolas, "Courier New", monospace;
	font-size: calc(10.5px / var(--ui-scale, 1));
	letter-spacing: 0.08em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--apv-ink);
	margin: 0;
}

.apv b { font-weight: 400; color: var(--apv-text); }

/* a label row with hairline rules between its parts */
.apv__label,
.apv__head {
	display: flex;
	align-items: center;
	gap: 0.9em;
}

.apv__label i,
.apv__head i {
	flex: 1 1 auto;
	height: var(--apv-px);
	background: var(--apv-hair);
}

/* =============================== strip =============================== */
.apv__strip-head { margin-bottom: var(--space-16); }

.apv__strip {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(72px, 112px));
	gap: var(--space-16);
}

.apv__strip li { margin: 0; padding: 0; }
.apv__strip li::before { content: none; }

.apv__thumb {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	text-align: left;
	color: inherit;
}

.apv__thumb img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	background: #FFFFFF;
	outline: var(--apv-px) solid var(--apv-hair);
	transition: outline-color var(--duration-base) ease, opacity var(--duration-base) ease;
}

.apv__no {
	display: flex;
	justify-content: space-between;
	margin-top: 0.6em;
}

.apv__no::after {
	content: "";
	width: 6px;
	height: 6px;
	align-self: center;
	border: var(--apv-px) solid var(--apv-hair);
	transition: background-color var(--duration-base) ease, border-color var(--duration-base) ease;
}

/* corner brackets that close in on hover / the open plate */
.apv__thumb::before,
.apv__thumb::after {
	content: "";
	position: absolute;
	width: 10px;
	height: 10px;
	border: 0 solid var(--apv-text);
	opacity: 0;
	transition: opacity var(--duration-base) ease, transform var(--duration-base) var(--apv-ease);
	pointer-events: none;
}

.apv__thumb::before { top: -5px; left: -5px; border-top-width: var(--apv-px); border-left-width: var(--apv-px); transform: translate(-4px, -4px); }
.apv__thumb::after { top: calc(100% - 1.4em - 10px); right: -5px; border-bottom-width: var(--apv-px); border-right-width: var(--apv-px); transform: translate(4px, 4px); }

.apv__thumb:hover::before,
.apv__thumb:hover::after,
.apv__thumb[aria-current="true"]::before,
.apv__thumb[aria-current="true"]::after { opacity: 1; transform: none; }

.apv__thumb:focus-visible { outline: none; }
.apv__thumb:focus-visible img { outline: var(--apv-px) solid var(--apv-text); outline-offset: 3px; }
.apv__thumb:hover img,
.apv__thumb:focus-visible img { outline-color: var(--apv-ink); }

.apv__thumb[aria-current="true"] img { outline-color: var(--apv-text); }
.apv__thumb[aria-current="true"] .apv__no { color: var(--apv-text); }
.apv__thumb[aria-current="true"] .apv__no::after { background: var(--apv-text); border-color: var(--apv-text); }

/* while the viewer is open, the other thumbnails step back a little */
.apv.is-open .apv__thumb:not([aria-current="true"]) img { opacity: 0.55; }
.apv.is-open .apv__thumb:not([aria-current="true"]):hover img { opacity: 1; }

/* =============================== stage =============================== */
.apv__stage {
	height: 0;
	overflow: hidden;
}

.apv__stage.is-animating { overflow: visible; }
.apv.is-open .apv__stage { height: auto; }

.apv__inner {
	display: grid;
	/* the plate is capped so the whole stage fits on screen */
	grid-template-columns: minmax(0, min(64%, calc(76 * var(--vh)))) minmax(0, 1fr);
	column-gap: var(--space-48);
	padding-bottom: var(--space-48);
}

html.bp-max-1024 .apv__inner { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-32); }
@media (max-width: 1024px) { html:not(.dfui) .apv__inner { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-32); } }

/* ---- the mount ---- */
.apv__view {
	position: relative;
	padding: var(--apv-ruler) 0 0 var(--apv-ruler);
}

.apv__ruler {
	position: absolute;
	pointer-events: none;
	transition: transform 0.7s var(--apv-ease) 0.15s;
}

.apv__ruler--x {
	left: var(--apv-ruler);
	right: 0;
	top: 0;
	height: var(--apv-ruler);
	transform-origin: left center;
	background:
		repeating-linear-gradient(to right, var(--apv-ink) 0 var(--apv-px), transparent var(--apv-px) 10%) left bottom / 100% 100% no-repeat,
		repeating-linear-gradient(to right, var(--apv-hair) 0 var(--apv-px), transparent var(--apv-px) 2.5%) left bottom / 100% 45% no-repeat;
}

.apv__ruler--y {
	top: var(--apv-ruler);
	bottom: 0;
	left: 0;
	width: var(--apv-ruler);
	transform-origin: center top;
	background:
		repeating-linear-gradient(to bottom, var(--apv-ink) 0 var(--apv-px), transparent var(--apv-px) 10%) right top / 100% 100% no-repeat,
		repeating-linear-gradient(to bottom, var(--apv-hair) 0 var(--apv-px), transparent var(--apv-px) 2.5%) right top / 45% 100% no-repeat;
}

.apv:not(.is-open) .apv__ruler--x { transform: scaleX(0); }
.apv:not(.is-open) .apv__ruler--y { transform: scaleY(0); }

/* the pointer's place on the rulers */
.apv__mark {
	position: absolute;
	background: var(--apv-text);
	opacity: 0;
	transition: opacity var(--duration-fast) ease;
	pointer-events: none;
}

.apv__mark--x { top: 0; width: var(--apv-px); height: var(--apv-ruler); }
.apv__mark--y { left: 0; height: var(--apv-px); width: var(--apv-ruler); }
.apv.is-probing .apv__mark { opacity: 1; }

.apv__frame {
	position: relative;
	aspect-ratio: 1 / 1;
	background: #FFFFFF;
	outline: var(--apv-px) solid var(--apv-hair);
	cursor: crosshair;
	touch-action: pan-y;
}

.apv__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transform-origin: 0 0;
	user-select: none;
	-webkit-user-drag: none;
}

/* the scan that brings in a new plate */
.apv__scan {
	position: absolute;
	top: -8px;
	bottom: -8px;
	left: 0;
	width: var(--apv-px);
	background: var(--apv-text);
	opacity: 0;
	pointer-events: none;
	z-index: 3;
}

/* crosshair */
.apv__cross {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: 0;
	transition: opacity var(--duration-fast) ease;
	z-index: 2;
}

.apv.is-probing .apv__cross { opacity: 1; }
.apv__cross i { position: absolute; background: rgba(26, 26, 26, 0.55); }
.apv__cross .apv__ch { left: 0; right: 0; height: var(--apv-px); }
.apv__cross .apv__cv { top: 0; bottom: 0; width: var(--apv-px); }

.apv__cross .apv__ret {
	width: 22px;
	height: 22px;
	margin: -11px 0 0 -11px;
	background: none;
	border: var(--apv-px) solid rgba(26, 26, 26, 0.85);
	border-radius: 50%;
}

/* brackets just off the mount */
.apv__brk {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.apv__brk::before,
.apv__brk::after,
.apv__frame::before,
.apv__frame::after {
	content: "";
	position: absolute;
	width: 14px;
	height: 14px;
	border: 0 solid var(--apv-ink);
	pointer-events: none;
	z-index: 4;
	transition: transform 0.6s var(--apv-ease) 0.25s, opacity 0.3s ease 0.25s;
}

.apv__frame::before { top: -6px; left: -6px; border-top-width: var(--apv-px); border-left-width: var(--apv-px); }
.apv__frame::after { bottom: -6px; right: -6px; border-bottom-width: var(--apv-px); border-right-width: var(--apv-px); }
.apv__brk::before { top: -6px; right: -6px; border-top-width: var(--apv-px); border-right-width: var(--apv-px); }
.apv__brk::after { bottom: -6px; left: -6px; border-bottom-width: var(--apv-px); border-left-width: var(--apv-px); }

.apv:not(.is-open) .apv__frame::before { transform: translate(24px, 24px); opacity: 0; }
.apv:not(.is-open) .apv__frame::after { transform: translate(-24px, -24px); opacity: 0; }
.apv:not(.is-open) .apv__brk::before { transform: translate(-24px, 24px); opacity: 0; }
.apv:not(.is-open) .apv__brk::after { transform: translate(24px, -24px); opacity: 0; }

/* ---- the side panel ---- */
.apv__panel {
	display: flex;
	flex-direction: column;
	gap: var(--space-24);
	padding-top: var(--apv-ruler);
	min-width: 0;
	transition: opacity 0.5s ease 0.3s, transform 0.6s var(--apv-ease) 0.3s;
}

.apv:not(.is-open) .apv__panel { opacity: 0; transform: translateY(12px); }

.apv__count {
	font-size: calc(26px / var(--ui-scale, 1));
	letter-spacing: 0.04em;
	line-height: 1;
}

.apv__count b { color: var(--apv-text); }

/* loupe: a magnified window on the plate, with a reticle over it */
.apv__loupe {
	position: relative;
	width: min(100%, 300px);
	aspect-ratio: 1 / 1;
}

html.bp-max-1024 .apv__loupe { width: min(48%, 220px); }
@media (max-width: 1024px) { html:not(.dfui) .apv__loupe { width: min(48%, 220px); } }

.apv__lens {
	position: absolute;
	inset: 8%;
	border-radius: 50%;
	background-color: #FFFFFF;
	overflow: hidden;
}

.apv__lens-img {
	position: absolute;
	left: 0;
	top: 0;
	max-width: none;
	height: auto;
	transform-origin: 0 0;
	user-select: none;
}

.apv__reticle {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
	pointer-events: none;
}

.apv__reticle * {
	vector-effect: non-scaling-stroke;
	stroke-width: calc(1px / var(--ui-scale, 1));
	fill: none;
}

.apv__reticle .r-ring { stroke: var(--apv-ink); }
.apv__reticle .r-ticks { stroke: var(--apv-hair); }
.apv__reticle .r-dash { stroke-dasharray: 2 4; }
/* the cross inverts whatever is under it, so it reads on paper and on the figure */
.apv__reticle .r-cross,
.apv__reticle .r-dash { stroke: #FFFFFF; mix-blend-mode: difference; }
.apv__reticle .r-spin { transform-origin: 50% 50%; animation: apv-rot 60s linear infinite; }
.apv.is-probing .apv__reticle .r-spin { animation-duration: 12s; }
@keyframes apv-rot { to { transform: rotate(360deg); } }

.apv__read { min-height: 1.4em; }

/* caption */
.apv__cap { border-top: var(--apv-px) solid var(--apv-hair); padding-top: var(--space-16); }

.apv__title {
	font-weight: 700;
	color: var(--apv-text);
	margin: 0 0 0.35em;
}

.apv__meta { text-transform: none; letter-spacing: 0.04em; }

.apv__note {
	color: var(--color-text-secondary);
	margin: 0.8em 0 0;
}

.apv__note:empty { display: none; }
.apv [data-pending] { font-style: italic; font-weight: 400; color: var(--apv-ink); }

/* controls */
.apv__ctrl {
	display: flex;
	align-items: center;
	gap: var(--space-8);
	margin-top: auto;
}

.apv__btn {
	flex: none;
	width: 36px;
	height: 36px;
	padding: 0;
	border: var(--apv-px) solid var(--apv-ink);
	border-radius: 50%;
	background: transparent;
	color: var(--apv-text);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color var(--duration-base) ease, color var(--duration-base) ease;
}

.apv__btn .material-symbols-outlined { font-size: 20px; }
.apv__btn:hover,
.apv__btn:focus-visible { background: var(--apv-text); color: var(--color-text-inverse); border-color: var(--apv-text); outline: none; }
.apv__btn[data-apv="close"] { margin-left: auto; }

.apv__keys { flex: 1 1 auto; text-align: center; }

@media (prefers-reduced-motion: reduce) {
	.apv *,
	.apv *::before,
	.apv *::after { transition-duration: 0s !important; animation: none !important; }
}

/* pointer position (set by the script as --fx / --fy, 0..1 over the plate) */
.apv__mark--x { left: calc(var(--apv-ruler) + (100% - var(--apv-ruler)) * var(--fx, 0.5)); }
.apv__mark--y { top: calc(var(--apv-ruler) + (100% - var(--apv-ruler)) * var(--fy, 0.5)); }
.apv__cross .apv__ch { top: calc(var(--fy, 0.5) * 100%); }
.apv__cross .apv__cv { left: calc(var(--fx, 0.5) * 100%); }
.apv__cross .apv__ret { left: calc(var(--fx, 0.5) * 100%); top: calc(var(--fy, 0.5) * 100%); }

/* opening scrolls the stage up under the nav, not behind it */
.apv__stage { scroll-margin-top: calc((var(--nav-height) + 40px) / var(--ui-scale, 1)); }

/* phones: one compact row of thumbnails; no keyboard hint */
html.bp-max-600 .apv__strip { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--space-8); }
html.bp-max-600 .apv__keys { visibility: hidden; }
@media (max-width: 600px) {
	html:not(.dfui) .apv__strip { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--space-8); }
	html:not(.dfui) .apv__keys { visibility: hidden; }
}
