/* ==========================================================================
   BLOCK: TEXT I IMATGE (Amb Tags i Botó)
   ========================================================================== */

.c-text-image {
  position: relative;
  z-index: 1;
  background-color: var(--bg-out);
  margin: var(--mar-out-d);
  padding: var(--pad-out-d);
  width: 100%;
  overflow-x: hidden;
}

.c-text-image:last-child {
  padding-bottom: 64px !important;
}

.c-text-image--bg-always,
.c-text-image--bg-desktop {
  background: var(--bg-out);
}

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

.c-text-image__wrap[class*="col-start-auto"] {
  margin-left: auto;
  margin-right: auto;
}

/* --------------------------------------------------------------------------
   CAIXA INTERIOR (BLANCA)
   -------------------------------------------------------------------------- */
.c-text-image__box {
  background-color: var(--bg-in);
  border-radius: var(--rad-box-d);
  padding: var(--pad-in-d);
  width: 100%;
}

/* --------------------------------------------------------------------------
   GRAELLA DE DUES COLUMNES
   -------------------------------------------------------------------------- */
.c-text-image__grid {
  display: grid;
  grid-template-columns: var(--grid-cols-d, 1fr 1fr);
  gap: var(--gap-d);
  align-items: var(--al-v-d, center);
}

/* --------------------------------------------------------------------------
   COLUMNA TEXT
   -------------------------------------------------------------------------- */
.c-text-image__col-txt {
  order: var(--o-txt-d, 1);
  text-align: var(--al-h-d, left);
}

/* Tags */
.c-text-image__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: var(--jc-d, flex-start);
  margin: var(--mar-tags-d);
  gap: 8px;
}

.c-text-image__tag {
  background-color: var(--c-tag-bg);
  color: var(--c-tag-txt);
  padding: var(--pad-tag-d);
  font-family: var(--ff-tag);
  font-size: var(--fs-tag-d);
  font-weight: var(--fw-tag);
  line-height: var(--lh-tag-d);
}

/* Títol */
.c-text-image__titol {
  font-family: var(--ff-tit);
  font-size: var(--fs-tit-d);
  font-weight: var(--fw-tit);
  line-height: var(--lh-tit-d);
  color: var(--c-tit);
  margin: var(--mar-tit-d);
}

/* Descripció */
.c-text-image__descripcio {
  font-family: var(--ff-desc);
  font-size: var(--fs-desc-d);
  font-weight: var(--fw-desc);
  line-height: var(--lh-desc-d);
  color: var(--c-desc);
  margin: var(--mar-desc-d);
}

.c-text-image__descripcio p { margin: 0; }
.c-text-image__descripcio p:not(:last-child) { margin-bottom: 1em; }

/* Botó */
.c-text-image__btn-wrap {
  display: flex;
  justify-content: var(--jc-d, flex-start);
  margin: var(--mar-btn-d);
}

.c-text-image__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background-color: transparent;
  color: var(--c-btn-txt);
  border: 2px solid var(--c-btn-bord);
  padding: var(--pad-btn-d);
  font-family: var(--ff-btn);
  font-size: var(--fs-btn-d);
  font-weight: var(--fw-btn);
  line-height: var(--lh-btn-d);
  transition: border-color 0.3s ease;
}

.c-text-image__btn:hover {
  border-color: var(--c-btn-bord-h);
}

/* --------------------------------------------------------------------------
   COLUMNA IMATGE
   -------------------------------------------------------------------------- */
.c-text-image__col-img {
  order: var(--o-img-d, 2);
  width: 100%;
  display: flex;
}

.c-text-image__picture {
  width: 100%;
  display: block;
  border-radius: var(--rad-img-d);
  aspect-ratio: calc(var(--ar-d));
  object-fit: var(--fit-d, cover);
}

.c-text-image__picture--placeholder {
  background: #E5E9FF;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000078;
  font-weight: bold;
}

/* ==========================================================================
   RESPONSIVE (Mòbil i Tablet)
   ========================================================================== */
@media (max-width: 768px) {
  
  .c-text-image {
    margin: var(--mar-out-m);
    padding: var(--pad-out-m);
  }

  .c-text-image__box {
    background-color: var(--bg-in);
    border-radius: var(--rad-box-m);
    padding: var(--pad-in-m);
    width: 100%;
    overflow: hidden;
  }

  .c-text-image__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    align-items: var(--al-v-m, center);
  }

  .c-text-image__col-txt {
    order: var(--o-txt-m, 2);
    text-align: var(--al-h-m, left);
  }

  .c-text-image__tags {
    justify-content: var(--jc-m, flex-start);
    margin: var(--mar-tags-m);
  }

  .c-text-image__tag {
    padding: var(--pad-tag-m);
    font-size: var(--fs-tag-m);
    line-height: var(--lh-tag-m);
  }

  .c-text-image__titol {
    font-size: var(--fs-tit-m);
    line-height: var(--lh-tit-m);
    margin: var(--mar-tit-m);
  }

  .c-text-image__descripcio {
    font-size: var(--fs-desc-m);
    line-height: var(--lh-desc-m);
    margin: var(--mar-desc-m);
  }

  .c-text-image__btn-wrap {
    justify-content: var(--jc-m, center); 
    margin: var(--mar-btn-m);
  }

  .c-text-image__btn {
    width: 100%;
    padding: var(--pad-btn-m);
    font-size: var(--fs-btn-m);
    line-height: var(--lh-btn-m);
  }

  .c-text-image__col-img {
    order: var(--o-img-m, 1);
    display: flex;
    width: calc(100% + var(--pi-l-m, 24px) + var(--pi-r-m, 24px));
    margin-left: calc(-1 * var(--pi-l-m, 24px));
    margin-right: calc(-1 * var(--pi-r-m, 24px));
  }

  .c-text-image--order-m-img-text .c-text-image__col-img {
    margin-top: calc(-1 * var(--pi-t-m, 16px));
    margin-bottom: var(--gap-m);
  }
  .c-text-image--order-m-text-img .c-text-image__col-img {
    margin-bottom: calc(-1 * var(--pi-b-m, 24px));
    margin-top: var(--gap-m);
  }

  .c-text-image__picture {
    border-radius: 0 !important;
    aspect-ratio: calc(var(--ar-m));
    object-fit: var(--fit-m, cover);
  }

}