html.pre-document-reader-html {
	background: #050607;
}

body.pre-document-reader-template {
	align-items: center;
	background: transparent;
	box-sizing: border-box;
	color: #fff;
	display: flex;
	height: 100dvh;
	isolation: isolate;
	justify-content: center;
	margin: 0;
	overflow: hidden;
	padding: 16px;
}

body.pre-document-reader-template::before {
	background: rgba(0, 0, 0, .82);
	content: "";
	height: 100dvh;
	inset: 0;
	position: fixed;
	width: 100%;
	z-index: 100000;
}

/* Character/enemy dialog values, scoped here because the reader is a separate route. */
.pre-document-reader {
	background: #080808;
	border: 1px solid rgba(255, 255, 255, .6);
	border-radius: 6px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
	box-sizing: border-box;
	color: #fff;
	direction: rtl;
	display: flex;
	flex-direction: column;
	font-family: "Cairo", "flat-jooza", Tahoma, Arial, sans-serif;
	height: min(760px, calc(100dvh - 48px));
	inset: 0;
	margin: auto;
	max-height: calc(100dvh - 48px);
	min-height: 0;
	overflow: hidden;
	padding: 0;
	position: fixed;
	width: min(920px, calc(100vw - 48px));
	z-index: 100001;
}

.pre-document-reader::before {
	background-image: linear-gradient(rgba(8, 8, 8, .2), rgba(8, 8, 8, .65)), var(--pre-document-reader-bg-image, none);
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
	content: "";
	filter: blur(1px);
	inset: 0;
	opacity: .12;
	pointer-events: none;
	position: absolute;
	z-index: 0;
}

body.admin-bar.pre-document-reader-template {
	padding-top: 48px;
}

.pre-document-reader *,
.pre-document-reader *::before,
.pre-document-reader *::after {
	box-sizing: border-box;
}

.pre-document-reader-topbar,
.pre-document-reader-stage,
.pre-document-reader-controls {
	position: relative;
	z-index: 1;
}

.pre-document-reader-topbar {
	align-items: center;
	display: grid;
	flex: 0 0 auto;
	grid-template-columns: minmax(0, 1fr);
	padding: 54px 26px 12px;
}

.pre-document-reader-close,
.pre-document-reader-icon-button,
.pre-document-reader-nav-button {
	align-items: center;
	appearance: none;
	background: #080808;
	border: 1px solid rgba(255, 255, 255, .55);
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	height: 36px;
	justify-content: center;
	line-height: 1;
	padding: 0;
	text-decoration: none;
	transition: background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
	width: 36px;
}

.pre-document-reader-close {
	inset-inline-start: 10px;
	margin: 0;
	position: absolute;
	top: 10px;
}

.pre-document-reader-close span:first-child {
	font-size: 24px;
	line-height: 1;
}

.pre-document-reader-close span:last-child {
	display: none;
}

.pre-document-reader-icon-button {
	font-size: 16px;
}

.pre-document-reader-close:hover,
.pre-document-reader-icon-button:hover,
.pre-document-reader-nav-button:hover:not(:disabled) {
	background: #242424;
	color: #fff;
}

.pre-document-reader-close:focus-visible,
.pre-document-reader-icon-button:focus-visible,
.pre-document-reader-nav-button:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.pre-document-reader-heading {
	min-width: 0;
	text-align: center;
}

.pre-document-reader-heading span,
.pre-document-reader-heading strong {
	display: block;
	overflow-wrap: anywhere;
}

.pre-document-reader-heading span {
	color: #bbbbbb;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.2;
	margin-bottom: 3px;
}

.pre-document-reader-heading strong {
	color: #fff;
	font-size: 28px;
	font-weight: 800;
	line-height: 1.5;
}

/* The generated cover title already identifies the cover. */
.pre-document-reader:has(.pre-document-page--cover.is-active) .pre-document-reader-heading strong {
	visibility: hidden;
}

.pre-document-reader-actions {
	direction: ltr;
	display: flex;
	gap: 8px;
	left: 10px;
	position: absolute;
	top: 10px;
}

.pre-document-reader-stage {
	align-items: stretch;
	display: flex;
	flex: 1 1 0;
	justify-content: center;
	min-height: 0;
	perspective: 1400px;
}

.pre-document-reader-pages {
	display: flex;
	flex-direction: column;
	min-height: 0;
	position: relative;
	width: 100%;
}

.pre-document-page {
	display: none;
	flex: 1 1 0;
	min-height: 0;
	position: relative;
}

.pre-document-page.is-active {
	display: flex;
}

.pre-document-page[aria-hidden="true"] {
	pointer-events: none;
}

.pre-document-page-surface {
	background: transparent;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
	position: relative;
	transform-origin: center;
	width: 100%;
}

.pre-document-reader.is-turning-forward .pre-document-page.is-active .pre-document-page-surface {
	animation: pre-document-turn-forward .36s ease both;
}

.pre-document-reader.is-turning-back .pre-document-page.is-active .pre-document-page-surface {
	animation: pre-document-turn-back .36s ease both;
}

.pre-document-page-scroll,
.pre-document-page--cover .pre-document-page-surface {
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-color: #484848 #080808;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.pre-document-page-scroll {
	flex: 1 1 auto;
	padding: 12px 26px 26px;
}

.pre-document-cover-media {
	flex: 0 0 auto;
	padding: 0 26px 6px;
}

.pre-document-cover-image {
	border: 1px solid rgba(213, 30, 30, .75);
	border-radius: 3px;
	display: block;
	height: auto;
	margin: 0 auto;
	max-height: 240px;
	max-width: 100%;
	object-fit: contain;
	width: auto;
}

.pre-document-cover-content {
	flex: 0 0 auto;
	padding: 12px 26px 26px;
	text-align: center;
}

.pre-document-cover-content p {
	background: #b90000;
	border-radius: 4px;
	color: #fff;
	display: inline-block;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1.5;
	margin: 0 0 8px;
	padding: 2px 12px;
}

.pre-document-cover-content h1 {
	color: #fff;
	font-family: inherit;
	font-size: 28px;
	font-weight: 800;
	line-height: 1.5;
	margin: 0;
	overflow-wrap: anywhere;
}

.pre-document-cover-content .pre-document-cover-subtitle {
	background: transparent;
	color: #bbbbbb;
	display: block;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.6;
	margin: 8px 0 0;
	padding: 0;
}

.pre-document-text-content {
	color: rgba(255, 255, 255, .82);
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.9;
	margin: 0;
	overflow-wrap: anywhere;
	width: 100%;
}

.pre-document-reader .pre-document-page--text .pre-document-text-content > .pre-document-reader-source-title-duplicate {
	display: none !important;
}

.pre-document-page--text .pre-document-text-content,
.pre-document-page--text .pre-document-text-content p,
.pre-document-page--text .pre-document-text-content h1,
.pre-document-page--text .pre-document-text-content h2,
.pre-document-page--text .pre-document-text-content h3,
.pre-document-page--text .pre-document-text-content h4,
.pre-document-page--text .pre-document-text-content h5,
.pre-document-page--text .pre-document-text-content h6,
.pre-document-page--text .pre-document-text-content div,
.pre-document-page--text .pre-document-text-content blockquote,
.pre-document-page--text .pre-document-text-content ul,
.pre-document-page--text .pre-document-text-content ol,
.pre-document-page--text .pre-document-text-content li {
	text-align: right !important;
}

.pre-document-text-content :first-child {
	margin-top: 0;
}

.pre-document-text-content :last-child {
	margin-bottom: 0;
}

.pre-document-text-content a {
	color: #fff;
	text-decoration: underline;
}

.pre-document-text-content p {
	margin: 0 0 8px;
}

.pre-document-page--text .pre-document-text-content h2,
.pre-document-page--text .pre-document-text-content h3,
.pre-document-page--text .pre-document-text-content h4 {
	color: #fff;
	font-family: inherit;
	font-weight: 600;
	line-height: 1.5;
	margin: .72em 0 .24em;
}

.pre-document-text-content h2 { font-size: 1.12em; }
.pre-document-text-content h3 { font-size: 1.06em; }
.pre-document-text-content h4 { font-size: .98em; }

.pre-document-page--text .pre-document-text-content ul,
.pre-document-page--text .pre-document-text-content ol {
	display: block;
	list-style-position: inside;
	margin: .08em 0 .42em;
	padding-inline-start: 0;
}

.pre-document-page--text .pre-document-text-content li + li {
	margin-top: .18em;
}

.pre-document-page--text .pre-document-text-content blockquote {
	border-inline-start: 3px solid rgba(255, 255, 255, .18);
	color: inherit;
	font-style: italic;
	margin: .62em auto;
	padding: .12em 1em;
}

.pre-document-text-content strong {
	color: inherit;
	font-weight: 700;
}

.pre-document-image-scroll {
	align-items: flex-start;
	display: flex;
	justify-content: center;
}

.pre-document-reader-image {
	display: block;
	height: auto;
	max-width: 100%;
	min-width: 0;
	width: auto;
}

.pre-document-page--empty .pre-document-text-content {
	text-align: center;
}

.pre-document-reader-controls {
	align-items: center;
	border-top: 1px solid rgba(255, 255, 255, .18);
	display: grid;
	flex: 0 0 auto;
	gap: 10px;
	grid-template-columns: auto auto auto;
	justify-content: center;
	margin: 0;
	padding: 12px 26px 26px;
}

.pre-document-reader-nav-button { font-size: 24px; }

.pre-document-reader-nav-button:disabled {
	cursor: default;
	opacity: .36;
}

.pre-document-reader-counter {
	align-items: center;
	background: #0c0c0c;
	border: 1px solid rgba(255, 255, 255, .16);
	border-radius: 4px;
	color: #fff;
	display: inline-flex;
	font-size: 16px;
	font-weight: 600;
	gap: 10px;
	justify-content: center;
	min-height: 36px;
	min-width: 96px;
	padding: 0 12px;
}

.pre-document-reader:fullscreen {
	border: 0;
	border-radius: 0;
	height: 100dvh;
	margin: 0;
	max-height: none;
	width: 100%;
}

.pre-document-reader:fullscreen .pre-document-reader-stage {
	align-self: center;
	width: min(100%, 820px);
}

@keyframes pre-document-turn-forward {
	0% { opacity: .68; transform: rotateY(-8deg) translateX(18px) scale(.992); }
	100% { opacity: 1; transform: rotateY(0) translateX(0) scale(1); }
}

@keyframes pre-document-turn-back {
	0% { opacity: .68; transform: rotateY(8deg) translateX(-18px) scale(.992); }
	100% { opacity: 1; transform: rotateY(0) translateX(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.pre-document-reader *,
	.pre-document-reader *::before,
	.pre-document-reader *::after {
		animation-duration: .01ms !important;
		scroll-behavior: auto !important;
		transition-duration: .01ms !important;
	}

	.pre-document-reader.is-turning-forward .pre-document-page.is-active .pre-document-page-surface,
	.pre-document-reader.is-turning-back .pre-document-page.is-active .pre-document-page-surface {
		animation: none;
	}
}

@media screen and (max-width: 782px) {
	body.admin-bar.pre-document-reader-template { padding-top: 56px; }
}

@media screen and (max-width: 767px) {
	body.pre-document-reader-template { padding: 10px; }
	.pre-document-reader:not(:fullscreen) {
		height: calc(100dvh - 20px);
		max-height: calc(100dvh - 20px);
		width: calc(100vw - 20px);
	}
	.pre-document-reader-topbar { padding: 60px 18px 12px; }

	.pre-document-reader-close,
	.pre-document-reader-icon-button,
	.pre-document-reader-nav-button {
		height: 40px;
		width: 40px;
	}

	.pre-document-reader-heading strong,
	.pre-document-cover-content h1 { font-size: 24px; }
	.pre-document-cover-media { padding: 0 18px 6px; }
	.pre-document-cover-image { max-height: 190px; }

	.pre-document-page-scroll,
	.pre-document-cover-content,
	.pre-document-reader-controls { padding: 12px 18px 22px; }
	.pre-document-reader-counter { min-height: 40px; }
}

/* Rich text pages keep their source HTML and intrinsic image proportions. */
.pre-document-page--text .pre-document-text-content img {
	border: 1px solid rgba(213, 30, 30, .75);
	border-radius: 3px;
	display: block;
	height: auto;
	margin: 0 auto;
	max-width: 100%;
	object-fit: contain;
}
