/**
 * Grapple to Top. The scripts draw the gun (or, with .bmn-gtt--web, Spider-Man's
 * hand) into .bmn-gtt and, on the first shot, add the flying grapnel (or web) and
 * its line. While it fires (.is-firing) the script sets transforms every frame,
 * so CSS transitions are off and the moving parts get their own layers.
 */

.bmn-gtt {
	--bmn-gtt-w: 32px;
	position: fixed;
	z-index: 9990; /* Under the admin bar, menu overlay and lightboxes; over the sticky archive bar (100). */
	right: max(24px, env(safe-area-inset-right));
	bottom: max(24px, env(safe-area-inset-bottom), var(--bmn-gtt-floor, 0px)); /* The script sets the floor: above the copyright bar. */
	width: var(--bmn-gtt-w);
	height: calc(var(--bmn-gtt-w) * 85 / 35);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transform-origin: 58% 25.4%; /* The muzzle, so it hangs from the line. */
	transition: opacity 0.25s, transform 0.25s, visibility 0s 0.25s;
	-webkit-tap-highlight-color: transparent;
}

@media (max-width: 599px) {
	.bmn-gtt {
		--bmn-gtt-w: 26px;
	}
}

/* Spider-Man's hand: 410 × 580, swaying from where the web leaves it. */
.bmn-gtt--web {
	--bmn-gtt-w: 40px;
	height: calc(var(--bmn-gtt-w) * 580 / 410);
	transform-origin: 36.3% 70%;
}

@media (max-width: 599px) {
	.bmn-gtt--web {
		--bmn-gtt-w: 34px;
	}
}

/* Batman News shows a floating Forums button (56px round, 16px in and 32px up)
   at 1024px and under: there the button stands centred on top of it. */
@media (max-width: 1024px) {
	.bmn-gtt--over-forums {
		right: calc(max(16px, env(safe-area-inset-right)) + (56px - var(--bmn-gtt-w)) / 2);
		bottom: max(calc(max(32px, env(safe-area-inset-bottom)) + 70px), var(--bmn-gtt-floor, 0px));
	}
}

/* On touch screens, a bigger target than the drawing: 9px more each side, so the
   gun is 44px wide to a finger. Hidden with the button, so it never blocks taps. */
@media (pointer: coarse) {
	.bmn-gtt::before {
		content: "";
		position: absolute;
		inset: -8px -9px;
	}
}

.bmn-gtt.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition-delay: 0s;
}

.bmn-gtt svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
	/* The light edge is in the SVG (see grapple.js); this is the soft shadow below. */
	filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.35));
}

/* Hover only where there's a real pointer; on touch it sticks after a tap. */
@media (hover: hover) {
	.bmn-gtt svg {
		transform-origin: 50% 100%;
		transition: transform 0.2s;
	}

	.bmn-gtt:hover svg {
		transform: rotate(-4deg);
	}
}

.bmn-gtt:focus-visible {
	outline: 2px solid #af001c;
	outline-offset: 4px;
}

.bmn-gtt.is-firing,
.bmn-gtt.is-firing svg {
	transition: none;
}

/* Moved every frame, so composited rather than repainted. The hook and line are
   display: none (hidden) between shots, so they hold no layer then. */
.bmn-gtt.is-firing,
.bmn-gtt__hook,
.bmn-gtt__rope {
	will-change: transform;
}

.bmn-gtt.is-firing svg {
	transform: none;
}

.bmn-gtt.is-launched .bmn-gtt__loaded {
	opacity: 0;
}

.bmn-gtt__hook,
.bmn-gtt__rope {
	position: fixed;
	z-index: 9990;
	top: 0;
	pointer-events: none;
}

.bmn-gtt__hook {
	transform-origin: 50% 10%;
}

.bmn-gtt__hook svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

.bmn-gtt__blades {
	transform-box: fill-box;
	transform-origin: 50% 0;
}

/* 1px tall, stretched to length with scaleY. Steel gray, which shows on white,
   red and dark backgrounds alike, so it needs no dark-mode color. */
.bmn-gtt__rope {
	width: 1.5px;
	height: 1px;
	background: #8c8c8c;
	transform-origin: 0 0;
}

/* A web strand: pale, with gray edges so it shows on white too. The gradient
   runs across it, so stretching it lengthwise doesn't smear it. */
.bmn-gtt__rope--web {
	width: 2.5px;
	background: linear-gradient(90deg, #6b6b6b, #f2f2f2 40% 60%, #6b6b6b);
}

@media (prefers-reduced-motion: reduce) {
	.bmn-gtt,
	.bmn-gtt svg {
		transition: none;
	}
}

@media print {
	.bmn-gtt {
		display: none;
	}
}

/* Focus lands on the page wrapper after the climb; no ring around the whole page. */
[data-bmn-gtt-focus]:focus {
	outline: none;
}
