/**
 * ZuidWest Staart: next article bar.
 *
 * Follows the theme header: gray-800 surface, rounded-sm corners,
 * filled Material icons and the green accent. Colours use the theme's
 * Tailwind variables, with fallbacks.
 */
.zw-staart-next-article {
	--zw-staart-next-article-surface: var(--color-gray-800, #1e2939);
	--zw-staart-next-article-edge: var(--color-gray-900, #101828);
	--zw-staart-next-article-muted: var(--color-gray-400, #99a1af);
	--zw-staart-next-article-quiet: var(--color-gray-500, #6a7282);
	--zw-staart-next-article-track: var(--color-gray-700, #364153);
	--zw-staart-next-article-green: #00de01;
	--zw-staart-next-article-blue: #009fe3;
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2147483000;
	border-top: 1px solid var(--zw-staart-next-article-edge);
	background: var(--zw-staart-next-article-surface);
	font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
	visibility: hidden;
	transform: translateY(100%);
	touch-action: none;
	transition: transform 0.25s ease-out, visibility 0s 0.25s;
}

/**
 * In dark mode the page itself is gray-800, so the bar steps up to
 * gray-700, like the theme's dark tabs and embed blocks. Label, close
 * button and track step up with it to keep their contrast.
 */
.dark .zw-staart-next-article {
	--zw-staart-next-article-surface: var(--color-gray-700, #364153);
	--zw-staart-next-article-muted: var(--color-gray-300, #d1d5dc);
	--zw-staart-next-article-quiet: var(--color-gray-400, #99a1af);
	--zw-staart-next-article-edge: var(--color-gray-600, #4a5565);
	--zw-staart-next-article-track: var(--color-gray-600, #4a5565);
}

/* The bar replaces the reading tips block while it is active. */
.zw-staart-has-next-article #zw-staart-top-posts-list {
	display: none;
}

.zw-staart-next-article.is-visible {
	visibility: visible;
	transform: none;
	transition: transform 0.25s ease-out, visibility 0s;
}

/* While swiping, the bar follows the finger directly. */
.zw-staart-next-article.is-dragging {
	transition: none;
}

.zw-staart-next-article .zw-staart-next-article-inner {
	display: flex;
	align-items: center;
	gap: 4px;
	max-width: 60rem;
	margin: 0 auto;
	padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.zw-staart-next-article svg {
	display: block;
	width: 24px;
	height: 24px;
	fill: currentcolor;
}

.zw-staart-next-article .zw-staart-next-article-link {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 12px;
	min-width: 0;
	padding: 4px;
	border-radius: 0.25rem;
	color: #fff;
	text-decoration: none;
}

/* Desktop only: a 16:9 thumbnail with rounded-sm corners, like the tiles. */
.zw-staart-next-article .zw-staart-next-article-image {
	flex: none;
	width: 80px;
	height: 45px;
	border-radius: 0.25rem;
	background: var(--zw-staart-next-article-track);
	object-fit: cover;
}

.zw-staart-next-article .zw-staart-next-article-text {
	flex: 1;
	min-width: 0;
}

.zw-staart-next-article .zw-staart-next-article-label {
	display: block;
	margin-bottom: 2px;
	color: var(--zw-staart-next-article-muted);
	font: 700 12px/1.3333 Nunito, sans-serif;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	white-space: nowrap;
}

.zw-staart-next-article .zw-staart-next-article-title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 1;
	overflow: hidden;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.375;
	transition: color 0.15s;
}

.zw-staart-next-article .zw-staart-next-article-link:hover .zw-staart-next-article-title {
	color: var(--zw-staart-next-article-blue);
}

/* Blue lacks contrast on the dark mode bar; underline, like the dossier list. */
.dark .zw-staart-next-article .zw-staart-next-article-link:hover .zw-staart-next-article-title {
	color: #fff;
	text-decoration: underline;
}

/**
 * Close button on desktop: a small cross next to the wheel, hovering like
 * the theme header buttons.
 */
.zw-staart-next-article .zw-staart-next-article-close {
	flex: none;
	margin-left: 4px;
	padding: 6px;
	border: 0;
	border-radius: 0.25rem;
	background: none;
	color: var(--zw-staart-next-article-quiet);
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}

.zw-staart-next-article .zw-staart-next-article-close svg {
	width: 16px;
	height: 16px;
}

.zw-staart-next-article .zw-staart-next-article-close:hover {
	background: var(--zw-staart-next-article-track);
	color: #fff;
}

/**
 * Wheel: fills while reading and closes into a full ring when the next
 * article loads. The fill follows the scrolling with a short delay, so the
 * last step visibly closes the ring.
 */
.zw-staart-next-article .zw-staart-next-article-wheel {
	position: relative;
	flex: none;
	width: 44px;
	height: 44px;
	margin-left: 8px;
}

.zw-staart-next-article .zw-staart-next-article-ring {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
}

.zw-staart-next-article .zw-staart-next-article-ring circle {
	fill: none;
	stroke-width: 4;
}

.zw-staart-next-article .zw-staart-next-article-ring-track {
	stroke: var(--zw-staart-next-article-track);
}

.zw-staart-next-article .zw-staart-next-article-ring-fill {
	stroke: var(--zw-staart-next-article-green);
	stroke-dasharray: 100;
	stroke-dashoffset: 100;
	transition: stroke-dashoffset 0.2s linear;
}

.zw-staart-next-article .zw-staart-next-article-arrow {
	position: absolute;
	top: 50%;
	left: 50%;
	margin: -12px 0 0 -12px;
}

.zw-staart-next-article.is-loading .zw-staart-next-article-arrow {
	fill: var(--zw-staart-next-article-green);
}

.zw-staart-next-article a:focus-visible,
.zw-staart-next-article button:focus-visible {
	outline: 2px solid var(--zw-staart-next-article-blue);
	outline-offset: 2px;
}

@media (max-width: 639px) {

	.zw-staart-next-article .zw-staart-next-article-link {
		gap: 8px;
	}

	.zw-staart-next-article .zw-staart-next-article-image {
		display: none;
	}

	.zw-staart-next-article .zw-staart-next-article-title {
		-webkit-line-clamp: 2;
		font-size: 15px;
		line-height: 1.3;
	}

	.zw-staart-next-article .zw-staart-next-article-wheel {
		width: 40px;
		height: 40px;
		margin-left: 4px;
	}

	/**
	 * On mobile the bar is closed by swiping it down. The button stays
	 * available for keyboard and screen reader users, but only becomes
	 * visible when it receives focus.
	 */
	.zw-staart-next-article .zw-staart-next-article-close:not(:focus-visible) {
		position: absolute;
		overflow: hidden;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		white-space: nowrap;
		clip-path: inset(50%);
	}

	.zw-staart-next-article .zw-staart-next-article-close:focus-visible {
		position: absolute;
		top: 4px;
		right: 4px;
		background: var(--zw-staart-next-article-surface);
	}
}

@media (prefers-reduced-motion: reduce) {

	.zw-staart-next-article,
	.zw-staart-next-article.is-visible,
	.zw-staart-next-article .zw-staart-next-article-ring-fill {
		transition: none;
	}
}
