/**
 * Page-transition loader — centered logo with a spinner ring.
 *
 * Solid background (no backdrop blur, so it cannot stutter over the hero video)
 * with a soft radial glow for depth. The logo is static (no movement) and only
 * the thin ring rotates, so nothing jumps. The reveal-on-load dissolve is CSS
 * with a JS-driven release once the page is ready; .is-leaving redraws it on an
 * internal link click. Navigation is never delayed.
 *
 * Where supported (Chromium / newer Safari), the native cross-document view
 * transition also crossfades the page so there is no white flash.
 */

@view-transition {
  navigation: auto;
}

.inst-pageloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Solid + subtle radial glow — premium, GPU-cheap, no blur. */
  background:
    radial-gradient(circle at 50% 42%, rgba(31, 106, 225, 0.20) 0%, transparent 58%),
    #0b2c4a;
  opacity: 1;
  visibility: visible;
  will-change: opacity;
  /* Failsafe reveal if JS never runs (kept long; JS normally reveals sooner). */
  animation: inst-pl-out 600ms cubic-bezier(0.4, 0, 0.2, 1) 2600ms forwards;
}

.inst-pageloader__inner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.inst-pageloader__ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
}

/* Thin slow spinner arc around the logo. */
.inst-pageloader__ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: #4f8cff;
  animation: inst-pl-spin 900ms linear infinite;
}

/* Logo is static and always fully visible — no movement, no re-pop. */
.inst-pageloader__logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
}

/* Page is ready — dissolve smoothly (set by JS). */
.inst-pageloader.is-revealed {
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 520ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 520ms;
}

/* Curtain drawn back over while navigating away (set by JS on link click). */
.inst-pageloader.is-leaving {
  animation: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes inst-pl-out {
  0% {
    opacity: 1;
    visibility: visible;
  }
  99% {
    opacity: 0;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@keyframes inst-pl-spin {
  to {
    transform: rotate(360deg);
  }
}

/* No motion: never animate, never block the page (also a safety net). */
@media (prefers-reduced-motion: reduce) {
  .inst-pageloader {
    display: none !important;
    animation: none !important;
  }
}
