/* ==========================================================================
   OgbonMath — Loading Progress
   --------------------------------------------------------------------------
   Two surfaces:
     .lp-inline   editorial card mounted inside a route container
                  (replaces tb-loading + lesson loading-state HTML)
     .lp-topbar   thin viewport-pinned strip for background loads
   The bar fill is driven by JS-set inline width; CSS handles transitions
   and the shimmer continuity layer.
   ========================================================================== */

/* ------------------------------------------------------------------------ */
/* Inline surface                                                           */
/* ------------------------------------------------------------------------ */

.lp-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 80px 24px 64px;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
  opacity: 0;
  animation: lp-fade-in 220ms ease-out forwards;
}

@keyframes lp-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.lp-inline.lp-leave {
  animation: lp-fade-out 220ms ease-in forwards;
}

@keyframes lp-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-4px); }
}

.lp-inline-glyph {
  font-family: var(--font-mono, monospace);
  font-size: 36px;
  line-height: 1;
  color: var(--ac);
  margin-bottom: 4px;
  user-select: none;
}

.lp-inline-label {
  font-family: var(--font-display, var(--font-sans));
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--tx);
  line-height: 1.35;
}

.lp-inline-track-wrap {
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
}

.lp-inline-track {
  position: relative;
  height: 4px;
  background: var(--bdr);
  border-radius: 999px;
  overflow: hidden;
}

.lp-inline-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--ac);
  border-radius: 999px;
  transition: width 80ms linear;
  z-index: 2;
}

.lp-inline-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 35%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.06) 65%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: lp-shimmer 1.6s linear infinite;
  z-index: 1;
  pointer-events: none;
}

@keyframes lp-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

[data-theme="light"] .lp-inline-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.04) 35%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 65%,
    transparent 100%
  );
  background-size: 200% 100%;
}

.lp-inline-stage {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--tx3);
  line-height: 1.4;
  min-height: 16px; /* prevents jitter when stage text is empty */
}

/* Error variant — used when fail() is called after the UI mounts. The
   caller may then overwrite this card with its own retry chrome. */
.lp-inline.lp-error .lp-inline-glyph {
  color: var(--rd);
}

.lp-inline.lp-error .lp-inline-fill {
  background: var(--rd);
}

.lp-inline.lp-error .lp-inline-shimmer {
  display: none; /* freeze motion on error */
}

@media (max-width: 480px) {
  .lp-inline {
    padding: 60px 18px 48px;
  }
  .lp-inline-glyph {
    font-size: 30px;
  }
  .lp-inline-label {
    font-size: 15px;
  }
}

/* Respect prefers-reduced-motion: cancel the entrance animation and
   shimmer; keep the bar fill animation since it's meaningful progress. */
@media (prefers-reduced-motion: reduce) {
  .lp-inline {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .lp-inline.lp-leave {
    animation: none;
    opacity: 0;
  }
  .lp-inline-shimmer {
    animation: none;
    background: none;
  }
}

/* ------------------------------------------------------------------------ */
/* Top-edge bar surface (background loads)                                  */
/* ------------------------------------------------------------------------ */

.lp-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.lp-topbar-visible {
  opacity: 1;
}

.lp-topbar-fill {
  height: 100%;
  width: 0%;
  background: var(--ac);
  transition: width 80ms linear;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .lp-topbar {
    transition: none;
  }
  .lp-topbar-fill {
    transition: none;
  }
}
