/* Shell of a portal page: the frame that stays put while the middle changes.
 *
 * Served from `shared/` rather than bundled, because the first spinner has to
 * paint before the bundle exists.
 */

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#gs-navbar {
  flex: 0 0 auto;
}

#root {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* An id selector outranks the browser's own rule for the attribute, so without
   this the container ships visible. */
#root[hidden] {
  display: none;
}

/* Positioning context of the overlay, which covers the content area and nothing
   else: the navigation bar and the footer stay usable while a view loads. */
#main {
  position: relative;
  flex: 1 0 auto;
}

.portal-boot,
.portal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--theme-bg, #ffffff);
}

.portal-boot {
  flex: 1 0 auto;
  justify-content: center;
  min-height: 60vh;
}

.portal-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  justify-content: flex-start;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

/* Covers at once, and fades on the way out only. A module already in the cache
   mounts a frame or two after the click, so a gradual cover is a race the
   content wins: the view appears, then the spinner hides what was just seen. */
.portal-loading[data-state='visible'] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: none;
}

/* The overlay is as tall as the content it hides, which on a long view is
   several screens: sticky keeps the spinner where the visitor is looking. */
.portal-loading .portal-spinner {
  position: sticky;
  top: calc(50vh - 48px);
}

.portal-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--theme-primary, #1b3a5c) 16%, transparent);
  border-top-color: var(--theme-accent, #0ea5e9);
  animation: portal-spin 720ms linear infinite;
}

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

/* A spinner that cannot spin still has to say the page is working. */
@media (prefers-reduced-motion: reduce) {
  .portal-spinner {
    animation: portal-pulse 1.6s ease-in-out infinite;
  }

  .portal-loading {
    transition: none;
  }
}

@keyframes portal-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
