/* Nav button: "AI Readiness" and "Visit VAULT" (with the VAULT logo) take turns
   in the same spot, on a 14s loop: each stays about 5.5s, then fades away while
   the other rises in. Pure CSS: both buttons share one grid cell, and visibility
   is animated together with the fade, so only the button you can see can be
   clicked or focused. Pointing at or tabbing to the button holds the loop, so it
   never changes under the cursor.

   Timeline of one 14s loop:
     0    – 3.2s   AI Readiness
     3.2  – 3.9s   AI Readiness leaves     (3.6 – 4.7s VAULT arrives)
     4.7  – 10.2s  VAULT
     10.2 – 10.9s  VAULT leaves            (10.6 – 11.7s AI Readiness arrives)
     11.7 – 14s    AI Readiness, then the loop starts over */

/* On narrow phones the nav is a little too tight for logo + button; like the
   original lone button, the pair may give up a few pixels (min-width: 0). */
.nav-swap {
	display: grid;
	grid-template-columns: minmax(0, auto);
	justify-items: end;
	align-items: center;
	min-width: 0;
}

/* The wrappers carry the swap, so each button keeps its own hover lift. */
.nav-swap-item {
	grid-area: 1 / 1;
	display: flex;
	min-width: 0;
	max-width: 100%;
	animation-duration: 14s;
	animation-iteration-count: infinite;
	animation-fill-mode: both;
}

.nav-swap-a { animation-name: nav-swap-a; }
.nav-swap-b { animation-name: nav-swap-b; }

.nav-swap:hover .nav-swap-item,
.nav-swap:focus-within .nav-swap-item,
.nav-swap:hover .nav-vault::before,
.nav-swap:focus-within .nav-vault::before {
	animation-play-state: paused;
}

/* Leaving: lift, blur and fade. Arriving: rise in from a slight blur. */
@keyframes nav-swap-a {
	0%, 22.857% {
		opacity: 1; filter: blur(0); transform: none; visibility: visible;
		animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
	}
	27.857% {
		opacity: 0; filter: blur(4px); transform: translateY(-8px) scale(0.96); visibility: hidden;
	}
	75.714% {
		opacity: 0; filter: blur(4px); transform: translateY(8px) scale(0.96); visibility: hidden;
		animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
	}
	83.571%, 100% {
		opacity: 1; filter: blur(0); transform: none; visibility: visible;
	}
}

@keyframes nav-swap-b {
	0%, 25.714% {
		opacity: 0; filter: blur(4px); transform: translateY(8px) scale(0.96); visibility: hidden;
		animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
	}
	33.571%, 72.857% {
		opacity: 1; filter: blur(0); transform: none; visibility: visible;
		animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
	}
	77.857%, 100% {
		opacity: 0; filter: blur(4px); transform: translateY(-8px) scale(0.96); visibility: hidden;
	}
}

/* The VAULT button: the VAULT card's near-black, edged with VAULT's four stream
   colours, which drift slowly around the pill. */
.btn-primary.nav-vault {
	gap: 8px;
	padding: 9px 23px;
	border: 1px solid transparent;
	color: #F5F5F7;
	background:
		linear-gradient(#050507, #050507) padding-box,
		linear-gradient(90deg, #ff9f0a, #ffd60a, #4da3ff, #30d158, #ff9f0a) border-box;
	background-size: 100% 100%, 200% 100%;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
	animation: nav-vault-edge 9s linear infinite;
}

.btn-primary.nav-vault:hover {
	background:
		linear-gradient(#000, #000) padding-box,
		linear-gradient(90deg, #ff9f0a, #ffd60a, #4da3ff, #30d158, #ff9f0a) border-box;
	background-size: 100% 100%, 200% 100%;
	box-shadow: 0 0 28px rgba(77, 163, 255, 0.26), 0 4px 18px rgba(0, 0, 0, 0.18);
}

@keyframes nav-vault-edge {
	from { background-position: 0 0, 0% 0; }
	to { background-position: 0 0, 200% 0; }
}

/* Each time VAULT arrives, a sheen sweeps across it once (the hover sheen is
   the button's own ::after and still works). */
.nav-vault::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: -80%;
	width: 50%;
	background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.16), transparent);
	transform: skewX(-20deg);
	pointer-events: none;
	animation: nav-vault-sheen 14s infinite both;
}

@keyframes nav-vault-sheen {
	0%, 29.286% { left: -80%; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
	38.571%, 100% { left: 130%; }
}

.nav-vault img {
	display: block;
	flex: none;
	height: 18px;
	width: auto;
}

/* Phones: next to the Pillar Delta logo there is room for the VAULT logo only
   (the button keeps its "Visit VAULT" label for screen readers). */
@media (max-width: 440px) {
	.nav-vault span {
		display: none;
	}
	.btn-primary.nav-vault {
		padding: 9px 17px;
	}
	.nav-vault img {
		height: 17px;
	}
}

/* Without motion: the two still take turns, but as a plain cross-fade, and the
   VAULT edge and sheen stay still. */
@media (prefers-reduced-motion: reduce) {
	.nav-swap-a { animation-name: nav-swap-a-still; }
	.nav-swap-b { animation-name: nav-swap-b-still; }
	.btn-primary.nav-vault,
	.nav-vault::before {
		animation: none;
	}
}

@keyframes nav-swap-a-still {
	0%, 22.857% { opacity: 1; visibility: visible; }
	27.857%, 75.714% { opacity: 0; visibility: hidden; }
	83.571%, 100% { opacity: 1; visibility: visible; }
}

@keyframes nav-swap-b-still {
	0%, 25.714% { opacity: 0; visibility: hidden; }
	33.571%, 72.857% { opacity: 1; visibility: visible; }
	77.857%, 100% { opacity: 0; visibility: hidden; }
}
