/*!
 * Dalane Lightbox 1.0.0
 * Jon Magne Bøe, Dalane Folkemuseum
 *
 * Colors, sizes and fonts come from CSS variables set in Settings → Bildevisning.
 * Override anything here with the "Custom CSS" field.
 */

/* Images in the content that open the viewer. */
img[data-dlb][role="button"]:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.dlb {
	/* Fallbacks; the plugin prints the real values inline. */
	--dlb-backdrop: rgba(21, 18, 14, .96);
	--dlb-backdrop-rgb: 21, 18, 14;
	--dlb-fg: #e6dfd1;
	--dlb-accent: #b89456;
	--dlb-btn-bg: rgba(42, 36, 28, .72);
	--dlb-btn-size: 44px;
	--dlb-radius: 999px;
	--dlb-font: inherit;
	--dlb-caption-size: 15px;
	--dlb-caption-align: left;
	--dlb-duration: 260ms;
	--dlb-shadow: 0 18px 60px rgba(0, 0, 0, .45);

	position: fixed;
	inset: 0;
	z-index: 100000;
	color: var(--dlb-fg);
	font-family: var(--dlb-font);
	font-size: 16px;
	line-height: 1.4;
	-webkit-tap-highlight-color: transparent;
	overscroll-behavior: contain;
	contain: layout style;
}

.dlb[hidden],
.dlb [hidden] {
	display: none !important;
}

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

.dlb:focus {
	outline: none;
}

/* ---------- Backdrop & stage ---------- */

.dlb__backdrop {
	position: absolute;
	inset: 0;
	background: var(--dlb-backdrop);
}

.dlb__stage {
	position: absolute;
	inset: 0;
	overflow: hidden;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
}

.dlb__frame {
	position: absolute;
	transform-origin: center center;
}

.dlb .dlb__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	object-fit: contain;
	transform-origin: center center;
	will-change: transform;
	box-shadow: var(--dlb-shadow);
	cursor: zoom-in;
	-webkit-user-drag: none;
	-webkit-touch-callout: none;
}

.dlb--zoomed .dlb__img {
	box-shadow: none;
	cursor: grab;
}

.dlb--zoomed .dlb__img:active {
	cursor: grabbing;
}

/* ---------- Loading & errors ---------- */

.dlb__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 2px solid rgba(var(--dlb-backdrop-rgb), .4);
	border-top-color: var(--dlb-accent);
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s;
	animation: dlb-spin .8s linear infinite;
}

.dlb--loading .dlb__spinner {
	opacity: 1;
}

@keyframes dlb-spin {
	to { transform: rotate(360deg); }
}

.dlb__error {
	position: absolute;
	top: 50%;
	left: 50%;
	width: min(90vw, 32rem);
	margin: 0;
	padding: 1rem 1.25rem;
	transform: translate(-50%, -50%);
	text-align: center;
	background: var(--dlb-btn-bg);
	border-radius: 8px;
}

/* ---------- Buttons ---------- */

.dlb .dlb__btn {
	appearance: none;
	display: inline-grid;
	place-items: center;
	flex: 0 0 auto;
	width: var(--dlb-btn-size);
	height: var(--dlb-btn-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--dlb-radius);
	background: var(--dlb-btn-bg);
	color: var(--dlb-fg);
	font: inherit;
	line-height: 0;
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: color .15s, background-color .15s, opacity .15s;
}

.dlb .dlb__btn svg {
	width: calc(var(--dlb-btn-size) * .5);
	height: calc(var(--dlb-btn-size) * .5);
}

.dlb .dlb__btn:hover {
	color: var(--dlb-accent);
}

.dlb .dlb__btn:focus-visible,
.dlb .dlb__thumb:focus-visible,
.dlb__caption a:focus-visible {
	outline: 2px solid var(--dlb-accent);
	outline-offset: 2px;
}

.dlb .dlb__btn:disabled {
	opacity: .32;
	cursor: default;
	color: var(--dlb-fg);
}

.dlb .dlb__btn[aria-pressed="true"] {
	color: var(--dlb-accent);
}

/* ---------- Top bar ---------- */

.dlb__bar--top {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding:
		calc(10px + env(safe-area-inset-top, 0px))
		calc(12px + env(safe-area-inset-right, 0px))
		10px
		calc(18px + env(safe-area-inset-left, 0px));
	background: linear-gradient(rgba(var(--dlb-backdrop-rgb), .75), rgba(var(--dlb-backdrop-rgb), 0));
	pointer-events: none;
}

.dlb__bar--top > * {
	pointer-events: auto;
}

.dlb__counter {
	margin: 0;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	opacity: .8;
	white-space: nowrap;
}

.dlb__tools {
	display: flex;
	gap: 6px;
	/* Room for focus rings, which the scroll container would otherwise clip. */
	margin: -6px -6px -6px auto;
	padding: 6px;
	overflow-x: auto;
	scrollbar-width: none;
}

.dlb__tools::-webkit-scrollbar {
	display: none;
}

.dlb__close {
	margin-left: 6px !important;
}

/* ---------- Previous / next ---------- */

.dlb .dlb__nav {
	position: absolute;
	top: 50%;
	margin-top: calc(var(--dlb-btn-size) / -2);
}

.dlb .dlb__nav--prev {
	left: calc(12px + env(safe-area-inset-left, 0px));
}

.dlb .dlb__nav--next {
	right: calc(12px + env(safe-area-inset-right, 0px));
}

/* ---------- Caption & thumbnails ---------- */

.dlb__bottom {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding:
		12px
		calc(18px + env(safe-area-inset-right, 0px))
		calc(14px + env(safe-area-inset-bottom, 0px))
		calc(18px + env(safe-area-inset-left, 0px));
	pointer-events: none;
}

.dlb__bottom > * {
	pointer-events: auto;
}

.dlb--caption-overlay .dlb__bottom,
.dlb--zoomed .dlb__bottom {
	padding-top: 36px;
	background: linear-gradient(to top, rgba(var(--dlb-backdrop-rgb), .88), rgba(var(--dlb-backdrop-rgb), 0));
}

.dlb__caption {
	width: 100%;
	max-width: 70ch;
	max-height: 28vh;
	margin: 0 auto;
	overflow-y: auto;
	font-size: var(--dlb-caption-size);
	line-height: 1.5;
	text-align: var(--dlb-caption-align);
	overscroll-behavior: contain;
}

.dlb__caption-text {
	margin: 0;
}

.dlb__caption a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--dlb-accent);
	text-underline-offset: 3px;
}

.dlb__note {
	margin: .4em 0 0;
	font-size: .85em;
	opacity: .7;
}

.dlb__thumbs {
	display: flex;
	gap: 6px;
	max-width: 100%;
	margin: 0 auto;
	padding: 3px;
	overflow-x: auto;
	scrollbar-width: none;
}

.dlb__thumbs::-webkit-scrollbar {
	display: none;
}

.dlb .dlb__thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	overflow: hidden;
	background: var(--dlb-btn-bg);
	opacity: .5;
	cursor: pointer;
	transition: opacity .15s;
}

.dlb .dlb__thumb:hover {
	opacity: .85;
}

.dlb .dlb__thumb[aria-current="true"] {
	opacity: 1;
	box-shadow: 0 0 0 2px var(--dlb-accent);
}

.dlb .dlb__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* ---------- Toast ---------- */

.dlb__toast {
	position: absolute;
	left: 50%;
	bottom: calc(24px + env(safe-area-inset-bottom, 0px));
	padding: .6em 1em;
	transform: translate(-50%, 8px);
	border-radius: 6px;
	background: var(--dlb-fg);
	color: rgb(var(--dlb-backdrop-rgb));
	font-size: 14px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s, transform .2s;
	max-width: 90vw;
	overflow-wrap: anywhere;
}

.dlb__toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- Hidden UI (tap on image), dismiss gesture ---------- */

.dlb__bar--top,
.dlb__nav,
.dlb__bottom {
	transition: opacity .2s;
}

.dlb--ui-hidden .dlb__bar--top,
.dlb--ui-hidden .dlb__nav,
.dlb--ui-hidden .dlb__bottom,
.dlb--dismissing .dlb__bar--top,
.dlb--dismissing .dlb__nav,
.dlb--dismissing .dlb__bottom {
	opacity: 0 !important;
	pointer-events: none;
}

.dlb--ui-hidden .dlb__bar--top > *,
.dlb--ui-hidden .dlb__bottom > * {
	pointer-events: none;
}

/* ---------- Small touch screens: pinch replaces zoom buttons ---------- */

@media (max-width: 600px) and (pointer: coarse) {
	.dlb .dlb__zoom-in,
	.dlb .dlb__zoom-out,
	.dlb .dlb__zoom-reset {
		display: none;
	}

	.dlb .dlb__nav {
		--dlb-btn-size: 38px;
		opacity: .85;
	}

	.dlb__bar--top {
		padding-left: calc(14px + env(safe-area-inset-left, 0px));
	}
}

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

	.dlb__spinner {
		animation: none;
	}
}

@media print {
	.dlb {
		display: none !important;
	}
}
