/**
 * Back To Top 001 — a square button with an upward arrow, fixed in the bottom
 * right corner, shown once the page has scrolled (pattern.js adds `.is-shown`).
 *
 * The square is a core Button in the Secondary style (the header's "Naroči se"):
 * frosted glass at rest, filled with ink on hover, both from asteri.css §3. This
 * only makes it square, hides the label and turns the arrow.
 */
.back-to-top-001 {
	--back-to-top-001-size: 3rem;
	--back-to-top-001-offset: var(--space-sm);
	/* A pixel larger than a button's arrow, as it is the whole content of the
	   square — the same as the slider arrows. Whole pixels, for the reason
	   asteri.css §3 gives. */
	--button-arrow: 14px;
	margin: 0;
}

/* Front end: fixed in the corner, hidden until pattern.js shows it. Doubled, as
   the editor puts `position: relative` on every block (and the editor rule below
   puts it back in flow there). Hidden only under `html.js` — with no script there
   is nothing to show it, so it simply stays visible. Under the header (1000) and
   the mega-menu overlay (900), above content. */
.back-to-top-001.back-to-top-001 {
	position: fixed;
	inset-block-end: max(var(--back-to-top-001-offset), env(safe-area-inset-bottom, 0px));
	inset-inline-end: max(var(--back-to-top-001-offset), env(safe-area-inset-right, 0px));
	z-index: 850;
}

html.js .back-to-top-001 {
	opacity: 0;
	visibility: hidden;
	translate: 0 var(--space-xs);
	transition: opacity 0.3s ease, translate 0.3s ease, visibility 0s linear 0.3s;
}

html.js .back-to-top-001.is-shown {
	opacity: 1;
	visibility: visible;
	translate: none;
	transition: opacity 0.3s ease, translate 0.3s ease;
}

/* The square. Over the button's (0,2,0) padding, type and gap. The label is
   kept as the link's text so it stays the accessible name; font-size 0 takes it
   off the screen, and the reel is sized in px, so it stays. */
.back-to-top-001 .back-to-top-001__button .wp-block-button__link {
	inline-size: var(--back-to-top-001-size);
	block-size: var(--back-to-top-001-size);
	padding: 0;
	gap: 0;
	font-size: 0;
}

/* The arrow, as in Feature List 003's back button: the corner arrow turned to
   point up, in a window a little larger than the glyph — turned, it runs along
   its diagonal, longer than its own side. On hover the reel rolls UP through two
   glyphs: the resting arrow leaves, the next passes through, the third lands. */
.back-to-top-001 .button-arrow {
	--back-to-top-001-window: calc(var(--button-arrow) + 6px);
	inline-size: var(--back-to-top-001-window);
	block-size: var(--back-to-top-001-window);
}

.back-to-top-001 .button-arrow__glyph {
	margin-inline: auto;
	rotate: -45deg;
}

.back-to-top-001 .button-arrow__reel {
	/* Half the window's extra 6px, so the glyph sits centred in it. */
	padding-block-start: 3px;
	transition-duration: calc(var(--button-arrow-roll) * 1.8);
}

.back-to-top-001 .wp-block-button__link:hover .button-arrow__reel,
.back-to-top-001 .wp-block-button__link:focus-visible .button-arrow__reel {
	transform: translateY(calc(-2 * (var(--button-arrow) + var(--button-arrow-slot-gap))));
}

/* Where focus goes after the jump (pattern.js), so the next Tab starts at the
   top of the page. It is not a control, so it shows no ring. */
.back-to-top-001-focus:focus {
	outline: none;
}

/* Editor: in flow, visible, so it can be selected — fixed, it would float over
   the canvas, and hidden, it could not be found. */
.editor-styles-wrapper .back-to-top-001.back-to-top-001 {
	position: relative;
	inset: auto;
	opacity: 1;
	visibility: visible;
	translate: none;
}

@media (prefers-reduced-motion: reduce) {
	html.js .back-to-top-001,
	html.js .back-to-top-001.is-shown {
		translate: none;
		transition: none;
	}
}
