/*
 * PDF flyer viewer - built by public-sites/public/js/public-flyer.js.
 *
 * Shared by every member site, so everything is namespaced under .hf-flyer and keeps its
 * own neutral palette, borrowing only the site's primary colour (set as
 * --hf-flyer-accent by the script) for accents.
 */
.hf-flyer {
	--hf-flyer-accent: #2563eb;
	--hf-flyer-surface: #ffffff;
	--hf-flyer-stage: #f1f5f9;
	--hf-flyer-border: #e2e8f0;
	--hf-flyer-text: #0f172a;
	--hf-flyer-muted: #64748b;
	--hf-flyer-hover: #f1f5f9;
	--hf-flyer-radius: 14px;
	--hf-flyer-pad: 20px;

	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--hf-flyer-border);
	border-radius: var(--hf-flyer-radius);
	background: var(--hf-flyer-stage);
	box-shadow:
		0 1px 2px rgba(15, 23, 42, 0.04),
		0 10px 30px rgba(15, 23, 42, 0.06);
	color: var(--hf-flyer-text);
	text-align: left;
	line-height: 1.4;
}

.hf-flyer *,
.hf-flyer *::before,
.hf-flyer *::after {
	box-sizing: border-box;
}

/* Toolbar */

.hf-flyer__toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 12px 10px 18px;
	border-bottom: 1px solid var(--hf-flyer-border);
	background: var(--hf-flyer-surface);
}

.hf-flyer__status {
	font-size: 15px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.hf-flyer__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.hf-flyer:not(.is-loaded) .hf-flyer__actions {
	visibility: hidden;
}

.hf-flyer__zoom {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--hf-flyer-border);
	border-radius: 10px;
}

.hf-flyer__zoom-level {
	min-width: 44px;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	color: var(--hf-flyer-muted);
	text-align: center;
}

.hf-flyer__icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--hf-flyer-text);
	cursor: pointer;
	transition:
		background-color 0.15s ease,
		opacity 0.2s ease,
		transform 0.2s ease;
}

.hf-flyer__icon-btn:hover:not(:disabled) {
	background: var(--hf-flyer-hover);
}

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

.hf-flyer__icon-btn--bordered {
	border: 1px solid var(--hf-flyer-border);
	border-radius: 10px;
}

.hf-flyer__download,
.hf-flyer__download:hover,
.hf-flyer__download:focus {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 36px;
	padding: 0 14px;
	border-radius: 10px;
	background: var(--hf-flyer-accent);
	color: #ffffff;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.hf-flyer__download:hover {
	filter: brightness(0.92);
}

.hf-flyer button:focus,
.hf-flyer a:focus,
.hf-flyer__viewport:focus {
	outline: none;
}

.hf-flyer button:focus-visible,
.hf-flyer a:focus-visible {
	outline: 2px solid var(--hf-flyer-accent);
	outline-offset: 2px;
}

/* Stage and pages */

.hf-flyer__stage {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.hf-flyer__viewport {
	position: relative;
	display: flex;
	min-height: 320px;
	overflow: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	/* Snap pages to where the track padding puts them, not flush against the edge */
	scroll-padding: 0 var(--hf-flyer-pad);
	-webkit-overflow-scrolling: touch;
}

.hf-flyer__viewport:focus-visible {
	box-shadow: inset 0 0 0 2px var(--hf-flyer-accent);
}

/* The scrollbar only appears while zoomed, where it helps show where you are */
.hf-flyer:not(.is-zoomed) .hf-flyer__viewport {
	scrollbar-width: none;
}

.hf-flyer:not(.is-zoomed) .hf-flyer__viewport::-webkit-scrollbar {
	display: none;
}

.hf-flyer.is-zoomed .hf-flyer__viewport {
	scroll-snap-type: none;
	cursor: grab;
}

.hf-flyer.is-panning .hf-flyer__viewport {
	cursor: grabbing;
	user-select: none;
}

/* margin: auto centres the pages when they all fit, and falls back to the start when they overflow */
.hf-flyer__track {
	display: flex;
	flex: none;
	gap: 14px;
	margin: auto;
	padding: var(--hf-flyer-pad);
}

.hf-flyer__page {
	position: relative;
	flex: none;
	overflow: hidden;
	border-radius: 4px;
	background: #ffffff;
	box-shadow:
		0 1px 3px rgba(15, 23, 42, 0.12),
		0 6px 18px rgba(15, 23, 42, 0.08);
	scroll-snap-align: start;
}

.hf-flyer__page canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.hf-flyer__page:not(.is-rendered) {
	background: linear-gradient(100deg, #ffffff 30%, #f1f5f9 50%, #ffffff 70%);
	background-size: 300% 100%;
	animation: hf-flyer-shimmer 1.4s ease-in-out infinite;
}

/* Floating page arrows */

.hf-flyer__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 46px;
	height: 46px;
	border: 1px solid var(--hf-flyer-border);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
	transform: translateY(-50%);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.hf-flyer__nav svg {
	width: 22px;
	height: 22px;
}

.hf-flyer__nav--prev {
	left: 14px;
}

.hf-flyer__nav--next {
	right: 14px;
}

.hf-flyer__nav:hover:not(:disabled) {
	background: #ffffff;
	transform: translateY(-50%) scale(1.06);
}

/* Hidden rather than greyed out at either end */
.hf-flyer__nav:disabled {
	opacity: 0;
	pointer-events: none;
}

/* Loading and error states */

.hf-flyer__loading {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: var(--hf-flyer-stage);
	color: var(--hf-flyer-muted);
	font-size: 15px;
	transition: opacity 0.3s ease;
}

.hf-flyer.is-ready .hf-flyer__loading {
	opacity: 0;
	pointer-events: none;
}

.hf-flyer__spinner {
	width: 38px;
	height: 38px;
	border: 3px solid rgba(100, 116, 139, 0.22);
	border-top-color: var(--hf-flyer-accent);
	border-radius: 50%;
	animation: hf-flyer-spin 0.8s linear infinite;
}

.hf-flyer.has-error .hf-flyer__toolbar {
	display: none;
}

.hf-flyer__error {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 460px;
	margin: 0 auto;
	padding: 48px 24px;
	text-align: center;
}

.hf-flyer__error-icon {
	margin-bottom: 16px;
	color: #dc2626;
}

.hf-flyer__error-title {
	margin-bottom: 8px;
	font-size: 20px;
	font-weight: 600;
}

.hf-flyer__error-message {
	margin-bottom: 22px;
	color: var(--hf-flyer-muted);
	font-size: 15px;
}

/* Full screen (the real Fullscreen API, or a fixed overlay where it isn't available) */

.hf-flyer.is-fullscreen {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1080;
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: 0;
}

body.hf-flyer-lock {
	overflow: hidden;
}

/* Phones */

@media (max-width: 575.98px) {
	.hf-flyer {
		--hf-flyer-radius: 10px;
		--hf-flyer-pad: 12px;
	}

	.hf-flyer__toolbar {
		padding: 8px 8px 8px 12px;
	}

	.hf-flyer__status {
		font-size: 14px;
	}

	.hf-flyer__actions {
		gap: 6px;
	}

	.hf-flyer__zoom-level,
	.hf-flyer__download-text {
		display: none;
	}

	.hf-flyer__toolbar .hf-flyer__download {
		width: 36px;
		padding: 0;
		justify-content: center;
	}

	.hf-flyer__track {
		gap: 10px;
	}

	.hf-flyer__nav {
		width: 40px;
		height: 40px;
	}

	.hf-flyer__nav--prev {
		left: 8px;
	}

	.hf-flyer__nav--next {
		right: 8px;
	}
}

/* Empty state shown while a member has no active flyer (flyer-inactive.mustache) */

.hf-flyer-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-width: 520px;
	margin: 0 auto;
	padding: 48px 24px;
	border: 1px dashed #cbd5e1;
	border-radius: 14px;
	background: #f8fafc;
	color: #475569;
	text-align: center;
}

.hf-flyer-empty__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #e2e8f0;
	color: #64748b;
}

.hf-flyer-empty__message {
	font-size: 16px;
}

@keyframes hf-flyer-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes hf-flyer-shimmer {
	from {
		background-position: 100% 0;
	}
	to {
		background-position: 0 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hf-flyer__page:not(.is-rendered) {
		animation: none;
	}

	.hf-flyer__nav:hover:not(:disabled) {
		transform: translateY(-50%);
	}
}
