/*
 * Page picker overlay: a dimmed ocean backdrop with a sky panel of page thumbnails.
 * Colours, radii, and shadows come from the custom properties in reader.css, so
 * the picker always matches the reader around it.
 */
.pages-overlay {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: var(--backdrop);
}

.pages-overlay__panel {
	display: flex;
	flex-direction: column;
	width: min(60rem, 100%);
	max-height: 100%;
	border-radius: var(--page-radius);
	background: var(--stage-gradient);
	box-shadow: var(--shadow-book);
	overflow: hidden;
}

.pages-overlay__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
	padding: 0.75rem 1rem;
	background: var(--header-surface);
	border-bottom: 2px solid var(--line);
}

.pages-overlay__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 800;
	color: var(--coa-purple);
}

.pages-overlay__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
	gap: 1rem;
	padding: 1rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/*
 * The tile padding is a custom property so the page art inside can derive its
 * corner radius from it and sit concentrically within the rounded tile.
 */
.pages-overlay__thumbnail {
	--tile-padding: 0.5rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.375rem;
	padding: var(--tile-padding);
	border: 3px solid transparent;
	border-radius: var(--page-radius);
	font: inherit;
	color: var(--ink);
	background: var(--surface);
	box-shadow: var(--shadow-soft);
	cursor: pointer;
	transition: border-color 150ms ease, transform 150ms ease;
}

.pages-overlay__thumbnail:hover {
	border-color: var(--coa-purple);
	transform: translateY(-2px);
}

/* Keyboard users get the same dashed purple ring as the reader's buttons. */
.pages-overlay__thumbnail:focus-visible {
	outline: 2px dashed var(--find);
	outline-offset: 2px;
}

/*
 * The pages already on screen are marked so the reader knows where they are.
 * A yellow border alone is faint on white, so a matching glow widens the marker.
 */
.pages-overlay__thumbnail[aria-current] {
	border-color: var(--lit);
	box-shadow: 0 0 0 3px var(--lit-glow), var(--shadow-soft);
}

.pages-overlay__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 3 / 4;
	object-fit: contain;
	border-radius: calc(var(--page-radius) - var(--tile-padding));
	background: var(--surface);
}

.pages-overlay__label {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--ocean-deep);
}

/* Phones: smaller thumbnails so several fit across a narrow screen. */
@media (max-width: 599px) {
	.pages-overlay {
		padding: 0.5rem;
	}

	.pages-overlay__grid {
		grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
		gap: 0.625rem;
		padding: 0.625rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pages-overlay__thumbnail {
		transition: none;
	}

	.pages-overlay__thumbnail:hover {
		transform: none;
	}
}
