/**
 * Loading ring — DaisyUI-style pulse rings, themed with brand colors.
 * Usage:
 *   <span class="loading loading-ring loading-md loading-brand"></span>
 */

:root {
  --loading-ring-mask: url("data:image/svg+xml,%3Csvg width='44' height='44' viewBox='0 0 44 44' xmlns='http://www.w3.org/2000/svg' stroke='%23fff'%3E%3Cg fill='none' fill-rule='evenodd' stroke-width='2'%3E%3Ccircle cx='22' cy='22' r='1'%3E%3Canimate attributeName='r' begin='0s' dur='1.8s' values='1;20' calcMode='spline' keySplines='0.165, 0.84, 0.44, 1' keyTimes='0;1' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-opacity' begin='0s' dur='1.8s' values='1;0' calcMode='spline' keySplines='0.3, 0.61, 0.355, 1' keyTimes='0;1' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='22' cy='22' r='1'%3E%3Canimate attributeName='r' begin='-0.9s' dur='1.8s' values='1;20' calcMode='spline' keySplines='0.165, 0.84, 0.44, 1' keyTimes='0;1' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-opacity' begin='-0.9s' dur='1.8s' values='1;0' calcMode='spline' keySplines='0.3, 0.61, 0.355, 1' keyTimes='0;1' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
}

.loading {
  display: inline-block;
  aspect-ratio: 1 / 1;
  width: 1.5rem;
  vertical-align: middle;
  background-color: currentColor;
  pointer-events: none;
  flex-shrink: 0;
}

.loading-ring {
  -webkit-mask-image: var(--loading-ring-mask);
  mask-image: var(--loading-ring-mask);
  -webkit-mask-size: 100%;
  mask-size: 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.loading-xs { width: 1rem; }
.loading-sm { width: 1.25rem; }
.loading-md { width: 1.5rem; }
.loading-lg { width: 2.25rem; }
.loading-xl { width: 3rem; }

/* Brand — uses Admin → Brand Theme primary/secondary */
.loading-brand {
  color: var(--color-primary);
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-secondary, var(--color-primary)) 55%,
    color-mix(in srgb, var(--color-accent, var(--color-primary)) 85%, white) 100%
  );
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--color-primary) 35%, transparent));
}

.loading-brand-soft {
  color: color-mix(in srgb, var(--color-primary) 55%, var(--site-text-muted));
  background: color-mix(in srgb, var(--color-primary) 22%, transparent);
  filter: none;
}

.loading-white {
  color: #fff;
  background: #fff;
  filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.15));
}

/* —— Page transition progress bar —— */
#page-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10001;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#page-progress.is-active {
  opacity: 1;
}

.page-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(
    90deg,
    var(--color-primary) 0%,
    var(--color-secondary, var(--color-primary)) 55%,
    color-mix(in srgb, var(--color-accent, var(--color-primary)) 90%, white) 100%
  );
  box-shadow: 0 0 12px color-mix(in srgb, var(--color-primary) 45%, transparent);
  transform-origin: left center;
}

#page-progress.is-active:not(.is-complete) .page-progress-bar {
  animation: page-progress-run 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

#page-progress.is-complete .page-progress-bar {
  width: 100% !important;
  animation: none;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes page-progress-run {
  0% { width: 0; margin-left: 0; opacity: 1; }
  45% { width: 52%; margin-left: 12%; opacity: 1; }
  75% { width: 68%; margin-left: 28%; opacity: 0.95; }
  100% { width: 88%; margin-left: 100%; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #page-progress { display: none; }

  .loading-ring {
    -webkit-mask-image: none;
    mask-image: none;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
    border-top-color: var(--color-primary);
    background: transparent !important;
    animation: loading-ring-spin 0.8s linear infinite;
    filter: none;
  }
}

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