/* ==========================================================================
   Ledger Shared Loading Foundation
   Single source of truth for skeletons, shimmers, and empty states.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
  --ldg-skel-base:        rgba(148, 163, 184, .12);
  --ldg-skel-shine:       rgba(148, 163, 184, .30);
  --ldg-skel-radius-pill: 999px;
  --ldg-skel-radius-sm:   6px;
  --ldg-skel-radius-md:   10px;
  --ldg-skel-radius-lg:   14px;
  --ldg-shimmer-duration: 1.6s;
}

[data-theme="dark"] {
  --ldg-skel-base:  rgba(148, 163, 184, .07);
  --ldg-skel-shine: rgba(148, 163, 184, .16);
}

/* --------------------------------------------------------------------------
   Keyframe — shared shimmer sweep
   -------------------------------------------------------------------------- */
@keyframes ldgShimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* --------------------------------------------------------------------------
   Base skeleton
   -------------------------------------------------------------------------- */
.ldg-skel {
  display: block;
  background: linear-gradient(
    90deg,
    var(--ldg-skel-base)  0%,
    var(--ldg-skel-shine) 50%,
    var(--ldg-skel-base)  100%
  );
  background-size: 200% 100%;
  animation: ldgShimmer var(--ldg-shimmer-duration) ease-in-out infinite;
  border-radius: var(--ldg-skel-radius-pill);
}

/* --------------------------------------------------------------------------
   Line / text placeholders
   -------------------------------------------------------------------------- */
.ldg-skel--line       { height: 11px; margin-top: 6px; width: 100%; }
.ldg-skel--line-hero  { height: 18px; width: 80%; }
.ldg-skel--line-sm    { width: 55%; }
.ldg-skel--line-md    { width: 72%; }
.ldg-skel--line-full  { width: 100%; }

/* --------------------------------------------------------------------------
   Metric placeholder
   -------------------------------------------------------------------------- */
.ldg-skel--metric {
  height: 28px;
  width: 90px;
  border-radius: var(--ldg-skel-radius-sm);
}

/* --------------------------------------------------------------------------
   Card placeholder
   -------------------------------------------------------------------------- */
.ldg-skel--card {
  height: 80px;
  border-radius: var(--ldg-skel-radius-md);
}

/* --------------------------------------------------------------------------
   Chart placeholder
   -------------------------------------------------------------------------- */
.ldg-skel--chart {
  height: 120px;
  border-radius: var(--ldg-skel-radius-lg);
  margin-top: 10px;
}

/* --------------------------------------------------------------------------
   List item placeholder
   -------------------------------------------------------------------------- */
.ldg-skel--list-row {
  height: 40px;
  border-radius: var(--ldg-skel-radius-sm);
}

/* --------------------------------------------------------------------------
   AI insight placeholder (thin pulse bars — neutral tone)
   -------------------------------------------------------------------------- */
.ldg-skel--ai-line {
  height: 11px;
  width: 100%;
  border-radius: var(--ldg-skel-radius-pill);
}

.ldg-skel--ai-hero {
  height: 18px;
  width: 86%;
  border-radius: var(--ldg-skel-radius-pill);
}

.ldg-skel--ai-block {
  height: 52px;
  width: 100%;
  border-radius: var(--ldg-skel-radius-md);
}

.ldg-skel--ai-card {
  height: 180px;
  width: 100%;
  border-radius: var(--ldg-skel-radius-lg);
}

/* --------------------------------------------------------------------------
   Loading text placeholder (text-only fallback, no skeleton)
   -------------------------------------------------------------------------- */
.ldg-loading {
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 0;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.ldg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 24px 16px;
  text-align: center;
}

.ldg-empty-icon {
  font-size: 20px;
  line-height: 1;
  opacity: .35;
  margin-bottom: 2px;
}

.ldg-empty-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.ldg-empty-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 280px;
}

/* --------------------------------------------------------------------------
   Refreshing state — keep existing content visible, add top shimmer bar
   -------------------------------------------------------------------------- */
[data-ldg-refreshing="true"] {
  position: relative;
  overflow: hidden;
}

[data-ldg-refreshing="true"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--ldg-skel-shine) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: ldgShimmer var(--ldg-shimmer-duration) ease-in-out infinite;
  border-radius: 0;
  pointer-events: none;
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Reduced-motion: disable shimmer, keep placeholder colour
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ldg-skel {
    animation: none;
    background: var(--ldg-skel-base);
  }

  [data-ldg-refreshing="true"]::after {
    animation: none;
    background: var(--ldg-skel-shine);
  }
}
