/* ==========================================================================
   Skeleton — a shimmering placeholder while content loads.

   Shapes:   <div class="skeleton" style="height: 8rem"></div>
             <div class="skeleton-text"></div>            one line of text (the last of a group is shorter)
             <div class="skeleton-circle"></div>          an avatar
   Real markup: put .skeleton on the element itself — it keeps its exact size and hides
             its content:  <h3 class="card-title skeleton">Monthly revenue</h3>
                           <button class="btn skeleton">Export</button>

   Wrap a whole area in aria-busy="true" so screen readers know it's loading.
   ========================================================================== */

.skeleton,
.skeleton-text,
.skeleton-circle {
  --mo-skeleton-base: color-mix(in oklab, var(--mo-fg-body) 7%, transparent);
  --mo-skeleton-shine: color-mix(in oklab, var(--mo-fg-body) 13%, transparent);
  display: block;
  background: linear-gradient(90deg, var(--mo-skeleton-base) 0 30%, var(--mo-skeleton-shine) 50%, var(--mo-skeleton-base) 70% 100%) 100% 0 / 250% 100% var(--mo-skeleton-base);
  border-radius: var(--mo-radius-control);
  animation: mo-skeleton 1.6s ease-in-out infinite;
}
@keyframes mo-skeleton { to { background-position: 0% 0; } }

/* On real elements: same size, content hidden, no borders or fills of their own */
.skeleton {
  color: transparent !important;
  pointer-events: none;
  user-select: none;
  border-color: transparent !important;
  box-shadow: none !important;
}
.skeleton > *,
.skeleton::placeholder { visibility: hidden; }
.skeleton:is(img, svg, video, canvas) { opacity: 0; }   /* media: just the shape */
:is(h1, h2, h3, h4, h5, h6, p, span, a, label).skeleton { display: inline-block; max-width: 100%; }
:is(h1, h2, h3, h4, h5, h6, p).skeleton { display: block; width: fit-content; }

/* A line of text: as tall as the text, the last line of a group shorter */
.skeleton-text {
  width: 100%;
  height: .75em;
  margin-block: .375em;
  border-radius: var(--mo-radius-pill);
}
.skeleton-text:last-child:not(:first-child) { width: 60%; }
.skeleton-circle {
  --mo-skeleton-size: 2.5rem;
  flex-shrink: 0;
  width: var(--mo-skeleton-size);
  height: var(--mo-skeleton-size);
  border-radius: 50%;
}

/* Pulse instead of shimmer: .skeleton-pulse on the element or a parent */
.skeleton-pulse :is(.skeleton, .skeleton-text, .skeleton-circle),
:is(.skeleton, .skeleton-text, .skeleton-circle).skeleton-pulse {
  background: var(--mo-skeleton-shine);
  animation: mo-skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes mo-skeleton-pulse { 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .skeleton-text, .skeleton-circle { animation: none; background: var(--mo-skeleton-shine); }
}
