/* 
 * CSR Universe Skeleton Loading Styles
 * Implementation based on Boneyard structural matching principles.
 * Optimized for low CLS, responsive grids, and premium aesthetics.
 */

:root {
  --sk-bg-color: #e2e8f0;
  --sk-shimmer-color: #f1f5f9;
  --sk-border-radius: 8px;
  --sk-shimmer-duration: 1.5s;
}

/* Skeleton animation container */
.csru-skeleton-wrapper {
  pointer-events: none;
  user-select: none;
  cursor: default;
}

/* Hardware-accelerated premium shimmer effect */
.csru-shimmer {
  position: relative;
  overflow: hidden;
  background-color: var(--sk-bg-color);
}

.csru-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 20%,
    rgba(255, 255, 255, 0.5) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: csru-shimmer var(--sk-shimmer-duration) infinite;
}

/* Shimmer keyframes */
@keyframes csru-shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Respect user prefers-reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .csru-shimmer::after {
    animation: none;
    transform: none;
  }
}

/* Bone shapes definitions */
.bone {
  display: block;
  background-color: var(--sk-bg-color);
  border-radius: var(--sk-border-radius);
}

.bone-circle {
  border-radius: 50% !important;
}

.bone-pill {
  border-radius: 9999px !important;
}

/* Title bones with appropriate line-height spacing */
.bone-title {
  height: 24px;
  margin-bottom: 12px;
}

/* Paragraph lines with natural varying widths to look like real text */
.bone-text {
  height: 14px;
  margin-bottom: 8px;
}

.bone-text:last-child {
  margin-bottom: 0;
}

.bone-text.w-full { width: 100%; }
.bone-text.w-95 { width: 95%; }
.bone-text.w-90 { width: 90%; }
.bone-text.w-85 { width: 85%; }
.bone-text.w-80 { width: 80%; }
.bone-text.w-75 { width: 75%; }
.bone-text.w-70 { width: 70%; }
.bone-text.w-65 { width: 65%; }
.bone-text.w-60 { width: 60%; }
.bone-text.w-50 { width: 50%; }
.bone-text.w-40 { width: 40%; }
.bone-text.w-30 { width: 30%; }

/* Button and tag bones */
.bone-btn {
  height: 38px;
  width: 120px;
}

.bone-badge {
  height: 18px;
  width: 60px;
  display: inline-block;
  margin-right: 6px;
}

/* Reserved aspect ratio frames to eliminate CLS */
.csru-media-skeleton-frame {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio default */
  background-color: var(--sk-bg-color);
  border-radius: var(--sk-border-radius);
  overflow: hidden;
}

.csru-media-skeleton-frame.aspect-cover {
  padding-bottom: 140%; /* Book covers / magazine */
}

.csru-media-skeleton-frame.aspect-logo {
  padding-bottom: 40%; /* Wide partner logo */
  border-radius: 4px;
}

.csru-media-skeleton-frame.aspect-square {
  padding-bottom: 100%;
}

.csru-media-skeleton-frame.aspect-hero {
  padding-bottom: 42%; /* Wide hero desktop */
}

@media (max-width: 768px) {
  .csru-media-skeleton-frame.aspect-hero {
    padding-bottom: 60%;
  }
}

.csru-media-skeleton-frame .bone-media-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Image loading integration wrapper */
.csru-lazy-image-wrapper {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  background-color: var(--sk-bg-color);
  border-radius: var(--sk-border-radius);
}

.csru-lazy-image-wrapper img {
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  width: 100%;
  height: auto;
}

.csru-lazy-image-wrapper.loaded img {
  opacity: 1;
}

.csru-lazy-image-wrapper.loaded::after {
  display: none !important;
}

/* Card Skeleton Layout Structure */
.skeleton-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.skeleton-card .skeleton-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.skeleton-card .skeleton-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

/* Specific component helpers */
.skeleton-showcase {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  margin-bottom: 32px;
}

.skeleton-news-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .skeleton-news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .skeleton-news-grid {
    grid-template-columns: 1fr;
  }
}
