/*
	Floating menu pill. The header now scrolls away with the page;
	once it leaves the viewport, this fixed pill fades in (top-right).
	Clicking it unfolds a panel of the same nav links — the pill and
	panel share the black capsule look so it reads as the button
	expanding into the menu. Shared by index.html and smd.html.
*/
.menuPill {
	position: fixed;
	top: clamp(0.9rem, 2vw, 1.4rem);
	/*
		Align the pill's right edge to the content column's right edge
		(same line as the header menu links) rather than the viewport
		edge. The column is min(87.5%, --widthContent) centred, so its
		right margin is whichever of these is larger.
	*/
	right: max(6.25vw, calc((100vw - var(--widthContent)) / 2));
	z-index: 40;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	/* Hidden until the header scrolls out of view */
	opacity: 0;
	transform: translateY(-130%);
	pointer-events: none;
	transition:
		opacity 0.4s var(--easeOut),
		transform 0.55s var(--easeSnap);
}

.menuPill.isVisible {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.menuPill__button {
	display: inline-flex;
	align-items: center;
	gap: 0.7rem;
	height: 3.5rem;
	padding: 0 1.6rem;
	border: none;
	border-radius: var(--radiusPill);
	background: var(--colorBlack);
	color: var(--colorWhite);
	font-family: var(--fontSans);
	font-size: var(--textSmall);
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.55);
	transition: transform 0.3s var(--easeOut);
}

.menuPill__button:hover {
	transform: translateY(-2px);
}

/* Three bars; the middle fades out and the outer two form an X when open */
.menuPill__icon {
	position: relative;
	width: 1.2rem;
	height: 0.85rem;
	flex-shrink: 0;
}

.menuPill__icon span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	border-radius: 2px;
	background: currentcolor;
	transition: transform 0.35s var(--easeSnap), opacity 0.2s var(--easeOut);
}

.menuPill__icon span:nth-child(1) {
	top: 0;
}

.menuPill__icon span:nth-child(2) {
	top: 50%;
	transform: translateY(-50%);
}

.menuPill__icon span:nth-child(3) {
	bottom: 0;
}

.menuPill.isOpen .menuPill__icon span:nth-child(1) {
	transform: translateY(0.385rem) rotate(45deg);
}

.menuPill.isOpen .menuPill__icon span:nth-child(2) {
	opacity: 0;
}

.menuPill.isOpen .menuPill__icon span:nth-child(3) {
	transform: translateY(-0.385rem) rotate(-45deg);
}

/* The unfolding panel — same black capsule lineage as the pill */
.menuPill__panel {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 13rem;
	margin-top: 0.6rem;
	padding: 0.6rem;
	border-radius: 1.4rem;
	background: var(--colorBlack);
	box-shadow: 0 26px 64px -22px rgba(0, 0, 0, 0.6);
	transform-origin: top right;
	transform: scale(0.72);
	opacity: 0;
	pointer-events: none;
	transition:
		transform 0.42s var(--easeSnap),
		opacity 0.28s var(--easeOut);
}

.menuPill.isOpen .menuPill__panel {
	transform: scale(1);
	opacity: 1;
	pointer-events: auto;
}

.menuPill__panel a {
	padding: 0.75rem 1rem;
	border-radius: 0.9rem;
	color: var(--colorWhite);
	font-size: var(--textBody);
	font-weight: 500;
	transition: background-color 0.25s var(--easeOut);
}

.menuPill__panel a:hover {
	background: rgba(255, 255, 255, 0.12);
}

@media (prefers-reduced-motion: reduce) {
	.menuPill,
	.menuPill__panel,
	.menuPill__icon span {
		transition: none;
	}
}

@media (max-width: 720px) {
	.menuPill {
		position: fixed;
		top: 1rem;
		left: calc(100vw - 4.75rem);
		right: auto;
		z-index: 999;
		width: 3rem;
		opacity: 1;
		transform: none;
		visibility: visible;
		pointer-events: auto;
	}

	.menuPill__button {
		justify-content: center;
		width: 3rem;
		height: 3rem;
		padding: 0;
		border: 1px solid rgba(255, 255, 255, 0.35);
		background: rgba(0, 0, 0, 0.72);
		backdrop-filter: blur(10px);
		-webkit-backdrop-filter: blur(10px);
	}

	.menuPill__label {
		display: none;
	}

	.menuPill__panel {
		position: absolute;
		top: 100%;
		right: 0;
		width: min(13rem, calc(100vw - 2rem));
		min-width: 0;
	}
}
