/* =========================================
   LLIBRES GRID BLOCK
   ========================================= */
.c-llibres-grid {
  margin-top: var(--mar-t, 0);
  margin-bottom: var(--mar-b, 0);
  padding-top: var(--pad-t, 80px);
  padding-bottom: var(--pad-b, 80px);
}

.c-llibres-grid__max-width {
  max-width: var(--max-w, 1440px);
  margin: 0 auto;
}

.c-llibres-grid__container.grid-container {
  row-gap: var(--gap-y, 24px);
  column-gap: var(--gap-x, 24px);
}

.c-llibres-grid__card {
  display: grid;
  grid-template-columns: var(--col-w, 240px) minmax(0, 1fr);
  transition: transform 0.3s ease;
  align-items: stretch;
  background: transparent;
}

.c-llibres-grid__card-image {
  width: 100%;
  max-width: var(--col-w, 240px);
  height: var(--img-min-h, auto);
  aspect-ratio: var(--img-ratio, auto);
  align-self: var(--img-align, start);
  
  overflow: hidden;
  position: relative;
  z-index: 2;
  border-radius: var(--br-img, 24px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.3s ease;
}

.c-llibres-grid__card-image img {
  width: 100%;
  height: 100%;
  object-fit: var(--img-fit, fill);
  display: block;
}

.c-llibres-grid__card-body {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  margin-left: -40px; 
  margin-top: 15px;
}

.c-llibres-grid__card-content {
  background-color: var(--bg-cont, #f5f7fa);
  border-radius: var(--br-cont, 0 20px 20px 0);
  padding: 32px 32px 24px 64px; 
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.c-llibres-grid__card-etapa {
  font-size: var(--fs-etapa, 16px);
  font-weight: var(--fw-etapa, 400);
  color: var(--c-etapa, #1e1348);
  line-height: 24px;
  margin-bottom: 4px;
}

.c-llibres-grid__card-title {
  font-size: var(--fs-tit, 18px);
  font-weight: var(--fw-tit, 600);
  color: var(--c-tit, #1e1348);
  line-height: 24px;
  margin-bottom: 12px;
  
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-llibres-grid__card-excerpt {
  font-size: var(--fs-exc, 16px);
  font-weight: var(--fw-exc, 400);
  color: var(--c-exc, #1e1348);
  line-height: 24px;
  margin: 0;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-llibres-grid__card-actions {
  display: flex;
  background-color: var(--bg-act, #ffffff);
  border-radius: var(--br-act, 0 0 24px 0);
  margin-right: 20px;
  padding-left: 40px;
  border-bottom: 2px solid var(--bg-cont, #f5f7fa);
  border-right: 2px solid var(--bg-cont, #f5f7fa);
}

.c-llibres-grid__card-link {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: var(--fs-link, 16px);
  font-weight: var(--fw-link, 600);
  color: var(--c-link, #5d4d9b);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.c-llibres-grid__card-link:hover {
  color: var(--c-link-h, #b2a4d2);
}

.c-llibres-grid__card-link .text-mobile {
  display: none;
}

.c-llibres-grid__card-link:first-child:not(:last-child) {
  position: relative;
}

.c-llibres-grid__card-link:first-child:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 25%;
  bottom: 25%;
  width: 2px;
  background-color: var(--bg-cont, #f5f7fa);
}

.c-llibres-grid__card:hover .c-llibres-grid__card-image {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.c-llibres-grid__loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4rem 0;
  grid-column: 1 / -1;
}

.c-llibres-grid__spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--bg-cont, #edecf0);
  border-top-color: var(--c-link, #5d4d9b);
  border-radius: 50%;
  animation: lg-spin 0.7s linear infinite;
}

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

.c-llibres-grid__empty {
  text-align: center;
  padding: 3rem 1.5rem;
  font-size: 16px;
  color: #666;
  grid-column: 1 / -1;
}

/* =========================================
   RESPONSIVE 
   ========================================= */

@media (max-width: 1250px) {
  .c-llibres-grid__card {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .c-llibres-grid__card-image {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    align-self: center; 
    height: var(--img-min-h-mob, auto);
    aspect-ratio: var(--img-ratio-mob, auto);
    z-index: 2;
  }
  
  .c-llibres-grid__card-image img {
    object-fit: var(--img-fit-mob, fill);
  }

  .c-llibres-grid__card-body {
    margin-left: 0;
    margin-top: -40px; 
    margin-right: 0;
    z-index: 1;
  }

  .c-llibres-grid__card-content {
    padding: 60px 24px 24px 24px;
    border-radius: var(--br-cont-mob, 24px);
    text-align: left;
  }

  .c-llibres-grid__card-excerpt {
    -webkit-line-clamp: 4; 
  }

  .c-llibres-grid__card-actions {
    padding-left: 0;
    border-radius: var(--br-act-mob, 0 0 24px 24px);
    border-right: none;
    margin-left: 24px;
    margin-right: 24px;
    border: 2px solid var(--bg-cont, #f5f7fa);
    border-top: none;
  }

  .c-llibres-grid__card-link {
    padding: 16px 10px;
  }
}

@media (max-width: 768px) {
  .c-llibres-grid {
    margin-top: var(--mar-t-mob, 0px);
    margin-bottom: var(--mar-b-mob, 0px);
    padding-top: var(--pad-t-mob, 32px);
    padding-bottom: var(--pad-b-mob, 32px);
  }

  .c-llibres-grid__container.grid-container {
    row-gap: var(--gap-y-mob, 48px);
    column-gap: var(--gap-x-mob, 16px);
  }

  .u-hide-mobile {
    display: none !important;
  }

  .c-llibres-grid__card-link {
    text-transform: capitalize;
    padding: 8px;
    font-size: 14px;
  }

  .c-llibres-grid__card-content {
    border-radius: var(--br-cont-mob, 10px);
  }

  .c-llibres-grid__card-actions {
    margin-left: 10px;
    margin-right: 10px;
    border-radius: var(--br-act-mob, 0 0 10px 10px);
  }

  .c-llibres-grid__card-link svg {
    display: none;
  }

  .c-llibres-grid__card-link .text-desktop {
    display: none;
  }

  .c-llibres-grid__card-link .text-mobile {
    display: inline;
  }
}

@media (max-width: 580px) {
  .c-llibres-grid__container.grid-container {
    column-gap: 12px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .c-llibres-grid__card-link {
    padding: 0;
  }
  
  .c-llibres-grid__card-actions {
    margin-left: 6px;
    margin-right: 6px;
  }

  .c-llibres-grid__card-content {
    padding: 60px 16px 16px 16px;
  }
  
  .c-llibres-grid__card-excerpt {
    display: none;
  }
  
  .c-llibres-grid__card-title {
    margin-bottom: 0;
  }
}