@use '../../css/breakpoints' as breakpoints;

/* Container for the entire component */
.relatedBlogsContainer {
  display: flex;
  flex-direction: column;
  padding-top: 32px;
}

.blogCardsContainer {
    display: flex;
    flex-direction: column;
    gap: 1em;
    width: 100%;
}

/* Container for individual card */
.relatedBlogCard {
  padding: 0px;
  margin: 0px;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;

  img {
    display: block;
    width: 100%;
    height: auto;
    border-left: 1px solid;
    border-right: 1px solid;
    border-top: 1px solid;
    border-radius: 12px 12px 0px 0px;
    margin: 0px;
  }

}

[data-theme='dark'] .relatedBlogCard img {
  border-color: #393939;
}

[data-theme='light'] .relatedBlogCard img {
  border-color: #c7c7c7;
}

.relatedBlogCard:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  text-decoration: none;
}

/* Container for the bottom half of the card */
.cardBottom {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  border-radius: 0px 0px 12px 12px;
  margin: 0px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-top: 1.5rem;
  justify-content: space-between;
}

/* Container for the bottom half of the card */
[data-theme='light'] .cardBottom {
  background-color: #f7f7fa;
  border-left: 1px solid #c7c7c7;
  border-right: 1px solid #c7c7c7;
  border-bottom: 1px solid #c7c7c7;
  border-top: 1px solid #c7c7c7;
}

/* Container for the bottom half of the card */
[data-theme='dark'] .cardBottom {
  background-color: #161615;
  border-left: 1px solid #393939;
  border-right: 1px solid #393939;
  border-bottom: 1px solid #393939;
}

// Image styles
.imageWrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background-color: #f5f7f9;
  overflow: hidden;
  border-radius: 12px 12px 0px 0px;
}

.imagePlaceholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0px 0px;

  &::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px 8px 0px 0px;
    border-top-color: #3b5998; /* Use your brand color */
    animation: spin 1s ease-in-out infinite;
  }
}

.imageWrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
  border-radius: 8px 8px 0px 0px;
}

.imageLoaded {
  opacity: 1;
}

.imageHidden {
  opacity: 0;
}

// Skeleton loading styles
.cardSkeleton {
  pointer-events: none;
}

.imageSkeletonWrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
}

.imageSkeleton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #edf2f7;
}

.titleSkeleton {
  height: 20px;
  width: 90%;
  background-color: #edf2f7;
  border-radius: 4px;
  margin-bottom: 0.8rem;
}

.dateSkeleton {
  height: 14px;
  width: 60%;
  background-color: #edf2f7;
  border-radius: 4px;
}

.skeletonPulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

@media (min-width: breakpoints.$laptop-breakpoint) {

/* Container for just the cards (excluding header) */
.blogCardsContainer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5em;
  width: 100%;
  height: 100%
}

}