/* ----------------------------------------------------------------------------
   progress.css — Every progress and loading surface, in one place: the blocking overlay
   for heavy library operations, the first-load boot overlay, the admin
   panel's first-open panel, the header sync pill, and the upload bar.
   Slice 7 of 16 (see css/tokens.css for the full load order).
   ------------------------------------------------------------------------- */
/* ---- blocking loading overlay for heavy library operations ---- */
.lib-busy {
  position: fixed;
  inset: 0;
  z-index: 120;
  /* above the modals (z 50): while it's up the whole app is inert */
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #000 55%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: drop-in 0.15s ease-out;
}

.lib-busy-card {
  width: min(360px, calc(100% - 40px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 34px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.lib-busy-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: lib-spin 0.8s linear infinite;
}

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

.lib-busy-label {
  font-weight: 650;
  font-size: 15px;
}

.lib-busy-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.lib-busy-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s ease;
}

/* unknown-total work sweeps a chip back and forth instead of tracking a % */
.lib-busy-fill.indeterminate {
  width: 40%;
  animation: lib-sweep 1.1s ease-in-out infinite;
}

@keyframes lib-sweep {
  0% {
    margin-left: -40%;
  }

  100% {
    margin-left: 100%;
  }
}

.lib-busy-count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}

.lib-busy-hint {
  margin: 0;
}

/* ---- first-load boot overlay ---- */
/* Sits over the login card as well as the app shell, so it has to clear the
   login view's own stacking rather than assume the shell's. */
.boot-busy {
  z-index: 130;
}

.boot-busy .lib-busy-card {
  gap: 12px;
}

/* .ghost is borderless by default, which reads as body text here — this is
   the one control on the overlay, so it has to look like one. */
#boot-skip-btn {
  margin-top: 2px;
  border-color: var(--border);
  color: var(--muted);
}

/* ---- admin panel first-open loading ---- */
/* Inline, not an overlay: the header and nav stay live so the tab can be left
   while it loads. Borrows the busy card's spinner/track/label classes. */
.admin-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding: 34px 34px 38px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}

.admin-loading .lib-busy-track {
  max-width: 320px;
}

/* ---- background sync pill (header) ---- */
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  animation: drop-in 0.18s ease-out;
}

.sync-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: sync-pulse 1.2s ease-in-out infinite;
}

@keyframes sync-pulse {

  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 720px) {

  /* the header is tight on phones — the boot overlay already covers the
     first load, and this is only ever an ambient hint */
  .sync-pill {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  .lib-busy-spinner {
    animation-duration: 2.4s;
  }

  .lib-busy-fill.indeterminate {
    animation: none;
    margin-left: 0;
    width: 100%;
    opacity: 0.6;
  }

  .sync-pill-dot {
    animation: none;
    opacity: 0.7;
  }
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes drop-bob {
  50% {
    transform: translateY(-5px);
  }
}

.upload-status {
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 2px;
}

/* upload progress — determinate across a batch; the indeterminate sweep is for
   a single file whose parse duration can't be known in advance. */
.upload-progress {
  margin: 12px 2px 0;
}

/* progress bar and its Cancel button share a row so the button sits inline
   with the track rather than pushing the layout around */
.upload-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-bar-row .upload-track {
  flex: 1;
}

.upload-cancel {
  flex-shrink: 0;
}

/* the library dims and stops accepting input while an upload is writing to it —
   files still populate live underneath, they just can't be touched until done */
.lib-locked {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.2s ease;
}

.upload-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.upload-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.upload-fill.indeterminate {
  width: 32%;
  transition: none;
  animation: upload-sweep 1.15s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes upload-sweep {
  0% {
    transform: translateX(-105%);
  }

  100% {
    transform: translateX(320%);
  }
}

.upload-count {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

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

  .upload-fill.indeterminate {
    animation-duration: 2.4s;
  }
}

