/* Page-to-page transition: a dark whirlpool spirals in from the centre to
   cover the page, the next page loads underneath it, then it spirals back
   into the centre to uncover the new page. Loaded as a plain stylesheet in
   each page's <head> so it applies before the first paint (src/pageTransition.js
   drives the classes on <html>). */
.page-whirl {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  background: #0a0a0b;
  clip-path: circle(0% at 50% 50%);
}
/* the rays: thin gold spokes that turn as the whirl opens and closes */
.page-whirl::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 260vmax;
  height: 260vmax;
  margin: -130vmax 0 0 -130vmax;
  background:
    radial-gradient(circle, rgba(10, 10, 11, 1) 0 3vmax, rgba(10, 10, 11, 0) 22vmax),
    repeating-conic-gradient(from 0deg, rgba(214, 195, 161, 0) 0deg 8deg, rgba(214, 195, 161, 0.16) 8deg 9deg);
}
/* the eye of the whirl */
.page-whirl::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3.2rem;
  height: 3.2rem;
  margin: -1.6rem 0 0 -1.6rem;
  border: 1px solid rgba(214, 195, 161, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 2rem rgba(214, 195, 161, 0.18);
}

/* covered: a page waiting underneath (arriving, or restoring its position) */
html.whirl-cover .page-whirl {
  visibility: visible;
  pointer-events: auto;
  clip-path: circle(150% at 50% 50%);
}
html.whirl-cover .page-whirl::before { animation: whirl-idle 6s linear infinite; }

/* leaving: spiral in from the centre until the page is covered */
html.whirl-in .page-whirl {
  visibility: visible;
  pointer-events: auto;
  animation: whirl-open 0.65s cubic-bezier(0.7, 0, 0.3, 1) forwards;
}
html.whirl-in .page-whirl::before { animation: whirl-spin-in 0.65s cubic-bezier(0.7, 0, 0.3, 1) forwards; }

/* arrived: spiral back into the centre, uncovering the new page */
html.whirl-out .page-whirl {
  visibility: visible;
  animation: whirl-close 0.8s cubic-bezier(0.7, 0, 0.3, 1) forwards;
}
html.whirl-out .page-whirl::before { animation: whirl-spin-out 0.8s cubic-bezier(0.7, 0, 0.3, 1) forwards; }

@keyframes whirl-open { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(150% at 50% 50%); } }
@keyframes whirl-close { from { clip-path: circle(150% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
@keyframes whirl-spin-in { from { transform: rotate(-220deg) scale(0.35); } to { transform: rotate(0deg) scale(1); } }
@keyframes whirl-spin-out { from { transform: rotate(0deg) scale(1); } to { transform: rotate(220deg) scale(0.35); } }
@keyframes whirl-idle { to { transform: rotate(360deg); } }

/* reduced motion: a plain quick fade instead of the spiral */
@media (prefers-reduced-motion: reduce) {
  .page-whirl { clip-path: none; opacity: 0; }
  html.whirl-cover .page-whirl { clip-path: none; opacity: 1; }
  html.whirl-in .page-whirl { animation: whirl-fade-in 0.25s ease forwards; }
  html.whirl-out .page-whirl { animation: whirl-fade-out 0.3s ease forwards; }
  html.whirl-cover .page-whirl::before,
  html.whirl-in .page-whirl::before,
  html.whirl-out .page-whirl::before { animation: none; }
  @keyframes whirl-fade-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes whirl-fade-out { from { opacity: 1; } to { opacity: 0; } }
}
