/* Enhanced Realistic Book Flipbook Styles */
.flipbook-container {
	margin: 0 auto;
	position: relative;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	font-family: "Georgia", "Times New Roman", serif;
	background: transparent;
	padding: 40px;
}

/* Fullscreen white background flipbook container */
.flipbook-container.fullscreen-white {
	width: 100vw;
	height: 100vh;
	padding: 0;
	margin: 0;
	background: transparent !important;
	font-family: "Arial", sans-serif;
}

.flipbook-page-content {
	background: transparent !important;
}

.flipbook-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 30px;
	padding: 20px;
	position: relative;
}

/* Book Base/Spine */
.book-container {
	position: relative;
	transform-style: preserve-3d;
	margin: 0 auto;
	perspective: 2000px;
	filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.4));
}

.book-container::before {
	content: "";
	position: absolute;
	left: -8px;
	top: -5px;
	bottom: -5px;
	width: 15px;
	background: linear-gradient(
		to right,
		#654321 0%,
		#8b4513 20%,
		#a0522d 40%,
		#8b4513 60%,
		#654321 100%
	);
	border-radius: 3px 0 0 3px;
	box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.3),
		inset -2px 0 4px rgba(255, 255, 255, 0.1);
	z-index: 1000;
}

.flipbook-page {
	background: linear-gradient(135deg, #fff8dc 0%, #fffaf0 50%, #fdf5e6 100%);
	border-radius: 2px 8px 8px 2px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1),
		inset 0 1px 0 rgba(255, 255, 255, 0.3);
	position: absolute;
	overflow: hidden;
	cursor: pointer;
	transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
	transform-style: preserve-3d;
	backface-visibility: hidden;
	transform-origin: left center;
	border: 1px solid #e6d7c3;
	border-left: 3px solid #d4c4a8;
}

.flipbook-page.flipping {
	pointer-events: none;
	z-index: 100;
	animation: realPageFlip 0.8s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

@keyframes realPageFlip {
	0% {
		transform: rotateY(0deg) scale(1);
		box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
	}
	25% {
		transform: rotateY(-45deg) scale(1.02);
		box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
	}
	50% {
		transform: rotateY(-90deg) scale(1.05);
		box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), 0 6px 12px rgba(0, 0, 0, 0.3);
	}
	75% {
		transform: rotateY(-135deg) scale(1.02);
		box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
	}
	100% {
		transform: rotateY(-180deg) scale(1);
		box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
	}
}

.flipbook-page.current {
	z-index: 10;
	transform: rotateY(0deg);
}

.flipbook-page.next {
	z-index: 5;
}

/* Paper Texture and Content Styling */
.page-content {
	padding: 60px 50px 80px 60px;
	height: calc(100% - 140px);
	overflow-y: auto;
	font-family: "Georgia", "Times New Roman", serif;
	line-height: 1.8;
	color: #2c1810;
	position: relative;
	background: radial-gradient(
			circle at 20% 80%,
			rgba(255, 248, 220, 0.3) 0%,
			transparent 50%
		),
		radial-gradient(
			circle at 80% 20%,
			rgba(255, 248, 220, 0.3) 0%,
			transparent 50%
		),
		linear-gradient(135deg, #fff8dc 0%, #fffaf0 50%, #fdf5e6 100%);
}

/* Add paper lines effect */
.page-content::before {
	content: "";
	position: absolute;
	top: 0;
	left: 60px;
	right: 0;
	bottom: 0;
	background-image: repeating-linear-gradient(
		transparent,
		transparent 32px,
		rgba(220, 180, 140, 0.2) 32px,
		rgba(220, 180, 140, 0.2) 33px
	);
	pointer-events: none;
	z-index: 1;
}

/* Left margin line */
.page-content::after {
	content: "";
	position: absolute;
	top: 0;
	left: 50px;
	bottom: 0;
	width: 1px;
	background: rgba(220, 100, 100, 0.3);
	pointer-events: none;
	z-index: 2;
}

/* Book-style Typography and Layout */
.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6 {
	color: #1a0f0a;
	margin-bottom: 1.8rem;
	font-weight: 600;
	letter-spacing: -0.015em;
	position: relative;
	z-index: 3;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.page-content h1 {
	font-size: 2.5rem;
	border-bottom: 3px double #8b4513;
	padding-bottom: 1rem;
	margin-bottom: 2.5rem;
	color: #654321;
	font-family: "Georgia", serif;
	text-align: center;
}

.page-content h2 {
	font-size: 2rem;
	color: #654321;
	margin-top: 2.5rem;
	border-left: 4px solid #cd853f;
	padding-left: 1rem;
}

.page-content h3 {
	font-size: 1.6rem;
	color: #8b4513;
	margin-top: 2rem;
}

.page-content p {
	margin-bottom: 1.5rem;
	text-align: justify;
	text-indent: 2em;
	color: #2c1810;
	position: relative;
	z-index: 3;
	font-size: 1.1rem;
}

.page-content p:first-of-type {
	margin-top: 1rem;
}

.page-content p:first-of-type::first-letter {
	float: left;
	font-size: 4rem;
	line-height: 3.2rem;
	padding-right: 0.5rem;
	margin-top: 0.2rem;
	color: #654321;
	font-family: "Georgia", serif;
	font-weight: bold;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.page-content img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
	margin: 2rem 0;
	position: relative;
	z-index: 3;
}

.page-content pre {
	background: rgba(139, 69, 19, 0.1);
	border: 1px solid #cd853f;
	border-radius: 6px;
	padding: 1.5rem;
	overflow-x: auto;
	margin: 2rem 0;
	font-family: "Courier New", monospace;
	font-size: 0.95rem;
	position: relative;
	z-index: 3;
}

.page-content blockquote {
	border-left: 4px solid #cd853f;
	margin: 2rem 0;
	padding: 1rem 2rem;
	background: rgba(205, 133, 63, 0.1);
	font-style: italic;
	color: #654321;
	position: relative;
	z-index: 3;
}

.page-content h2 {
	font-size: 1.875rem;
	color: #374151;
	margin-top: 2rem;
}

.page-content h3 {
	font-size: 1.5rem;
	color: #4b5563;
	margin-top: 1.5rem;
}

.page-content p {
	margin-bottom: 1.25rem;
	text-align: justify;
	color: #374151;
}

.page-content img {
	max-width: 100%;
	height: auto;
	border-radius: 12px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	margin: 1.5rem 0;
}

.page-content blockquote {
	border-left: 4px solid #3b82f6;
	padding-left: 1.5rem;
	margin: 1.5rem 0;
	font-style: italic;
	color: #6b7280;
	background: #f8fafc;
	padding: 1rem 1.5rem;
	border-radius: 0 8px 8px 0;
}

.page-content ul,
.page-content ol {
	padding-left: 1.5rem;
	margin-bottom: 1.25rem;
}

.page-content li {
	margin-bottom: 0.5rem;
	color: #374151;
}

.page-content code {
	background: #f1f5f9;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	font-family: "Monaco", "Consolas", monospace;
	font-size: 0.875rem;
	color: #1e40af;
}

.page-content pre {
	background: #1e293b;
	color: #e2e8f0;
	padding: 1.5rem;
	border-radius: 8px;
	overflow-x: auto;
	margin: 1.5rem 0;
}

/* Enhanced Page Number Design */
.page-number {
	position: absolute;
	bottom: 25px;
	right: 30px;
	font-size: 0.9rem;
	color: #8b4513;
	font-weight: 500;
	font-family: "Georgia", serif;
	background: rgba(255, 248, 220, 0.8);
	padding: 6px 12px;
	border-radius: 15px;
	border: 1px solid #cd853f;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	z-index: 10;
}

/* Elegant Navigation Controls */
.flipbook-controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 25px;
	margin-top: 30px;
	padding: 20px 30px;
	background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #cd853f 100%);
	border-radius: 25px;
	box-shadow: 0 10px 20px rgba(139, 69, 19, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.flipbook-btn {
	background: linear-gradient(135deg, #654321 0%, #8b4513 50%, #a0522d 100%);
	color: #fff8dc;
	border: none;
	padding: 15px 25px;
	border-radius: 15px;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.95rem;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2),
		inset 0 1px 0 rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	gap: 10px;
	text-transform: capitalize;
	letter-spacing: 0.025em;
	font-family: "Georgia", serif;
	border: 2px solid rgba(255, 248, 220, 0.3);
}

.flipbook-btn:hover:not(:disabled) {
	background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #cd853f 100%);
	transform: translateY(-3px);
	box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.3);
	border-color: rgba(255, 248, 220, 0.5);
}

.flipbook-btn:active {
	transform: translateY(-1px);
}

.flipbook-btn:disabled {
	background: linear-gradient(135deg, #999 0%, #777 100%);
	cursor: not-allowed;
	transform: none;
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1),
		inset 0 1px 0 rgba(255, 255, 255, 0.1);
	opacity: 0.6;
}

.flipbook-btn svg {
	width: 18px;
	height: 18px;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Elegant Page Progress */
.page-progress {
	display: flex;
	align-items: center;
	gap: 15px;
	background: rgba(255, 248, 220, 0.9);
	padding: 12px 20px;
	border-radius: 20px;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1),
		0 2px 4px rgba(255, 255, 255, 0.2);
	border: 2px solid rgba(139, 69, 19, 0.3);
}

.page-progress-text {
	font-size: 0.95rem;
	font-weight: 600;
	color: #654321;
	min-width: 90px;
	text-align: center;
	font-family: "Georgia", serif;
	text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.progress-bar {
	width: 140px;
	height: 8px;
	background: linear-gradient(to right, #e6d7c3 0%, #d4c4a8 100%);
	border-radius: 4px;
	overflow: hidden;
	border: 1px solid #cd853f;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progress-fill {
	height: 100%;
	background: linear-gradient(90deg, #654321 0%, #8b4513 50%, #cd853f 100%);
	border-radius: 3px;
	transition: width 0.4s ease;
	box-shadow: 0 0 10px rgba(139, 69, 19, 0.5);
}

/* Enhanced Paper Texture and Book Binding Effects */
.flipbook-container::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	pointer-events: none;
}

/* Book Spine Shadow */
.book-container::after {
	content: "";
	position: absolute;
	left: -20px;
	top: 0;
	bottom: 0;
	width: 20px;
	background: linear-gradient(
		to right,
		rgba(0, 0, 0, 0.3) 0%,
		rgba(0, 0, 0, 0.1) 70%,
		transparent 100%
	);
	border-radius: 3px 0 0 3px;
	z-index: 999;
}

/* Page Stack Effect */
.flipbook-page::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	right: -3px;
	bottom: -3px;
	background: linear-gradient(135deg, #f5f5dc 0%, #f0f0e6 100%);
	border-radius: 2px 8px 8px 2px;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
	z-index: -1;
	opacity: 0.7;
}

.flipbook-page::after {
	content: "";
	position: absolute;
	top: 6px;
	left: 6px;
	right: -6px;
	bottom: -6px;
	background: linear-gradient(135deg, #efefdf 0%, #e8e8d8 100%);
	border-radius: 2px 8px 8px 2px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	z-index: -2;
	opacity: 0.5;
}

/* Enhanced Book Typography */
.page-content::before {
	content: "";
	position: absolute;
	top: 0;
	left: 60px;
	right: 0;
	bottom: 0;
	background-image: repeating-linear-gradient(
		transparent,
		transparent 32px,
		rgba(205, 133, 63, 0.15) 32px,
		rgba(205, 133, 63, 0.15) 33px
	);
	pointer-events: none;
	z-index: 1;
}

/* Vintage Paper Effect */
.page-content {
	background-image: radial-gradient(
			circle at 20% 80%,
			rgba(139, 69, 19, 0.03) 0%,
			transparent 50%
		),
		radial-gradient(
			circle at 80% 20%,
			rgba(160, 82, 45, 0.03) 0%,
			transparent 50%
		),
		radial-gradient(
			circle at 40% 40%,
			rgba(222, 184, 135, 0.05) 0%,
			transparent 50%
		);
}

/* Reading Light Effect */
.flipbook-page.current {
	position: relative;
}

.flipbook-page.current::before {
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15),
		inset 0 0 50px rgba(255, 248, 220, 0.3);
}

/* Bookmark Effect */
.flipbook-page-indicator {
	position: relative;
}

.flipbook-page-indicator::before {
	content: "";
	position: absolute;
	top: -5px;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 0;
	border-left: 8px solid transparent;
	border-right: 8px solid transparent;
	border-bottom: 8px solid #8b4513;
	opacity: 0.8;
}

/* Performance optimizations */
.flipbook-page {
	will-change: transform;
	contain: layout style paint;
}

.flipbook-page.flipping {
	will-change: transform, z-index;
}

/* Smooth loading animation */
@keyframes fadeInScale {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.flipbook-wrapper {
	animation: fadeInScale 0.5s ease-out;
}

/* Page flip effect enhancement */
@keyframes pageFlip {
	0% {
		transform: rotateY(0deg);
	}
	50% {
		transform: rotateY(-90deg) scale(0.98);
	}
	100% {
		transform: rotateY(-180deg);
	}
}

.flipbook-page.flipping {
	animation: pageFlip 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Loading states */
.flipbook-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 400px;
	font-size: 1.1rem;
	color: #6b7280;
}

.flipbook-loading::before {
	content: "📚";
	margin-right: 12px;
	font-size: 2rem;
	animation: bounce 1s infinite;
}

@keyframes bounce {
	0%,
	100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-10px);
	}
}

/* Enhanced focus states for accessibility */
.flipbook-btn:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
}

.flipbook-page:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 4px;
}

/* Tablet landscape adjustments */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
	.flipbook-wrapper {
		padding: 24px;
	}

	.page-content {
		padding: 32px;
	}

	.flipbook-controls {
		gap: 20px;
	}
}

/* Ultra-wide screen optimizations */
@media (min-width: 1920px) {
	.flipbook-wrapper {
		max-width: 1400px;
		margin: 0 auto;
	}
}

/* Print styles */
@media print {
	.flipbook-wrapper,
	.flipbook-controls {
		display: none !important;
	}

	.flipbook-container {
		display: none !important;
	}
}

.page-content-vanilla p {
	margin-bottom: 1rem;
	text-align: justify;
}

.page-content-vanilla img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	margin: 1rem 0;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-content-vanilla blockquote {
	border-left: 4px solid #3498db;
	padding-left: 1rem;
	margin: 1rem 0;
	font-style: italic;
	background: #f8f9fa;
	padding: 1rem;
	border-radius: 4px;
}

.page-content-vanilla ul,
.page-content-vanilla ol {
	margin: 1rem 0;
	padding-left: 2rem;
}

.page-content-vanilla li {
	margin-bottom: 0.5rem;
}

.page-number-vanilla {
	position: absolute;
	bottom: 20px;
	right: 20px;
	background: rgba(52, 73, 94, 0.8);
	color: white;
	padding: 5px 12px;
	border-radius: 15px;
	font-size: 12px;
	font-weight: 500;
}

.flipbook-navigation-vanilla {
	display: flex;
	justify-content: center;
	width: 100%;
	margin-top: 20px;
}

.nav-controls-vanilla {
	display: flex;
	align-items: center;
	gap: 20px;
	background: white;
	padding: 12px 24px;
	border-radius: 25px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	border: 1px solid #e1e8ed;
}

.nav-btn-vanilla {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #3498db;
	color: white;
	border: none;
	padding: 10px 16px;
	border-radius: 20px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	transition: all 0.3s ease;
	text-decoration: none;
}

.nav-btn-vanilla:hover:not(:disabled) {
	background: #2980b9;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.nav-btn-vanilla:disabled {
	background: #bdc3c7;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
	opacity: 0.5;
}

.nav-btn-vanilla svg {
	transition: transform 0.3s ease;
}

.nav-btn-vanilla:hover:not(:disabled) svg {
	transform: translateX(2px);
}

.prev-btn-vanilla:hover:not(:disabled) svg {
	transform: translateX(-2px);
}

.page-info-vanilla {
	font-size: 14px;
	color: #7f8c8d;
	font-weight: 500;
	min-width: 120px;
	text-align: center;
}

/* Book binding effect */
.book-container::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: linear-gradient(to bottom, #8e44ad, #9b59b6);
	z-index: 1000;
	border-radius: 2px;
	box-shadow: 0 0 10px rgba(142, 68, 173, 0.3);
}

/* Page flip animations */
@keyframes pageFlipRight {
	0% {
		transform: rotateY(0deg);
	}
	100% {
		transform: rotateY(-180deg);
	}
}

@keyframes pageFlipLeft {
	0% {
		transform: rotateY(-180deg);
	}
	100% {
		transform: rotateY(0deg);
	}
}

/* Responsive Design */
@media (max-width: 768px) {
	.flipbook-wrapper-vanilla {
		padding: 10px;
	}

	.page-content-vanilla {
		padding: 20px;
		font-size: 14px;
	}

	.page-content-vanilla h1 {
		font-size: 1.5rem;
	}

	.page-content-vanilla h2 {
		font-size: 1.25rem;
	}

	.nav-controls-vanilla {
		padding: 8px 16px;
		gap: 15px;
		flex-wrap: wrap;
	}

	.nav-btn-vanilla {
		padding: 8px 12px;
		font-size: 12px;
	}

	.page-info-vanilla {
		font-size: 12px;
		min-width: 100px;
	}
}

@media (max-width: 480px) {
	.page-content-vanilla {
		padding: 15px;
	}

	.nav-controls-vanilla {
		flex-direction: column;
		gap: 10px;
	}

	.nav-btn-vanilla {
		width: 100%;
		justify-content: center;
	}

	.book-container {
		transform: scale(0.9);
	}
}

/* Loading animation */
.flipbook-loading {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 200px;
	font-size: 18px;
	color: #7f8c8d;
}

.flipbook-loading::after {
	content: "";
	width: 20px;
	height: 20px;
	border: 2px solid #3498db;
	border-top: 2px solid transparent;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-left: 10px;
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

/* 3D perspective enhancements */
.book-container {
	perspective: 1400px;
	perspective-origin: center center;
}

/* Shadow effects for turned pages */
.page-vanilla[style*="rotateY(-180deg)"] {
	box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
}

/* Smooth transitions for all interactive elements */
* {
	box-sizing: border-box;
}

.flipbook-wrapper-vanilla * {
	transition: all 0.3s ease;
}

/* Page Indicator */
.flipbook-page-indicator {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: 16px;
	padding: 8px 16px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border-radius: 20px;
	font-size: 0.875rem;
	font-weight: 500;
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
	transition: all 0.3s ease;
}

.flipbook-page-indicator:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.flipbook-page-indicator .page-info {
	display: flex;
	align-items: center;
	gap: 4px;
}

.flipbook-page-indicator .current-page {
	font-weight: 700;
	color: #fbbf24;
}

.flipbook-page-indicator .total-pages {
	color: rgba(255, 255, 255, 0.9);
}
