/* Shared loading system — public + admin. "Gold thread" family (same motif as the
   showroom curtain): top navigation line, page fades, busy buttons. CSS classes only (CSP). */

/* 1. Navigation line — driven by classes from js/shared/loading.js. */
.ui-page-progress {
  height: 3px;
  inset-block-start: 0;
  inset-inline: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.3s ease;
  z-index: 2147483000;
}

.ui-page-progress__bar {
  background: linear-gradient(90deg, transparent, var(--color-accent, #1f4a37) 18%, var(--color-accent-warm, #ac6c4c) 60%, var(--color-accent, #b8922a));
  box-shadow: 0 0 10px color-mix(in srgb, var(--color-accent, #b8922a) 70%, transparent);
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  width: 100%;
}

/* RTL: the thread grows from the reading start. */
[dir="rtl"] .ui-page-progress__bar {
  transform-origin: right center;
}

.ui-page-progress.is-active {
  opacity: 1;
}

/* Quick jump, then a slow trickle that never quite finishes until the next page paints. */
.ui-page-progress.is-active .ui-page-progress__bar {
  animation:
    ui-progress-start 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards,
    ui-progress-trickle 12s cubic-bezier(0.1, 0.6, 0.2, 1) 0.4s forwards;
}

.ui-page-progress.is-done {
  opacity: 0;
  transition: opacity 0.35s ease 0.15s;
}

.ui-page-progress.is-done .ui-page-progress__bar {
  animation: none;
  transform: scaleX(1);
  transition: transform 0.2s ease;
}

@keyframes ui-progress-start {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(0.3);
  }
}

@keyframes ui-progress-trickle {
  from {
    transform: scaleX(0.3);
  }

  to {
    transform: scaleX(0.92);
  }
}

/* 2. Page-to-page fade (cross-document View Transitions; unsupported browsers just navigate). */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: ease;
}

/* 3. Busy buttons: spinner after the label, label dimmed; never resized (no layout jump). */
.is-loading,
[aria-busy="true"]:is(button, a, input[type="submit"]) {
  cursor: progress;
  pointer-events: none;
  position: relative;
}

button.is-loading,
a.is-loading {
  color: color-mix(in srgb, currentcolor 55%, transparent);
}

button.is-loading::after,
a.is-loading::after {
  animation: ui-busy-spin 0.7s linear infinite;
  border: 2px solid color-mix(in srgb, var(--color-accent, #b8922a) 30%, transparent);
  border-block-start-color: var(--color-accent, #b8922a);
  border-radius: 50%;
  content: "";
  height: 1em;
  inset-block-start: calc(50% - 0.5em);
  inset-inline-end: 0.6em;
  position: absolute;
  width: 1em;
}

@keyframes ui-busy-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-page-progress.is-active .ui-page-progress__bar {
    animation: none;
    transform: scaleX(0.6);
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }

  button.is-loading::after,
  a.is-loading::after {
    animation-duration: 1.6s;
  }
}
