/* Section skeletons: a section with [data-loading] shows its .section-skeleton over the (hidden) content
   until skeleton.js removes the attribute. The .js class (set in <head>) keeps content visible without JavaScript. */

.section-skeleton {
  display: none;
}

.js [data-section][data-loading] > .section-skeleton {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 20;
}

/* animation: none here so the fade-in below starts when the section is revealed */
.js [data-section][data-loading] > :not(.section-skeleton) {
  visibility: hidden;
  animation: none;
}

[data-section] > :not(.section-skeleton) {
  animation: section-fade-in 0.4s ease-out;
}

/* In a cascade layer so Tailwind utilities on a skeleton block (rounded-full, rounded-[40px]...) win over these defaults */
@layer components {
  .skeleton {
    background: linear-gradient(90deg, rgb(0 0 0 / 0.06) 25%, rgb(0 0 0 / 0.025) 37%, rgb(0 0 0 / 0.06) 63%);
    background-size: 400% 100%;
    border-radius: 0.5rem;
    animation: skeleton-shimmer 1.4s ease infinite;
  }

  .skeleton-dark {
    background-image: linear-gradient(90deg, rgb(255 255 255 / 0.1) 25%, rgb(255 255 255 / 0.04) 37%, rgb(255 255 255 / 0.1) 63%);
  }
}

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

@keyframes section-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  [data-section] > :not(.section-skeleton) {
    animation: none;
  }
}
