.ifb-outer {
	width: 100%;
	display: flex;
	justify-content: center;
}

.ifb-container {
	--ifb-width: 350px;
	--ifb-height: 500px;
	/* Approx. footprint of the fully-open book (cover + page spread + hint text). */
	--ifb-stage-w: calc(var(--ifb-width) * 3.5);
	--ifb-stage-h: calc(var(--ifb-height) + 100px);
	/* Shrink to fit the viewport, but never enlarge past the authored size. */
	--ifb-scale: min(1, calc((100vw - 24px) / var(--ifb-stage-w)), calc((100dvh - 96px) / var(--ifb-stage-h)));
	position: relative;
	width: calc(var(--ifb-stage-w) * var(--ifb-scale));
	height: calc(var(--ifb-stage-h) * var(--ifb-scale));
	max-width: 100%;
	margin: 0 auto;
	font-family: Georgia, 'Times New Roman', serif;
}

.ifb-stage {
	position: absolute;
	top: 50%;
	left: 50%;
	width: var(--ifb-stage-w);
	height: var(--ifb-stage-h);
	transform: translate(-50%, -50%) scale(var(--ifb-scale));
	transform-origin: center center;
	display: flex;
	align-items: center;
	justify-content: center;
	perspective: 2000px;
}

.ifb-book {
	position: relative;
	width: var(--ifb-width);
	height: var(--ifb-height);
	transform-style: preserve-3d;
	transform: translateX(0);
	transition: transform 1.4s cubic-bezier(0.25, 0, 0, 1);
}

.ifb-container.ifb-open .ifb-book {
	transform: translateX(calc(var(--ifb-width) / 2));
}

/* ---------- Cover ---------- */
.ifb-cover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	transform-origin: left center;
	transform: rotateY(0deg);
	transition: transform 1.4s cubic-bezier(0.25, 0, 0, 1);
	cursor: pointer;
	z-index: 100;
}

.ifb-container:not(.ifb-open) .ifb-cover:hover {
	transform: rotateY(-15deg);
}

.ifb-container.ifb-open .ifb-cover {
	transform: rotateY(-180deg);
	z-index: 0;
	transition: transform 1.4s cubic-bezier(0.25, 0, 0, 1), z-index 0s linear 0.55s;
}

.ifb-cover-front,
.ifb-cover-back {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	border-radius: 3px 6px 6px 3px;
	overflow: hidden;
}

.ifb-cover-front {
	background-size: cover;
	background-position: center;
	transform: translateZ(0.5px);
}

.ifb-spine {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 16px;
	background: linear-gradient(to right, rgba(255, 255, 255, 0.3), transparent);
	opacity: 0.4;
}

.ifb-cover-back {
	background: #fdfbf7;
	transform: rotateY(180deg) translateZ(0.5px);
	border-right: 1px solid #e5e5e5;
}

/* Shown only when there's no 2nd-page image to fill the inside-front cover. */
.ifb-cover-back-fallback {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 2rem;
	box-sizing: border-box;
}

.ifb-cover-back h2 {
	font-size: 22px;
	color: #262626;
	margin: 0 0 8px;
	letter-spacing: 0.02em;
}

.ifb-divider {
	width: 32px;
	height: 1px;
	background: #d4d4d4;
	margin-bottom: 12px;
}

.ifb-eyebrow {
	font-size: 11px;
	color: #737373;
	text-transform: uppercase;
	letter-spacing: 0.2em;
	margin: 0;
}

/* ---------- Pages ---------- */
.ifb-pages {
	position: absolute;
	inset: 0;
	transform-style: preserve-3d;
}

.ifb-page {
	position: absolute;
	inset: 0;
	transform-style: preserve-3d;
	transform-origin: left center;
	transform: rotateY(0deg);
	background: #fdfbf7;
	border-radius: 0 3px 3px 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	border: 1px solid #f0f0ee;
	transition: transform 0.55s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.ifb-page.ifb-flipped {
	transform: rotateY(-180deg);
}

.ifb-page-front,
.ifb-page-back {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	padding: 2rem;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	cursor: pointer;
	overflow: hidden;
}

.ifb-page-front {
	transform: translateZ(0.5px);
}

.ifb-page-back {
	transform: rotateY(180deg) translateZ(0.5px);
	border-right: 1px solid #e5e5e5;
}

.ifb-page-number {
	font-size: 11px;
	color: #a3a3a3;
	font-family: Arial, sans-serif;
	letter-spacing: 0.05em;
	margin-bottom: 1rem;
}

.ifb-page-front .ifb-page-number {
	text-align: right;
}

.ifb-page-body {
	flex: 1;
	color: #404040;
	font-size: 14px;
	line-height: 1.7;
	overflow-y: auto;
}

.ifb-page-image-slot {
	padding: 0;
}

.ifb-page-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Interior leaf side with no image for it (the lone unpaired page right
   before the closing page, when an odd number of images remain after the
   inside-front cover) — a plain, blank sheet rather than a placeholder
   graphic. */
.ifb-page-blank {
	width: 100%;
	height: 100%;
	background: #fdfbf7;
}

.ifb-page-body h3 {
	font-size: 19px;
	font-weight: 500;
	text-align: center;
	margin: 0 0 1.5rem;
	color: #262626;
}

.ifb-watermark {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 90px;
	font-style: italic;
	font-weight: 700;
	color: #000;
	opacity: 0.03;
}

/* End page */
.ifb-end-wrap {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
}

.ifb-end-text {
	font-style: italic;
	color: #737373;
	font-size: 16px;
	margin-bottom: 1rem;
}

.ifb-restart {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: 999px;
	background: #f5f5f5;
	border: none;
	color: #525252;
	font-size: 13px;
	cursor: pointer;
	font-family: Arial, sans-serif;
	transition: background 0.2s ease;
}

.ifb-restart:hover {
	background: #e5e5e5;
}

/* Static back cover */
.ifb-back-cover {
	position: absolute;
	inset: 0;
	background: #fdfbf7;
	border-radius: 0 3px 3px 0;
	border: 1px solid #e5e5e5;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
	transform: translateZ(-1px);
	z-index: -1;
}

/* ---------- Chrome ---------- */
.ifb-close {
	position: absolute;
	top: 24px;
	right: 24px;
	width: 40px;
	height: 40px;
	border-radius: 999px;
	border: none;
	background: rgba(255, 255, 255, 0.6);
	backdrop-filter: blur(4px);
	color: #262626;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	z-index: 1000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.2s ease;
}

.ifb-container.ifb-open .ifb-close {
	opacity: 1;
	pointer-events: auto;
}

.ifb-close:hover {
	transform: scale(1.1);
	background: #fff;
}

.ifb-hint {
	position: absolute;
	bottom: 4px;
	left: 50%;
	transform: translateX(-50%);
	color: #737373;
	font-size: 12px;
	font-family: Arial, sans-serif;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	cursor: pointer;
	z-index: 50;
	opacity: 0;
	animation: ifb-fade-in 0.8s ease 0.6s forwards;
}

.ifb-container.ifb-open .ifb-hint {
	display: none;
}

@keyframes ifb-fade-in {
	to {
		opacity: 1;
	}
}
