/**
 * The e-paper reader chrome: toolbar, stage, thumbnail strip.
 */

.pbbep-reader {
	--pbbep-chrome-bg: #1d1a17;
	--pbbep-chrome-ink: #f5f1e8;
	--pbbep-chrome-line: rgba(245, 241, 232, 0.16);

	margin: 0 0 2rem;
	background: #2a2622;
	border-radius: 10px;
	overflow: hidden;
	font-family: var(--pbbep-serif);
}

/* ---------- Toolbar ---------- */

.pbbep-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	background: var(--pbbep-chrome-bg);
	color: var(--pbbep-chrome-ink);
	border-bottom: 1px solid var(--pbbep-chrome-line);
}

.pbbep-toolbar-group {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.pbbep-toolbar-group--nav {
	flex: 1 1 auto;
	justify-content: center;
}

.pbbep-edition-date {
	font-size: 0.95rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pbbep-archive {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.pbbep-archive-field {
	display: inline-flex;
	min-width: 0;
}

.pbbep-archive-select {
	max-width: 240px;
	padding: 5px 8px;
	background: rgba(245, 241, 232, 0.08);
	color: var(--pbbep-chrome-ink);
	border: 1px solid var(--pbbep-chrome-line);
	border-radius: 6px;
	font: inherit;
	font-size: 0.9rem;
}

.pbbep-archive-select option,
.pbbep-archive-select optgroup {
	color: #14100c;
}

/*
 * Stepping between issues is a different act from turning a page, so these sit
 * with the issue dropdown and are drawn lighter than the page arrows.
 */
.pbbep-btn--ghost {
	background: transparent;
	min-width: 30px;
	height: 30px;
	padding: 0 8px;
	opacity: 0.85;
}

.pbbep-btn--ghost:hover:not(:disabled) {
	background: rgba(245, 241, 232, 0.12);
	opacity: 1;
}

.pbbep-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 12px;
	background: rgba(245, 241, 232, 0.08);
	color: var(--pbbep-chrome-ink);
	border: 1px solid var(--pbbep-chrome-line);
	border-radius: 6px;
	font: inherit;
	font-size: 1rem;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.pbbep-btn:hover:not(:disabled) {
	background: rgba(245, 241, 232, 0.18);
	color: var(--pbbep-chrome-ink);
}

.pbbep-btn:focus-visible {
	outline: 2px solid var(--pbbep-accent);
	outline-offset: 2px;
}

.pbbep-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.pbbep-btn--primary {
	background: var(--pbbep-accent);
	border-color: var(--pbbep-accent);
	font-size: 0.9rem;
	white-space: nowrap;
}

.pbbep-btn--primary:hover {
	background: var(--pbbep-accent);
	filter: brightness(1.15);
}

.pbbep-counter {
	min-width: 84px;
	font-size: 0.95rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* ---------- Stage ---------- */

.pbbep-stage {
	position: relative;
	max-height: 82vh;
	padding: 20px;
	overflow: auto;
	background:
		radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
		#2a2622;
	-webkit-overflow-scrolling: touch;
}

.pbbep-stage:focus-visible {
	outline: 2px solid var(--pbbep-accent);
	outline-offset: -2px;
}

.pbbep-stage.is-grabbable {
	cursor: grab;
}

.pbbep-stage.is-grabbing {
	cursor: grabbing;
}

.pbbep-canvas {
	position: relative;
	margin: 0 auto;
}

.pbbep-canvas .pbbep-page {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: top left;
	display: none;
}

.pbbep-canvas .pbbep-page.is-active {
	display: block;
}

/* Shown while a page image is still arriving, so turning the page does not
   flash a blank white sheet. Cleared once the image lands, so the spinner is
   not left animating out of sight behind every page. */
.pbbep-canvas .pbbep-page.is-loaded {
	background-image: none;
}

.pbbep-canvas .pbbep-page {
	background: #efece5 url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Ccircle cx='24' cy='24' r='10' fill='none' stroke='%23b9b1a4' stroke-width='3' stroke-dasharray='40 20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 24 24' to='360 24 24' dur='0.9s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E" ) no-repeat center;
}

/* Before the script runs, show page one at its natural size so the content is
   never invisible to crawlers or to readers on a slow connection. */
.pbbep-reader:not(.is-ready) .pbbep-canvas {
	max-width: 100%;
	overflow: hidden;
}

.pbbep-reader:not(.is-ready) .pbbep-canvas .pbbep-page {
	position: static;
	display: flex;
}

/* ---------- Thumbnails ---------- */

.pbbep-thumbs {
	display: flex;
	gap: 10px;
	padding: 12px 14px;
	overflow-x: auto;
	background: var(--pbbep-chrome-bg);
	border-top: 1px solid var(--pbbep-chrome-line);
}

.pbbep-thumb {
	position: relative;
	flex: 0 0 auto;
	padding: 0;
	background: none;
	border: 2px solid transparent;
	border-radius: 4px;
	cursor: pointer;
	overflow: hidden;
	line-height: 0;
}

.pbbep-thumb:focus-visible {
	outline: 2px solid var(--pbbep-accent);
	outline-offset: 2px;
}

.pbbep-thumb.is-active {
	border-color: var(--pbbep-accent);
}

.pbbep-thumb-inner {
	/* A span is inline by default, which would ignore the width and height the
	   script sets and collapse the whole strip. */
	display: block;
	position: relative;
	overflow: hidden;
	background: #fff;
}

.pbbep-thumb-inner .pbbep-page {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: top left;
	box-shadow: none;
	pointer-events: none;
}

.pbbep-thumb-label {
	position: absolute;
	right: 4px;
	bottom: 4px;
	padding: 1px 6px;
	background: rgba(29, 26, 23, 0.85);
	color: #f5f1e8;
	border-radius: 3px;
	font-size: 11px;
	line-height: 1.6;
}

/* ---------- Empty state ---------- */

.pbbep-reader--empty {
	padding: 48px 24px;
	background: var(--pbbep-paper, #fbf8f1);
	color: #14100c;
	text-align: center;
}

.pbbep-empty-title {
	margin: 0 0 6px;
	font-size: 1.25rem;
	font-weight: 700;
}

.pbbep-empty-text {
	margin: 0;
	color: #4a423a;
}

.pbbep-empty-admin {
	margin: 16px 0 6px;
	font-weight: 600;
}

.pbbep-empty-note {
	margin: 0;
	font-size: 0.9rem;
	color: #4a423a;
}

.pbbep-noscript {
	padding: 16px;
	background: var(--pbbep-paper, #fbf8f1);
	color: #14100c;
	text-align: center;
}

/* ---------- Small screens ---------- */

@media (max-width: 782px) {
	.pbbep-toolbar {
		justify-content: center;
	}

	.pbbep-toolbar-group--start {
		order: 1;
		width: 100%;
		justify-content: center;
	}

	.pbbep-toolbar-group--nav {
		order: 2;
	}

	.pbbep-toolbar-group--end {
		order: 3;
	}

	.pbbep-stage {
		max-height: 70vh;
		padding: 12px;
	}

	.pbbep-edition-date {
		font-size: 0.85rem;
	}
}

@media print {
	.pbbep-toolbar,
	.pbbep-thumbs {
		display: none;
	}
}

/* ---------- Article clipping dialog ---------- */

.pbbep-hotspot--clip {
	cursor: pointer;
	border: 0;
	padding: 0;
}

/* A small mark so a tappable article does not look like plain newsprint. */
.pbbep-hotspot-badge {
	position: absolute;
	right: 4px;
	top: 4px;
	width: 22px;
	height: 22px;
	background: var(--pbbep-accent);
	color: #fff;
	border-radius: 50%;
	font-size: 13px;
	line-height: 22px;
	text-align: center;
	opacity: 0;
	transition: opacity 0.15s ease;
}

.pbbep-hotspot--clip:hover .pbbep-hotspot-badge,
.pbbep-hotspot--clip:focus-visible .pbbep-hotspot-badge {
	opacity: 1;
}

/* On touch there is no hover, so the mark is always visible. */
@media (hover: none) {
	.pbbep-hotspot-badge {
		opacity: 0.9;
	}
}

body.pbbep-clip-open {
	overflow: hidden;
}

/*
 * The dialog fills the viewport and stays transparent; the panel inside it is
 * what the reader sees. Filling the viewport is what makes a click anywhere
 * around the panel land on the dialog itself and close it.
 */
.pbbep-clip {
	width: 100%;
	max-width: 100vw;
	height: 100%;
	max-height: 100vh;
	margin: 0;
	padding: 20px;
	border: 0;
	background: transparent;
	overflow: visible;
}

.pbbep-clip::backdrop {
	background: rgba(20, 16, 12, 0.72);
}

.pbbep-clip[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.pbbep-clip:not([open]),
.pbbep-clip[hidden] {
	display: none;
}

/* Only reached where <dialog> is unsupported and the node is moved to the body. */
.pbbep-clip[open]:not(:modal) {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	background: rgba(20, 16, 12, 0.72);
}

.pbbep-clip-dialog {
	position: relative;
	/* The dialog is the click-to-close area, so the panel must not swallow it. */
	margin: auto;
	display: flex;
	flex-direction: column;
	width: min(720px, 100%);
	max-height: 90vh;
	background: var(--pbbep-paper, #fbf8f1);
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.pbbep-clip-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--pbbep-rule, #cbc3b8);
}

.pbbep-clip-title {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.35;
}

.pbbep-clip-meta {
	margin: 2px 0 0;
	font-size: 0.85rem;
	color: var(--pbbep-ink-soft, #4a423a);
}

.pbbep-clip-close {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	background: none;
	border: 0;
	font-size: 24px;
	line-height: 1;
	color: var(--pbbep-ink-soft, #4a423a);
	cursor: pointer;
}

.pbbep-clip-body {
	flex: 1 1 auto;
	padding: 14px 16px;
	overflow: auto;
	background: #fff;
	text-align: center;
}

.pbbep-clip-body img {
	max-width: 100%;
	height: auto;
}

.pbbep-clip-error {
	margin: 0;
	padding: 20px;
	color: #8a1c1c;
}

.pbbep-clip-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--pbbep-rule, #cbc3b8);
}

.pbbep-clip-actions .pbbep-btn {
	background: rgba(20, 16, 12, 0.06);
	color: #14100c;
	border-color: rgba(20, 16, 12, 0.16);
	text-decoration: none;
}

.pbbep-clip-actions .pbbep-btn--primary {
	background: var(--pbbep-accent);
	border-color: var(--pbbep-accent);
	color: #fff;
}

.pbbep-clip-actions .pbbep-btn[hidden] {
	display: none;
}

.pbbep-clip-actions .pbbep-btn.is-busy {
	opacity: 0.5;
	pointer-events: none;
}
