/*
 * Placeholder while content loads. Always aria-hidden="true": the busy container announces
 * the loading state once (aria-busy + a visually-hidden status text), not every grey bar.
 * The shine moves with transform only and runs a few passes, never forever (docs/DESIGN.md, Tokens);
 * with reduced motion it is a static highlight.
 */
@layer components {
  .skeleton {
    position: relative;
    display: block;
    overflow: hidden;
    block-size: var(--space-4);
    border-radius: var(--radius-md);
    /* --color-border, not -sunken: sunken is almost the page color and the bars vanish (seen at 375px). */
    background: var(--color-border);

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent, var(--color-surface) 50%, transparent);
      opacity: 0.7;
      transform: translateX(-100%);
      animation: skeleton-shine calc(var(--duration-slow) * 5) var(--ease-out) 8;
    }
  }

  /* One line of text; consecutive lines stack tight and the last one is shorter, like a paragraph. */
  .skeleton--text {
    border-radius: var(--radius-sm);

    & + & {
      margin-block-start: var(--space-2);
    }

    &:last-child:not(:first-child) {
      inline-size: 60%;
    }
  }

  .skeleton--card {
    block-size: calc(var(--space-16) * 2);
    border-radius: var(--radius-lg);
  }

  .skeleton--avatar {
    flex: none;
    inline-size: var(--space-12);
    block-size: var(--space-12);
    border-radius: var(--radius-full);
  }

  @keyframes skeleton-shine {
    to {
      transform: translateX(100%);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .skeleton::after {
      animation: none;
      transform: none;
      opacity: 0.4;
    }
  }
}
