/* Floating "Go to top" button — markup in functions.back-to-top.php.

   Hidden with visibility (not just opacity) so it also leaves the tab order
   and the accessibility tree until back-to-top.js reveals it. */

.ms-back-to-top {
	position: fixed;
	right: 1.5rem;
	bottom: 1.5rem;
	/* Level with the mobile contact bar; under the header (1400), the drawer
	   (2200) and the gallery lightbox (9999). */
	z-index: 1000;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.0625rem;
	width: 3.5rem;
	height: 3.5rem;
	padding: 0 0 0.125rem;
	border: 0;
	border-radius: 50%;
	background: var(--global-palette7, #123659);
	color: #fff;
	box-shadow: 0 6px 18px rgba(4, 12, 20, 0.22);
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.75rem);
	transition:
		opacity 0.2s ease,
		transform 0.2s ease,
		background-color 0.2s ease,
		visibility 0s linear 0.2s;
}

/* Kadence styles button:hover, :focus and :active with its gold hover colour,
   and button:hover outranks the class alone. Touch browsers keep :hover on
   the button after a tap, so without this it came back gold the next time it
   appeared. The desktop hover below still wins, as it comes later. */
.ms-back-to-top:hover,
.ms-back-to-top:focus,
.ms-back-to-top:active {
	background: var(--global-palette7, #123659);
	color: #fff;
	box-shadow: 0 6px 18px rgba(4, 12, 20, 0.22);
}

.ms-back-to-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition-delay: 0s;
}

/* A darker shade of the brand gold (palette1, #a78854): white text on
   palette1 is only 3.3:1, short of the 4.5:1 the "Top" label needs. This
   is 4.85:1. */
@media (hover: hover) {
	.ms-back-to-top:hover {
		background: #8a6d3b;
		color: #fff;
	}
}

.ms-back-to-top svg {
	flex-shrink: 0;
	/* Pull the arrow's empty lower half closer to the label. */
	margin-bottom: -0.25rem;
}

.ms-back-to-top__label {
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
}

/* Visually hidden but read by screen readers. Defined here so the button
   doesn't rely on the parent theme's .screen-reader-text. */
.ms-back-to-top__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ms-back-to-top:focus-visible {
	outline: 3px solid var(--global-palette1, #a78854);
	outline-offset: 3px;
}

/* Mobile: the contact bar owns the bottom edge and the WhatsApp bubble sits
   bottom-right (5rem–9rem up). Mirror the bubble on the left, centred on it,
   so neither tap target crowds the other. */
@media screen and (max-width: 48rem) {
	.ms-back-to-top {
		right: auto;
		left: 1rem;
		/* 3.5rem tall, so centred on the bubble's 7rem midline. */
		bottom: 5.25rem;
	}
}

/* Matches the contact bar and WhatsApp bubble: nothing floats over the
   open drawer. */
body.ms-nav-open .ms-back-to-top {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.ms-back-to-top {
		transition: none;
	}
}
