/**
 * Work overlay (stalne razstave) – light, mobile first.
 * Markup is built by js/work-overlay.js.
 */

.gbj-work {
	--gbj-work-bg: #f5f5f2;
	--gbj-work-card: #ffffff;
	--gbj-work-ink: #000000;
	--gbj-work-muted: #555555;
	--gbj-work-line: #dedede;
	--gbj-work-accent: #154ea2;
	--gbj-work-bar: 68px;
	--gbj-work-thumbs: 72px;

	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: var(--gbj-work-bg);
	color: var(--gbj-work-ink);
	font-family: inherit;
}

.gbj-work[hidden],
.gbj-work [hidden] {
	display: none !important; /* e.g. the language link, which is inline-block */
}

/*
 * Transitions – calm and unhurried (timings mirrored in js/work-overlay.js):
 * - open: backdrop fades in (0.5 s); the picture grows from its thumbnail (0.8 s,
 *   or rises in when opened from a link); the text follows a moment later;
 * - switch: old work fades out (0.3 s), new one fades in (0.6 s);
 * - close: text fades first, then the backdrop (0.6 s); the picture settles back
 *   into its thumbnail (0.7 s).
 * Easing: eases in gently, then a long, soft landing – nothing snaps.
 */
.gbj-work {
	--gbj-ease-out: cubic-bezier(.45, 0, .15, 1); /* gentle start, long soft landing */
	--gbj-ease-in-out: cubic-bezier(.6, 0, .25, 1);

	opacity: 0;
	transition: opacity .6s var(--gbj-ease-in-out) .08s;
}

.gbj-work.is-open {
	opacity: 1;
	transition: opacity .6s cubic-bezier(.4, 0, .2, 1);
}

.gbj-work__stage {
	opacity: 0;
	transform: translateY(18px);
	transition: opacity .3s ease, transform .3s ease;
}

.gbj-work.is-ready .gbj-work__stage {
	opacity: 1;
	transform: none;
	transition: opacity .7s var(--gbj-ease-out) .1s, transform .9s var(--gbj-ease-out) .1s;
}

.gbj-work.is-ready.is-switching .gbj-work__stage {
	opacity: 0;
	transform: none;
	transition: opacity .3s var(--gbj-ease-in-out);
}

/* Closing: the text goes first, the backdrop follows. */
.gbj-work.is-ready:not(.is-open) .gbj-work__stage {
	opacity: 0;
	transition: opacity .35s var(--gbj-ease-in-out);
}

.gbj-work__bar,
.gbj-work__thumbs {
	transition: transform .7s var(--gbj-ease-out);
}

.gbj-work:not(.is-open) .gbj-work__bar {
	transform: translateY(-12px);
}

.gbj-work:not(.is-open) .gbj-work__thumbs {
	transform: translateY(12px);
}

/* Zoom from / back to the gallery thumbnail (js/work-overlay.js): a copy of the
   picture flies above the overlay while the real image is hidden. */
.gbj-work-fly {
	position: fixed;
	z-index: 100001;
	margin: 0;
	max-width: none;
	object-fit: fill;
	transform-origin: 0 0;
	pointer-events: none;
	will-change: transform;
}

.gbj-work.is-zooming .gbj-work__image {
	visibility: hidden;
}

.gbj-work.is-zooming .gbj-work__stage {
	transform: none;
	/* No slide (the picture must land where it was measured); text appears as the picture settles. */
	transition: opacity .8s var(--gbj-ease-out) .4s;
}

.gbj-work.is-zooming:not(.is-open) .gbj-work__stage {
	transition: opacity .3s var(--gbj-ease-in-out);
}

/* Image still loading on a slow connection: fades in when it arrives. */
.gbj-work__image {
	transition: opacity .5s ease;
}

.gbj-work__image.is-pending {
	opacity: 0;
}

.gbj-work:focus {
	outline: none;
}

html.gbj-work-open,
html.gbj-work-open body {
	overflow: hidden;
}

/* Admin bar stays above; leave room for it. */
.admin-bar .gbj-work {
	top: var(--wp-admin--admin-bar--height, 32px);
}

.gbj-work button {
	font: inherit;
	color: inherit;
	cursor: pointer;
}

.gbj-work button:focus-visible,
.gbj-work a:focus-visible {
	outline: 3px solid var(--gbj-work-accent);
	outline-offset: 2px;
}

/* Top bar: counter + close */
.gbj-work__bar {
	flex: 0 0 var(--gbj-work-bar);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 21px 0 24px; /* X icon (38px in a 44px button) sits ~19px from the top, 24px from the right, like the counter. */
	background: transparent;
}

/* Phones: no strip above the work – counter and X float over the full-bleed image. */
@media (max-width: 899px) {
	.gbj-work__bar {
		position: absolute;
		top: 0;
		right: 0;
		left: 0;
		z-index: 2;
		height: var(--gbj-work-bar);
		pointer-events: none;
	}

	.gbj-work__bar > * {
		pointer-events: auto;
	}
}

.gbj-work__counter {
	font-size: 16px;
	color: var(--gbj-work-muted);
	font-variant-numeric: tabular-nums;
}

.gbj-work__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
}

.gbj-work__close-icon {
	display: block;
	width: 38px;
	height: 38px;
	object-fit: cover;
}

.gbj-work__close:hover {
	opacity: .75;
}

/* Main: stacked on phones, side by side on wide screens */
.gbj-work__main {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.gbj-work__media {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0; /* Phones: the work is full bleed. */
}

.gbj-work__image {
	display: block;
	/* Phones: full bleed, always edge to edge (tall works scroll; the text follows below). */
	width: 100%;
	max-width: 100%;
	height: auto;
	object-fit: contain;
}

/* Arrows: on phones centred on the image, on wide screens on the overlay edges. */
.gbj-work__nav {
	position: absolute;
	/* Centred on the image; --gbj-work-media-h is set by js/work-overlay.js. */
	top: calc(var(--gbj-work-media-h, 40vh) / 2);
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin-top: -22px;
	padding: 0;
	border: 1px solid var(--gbj-work-line);
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

/* Phones: no arrows – swipe the image or tap a thumbnail. */
@media (max-width: 899px) {
	.gbj-work__nav {
		display: none;
	}
}

.gbj-work__nav--prev {
	left: 8px;
}

.gbj-work__nav--next {
	right: 8px;
}

.gbj-work__nav:disabled {
	opacity: 0;
	pointer-events: none;
}

.gbj-work__info {
	max-width: 640px;
	margin: 0 auto;
	padding: 24px 20px 32px;
}

.gbj-work__author {
	margin: 0 0 6px;
	font-size: 1.8rem;
	line-height: 1.4;
	color: var(--gbj-work-muted);
}

.gbj-work__title {
	margin: 0 0 8px;
	font-size: 2.5rem;
	line-height: 1.25;
	font-weight: 700;
	color: var(--gbj-work-ink);
}

.gbj-work__meta {
	margin: 0 0 24px;
	font-size: 17px;
	line-height: 1.5;
	color: var(--gbj-work-muted);
}

.gbj-work__meta span {
	display: block;
}

.gbj-work__technique {
	font-style: italic;
}

.gbj-work__audio {
	margin: 0 0 12px;
}

.gbj-work__audio-label {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 500;
	color: var(--gbj-work-ink);
}

/* Own audio player: no frame, white square buttons, nothing rounded (identical in every browser). */
.gbj-player {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--gbj-work-ink);
	font-variant-numeric: tabular-nums;
}

.gbj-player audio {
	display: none;
}

.gbj-work .gbj-player__toggle {
	flex: 0 0 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--gbj-work-ink);
	border-radius: 0;
	background: #ffffff;
	color: var(--gbj-work-ink);
}

/* The site styles svg paths; keep the icon in the button colour. */
.gbj-work .gbj-player__toggle svg path {
	fill: currentColor;
}

.gbj-work .gbj-player__toggle:hover {
	background: var(--gbj-work-bg);
}

.gbj-work .gbj-player__toggle:focus-visible {
	outline: 3px solid var(--gbj-work-accent);
	outline-offset: 2px;
}

.gbj-player__time {
	flex: 0 0 auto;
	min-width: 2.6em;
	font-size: 14px;
	line-height: 1;
	color: var(--gbj-work-ink);
}

.gbj-player__time--total {
	text-align: right;
}

/* Seek bar */
.gbj-player__seek {
	--progress: 0%;
	flex: 1 1 auto;
	min-width: 0;
	height: 24px;
	margin: 0;
	padding: 0;
	background: transparent;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}

.gbj-player__seek:focus {
	outline: none;
}

.gbj-player__seek:focus-visible {
	outline: 2px solid var(--gbj-work-accent);
	outline-offset: 2px;
	border-radius: 0;
}

.gbj-player__seek::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 0;
	background: linear-gradient(to right, var(--gbj-work-ink) var(--progress), rgba(0, 0, 0, .18) var(--progress));
}

.gbj-player__seek::-moz-range-track {
	height: 4px;
	border-radius: 0;
	background: rgba(0, 0, 0, .18);
}

.gbj-player__seek::-moz-range-progress {
	height: 4px;
	border-radius: 0;
	background: var(--gbj-work-ink);
}

.gbj-player__seek::-webkit-slider-thumb {
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin-top: -6px;
	border: 1px solid var(--gbj-work-ink);
	border-radius: 0;
	background: #ffffff;
	-webkit-appearance: none;
	appearance: none;
}

.gbj-player__seek::-moz-range-thumb {
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	border: 1px solid var(--gbj-work-ink);
	border-radius: 0;
	background: #ffffff;
}

.gbj-work__lang {
	display: inline-block;
	margin: 0 0 24px;
	font-size: 15px;
	font-weight: 400;
	color: var(--gbj-work-accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.gbj-work__description {
	font-size: 18px;
	line-height: 1.65; /* = body */
}

.gbj-work__description p {
	margin: 0 0 1em;
}

.gbj-work__copyright {
	margin: 16px 0 0;
	font-size: 14px; /* = captions */
	color: var(--gbj-work-muted);
}

/* Thumbnails */
.gbj-work__thumbs {
	flex: 0 0 var(--gbj-work-thumbs);
	border-top: 1px solid var(--gbj-work-line);
	background: var(--gbj-work-bg);
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: thin;
}

.gbj-work__thumbs ul {
	display: flex;
	gap: 8px;
	width: max-content;
	min-width: 100%;
	justify-content: center;
	margin: 0;
	padding: 10px 72px 10px 16px; /* Room for the accessibility button in the bottom right corner. */
	list-style: none;
}

.gbj-work__thumb {
	display: block;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	background: var(--gbj-work-card);
	opacity: .6;
	overflow: hidden;
	transition: opacity .15s ease;
}

.gbj-work__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.gbj-work__thumb:hover,
.gbj-work__thumb[aria-current="true"] {
	opacity: 1;
}

.gbj-work__thumb[aria-current="true"] {
	border-color: var(--gbj-work-accent);
}

/* Wide screens: image and text as one centred block, text bottom-aligned with the image. */
@media (min-width: 900px) {
	.gbj-work {
		--gbj-work-stage-height: calc(100vh - var(--gbj-work-bar) - var(--gbj-work-thumbs) - 32px);
	}

	.admin-bar .gbj-work {
		--gbj-work-stage-height: calc(100vh - var(--gbj-work-bar) - var(--gbj-work-thumbs) - 32px - var(--wp-admin--admin-bar--height, 32px));
	}

	.gbj-work {
		--gbj-work-bar: 84px;
	}

	.gbj-work__bar {
		padding: 20px 37px 0 40px; /* X icon ~31px from the top, 40px from the right. */
	}

	.gbj-work__main {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 16px 80px;
		overflow: hidden;
	}

	.gbj-work__stage {
		display: flex;
		align-items: flex-end; /* Text sits on the image's bottom edge. */
		justify-content: center;
		gap: 56px;
		width: 100%;
		max-width: 1720px;
	}

	.gbj-work__media {
		flex: 0 1 auto;
		min-width: 0;
		padding: 0;
	}

	.gbj-work__image {
		width: auto;
		max-height: var(--gbj-work-stage-height);
		background: var(--gbj-work-card);
		box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
	}

	.gbj-work__info .is-last,
	.gbj-work__info .is-last > :last-child {
		margin-bottom: 0;
	}

	.gbj-work__info {
		flex: 0 0 420px;
		max-width: 420px;
		max-height: var(--gbj-work-stage-height);
		margin: 0;
		padding: 0 8px 0 0;
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.gbj-work__nav {
		top: 50%;
	}

	.gbj-work__nav--prev {
		left: 24px;
	}

	.gbj-work__nav--next {
		right: 24px;
	}

}

@media (min-width: 1400px) {
	.gbj-work__info {
		flex-basis: 460px;
		max-width: 460px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gbj-work,
	.gbj-work * {
		transition: none !important;
	}

	.gbj-work__stage,
	.gbj-work:not(.is-open) .gbj-work__bar,
	.gbj-work:not(.is-open) .gbj-work__thumbs {
		transform: none !important;
	}
}
