/* SPAR Flipbook – smíðað af Avero – avero.is */

/*
 * Stærð er reiknuð alfarið í CSS út frá hlutfalli síðu (--spar-fb-r = hæð/breidd)
 * svo rétt pláss er tekið frá áður en nokkur JavaScript keyrir. Engin hliðrun.
 */
.spar-fb {
	--spar-fb-r: 1.4142;
	--spar-fb-red: #e4002b;
	--spar-fb-ink: #1d1d1b;
	--spar-fb-skeleton: #f1f1f1;
	--spar-fb-h: max(320px, calc(85vh - 72px));
	position: relative;
	width: 100%;
	margin: 0 auto;
	background: transparent;
	color: var(--spar-fb-ink);
	outline: none;
	overflow-x: clip;
	container-type: inline-size;
}

@supports (height: 1svh) {
	.spar-fb {
		--spar-fb-h: max(320px, calc(85svh - 72px));
	}
}

.spar-fb:focus-visible {
	outline: 2px solid var(--spar-fb-red);
	outline-offset: 6px;
}

/* Tengill á PDF fyrir skjálesara og leitarvélar – sést ekki en er aðgengilegur */
.spar-fb .spar-fb__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.spar-fb .spar-fb__sr:focus {
	position: static !important;
	display: inline-block;
	width: auto;
	height: auto;
	margin: 12px 0 0;
	clip: auto;
	color: var(--spar-fb-red);
}

/* Opna (tvær síður) */
.spar-fb__stage {
	position: relative;
	width: 100%;
	max-width: calc(var(--spar-fb-h) / var(--spar-fb-r) * 2);
	min-width: min(100%, 600px);
	aspect-ratio: 2 / var(--spar-fb-r);
	margin: 0 auto;
}

.spar-fb__book {
	position: relative;
	z-index: 1;
	background: transparent;
	opacity: 0;
	transform: translateX(-25%); /* Forsíðan ein í miðjunni */
	transition: opacity 0.35s ease, transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.spar-fb__book.no-anim {
	transition: opacity 0.35s ease;
}

.spar-fb.is-ready .spar-fb__book {
	opacity: 1;
}

/* Biðstaða: forsíða (eða beinagrind) á sama stað og forsíðan lendir */
.spar-fb__placeholder {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	transition: opacity 0.35s ease;
}

.spar-fb.is-ready .spar-fb__placeholder {
	opacity: 0;
}

.spar-fb.is-done .spar-fb__placeholder {
	display: none;
}

.spar-fb__ph-page {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 25%;
	width: 50%;
	overflow: hidden;
	background: var(--spar-fb-skeleton);
	background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%);
	background-size: 250% 100%;
	animation: spar-fb-shimmer 1.6s ease-in-out infinite;
}

.spar-fb .spar-fb__poster {
	display: block;
	position: absolute;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	object-fit: cover;
}

/* Mjó framvindustika neðst á síðunni */
.spar-fb__progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.06);
}

.spar-fb__progress-bar {
	display: block;
	width: 30%;
	height: 100%;
	background: var(--spar-fb-red);
	animation: spar-fb-indeterminate 1.2s ease-in-out infinite;
}

/* Síður */
.spar-fb .spar-fb__page {
	overflow: hidden;
	background: var(--spar-fb-skeleton);
}

.spar-fb .spar-fb__page.is-loaded {
	background: #fff;
}

.spar-fb .spar-fb__page img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	pointer-events: none;
}

.spar-fb .spar-fb__page img:not([src]) {
	visibility: hidden;
}

/* Ein síða í einu á mjóum skjám */
@container (max-width: 599.98px) {
	.spar-fb__stage {
		max-width: calc(var(--spar-fb-h) / var(--spar-fb-r));
		min-width: 0;
		aspect-ratio: 1 / var(--spar-fb-r);
	}

	.spar-fb__ph-page {
		left: 0;
		width: 100%;
	}

	.spar-fb__book {
		transform: none;
	}
}

@supports not (container-type: inline-size) {
	@media (max-width: 640px) {
		.spar-fb__stage {
			max-width: calc(var(--spar-fb-h) / var(--spar-fb-r));
			min-width: 0;
			aspect-ratio: 1 / var(--spar-fb-r);
		}

		.spar-fb__ph-page {
			left: 0;
			width: 100%;
		}

		.spar-fb__book {
			transform: none;
		}
	}
}

/* Villa */
.spar-fb__error {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 0;
	padding: 16px;
	text-align: center;
	font-size: 15px;
}

.spar-fb__error[hidden] {
	display: none;
}

.spar-fb__error a {
	color: var(--spar-fb-red);
	font-weight: 600;
}

.spar-fb.is-error .spar-fb__placeholder,
.spar-fb.is-error .spar-fb__book {
	visibility: hidden;
}

/* Stjórnstika – alltaf á sínum stað svo ekkert hoppar */
.spar-fb__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 40px;
	margin-top: 16px;
	font-size: 14px;
	line-height: 1;
	transition: opacity 0.35s ease;
}

.spar-fb:not(.is-ready) .spar-fb__controls {
	opacity: 0.4;
}

.spar-fb.is-error .spar-fb__controls {
	visibility: hidden;
}

.spar-fb__counter {
	min-width: 72px;
	text-align: center;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
}

.spar-fb__extra {
	display: inline-flex;
	gap: 6px;
	margin-left: 10px;
	padding-left: 12px;
	border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.spar-fb__extra:empty,
.spar-fb.no-fullscreen .spar-fb__extra:not(:has(.spar-fb__download)) {
	display: none;
}

.spar-fb.no-fullscreen .spar-fb__full {
	display: none;
}

.spar-fb .spar-fb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	box-shadow: none;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.spar-fb .spar-fb__btn:hover {
	background: rgba(0, 0, 0, 0.05);
	color: var(--spar-fb-red);
}

.spar-fb .spar-fb__btn:focus-visible {
	outline: 2px solid var(--spar-fb-red);
	outline-offset: 2px;
}

.spar-fb .spar-fb__btn:disabled {
	opacity: 0.25;
	cursor: default;
	background: transparent;
	color: inherit;
}

.spar-fb__btn svg {
	display: block;
}

/* Fullur skjár */
.spar-fb:fullscreen {
	--spar-fb-h: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 24px;
	background: #fff;
	box-sizing: border-box;
}

.spar-fb:-webkit-full-screen {
	--spar-fb-h: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 24px;
	background: #fff;
	box-sizing: border-box;
}

@keyframes spar-fb-shimmer {
	from { background-position: 150% 0; }
	to { background-position: -100% 0; }
}

@keyframes spar-fb-indeterminate {
	from { transform: translateX(-100%); }
	to { transform: translateX(340%); }
}

@media (prefers-reduced-motion: reduce) {
	.spar-fb__ph-page,
	.spar-fb__progress-bar {
		animation: none;
	}
}

/* Forsíðumynd til staðar – engin glitrandi beinagrind undir henni */
.spar-fb__ph-page:has(.spar-fb__poster) {
	animation: none;
	background-image: none;
}
