.greatcomm-flipbook {
	--gc-flipbook-ink: #1d2730;
	--gc-flipbook-paper: #fffefa;
	--gc-flipbook-accent: var(--color-primary, #00cd6c);
	box-sizing: border-box;
	width: 100%;
	margin: 1.5rem 0;
	color: var(--gc-flipbook-ink);
	font-family: var(--font-primary, system-ui, sans-serif);
}

.greatcomm-flipbook *,
.greatcomm-flipbook *::before,
.greatcomm-flipbook *::after {
	box-sizing: border-box;
}

.greatcomm-flipbook__toolbar {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 48px;
	padding: 0.4rem 0.55rem;
	border: 1px solid #dfe4e8;
	border-bottom: 0;
	border-radius: 8px 8px 0 0;
	background: #f8fafb;
}

.greatcomm-flipbook__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 36px;
	width: 36px;
	height: 34px;
	padding: 0;
	border: 1px solid #d9e0e5;
	border-radius: 5px;
	background: #fff;
	color: #25313a;
	font: inherit;
	font-size: 1.25rem;
	line-height: 1;
	text-decoration: none !important;
	cursor: pointer;
	transition: background-color 0.18s ease, border-color 0.18s ease;
}

.greatcomm-flipbook__button:hover:not(:disabled) {
	border-color: var(--gc-flipbook-accent);
	background: #f1fbf6;
	color: #14251c;
}

.greatcomm-flipbook__button:focus-visible,
.greatcomm-flipbook__page-number:focus-visible {
	outline: 2px solid var(--gc-flipbook-accent);
	outline-offset: 2px;
}

.greatcomm-flipbook__button:disabled {
	opacity: 0.42;
	cursor: not-allowed;
}

.greatcomm-flipbook__toolbar-spacer {
	flex: 1 1 auto;
}

.greatcomm-flipbook__page-label {
	display: inline-flex;
	align-items: center;
	margin: 0 0 0 0.35rem;
}

.greatcomm-flipbook__page-number {
	width: 3.2rem;
	height: 34px;
	padding: 0.25rem;
	border: 1px solid #d9e0e5;
	border-radius: 5px;
	background: #fff;
	color: #25313a;
	font: inherit;
	text-align: center;
}

.greatcomm-flipbook__page-number::-webkit-inner-spin-button,
.greatcomm-flipbook__page-number::-webkit-outer-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.greatcomm-flipbook__page-number {
	-moz-appearance: textfield;
}

.greatcomm-flipbook__page-total {
	margin-right: 0.35rem;
	color: #65717a;
	font-size: 0.875rem;
	white-space: nowrap;
}

.greatcomm-flipbook__stage {
	display: flex;
	justify-content: flex-start;
	overflow: auto;
	min-height: 240px;
	padding: clamp(0.75rem, 3vw, 2rem);
	border: 1px solid #dfe4e8;
	border-radius: 0 0 8px 8px;
	background:
		radial-gradient(ellipse at center, #f8f8f6 0, #e6e7e5 70%, #d9dcda 100%);
	perspective: 1800px;
	touch-action: pan-y;
}

.greatcomm-flipbook__book {
	position: relative;
	flex: 0 0 auto;
	margin: 0 auto;
	width: min(100%, 760px);
	overflow: visible;
	aspect-ratio: 0.707;
	background: var(--gc-flipbook-paper);
	box-shadow: 0 16px 38px rgba(28, 35, 38, 0.28), 0 3px 8px rgba(28, 35, 38, 0.2);
	transform-style: preserve-3d;
}

.greatcomm-flipbook__base,
.greatcomm-flipbook__face {
	position: absolute;
	inset: 0;
	overflow: hidden;
	background: var(--gc-flipbook-paper);
}

.greatcomm-flipbook__base::after,
.greatcomm-flipbook__face::after {
	position: absolute;
	z-index: 1;
	top: 0;
	right: 0;
	bottom: 0;
	width: 7%;
	background: linear-gradient(90deg, transparent, rgba(48, 43, 35, 0.08));
	content: "";
	pointer-events: none;
}

.greatcomm-flipbook__base canvas,
.greatcomm-flipbook__face canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.greatcomm-flipbook__leaf {
	position: absolute;
	z-index: 2;
	inset: 0;
	transform: rotateY(0);
	transform-origin: left center;
	transform-style: preserve-3d;
	transition: transform 680ms cubic-bezier(0.22, 0.68, 0, 1);
}

.greatcomm-flipbook__leaf.is-turning-forward {
	transform: rotateY(-180deg);
}

.greatcomm-flipbook__leaf.is-turning-backward {
	transform: rotateY(180deg);
}

.greatcomm-flipbook__leaf.is-resetting {
	transition: none;
}

.greatcomm-flipbook__face {
	backface-visibility: hidden;
}

.greatcomm-flipbook__face--front {
	box-shadow: inset -12px 0 18px -18px rgba(0, 0, 0, 0.8);
}

.greatcomm-flipbook__face--back {
	transform: rotateY(180deg);
	box-shadow: inset 12px 0 18px -18px rgba(0, 0, 0, 0.8);
}

.greatcomm-flipbook__status {
	margin: 0.6rem 0 0;
	color: #65717a;
	font-size: 0.875rem;
	text-align: center;
}

.greatcomm-flipbook__status[hidden] {
	display: none;
}

.greatcomm-flipbook:fullscreen {
	display: flex;
	flex-direction: column;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: clamp(0.5rem, 2vw, 1.5rem);
	background: #e6e7e5;
}

.greatcomm-flipbook:fullscreen .greatcomm-flipbook__stage {
	flex: 1 1 auto;
	align-items: center;
	border-radius: 0 0 8px 8px;
}

@media (max-width: 520px) {
	.greatcomm-flipbook__toolbar {
		gap: 0.25rem;
		padding-right: 0.35rem;
		padding-left: 0.35rem;
	}

	.greatcomm-flipbook__button {
		flex-basis: 32px;
		width: 32px;
		height: 32px;
	}

	.greatcomm-flipbook__page-number {
		width: 2.6rem;
		height: 32px;
	}

	.greatcomm-flipbook__page-label {
		margin-left: 0.1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.greatcomm-flipbook__leaf {
		transition-duration: 1ms;
	}
}
