/**
 * RAWZA "terug naar boven" button (inc/rawza/back-to-top.php).
 *
 * Loaded on every page. Self-contained: tokens are scoped to .rz-to-top so it
 * reads in the RAWZA palette on the homepage and on regular GeneratePress
 * pages alike. `body button.rz-to-top` (0,1,2) outranks both the
 * GeneratePress button rules and the homepage button reset.
 * Bottom left, level with the WhatsApp button on the right (15px inset,
 * 50px high), so the two never compete for the same corner.
 */

body button.rz-to-top {
	--rz-tt-green: rgb(21 35 28 / 94%);
	--rz-tt-gold: #edbd76;
	--rz-tt-ink: #2a1a12;
	--rz-tt-progress: 0;
	position: fixed;
	z-index: 999;
	left: calc(16px + env(safe-area-inset-left, 0px));
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--rz-tt-gold);
	border-radius: 0;
	background: var(--rz-tt-green);
	color: var(--rz-tt-gold);
	box-shadow: 0 8px 30px #050a0759;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity .3s ease, transform .3s ease, visibility 0s linear .3s, background-color .2s, color .2s;
}

/* Scroll progress: a fine gold rule along the bottom edge. */
body button.rz-to-top::after {
	content: '';
	position: absolute;
	inset: auto 0 0;
	height: 2px;
	background: currentColor;
	transform: scaleX(var(--rz-tt-progress));
	transform-origin: left;
	opacity: .7;
}

body button.rz-to-top svg {
	display: block;
	width: 18px;
	height: 18px;
	transition: transform .2s ease;
}

body button.rz-to-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .3s ease, transform .3s ease, visibility 0s, background-color .2s, color .2s;
}

body button.rz-to-top:focus {
	background: var(--rz-tt-green);
	color: var(--rz-tt-gold);
}

body button.rz-to-top:focus-visible {
	outline: 3px solid var(--rz-tt-gold);
	outline-offset: 5px;
}

@media (hover: hover) {
	body button.rz-to-top.is-visible:hover {
		background: var(--rz-tt-gold);
		color: var(--rz-tt-ink);
		transform: translateY(-2px);
	}

	body button.rz-to-top:hover svg {
		transform: translateY(-2px);
	}
}

/* Out of the way while the mobile menu or a dialog is open. */
body:has(#hoofdnavigatie.is-open) button.rz-to-top,
body.dialog-open button.rz-to-top {
	opacity: 0;
	visibility: hidden;
}

@media (max-width: 760px) {
	body button.rz-to-top {
		bottom: calc(17px + env(safe-area-inset-bottom, 0px));
		width: 46px;
		height: 46px;
	}
}

@media (prefers-reduced-motion: reduce) {
	body button.rz-to-top,
	body button.rz-to-top.is-visible,
	body button.rz-to-top svg {
		transform: none;
		transition: opacity .01s, visibility 0s;
	}

	body button.rz-to-top.is-visible:hover,
	body button.rz-to-top:hover svg {
		transform: none;
	}
}

@media print {
	body button.rz-to-top {
		display: none;
	}
}
