/**
 * BoltScroll base styles
 */

.bolt-scroll {
	position: relative;
}

.bolt-scroll .bolt-scroll-listing {
	list-style: none;
	margin: 0;
	padding: 0;
}

.bolt-scroll .bolt-scroll-actions {
	display: grid;
	place-items: center;
	margin: 1.5rem 0;
	min-height: 2.75rem;
}

.bolt-scroll .bolt-scroll-button,
.bolt-scroll .bolt-scroll-previous {
	grid-area: 1 / 1;
	cursor: pointer;
	border: none;
	padding: 0.75rem 1.5rem;
	font: inherit;
}

/*
 * 0.7.0: on link page 2 and later the nav holds Previous before Next (and the spinner, in Next's cell). A page
 * with no items holds Previous alone.
 */
.bolt-scroll .bolt-scroll-actions.has-previous {
	grid-template-columns: auto auto;
	justify-content: center;
	column-gap: 1rem;
}

.bolt-scroll .bolt-scroll-actions.has-previous .bolt-scroll-button,
.bolt-scroll .bolt-scroll-actions.has-previous .bolt-scroll-spinner:not([hidden]) {
	grid-area: 1 / 2;
}

/*
 * 0.8.0, pagination="numbers": the nav holds Previous, the row of page numbers (ol.bolt-scroll-pages) and Next on one
 * line, wrapping when narrow. The rules on the row and its entries have the specificity of one class (:where()), so a
 * theme's own .bolt-scroll-pages / .bolt-scroll-page / .bolt-scroll-gap rules win.
 */
.bolt-scroll .bolt-scroll-actions.has-pages {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.5rem 1rem;
}

:where(.bolt-scroll) .bolt-scroll-pages {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.25rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

/* 0.8.0: the script hides the row (the hidden attribute) while it pages the list in place. */
.bolt-scroll .bolt-scroll-pages[hidden] {
	display: none !important;
}

:where(.bolt-scroll .bolt-scroll-pages) li {
	margin: 0;
	padding: 0;
}

:where(.bolt-scroll) .bolt-scroll-page {
	display: inline-block;
	min-width: 2.75rem;
	padding: 0.75rem 0.5rem;
	box-sizing: border-box;
	text-align: center;
	line-height: normal;
}

:where(.bolt-scroll a).bolt-scroll-page {
	text-decoration: none;
	color: ButtonText;
	background-color: ButtonFace;
}

/* The current page is told apart by more than colour: bold, underlined and outlined. */
:where(.bolt-scroll) .bolt-scroll-page:where([aria-current="page"]) {
	font-weight: bold;
	text-decoration: underline;
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

:where(.bolt-scroll) .bolt-scroll-gap {
	padding: 0.75rem 0.25rem;
}

/*
 * 0.7.0: on a paginated listing the control is a link (a.bolt-scroll-button, inside nav.bolt-scroll-actions), and
 * link page 2 and later add a Previous link (a.bolt-scroll-previous). Give both the button's base look. :where() keeps this at the specificity of one class, so a theme's own
 * .bolt-scroll-button rules still win; a theme's a:hover and a:visited rules can reach it.
 */
:where(.bolt-scroll a).bolt-scroll-button,
:where(.bolt-scroll a).bolt-scroll-previous {
	display: inline-block;
	text-align: center;
	text-decoration: none;
	line-height: normal;
	color: ButtonText;
	background-color: ButtonFace;
}

.bolt-scroll .bolt-scroll-button:disabled,
.bolt-scroll .bolt-scroll-button[aria-disabled="true"] {
	opacity: 0.6;
	cursor: wait;
}

/*
 * While a batch loads the spinner takes the button's place. The button stays focusable and in the
 * accessibility tree (opacity, not visibility, which would drop keyboard focus); it is
 * aria-disabled meanwhile.
 */
.bolt-scroll.is-loading .bolt-scroll-button {
	opacity: 0;
	pointer-events: none;
}

/*
 * Infinite-scroll mode: the button is visually hidden but stays a working control for keyboard
 * and screen-reader users, and shows itself while it has focus.
 */
.bolt-scroll.bolt-scroll-auto .bolt-scroll-button:not(:focus),
.bolt-scroll .bolt-scroll-status,
.bolt-scroll .bolt-scroll-page-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/*
 * 0.8.0: the rest of a numbers-row entry's page label ("Page " before the number) is read, not shown. Its spaces are
 * kept (pre), so the text a screen reader is given is "Page 5", not "Page5".
 */
.bolt-scroll .bolt-scroll-page-label {
	white-space: pre;
}

.bolt-scroll.bolt-scroll-auto .bolt-scroll-actions {
	margin: 2rem 0 0;
	min-height: 1px;
}

.bolt-scroll .bolt-scroll-spinner[hidden] {
	display: none !important;
}

.bolt-scroll .bolt-scroll-spinner:not([hidden]) {
	grid-area: 1 / 1;
}

.bolt-scroll .bolt-scroll-button.blue,
.bolt-scroll.blue .bolt-scroll-button {
	background: #2563eb;
	color: #fff;
	border-radius: 4px;
}

.bolt-scroll .bolt-scroll-button.red,
.bolt-scroll.red .bolt-scroll-button {
	background: #dc2626;
	color: #fff;
	border-radius: 4px;
}

/* Appended item transitions (transition="fade") */
@keyframes bolt-scroll-item-fade-in {
	from {
		opacity: 0;
		transform: translateY(1rem);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.bolt-scroll--transition-fade .bolt-scroll-listing > .bolt-scroll-enter {
	animation-name: bolt-scroll-item-fade-in;
	animation-timing-function: ease;
	animation-fill-mode: both;
}

@media (prefers-reduced-motion: reduce) {
	.bolt-scroll--transition-fade .bolt-scroll-listing > .bolt-scroll-enter {
		animation: none;
	}

	.bolt-scroll .bolt-scroll-button:disabled {
		opacity: 0.6;
	}
}
