/* Flipbook Viewer Styles */

/* Reset body for standalone flipbook page */
body:has(#flipbook-wrapper) {
	margin: 0;
	padding: 0;
	overflow: hidden;
}

/* Full-screen wrapper - fits exactly in viewport, no scroll */
#flipbook-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100vh;
	background: var(--color-secundario);
	padding: 20px 20px 10px;
	box-sizing: border-box;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
}

/* === DESKTOP viewer wrap === */
#flipbook-viewer-wrap {
	position: relative;
}

/* === MOBILE viewer wrap === */
/* touch-action: el navegador se queda con el desplazamiento vertical y le deja al visor los gestos
   horizontales (pasar de pagina, flipbook.js > wireTouchGestures). */
#flipbook-viewer-wrap-mobile {
	position: relative;
	touch-action: pan-y;
}

/* Toggle: desktop visible, mobile hidden on >= 769px */
@media (min-width: 769px) {
	.flipbook-mobile {
		display: none !important;
	}
}

/* Toggle: mobile visible, desktop hidden on <= 768px */
@media (max-width: 768px) {
	.flipbook-desktop {
		display: none !important;
	}
}

/* Boundary overlays - absorb mouse events on forbidden sides */
#flipBoundaryLeft,
#flipBoundaryRight {
	position: absolute;
	top: 0;
	width: 50%;
	height: 100%;
	z-index: 5;
	cursor: default;
}

#flipBoundaryLeft {
	left: 0;
}

#flipBoundaryRight {
	right: 0;
}

/* Mobile boundary overlays - 50% to block only the side with no more pages */
#flipBoundaryLeftMobile,
#flipBoundaryRightMobile {
	position: absolute;
	top: 0;
	width: 50%;
	height: 100%;
	z-index: 5;
	cursor: default;
}

#flipBoundaryLeftMobile {
	left: 0;
}

#flipBoundaryRightMobile {
	right: 0;
}

/* Book viewers */
#flipbook-viewer,
#flipbook-viewer-mobile {
	margin: 0 auto;
	position: relative;
}

#flipbook-viewer .flip-page,
#flipbook-viewer-mobile .flip-page {
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

/* Page bar (segment slider with thumbnail tooltip) */
#flipbook-pagebar {
	position: relative;
	width: 100%;
	max-width: 700px;
	margin-top: 12px;
	padding: 8px 0;
	flex-shrink: 0;
}

/* Tooltip */
#flipbookTooltip {
	position: absolute;
	bottom: 34px;
	transform: translateX(-50%);
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s;
	z-index: 10;
	display: flex;
	flex-direction: column;
	align-items: center;
}

#flipbookTooltipThumb {
	width: 80px;
	height: 110px;
	background: #fff;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#flipbookTooltipNum {
	margin-top: 4px;
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
	font-size: 11px;
	padding: 2px 7px;
	border-radius: 4px;
	white-space: nowrap;
}

/* Range slider */
#flipbookPageBar {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 6px;
	border-radius: 3px;
	outline: none;
	cursor: pointer;
	background: linear-gradient(to right, var(--color-primario) 0%, rgba(255, 255, 255, 0.15) 0%);
	transition: height 0.15s;
}

#flipbookPageBar:hover {
	height: 10px;
}

/* Webkit (Chrome, Safari, Edge) */
#flipbookPageBar::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
	transition: transform 0.15s;
}

#flipbookPageBar:hover::-webkit-slider-thumb {
	transform: scale(1.2);
}

#flipbookPageBar:active::-webkit-slider-thumb {
	transform: scale(1.3);
}

/* Firefox */
#flipbookPageBar::-moz-range-track {
	height: 6px;
	border-radius: 3px;
	background: transparent;
}

#flipbookPageBar::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
	border: none;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#flipbookPageBar::-moz-range-progress {
	background: var(--color-primario);
	border-radius: 3px;
	height: 6px;
}

/* Bottom info row: page info + download button */
#flipbook-bottom-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-top: 4px;
	flex-shrink: 0;
}

#flipbook-bottom-row .flip-page-info {
	color: rgba(255, 255, 255, 0.5);
	font-size: 13px;
	user-select: none;
}

#flipbook-bottom-row .flip-download-btn {
	color: rgba(255, 255, 255, 0.5);
	cursor: pointer;
	font-size: 22px;
	transition: color 0.2s;
	line-height: 1;
}

#flipbook-bottom-row .flip-download-btn:hover {
	color: rgba(255, 255, 255, 0.9);
}

/* Loading */
#flipbook-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: #fff;
	gap: 15px;
}

#flipbook-loading .spinner {
	width: 40px;
	height: 40px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: #fff;
	border-radius: 50%;
	animation: flipbook-spin 0.8s linear infinite;
}

@keyframes flipbook-spin {
	to { transform: rotate(360deg); }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
	#flipbook-wrapper {
		padding: 10px 10px 6px;
	}

	#flipbook-pagebar {
		max-width: 90%;
		margin-top: 8px;
	}

	#flipbook-bottom-row .flip-page-info {
		font-size: 11px;
	}

	#flipbook-bottom-row .flip-download-btn {
		font-size: 20px;
	}

	#flipbookTooltipThumb {
		width: 60px;
		height: 82px;
	}
}

/* Hotspot wrapper — halo fijo, tamaño constante, nunca transiciona */
.flipbook-hotspot {
	position: absolute;
	border-radius: 50%;
	background: rgba(0,0,0,0.5);
	pointer-events: none;
	z-index: 2;
}

/* Punto interactivo dentro del halo */
.flipbook-hotspot-dot {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	box-sizing: border-box;
	cursor: pointer;
	pointer-events: auto;
	transition: width 0.3s ease, height 0.3s ease, border-width 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.flipbook-hotspot-dot:hover {
	width: var(--hs-size-hover) !important;
	height: var(--hs-size-hover) !important;
	border-width: var(--hs-bw-hover) !important;
	background-color: var(--hs-color) !important;
	border-color: var(--hs-border) !important;
}

/* Show tooltip on hover via pure CSS */
.flipbook-hotspot-dot:hover .flipbook-hotspot-tooltip {
	opacity: 1;
}

/* Hotspot tooltip */
.flipbook-hotspot-tooltip {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 8px;
	background: rgba(0,0,0,0.85);
	color: #fff;
	padding: 6px 12px;
	border-radius: 6px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s;
	z-index: 4;
	font-size: 13px;
	line-height: 1.4;
	max-width: 200px;
}

.flipbook-hotspot-tooltip-title {
	font-weight: 600;
	font-size: 14px;
}

.flipbook-hotspot-tooltip-subtitle {
	font-size: 11px;
	opacity: 0.8;
	white-space: normal;
}

.flipbook-hotspot-tooltip-price {
	font-weight: 700;
	font-size: 14px;
	margin-top: 2px;
}

/* Inner wrapper for hotspot positioning - keeps .flip-page clean for StPageFlip */
/* isolation: isolate contains hotspot z-index within this wrapper */
.flip-page-inner {
	position: relative;
	width: 100%;
	height: 100%;
	isolation: isolate;
}

/* Mobile responsive */
@media (max-width: 768px) {
	.flipbook-hotspot-tooltip {
		font-size: 11px;
		padding: 4px 8px;
	}
}

/* === Sugerencia sobre la portada (flipbook.js > mostrarSugerenciaFlipbook) ===
   Una pastilla con una mano que se mueve, sobre la parte de abajo de la portada, y en el celular un
   amague de la pagina hacia la izquierda. No toma el toque: el gesto pasa a traves. */
.flipbook-sugerencia {
	position: absolute;
	left: 50%;
	bottom: 12%;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 18px 8px 8px;
	border-radius: 999px;
	background: rgba(10, 14, 10, 0.62);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transform: translate(-50%, 12px);
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.flipbook-sugerencia.visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* En escritorio la portada ocupa la mitad derecha del libro */
.flipbook-sugerencia-escritorio {
	left: 75%;
}

.flipbook-sugerencia-icono {
	position: relative;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
}

.flipbook-sugerencia-icono::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.7);
	animation: flipbookSugerenciaLatido 1.8s ease-out infinite;
}

.flipbook-sugerencia-icono i {
	font-size: 22px;
	line-height: 1;
	animation: flipbookSugerenciaDeslizar 1.8s ease-in-out infinite;
}

/* Con mouse, la mano hace el gesto de clic en vez de deslizar */
.flipbook-sugerencia-clic .flipbook-sugerencia-icono i {
	animation-name: flipbookSugerenciaClic;
}

@keyframes flipbookSugerenciaLatido {
	0% { transform: scale(1); opacity: 0.8; }
	100% { transform: scale(1.7); opacity: 0; }
}

@keyframes flipbookSugerenciaDeslizar {
	0%, 100% { transform: translateX(5px); }
	50% { transform: translateX(-6px); }
}

@keyframes flipbookSugerenciaClic {
	0%, 100% { transform: scale(1); }
	45% { transform: scale(0.82); }
}

/* Amague: la pagina se corre un poco hacia la izquierda y vuelve, dos veces */
#flipbook-viewer-wrap-mobile.flipbook-amague {
	animation: flipbookAmague 1.5s ease-in-out 0.2s 2;
}

@keyframes flipbookAmague {
	0%, 100% { transform: translateX(0); }
	35% { transform: translateX(-16px); }
	55% { transform: translateX(-16px); }
}

@media (prefers-reduced-motion: reduce) {
	.flipbook-sugerencia-icono::after,
	.flipbook-sugerencia-icono i,
	#flipbook-viewer-wrap-mobile.flipbook-amague {
		animation: none;
	}
}
