/*
 * Boot screen shown between the first byte of HTML and React taking over.
 *
 * This file is linked directly from index.html and renders before the
 * application bundle exists, so it has to be entirely self-contained: no
 * variables from the app's stylesheets, no webfont, no images.
 *
 * The wordmark deliberately uses the system font stack rather than Manrope,
 * which is what the marketing site uses. Loading a webfont here would mean the
 * first thing a user sees on every single page load is a font swap - the
 * wordmark rendering in a fallback and then jumping. A loading screen that
 * waits on the network to look right is worse than one that does not.
 *
 * Colours are the brand tokens from sendlz-web, inlined for the same reason:
 *   ink    #14161a      brand  #2e6be6      muted  #6b727c
 */

.app-loading {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  color: #14161a;
}

.app-loading p {
  display: block;
  font-size: 1.17em;
  margin-inline-start: 0;
  margin-inline-end: 0;
  font-weight: normal;
}

/* ---------- wordmark ---------- */

.sendlz-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  /* Height sits here rather than on .app-loading: index.html uses that class
     twice, once for this loader and once for the hidden error panel, and a
     min-height on the shared class would reserve a screenful of empty space
     below the wordmark for a panel that is not displayed. */
  min-height: 55vh;
}

.sendlz-wordmark {
  display: inline-flex;
  align-items: baseline;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 800;
  /* Tightened to sit closer to Manrope ExtraBold, which the system stack is
     standing in for here. */
  letter-spacing: -0.045em;
  line-height: 1;
  color: #14161a;
}

/* The sent-status dot from the logo, doing the work of a spinner: it is the
   one element that is already part of the brand and already means "delivered",
   so animating it reads as progress rather than as decoration. */
.sendlz-dot {
  width: 0.22em;
  height: 0.22em;
  margin-left: 0.14em;
  border-radius: 50%;
  background: #2e6be6;
  animation: sendlz-dot-pulse 1.4s ease-in-out infinite;
}

@keyframes sendlz-dot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.55);
    opacity: 0.35;
  }
}

/* ---------- accelerating bars ---------- */

/* The three bars beneath the logo lockup, sweeping left to right in sequence.
   Widths increase to echo the lockup's acceleration. */
.sendlz-bars {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: clamp(96px, 26vw, 132px);
}

.sendlz-bars span {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: #dce7fb;
  position: relative;
  overflow: hidden;
}

.sendlz-bars span:nth-child(1) {
  width: 55%;
}
.sendlz-bars span:nth-child(2) {
  width: 78%;
}
.sendlz-bars span:nth-child(3) {
  width: 100%;
}

.sendlz-bars span::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #2e6be6;
  transform: translateX(-100%);
  animation: sendlz-bar-sweep 1.4s ease-in-out infinite;
}

.sendlz-bars span:nth-child(1)::after {
  animation-delay: 0s;
}
.sendlz-bars span:nth-child(2)::after {
  animation-delay: 0.12s;
}
.sendlz-bars span:nth-child(3)::after {
  animation-delay: 0.24s;
}

@keyframes sendlz-bar-sweep {
  0% {
    transform: translateX(-100%);
  }
  55%,
  100% {
    transform: translateX(100%);
  }
}

/* Screen readers get a spoken status; the animation is decorative. */
.sendlz-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- respect user preferences ---------- */

/* Motion here is ambient and runs until the app boots, which is exactly the
   kind of thing that triggers vestibular discomfort. Hold the bars part-swept
   so the screen still reads as "working" rather than "stuck". */
@media (prefers-reduced-motion: reduce) {
  .sendlz-dot,
  .sendlz-bars span::after {
    animation: none;
  }
  .sendlz-bars span::after {
    transform: translateX(-35%);
  }
}

@media (prefers-color-scheme: dark) {
  .app-loading {
    color: #f4f4f2;
  }
  .sendlz-wordmark {
    color: #f4f4f2;
  }
  .sendlz-bars span {
    background: #262b33;
  }
}

/* ---------- failure state ---------- */

/* Revealed by the timeout in index.html when the bundle never ran. Styled here
   because this is the only stylesheet that exists at that point. */
.sendlz-error {
  max-width: 32rem;
  text-align: center;
}

.sendlz-error h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.sendlz-error p {
  font-size: 1rem;
  line-height: 1.55;
  color: #6b727c;
  margin: 0 0 1rem;
}

.sendlz-retry {
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: #2e6be6;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
}

.sendlz-retry:hover {
  background: #1f55c4;
}

/* Keyboard users need to see focus; the default outline is removed by the
   border reset above on some engines. */
.sendlz-retry:focus-visible {
  outline: 2px solid #2e6be6;
  outline-offset: 3px;
}

.sendlz-error-hint {
  font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
  .sendlz-error p {
    color: #9aa1ab;
  }
}
