/**
 * Sample EPUB reader. Loaded only on a guide landing.
 */

.mg-epub {
	position: fixed;
	inset: 0;
	z-index: 80;
	box-sizing: border-box;
	display: flex;
	height: 100vh;
	height: 100dvh;
	padding: 0.6rem;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.46);
	color: rgba(0, 0, 0, 0.92);
}

body.admin-bar .mg-epub {
	top: 0;
	height: 100vh;
	height: 100dvh;
}

.mg-epub-dialog {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 0;
	overflow: hidden;
	background: #fff;
}

.mg-epub-header,
.mg-epub-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex: 0 0 auto;
	padding: 0.45rem 0.7rem;
}

.mg-epub-header {
	position: relative;
	z-index: 5;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
}

.mg-epub__label {
	margin: 0;
	font-family: var(--mg-display);
	font-size: 1.2rem;
	font-weight: 500;
	letter-spacing: 0.08em;
	line-height: 1;
	text-transform: uppercase;
}

.mg-epub__close,
.mg-epub-footer button,
.mg-epub__fallback {
	font-family: var(--mg-text);
	color: inherit;
	background: transparent;
	border: 0;
	box-shadow: none;
	cursor: pointer;
}

.mg-epub__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin-right: -0.35rem;
	font-size: 1.8rem;
	line-height: 1;
}

.mg-epub-audio {
	position: relative;
	z-index: 4;
	display: grid;
	grid-template-columns: 3rem minmax(0, 1fr);
	column-gap: 0.85rem;
	align-items: center;
	flex: 0 0 auto;
	box-sizing: border-box;
	width: min(100%, 30rem);
	max-height: 5.8rem;
	margin: 0 auto;
	padding: 0.4rem 0.85rem 0.15rem;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
	font-family: var(--mg-text);
	color: #1c1c1c;
}

.mg-epub-audio[hidden] {
	display: none;
}

.mg-epub__player-toggle {
	grid-row: 1 / span 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #1c1c1c;
	color: #fff;
	cursor: pointer;
}

.mg-epub__player-toggle:focus-visible {
	outline: 2px solid #1c1c1c;
	outline-offset: 3px;
}

.mg-epub__player-toggle svg {
	display: block;
	width: 1.15rem;
	height: 1.15rem;
}

.mg-epub__player-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.6rem;
	min-width: 0;
}

.mg-epub__player-times {
	margin: 0;
	font-variant-numeric: tabular-nums;
	font-size: 1.05rem;
	line-height: 1.2;
}

.mg-epub__player-index {
	display: flex;
	align-items: center;
	gap: 0.1rem;
	font-variant-numeric: tabular-nums;
	font-size: 0.95rem;
}

.mg-epub__player-index[hidden] {
	display: none;
}

.mg-epub__player-step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 1.35rem;
	line-height: 1;
	cursor: pointer;
}

.mg-epub__player-step:disabled {
	opacity: 0.3;
	cursor: default;
}

.mg-epub__player-seek {
	grid-column: 2;
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 2.5rem;
	margin: 0;
	background: transparent;
	cursor: pointer;
}

.mg-epub__player-seek::-webkit-slider-runnable-track {
	height: 0.28rem;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.16);
}

.mg-epub__player-seek::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 1rem;
	height: 1rem;
	margin-top: -0.36rem;
	border: 0;
	border-radius: 50%;
	background: #1c1c1c;
}

.mg-epub__player-seek::-moz-range-track {
	height: 0.28rem;
	border: 0;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.16);
}

.mg-epub__player-seek::-moz-range-thumb {
	width: 1rem;
	height: 1rem;
	border: 0;
	border-radius: 50%;
	background: #1c1c1c;
}

.mg-epub-viewport {
	position: relative;
	z-index: 1;
	display: flex;
	flex: 1 1 auto;
	justify-content: center;
	min-height: 0;
	margin: 0;
	overflow: hidden;
	overflow-anchor: none;
	contain: layout paint;
	isolation: isolate;
	background: #f3efe8;
}

#epub-render-target {
	position: relative;
	width: min(100%, 85rem);
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	overflow: hidden;
	overflow-anchor: none;
	background: #fff;
}

#epub-render-target .epub-container {
	overflow: hidden !important;
	overflow-anchor: none;
}

.mg-epub__status {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.7rem;
	padding: 1.5rem;
	overflow: hidden;
	background: #fff;
	font-family: var(--mg-text);
	font-size: 1.25rem;
	text-align: center;
}

.mg-epub__note,
.mg-epub__detail {
	max-width: 22rem;
	margin: 0;
	overflow-wrap: anywhere;
}

.mg-epub__detail {
	font-size: 1rem;
	line-height: 1.35;
}

.mg-epub__meter {
	position: relative;
	width: min(16rem, 100%);
	height: 0.4rem;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.12);
}

.mg-epub__meter-fill {
	display: block;
	height: 100%;
	width: 0;
	background: #8a6232;
}

.mg-epub__meter.is-indeterminate .mg-epub__meter-fill {
	width: 38%;
	animation: mg-epub-progress 1.05s ease-in-out infinite;
}

.mg-epub__percent {
	margin: 0;
	font-size: 1.45rem;
	font-variant-numeric: tabular-nums;
	line-height: 1;
}

.mg-epub__sizes {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.2;
	opacity: 0.72;
}

@keyframes mg-epub-progress {
	0% { transform: translateX(-130%); }
	100% { transform: translateX(280%); }
}

.mg-epub__status[hidden] {
	display: none;
}

.mg-epub__fallback {
	display: inline-block;
	padding: 0.7rem 1rem;
	font-size: 1.05rem;
	text-decoration: underline;
}

.mg-epub__fallback[hidden] {
	display: none;
}

.mg-epub-footer {
	position: relative;
	z-index: 5;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
}

.mg-epub-footer button {
	min-width: 7.5rem;
	min-height: 2.75rem;
	padding: 0.4rem 0.9rem;
	font-size: 1.15rem;
}

.mg-epub-footer button:disabled {
	opacity: 0.35;
	cursor: default;
}

@media (max-width: 782px) {
	body.admin-bar .mg-epub {
		top: 0;
		height: 100vh;
		height: 100dvh;
	}
}

@media (max-width: 759px) {
	.mg-epub {
		padding: 0;
	}

	.mg-epub__close,
	.mg-epub-footer button {
		min-height: 3rem;
	}

	.mg-epub-footer button {
		min-width: 0;
		flex: 1 1 0;
	}
}
