.pfr-flipbook {
	--pfr-ratio: 2;
	position: relative;
	display: block;
	width: 100%;
	min-width: 0;
	flex: 1 1 100%;       /* בתוך קונטיינר flex של אלמנטור – תופס את כל הרוחב */
	align-self: stretch;
	margin: 1.5em 0;
	background: #2b2f36;
	border-radius: 10px;
	padding: 16px 12px 0;
	box-sizing: border-box;
	outline: none;
	color: #fff;
	font-family: inherit;
}
.pfr-flipbook *,
.pfr-flipbook *::before,
.pfr-flipbook *::after { box-sizing: border-box; }

/* הספר עצמו – תמיד LTR פנימית כי הספרייה עובדת בקואורדינטות פיזיות */
/* ברירת מחדל: הספר תופס את כל רוחב האזור והגובה נגזר מהיחס */
.pfr-box {
	width: 100%;
	margin: 0 auto;
	/* אפקט הפינה המתקפלת והצללים נשפכים מחוץ לספר – חותכים אותם כדי שלא יחרגו מהמסגרת ולא ייצרו גלילה */
	overflow: hidden;
	position: relative;
}
/* fit="screen": הספר כולו נכנס בגובה המסך (עשוי להיות צר יותר מהאזור) */
.pfr-fit-screen .pfr-box {
	max-width: calc(80vh * var(--pfr-ratio));
}
.pfr-stage {
	direction: ltr;
	width: 100%;
	aspect-ratio: var(--pfr-ratio);
	position: relative;
	visibility: hidden;
}
.pfr-flipbook.pfr-ready .pfr-stage { visibility: visible; }
/* מסך צר: עמוד יחיד */
.pfr-portrait .pfr-stage { aspect-ratio: calc(var(--pfr-ratio) / 2); }

.pfr-page {
	background: #fff;
	position: relative;
	overflow: hidden;
	margin: 0;
	padding: 0;
}
.pfr-page canvas,
.pfr-page img.pfr-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #fff;
}
.pfr-page img.pfr-img {
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	pointer-events: none;
	max-width: none;
}
.pfr-page-error small {
	display: block;
	direction: ltr;
	margin-top: 8px;
	font-size: 10px;
	line-height: 1.3;
	color: #a33;
	word-break: break-word;
}
.pfr-page-error {
	flex-direction: column;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 12px;
	color: #888;
	font-size: 13px;
	text-align: center;
}
.pfr-debug {
	direction: ltr;
	text-align: left;
	margin: 8px 0 0;
	padding: 8px;
	background: #000;
	color: #6f6;
	font: 11px/1.4 monospace;
	white-space: pre-wrap;
	word-break: break-all;
	max-height: 35vh;
	overflow: auto;
	border-radius: 6px;
}
.pfr-links {
	position: absolute;
	inset: 0;
	pointer-events: none;
}
.pfr-links a {
	position: absolute;
	display: block;
	pointer-events: auto;
	cursor: pointer;
	background: transparent;
	text-decoration: none;
	border-radius: 2px;
	transition: background .15s;
}
.pfr-links a:hover,
.pfr-links a:focus-visible {
	background: rgba(255, 200, 0, .28);
	outline: 1px solid rgba(255, 170, 0, .8);
}

/* סטטוס טעינה */
.pfr-status {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	z-index: 5;
	font-size: 15px;
}
.pfr-flipbook.pfr-ready .pfr-status { display: none; }
.pfr-flipbook.pfr-error .pfr-status { color: #ffb4b4; }
.pfr-flipbook.pfr-error .pfr-spinner { display: none; }
.pfr-flipbook:not(.pfr-ready):not(.pfr-error) { min-height: 320px; }
.pfr-spinner {
	width: 22px;
	height: 22px;
	border: 3px solid rgba(255, 255, 255, .3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: pfr-spin .8s linear infinite;
}
@keyframes pfr-spin { to { transform: rotate(360deg); } }

/* סרגל כלים */
.pfr-toolbar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 0 12px;
	user-select: none;
}
.pfr-btn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	text-decoration: none;
	line-height: 1;
	transition: background .15s;
}
.pfr-btn:hover:not(:disabled),
.pfr-btn:focus-visible { background: rgba(255, 255, 255, .25); }
.pfr-btn:disabled { opacity: .35; cursor: default; }
.pfr-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* SVG הבסיס מצביע שמאלה (LTR: "הקודם" בשמאל). ב-RTL הכפתור הראשון נמצא בימין ולכן הופכים */
.pfr-flipbook[dir="rtl"] .pfr-first svg,
.pfr-flipbook[dir="rtl"] .pfr-prev svg,
.pfr-flipbook[dir="rtl"] .pfr-next svg { transform: scaleX(-1); }
.pfr-next svg { transform: scaleX(-1); }
.pfr-flipbook[dir="rtl"] .pfr-next svg { transform: none; }

.pfr-indicator {
	min-width: 150px;
	text-align: center;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	padding: 0 8px;
}
.pfr-spacer { flex: 0 0 8px; }

/* מסך מלא */
.pfr-flipbook:fullscreen {
	max-width: none !important;
	margin: 0;
	border-radius: 0;
	display: flex;
	flex-direction: column;
	height: 100vh;
	padding: 12px 12px 0;
}
.pfr-flipbook:fullscreen { justify-content: center; }
.pfr-flipbook:fullscreen .pfr-box,
.pfr-flipbook.pfr-fit-screen:fullscreen .pfr-box {
	max-width: calc((100vh - 100px) * var(--pfr-ratio));
}
.pfr-portrait.pfr-flipbook:fullscreen .pfr-box {
	max-width: calc((100vh - 100px) * var(--pfr-ratio) / 2);
}
.pfr-portrait.pfr-fit-screen .pfr-box { max-width: calc(80vh * var(--pfr-ratio) / 2); }
.pfr-flipbook:fullscreen .pfr-toolbar { flex: 0 0 auto; }

@media (max-width: 600px) {
	.pfr-flipbook { padding: 10px 6px 0; border-radius: 6px; }
	.pfr-btn { width: 42px; height: 42px; }
	.pfr-indicator { min-width: 110px; font-size: 13px; }
}
