/**
 * Styling of the back to top button.
 *
 * Everything adjustable comes in as a custom property, so this file never
 * changes with the settings and stays cacheable.
 */

.dst-button {
	position: fixed;
	z-index: 99999;
	bottom: var(--dst-offset-y, 24px);
	display: flex;
	align-items: center;
	justify-content: center;
	/* Never smaller than a fingertip, whatever size was configured. */
	min-width: 44px;
	min-height: 44px;
	width: var(--dst-size, 48px);
	height: var(--dst-size, 48px);
	padding: 0;
	border: 0;
	border-radius: var(--dst-radius, 50%);
	background: var(--dst-bg, #0d2734);
	color: var(--dst-color, #fff);
	cursor: pointer;
	transition: opacity .25s ease, transform .25s ease, background-color .2s ease, color .2s ease;
}

/*
 * Visible by default, and hidden by the script until the visitor has scrolled.
 *
 * The other way round - invisible in CSS, shown by a class the script adds -
 * looks tidier and breaks in the field: optimisers that strip "unused" CSS
 * remove a class that appears nowhere in the markup, and the button then stays
 * invisible forever. Inline styles set by the script survive that. And should
 * the script never run at all, a permanently visible button is a far smaller
 * problem than one nobody can see.
 */

.dst-pos-right  { right: var(--dst-offset-x, 24px); }
.dst-pos-left   { left: var(--dst-offset-x, 24px); }
.dst-pos-center { left: 50%; margin-left: calc(var(--dst-size, 48px) / -2); }

.dst-button:hover,
.dst-button:focus-visible {
	background: var(--dst-bg-hover, #1b4457);
	color: var(--dst-color-hover, #fff);
}

/* A focus ring that survives any theme: a light and a dark outline on top of
   each other, so it stays visible on either background. */
.dst-button:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px #0d2734;
}

.dst-icon {
	width: var(--dst-icon-size, 20px);
	height: var(--dst-icon-size, 20px);
	display: block;
}

@media (max-width: 782px) {
	.dst-button { display: var(--dst-mobile, flex); }
}

@media (prefers-reduced-motion: reduce) {
	.dst-button { transition: opacity .15s linear; transform: none; }
}

/* ── Abweichende Position auf dem Smartphone ────────────────────
   Unten mittig ist mit dem Daumen oft leichter zu erreichen als
   eine Ecke - vor allem auf großen Geräten und mit einer Hand. */

@media (max-width: 767px) {
	.dst-button.dst-phone-right {
		right: var(--dst-offset-x, 24px);
		left: auto;
		margin-left: 0;
	}

	.dst-button.dst-phone-left {
		left: var(--dst-offset-x, 24px);
		right: auto;
		margin-left: 0;
	}

	.dst-button.dst-phone-center {
		left: 50%;
		right: auto;
		margin-left: calc(var(--dst-size, 48px) / -2);
	}
}

/* ── Eigene Icons ───────────────────────────────────────────────
   Ein SVG aus der Mediathek wird als Maske verwendet, nicht als
   Bild: So nimmt es die eingestellte Icon-Farbe an und wechselt
   sie beim Überfahren mit - und aus der hochgeladenen Datei wird
   nichts ausgewertet oder ausgeführt. */

.dst-icon-mask {
	background-color: currentColor;
	-webkit-mask-image: var(--dst-mask);
	mask-image: var(--dst-mask);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
}

img.dst-icon {
	object-fit: contain;
}

.dst-icon-text {
	display: block;
	width: auto;
	height: auto;
	font-size: var(--dst-icon-size, 20px);
	line-height: 1;
	font-weight: 700;
}


/* ── Darstellung im Builder ─────────────────────────────────────
   Im Builder steht der Button an Ort und Stelle statt am
   Bildschirmrand: fixiert wäre er nicht auswählbar und würde die
   Oberfläche verdecken. */

.dst-button--preview {
	position: relative;
	bottom: auto;
	right: auto;
	left: auto;
	margin-left: 0;
	opacity: 1;
	transform: none;
}
