/*
 * Startup splash, shared by:
 * - /boot (public/boot/index.html), the installed app's start_url, served
 *   instantly from the service worker cache while "/" loads from the network;
 * - <CommonBootSplash />, the same splash rendered over every server-rendered
 *   page (browser and installed app) and removed once Vue has hydrated.
 * Pure CSS on purpose: it must animate before any JavaScript has loaded.
 * Kept outside the Nuxt bundle so the static boot page can use it too.
 */

.boot {
  --boot-ground: #ffffff;
  --boot-track: #dce2dd;
  --boot-enamel: #0e4d2e;
  --boot-muted: #5b6560;

  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--boot-ground);
  font-family: 'Readex Pro', 'Public Sans', system-ui, sans-serif;
  text-align: center;
}

.dark .boot {
  --boot-ground: #0f1311;
  --boot-track: #2a322d;
  --boot-enamel: #4fb37a;
  --boot-muted: #a3ada7;
}

/* Safety net: if the app never hydrates (script error), stop covering the
   server-rendered page after a while instead of hanging forever. */
.boot--overlay {
  animation: boot-give-up 0s linear 15s forwards;
}

/* The logo sits at the exact centre of the screen, where Android draws the
   icon of its native launch screen, so that screen hands over seamlessly. */
.boot__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
}

/* Wordmark and hint hang below the mark without pushing it off centre. */
.boot__below {
  position: absolute;
  top: calc(50% + 74px + 20px);
  inset-inline: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* The orbit: the hero's three enamel steps (full, 55%, 20%) set on a ring. */
.boot__orbit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: boot-spin 1.2s linear infinite;
}

.boot__orbit circle {
  fill: none;
  stroke-width: 3;
}

.boot__track {
  stroke: var(--boot-track);
}

.boot__step {
  stroke: var(--boot-enamel);
  stroke-dasharray: 56 396.4;
}

.boot__step--2 {
  stroke-dashoffset: 62;
  opacity: 0.55;
}

.boot__step--3 {
  stroke-dashoffset: 124;
  opacity: 0.2;
}

.boot__logo {
  width: 92px;
  height: auto;
  animation: boot-breathe 2.4s ease-in-out infinite;
}

.boot__wordmark {
  height: 32px;
  width: auto;
}

.boot__wordmark--dark,
.dark .boot__wordmark--light {
  display: none;
}

.dark .boot__wordmark--dark {
  display: block;
}

/* Only shown when the wait gets long, to say it is loading, not stuck. */
.boot__hint {
  max-width: 18rem;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.43;
  color: var(--boot-muted);
  opacity: 0;
  animation: boot-fade-in 0.4s ease 6s forwards;
}

.boot--offline .boot__hint {
  animation-delay: 0s;
}

/* Entrance, on the boot page only (the overlay continues it, no replay).
   The logo is already there, as on the native launch screen; the ring and
   the wordmark come in around it. */
.boot--enter .boot__orbit {
  animation:
    boot-spin 1.2s linear infinite,
    boot-appear 0.3s ease both;
}

.boot--enter .boot__wordmark {
  animation: boot-rise 0.45s ease 0.12s both;
}

/* Fade out when the overlay is removed (<Transition name="boot">). Taps go
   through at once: the page is ready, it must not wait for the fade. */
.boot-leave-active {
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.boot-leave-to {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .boot__orbit,
  .boot__logo,
  .boot--enter .boot__orbit,
  .boot--enter .boot__wordmark {
    animation: none;
  }
}

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

@keyframes boot-breathe {
  50% {
    transform: scale(0.95);
  }
}

@keyframes boot-appear {
  from {
    opacity: 0;
  }
}

@keyframes boot-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes boot-fade-in {
  to {
    opacity: 1;
  }
}

@keyframes boot-give-up {
  to {
    visibility: hidden;
    pointer-events: none;
  }
}
