/* ============================================================
 * ds-loading — loading / progress / skeleton components.
 *
 * Three families, all MUI/MODEC-style:
 *
 * 1. `.ds-circular` — spinning arc, indeterminate.
 *    Sizes: --xs (12), --sm (16), --md (24, default), --lg (32).
 *
 * 2. `.ds-linear` — horizontal bar, indeterminate.
 *    Variants: default (primary brand), --inherit, --secondary.
 *
 * 3. `.ds-skeleton` — placeholder shimmer.
 *    Variants: --text (low-height rounded bar),
 *              --circle (round avatar placeholder),
 *              --rect (rounded rectangle, custom size).
 *
 * Apply via class on any element. Sizing is intrinsic unless
 * overridden; e.g. `<div class="ds-skeleton ds-skeleton--rect"
 * style="height: 200px;">`.
 * ============================================================ */
@layer components {

/* ── Loading row — spinner + text label layout helper ─────── */
.ds-loading-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-family: var(--font-family-sans);
  font-size: 14px;
}

/* ── Loading center — fills its container and centers the spinner
 *    (both axes). Default min-height keeps the placeholder visible
 *    even if the parent has no fixed height. Override min-height
 *    inline if a specific layout needs it. */
.ds-loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 240px;
}

/* ── 1. Circular progress (indeterminate) ──────────────────── */
.ds-circular {
  display: inline-block;
  vertical-align: middle;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(63, 91, 255, 0.15);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: ds-circular-spin 0.8s linear infinite;
}
.ds-circular--xs { width: 12px; height: 12px; border-width: 2px; }
.ds-circular--sm { width: 16px; height: 16px; border-width: 2px; }
.ds-circular--md { width: 24px; height: 24px; border-width: 3px; }
.ds-circular--lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes ds-circular-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── 2. Linear progress (indeterminate, MUI two-bar pattern) ── */
.ds-linear {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 4px;
  background: rgba(63, 91, 255, 0.18);
  border-radius: 2px;
}
.ds-linear::before,
.ds-linear::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--color-accent);
  border-radius: inherit;
}
.ds-linear::before { animation: ds-linear-bar1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; }
.ds-linear::after  { animation: ds-linear-bar2 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite; }

/* Color variants */
.ds-linear--secondary {
  background: rgba(222, 50, 110, 0.18);
}
.ds-linear--secondary::before,
.ds-linear--secondary::after {
  background: var(--c-secondary-500);
}
.ds-linear--inherit {
  background: currentColor;
  opacity: 1;
}
.ds-linear--inherit::before,
.ds-linear--inherit::after {
  background: currentColor;
  opacity: 0.4;
}

@keyframes ds-linear-bar1 {
  0%   { left: -35%;  right: 100%; }
  60%  { left: 100%;  right: -90%; }
  100% { left: 100%;  right: -90%; }
}
@keyframes ds-linear-bar2 {
  0%   { left: -200%; right: 100%; }
  60%  { left: 107%;  right: -8%;  }
  100% { left: 107%;  right: -8%;  }
}

/* ── 3. Skeleton placeholder ───────────────────────────────── */
.ds-skeleton {
  display: block;
  background: linear-gradient(
    90deg,
    var(--c-neutral-200) 0%,
    var(--c-neutral-100) 50%,
    var(--c-neutral-200) 100%
  );
  background-size: 200% 100%;
  animation: ds-skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}
.ds-skeleton--text {
  height: 1em;
  border-radius: 4px;
  width: 100%;
  /* Sit on the text baseline so the bar replaces a line of text inline. */
  display: inline-block;
  vertical-align: middle;
}
.ds-skeleton--circle {
  border-radius: 50%;
  width: 40px;
  height: 40px;
}
.ds-skeleton--rect {
  border-radius: var(--radius-md);
  width: 100%;
  height: 120px;
}

@keyframes ds-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .ds-circular,
  .ds-linear::before,
  .ds-linear::after,
  .ds-skeleton {
    animation: none;
  }
}

} /* end @layer components */
