:root { --page-handoff-color: #0c0b10; }

@media (prefers-reduced-motion: no-preference) {
  body[data-transition-images]::before {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--page-handoff-color);
    pointer-events: none;
    animation: page-transition-unseal 240ms ease-out 900ms both;
    content: "";
  }
}

.page-transition {
  --page-transition-ease: cubic-bezier(.44, .03, .24, 1);
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  color: #fff;
}

.page-transition-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgb(145 21 91 / 22%), transparent 62%),
    rgb(13 10 16 / 69%);
  -webkit-backdrop-filter: blur(20px) saturate(.72);
  backdrop-filter: blur(20px) saturate(.72);
}

.page-transition-bridge {
  position: absolute;
  inset: 0;
  background: var(--page-handoff-color);
  opacity: 0;
}

.page-transition-signature {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(76px, 8vw, 108px);
  pointer-events: none;
}

.page-transition-logo {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.page-transition-logo-trace {
  stroke-dasharray: 1;
  animation: page-transition-draw 600ms cubic-bezier(.5, .04, .66, 1) both;
}

.page-transition-percent {
  position: absolute;
  top: calc(100% + 25px);
  color: #fff;
  font: 600 .82rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: .14em;
  white-space: nowrap;
}

.page-transition-meter {
  position: absolute;
  top: calc(100% + 49px);
  width: clamp(66px, 7vw, 92px);
  height: 2px;
  background: rgb(255 255 255 / 25%);
}

.page-transition-meter::after {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff33a1, #d248ee);
  transform: scaleX(var(--page-progress, 0));
  transform-origin: left center;
  content: "";
}

.page-transition[data-phase="leaving"] .page-transition-veil {
  animation: page-transition-cover 340ms var(--page-transition-ease) both;
}

.page-transition[data-phase="leaving"] .page-transition-bridge {
  animation: page-transition-seal 340ms var(--page-transition-ease) both;
}

.page-transition[data-phase="loading"] .page-transition-bridge {
  animation: page-transition-unseal 420ms var(--page-transition-ease) both;
}

.page-transition[data-phase="leaving"] .page-transition-signature {
  visibility: hidden;
}

.page-transition[data-phase="revealing"] { pointer-events: none; }

.page-transition[data-phase="revealing"] .page-transition-veil {
  animation: page-transition-reveal 580ms var(--page-transition-ease) both;
}

.page-transition[data-phase="revealing"] .page-transition-signature {
  animation: page-transition-mark-out 320ms var(--page-transition-ease) both;
}

@keyframes page-transition-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes page-transition-cover {
  from {
    opacity: 0;
    -webkit-backdrop-filter: blur(0) saturate(1);
    backdrop-filter: blur(0) saturate(1);
  }
  to { opacity: 1; }
}

@keyframes page-transition-seal {
  0%, 28% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes page-transition-unseal {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes page-transition-reveal {
  from { clip-path: inset(0); opacity: 1; }
  to {
    clip-path: inset(50% 0);
    opacity: 0;
    -webkit-backdrop-filter: blur(0) saturate(1);
    backdrop-filter: blur(0) saturate(1);
  }
}

@keyframes page-transition-mark-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-8px) scale(.98); }
}

@media (prefers-reduced-motion: reduce) {
  .page-transition * { animation: none !important; }
  .page-transition[data-phase="revealing"] { visibility: hidden; }
}
