/**
 * Visor de PDF propio de Biblioteca de Archivos.
 * No depende de ningún otro plugin: sólo de pdf.js, que viaja con este.
 */

.bibv {
	--bibv-bg: #2b3440;
	--bibv-bar: #1f2833;
	--bibv-bar-text: #e8eef4;
	--bibv-accent: var(--bib-primary, #0f8b8d);
	--bibv-page-shadow: 0 10px 30px rgba(0, 0, 0, .35);
	--bibv-flip-duration: .7s;

	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 260px;
	background: var(--bibv-bg);
	color: var(--bibv-bar-text);
	font-family: inherit;
	font-size: 14px;
	outline: none;
	overflow: hidden;
}

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

.bibv:focus-visible {
	outline: 2px solid var(--bibv-accent);
	outline-offset: -2px;
}

.bibv.is-fullscreen {
	border-radius: 0;
}

.bibv__main {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
}

/* ------------------------------------------------------------------ Escena */

.bibv__stage {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	padding: 12px;
	overflow: hidden;
	perspective: 2400px;
}

.bibv__area {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
}

.bibv__area--scroll {
	display: block;
	width: 100%;
	padding-bottom: 20px;
}

.bibv--scroll .bibv__stage,
.bibv.is-zoomed .bibv__stage {
	align-items: flex-start;
	overflow: auto;
}

.bibv__spread {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0;
	transform-style: preserve-3d;
}

.bibv__page {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	box-shadow: var(--bibv-page-shadow);
	overflow: hidden;
}

.bibv__page--empty {
	background: none;
	box-shadow: none;
}

.bibv__page--scroll {
	margin: 0 auto 14px;
}

.bibv__canvas {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Capa de texto: selección y accesibilidad sobre el lienzo. */

.bibv__text {
	position: absolute;
	inset: 0;
	overflow: hidden;
	opacity: .2;
	line-height: 1;
	text-align: initial;
}

.bibv__text > span {
	position: absolute;
	color: transparent;
	white-space: pre;
	cursor: text;
	transform-origin: 0 0;
}

.bibv__text ::selection {
	background: rgba(15, 139, 141, .45);
}

/* --------------------------------------------------------- Giro de página */

.bibv__leaf {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 50%;
	transform-style: preserve-3d;
	transition: transform var(--bibv-flip-duration) cubic-bezier(.4, .05, .35, 1);
	will-change: transform;
	z-index: 3;
}

.bibv__leaf--right {
	right: 0;
	transform-origin: left center;
}

.bibv__leaf--left {
	left: 0;
	transform-origin: right center;
}

.bibv__leaf--right.is-turning {
	transform: rotateY(-180deg);
}

.bibv__leaf--left.is-turning {
	transform: rotateY(180deg);
}

.bibv__leaf-face {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	backface-visibility: hidden;
	box-shadow: var(--bibv-page-shadow);
	overflow: hidden;
}

.bibv__leaf-face--back {
	transform: rotateY(180deg);
}

.bibv__leaf-face .bibv__canvas {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
	.bibv__leaf {
		transition-duration: .01ms;
	}
}

/* ---------------------------------------------------------------- Flechas */

.bibv__arrow {
	position: absolute;
	top: 50%;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .35);
	color: #fff;
	cursor: pointer;
	transform: translateY(-50%);
	transition: background .16s ease, opacity .16s ease;
}

.bibv__arrow:hover:not(:disabled) {
	background: rgba(0, 0, 0, .6);
}

.bibv__arrow:disabled {
	opacity: .25;
	cursor: default;
}

.bibv__arrow--prev { left: 10px; }
.bibv__arrow--next { right: 10px; }

/* ----------------------------------------------------------- Panel lateral */

.bibv__side {
	flex: 0 0 240px;
	width: 240px;
	border-right: 1px solid rgba(255, 255, 255, .08);
	background: rgba(0, 0, 0, .18);
	overflow: hidden;
}

.bibv__side[hidden] {
	display: none;
}

.bibv__side-body {
	height: 100%;
	padding: 12px;
	overflow-y: auto;
}

.bibv__thumbs {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.bibv__thumb {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.bibv__thumb-box {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 90px;
	border: 1px solid rgba(255, 255, 255, .12);
	border-radius: 4px;
	background: #fff;
	overflow: hidden;
}

.bibv__thumb-box canvas {
	display: block;
	width: 100%;
	height: auto;
}

.bibv__thumb:hover .bibv__thumb-box {
	border-color: var(--bibv-accent);
}

.bibv__thumb-num {
	font-size: 12px;
	opacity: .7;
}

.bibv__search {
	margin-bottom: 10px;
}

.bibv__search-input {
	width: 100%;
	height: 36px;
	padding: 0 12px;
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: 6px;
	background: rgba(255, 255, 255, .06);
	color: inherit;
	font: inherit;
	outline: none;
}

.bibv__search-input:focus {
	border-color: var(--bibv-accent);
}

.bibv__search-status {
	margin: 0 0 8px;
	font-size: 12px;
	opacity: .7;
}

.bibv__search-hit {
	display: block;
	width: 100%;
	margin-bottom: 6px;
	padding: 8px 10px;
	border: 0;
	border-radius: 6px;
	background: rgba(255, 255, 255, .06);
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.bibv__search-hit:hover {
	background: rgba(255, 255, 255, .13);
}

.bibv__search-page {
	display: block;
	margin-bottom: 2px;
	color: var(--bibv-accent);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
}

.bibv__search-excerpt {
	display: block;
	font-size: 12.5px;
	line-height: 1.4;
	opacity: .85;
}

/* --------------------------------------------------------------- Barra */

.bibv__toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
	padding: 8px 12px;
	border-top: 1px solid rgba(255, 255, 255, .08);
	background: var(--bibv-bar);
}

.bibv__group {
	display: flex;
	align-items: center;
	gap: 4px;
}

.bibv__group--center {
	flex: 1 1 auto;
	justify-content: center;
	gap: 6px;
}

.bibv__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--bibv-bar-text);
	cursor: pointer;
	text-decoration: none;
	transition: background .14s ease, opacity .14s ease;
}

.bibv__btn:hover:not(:disabled) {
	background: rgba(255, 255, 255, .12);
}

.bibv__btn:disabled {
	opacity: .35;
	cursor: default;
}

.bibv__btn:focus-visible,
.bibv__arrow:focus-visible {
	outline: 2px solid var(--bibv-accent);
	outline-offset: 2px;
}

.bibv__page-input {
	width: 56px;
	height: 32px;
	padding: 0 8px;
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: 6px;
	background: rgba(255, 255, 255, .06);
	color: inherit;
	font: inherit;
	text-align: center;
	outline: none;
}

.bibv__page-input:focus {
	border-color: var(--bibv-accent);
}

.bibv__page-total {
	font-size: 13px;
	opacity: .7;
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- Estados */

.bibv__status {
	position: absolute;
	inset: 0;
	z-index: 6;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: var(--bibv-bg);
	text-align: center;
}

.bibv__status[hidden] {
	display: none;
}

.bibv__status p {
	margin: 0;
	opacity: .8;
}

.bibv__error {
	color: #ffb4ad;
}

.bibv__fallback {
	padding: 10px 20px;
	border-radius: 6px;
	background: var(--bibv-accent);
	color: #fff;
	text-decoration: none;
}

.bibv__spinner {
	width: 30px;
	height: 30px;
	border: 3px solid rgba(255, 255, 255, .2);
	border-top-color: var(--bibv-accent);
	border-radius: 50%;
	animation: bibv-spin .8s linear infinite;
}

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

.bibv__live {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/* ---------------------------------------------------------- Responsive */

@media (max-width: 782px) {
	.bibv__side {
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 7;
		flex: none;
		background: #1f2833;
	}

	.bibv__arrow {
		width: 38px;
		height: 38px;
	}

	.bibv__thumbs {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 520px) {
	.bibv__toolbar {
		gap: 2px;
		padding: 6px;
	}

	.bibv__btn {
		width: 32px;
		height: 32px;
	}

	.bibv__page-input {
		width: 46px;
	}

	.bibv__page-total {
		white-space: nowrap;
	}

	.bibv__group--center {
		flex: 0 0 auto;
	}
}

/* ------------------------------------ Elementos sobre la página */

.bibv__items {
	position: absolute;
	inset: 0;
	z-index: 2;
}

.bibv__item {
	--bibv-item-color: var(--bibv-accent, #0f8b8d);

	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: none;
	overflow: hidden;
}

a.bibv__item,
button.bibv__item {
	cursor: pointer;
}

/* Aspecto del área */

.bibv__item--hotspot {
	border: 2px solid color-mix(in srgb, var(--bibv-item-color) 70%, transparent);
	border-radius: 4px;
	background: color-mix(in srgb, var(--bibv-item-color) 10%, transparent);
	transition: background .16s ease, box-shadow .16s ease;
}

.bibv__item--hotspot:hover,
.bibv__item--hotspot:focus-visible {
	background: color-mix(in srgb, var(--bibv-item-color) 26%, transparent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bibv-item-color) 30%, transparent);
}

.bibv__item--solid {
	border-radius: 4px;
	background: color-mix(in srgb, var(--bibv-item-color) 34%, transparent);
}

.bibv__item--hidden {
	background: transparent;
}

.bibv__item--hidden:hover,
.bibv__item--hidden:focus-visible {
	background: color-mix(in srgb, var(--bibv-item-color) 18%, transparent);
	box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--bibv-item-color) 60%, transparent);
}

.bibv__item:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

/* Contenido incrustado */

.bibv__item--video,
.bibv__item--iframe,
.bibv__item--gallery,
.bibv__item--image {
	background: rgba(0, 0, 0, .06);
}

.bibv__item iframe,
.bibv__item video {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

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

.bibv__item--image.bibv__item--hidden img {
	display: none;
}

.bibv__item-play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: color-mix(in srgb, var(--bibv-item-color) 26%, transparent);
	color: #fff;
	cursor: pointer;
	transition: background .16s ease;
}

.bibv__item-play::before {
	content: "";
	position: absolute;
	width: 54px;
	height: 54px;
	max-width: 70%;
	max-height: 70%;
	border-radius: 50%;
	background: rgba(0, 0, 0, .55);
}

.bibv__item-play svg {
	position: relative;
	fill: currentColor;
	stroke: none;
}

.bibv__item-play:hover {
	background: color-mix(in srgb, var(--bibv-item-color) 42%, transparent);
}

.bibv__item-badge {
	position: absolute;
	right: 6px;
	bottom: 6px;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, .62);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	pointer-events: none;
}

.bibv__item-title {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 4px 8px;
	background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent);
	color: #fff;
	font-size: 12px;
	line-height: 1.3;
	text-align: left;
	pointer-events: none;
}

.bibv__item--text {
	display: block;
	padding: 8px 10px;
	background: rgba(255, 255, 255, .92);
	color: #16273a;
	font-size: 14px;
	line-height: 1.4;
	overflow: auto;
}

.bibv__item--text p:first-child { margin-top: 0; }
.bibv__item--text p:last-child { margin-bottom: 0; }

/* -------------------------------------------------- Galería ampliada */

.bibv__lightbox {
	position: absolute;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px;
	background: rgba(9, 15, 22, .9);
}

.bibv__lightbox-figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
}

.bibv__lightbox-figure img {
	max-width: 100%;
	max-height: calc(100% - 40px);
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}

.bibv__lightbox-caption {
	max-width: 70ch;
	color: rgba(255, 255, 255, .85);
	font-size: 13.5px;
	text-align: center;
}

.bibv__lightbox-caption[hidden] {
	display: none;
}

.bibv__lightbox-counter {
	position: absolute;
	top: 14px;
	left: 16px;
	color: rgba(255, 255, 255, .7);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.bibv__lightbox-close {
	position: absolute;
	top: 10px;
	right: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
}

.bibv__lightbox-close:hover {
	background: rgba(255, 255, 255, .24);
}

.bibv__lightbox-nav {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	transform: translateY(-50%);
}

.bibv__lightbox-nav:hover {
	background: rgba(255, 255, 255, .24);
}

.bibv__lightbox-nav--prev { left: 14px; }
.bibv__lightbox-nav--next { right: 14px; }

@media (max-width: 640px) {
	.bibv__lightbox {
		padding: 16px;
	}

	.bibv__lightbox-nav {
		width: 38px;
		height: 38px;
	}
}
