@import "../../theme.scss";

$linear-placeholder: linear-gradient(
  to bottom,
  transparent 0%,
  transparent 8.1%,
  rgba(0, 0, 0, 0.001) 15.5%,
  rgba(0, 0, 0, 0.003) 22.5%,
  rgba(0, 0, 0, 0.005) 29%,
  rgba(0, 0, 0, 0.008) 35.3%,
  rgba(0, 0, 0, 0.011) 41.2%,
  rgba(0, 0, 0, 0.014) 47.1%,
  rgba(0, 0, 0, 0.016) 52.9%,
  rgba(0, 0, 0, 0.019) 58.8%,
  rgba(0, 0, 0, 0.022) 64.7%,
  rgba(0, 0, 0, 0.025) 71%,
  rgba(0, 0, 0, 0.027) 77.5%,
  rgba(0, 0, 0, 0.029) 84.5%,
  rgba(0, 0, 0, 0.03) 91.9%,
  rgba(0, 0, 0, 0.03) 100%
);

$card-bg: #683389;

// Applies to all

.CTACard--dimmed {
  .CTACardPrimary-root {
    .CTACardPrimary-imageContainer {
      img {
        filter: brightness(0.5);
      }
    }

    .CTACardPrimary-body {
      color: #858181b8;
    }
  }
}

.CTACard-meta {
  color: #868686;
  font-weight: 400;
  font-size: 12px;
}

.CTACard-title {
  font-size: 20px;
  font-weight: 700;
  transition: opacity 0.4s;
  line-height: 1.5;
  cursor: pointer;
  -webkit-line-clamp: 3;
  line-clamp: 3;

  &:hover {
    opacity: 0.7;
  }
}

.CTACard-image {
  transition: transform 0.4s;
}

.CTACard-image:hover {
  border-radius: 6px;
  transition: transform 0.4s;
  transform: scale(1.1);
}

.CTACard {
  position: relative;
  font-family: inherit;
  width: 100%;
  overflow: hidden;

  svg {
    fill: #878787;
  }

  .CTACard-line {
    width: 100%;
    height: 2px;
    background: linear-gradient(
      to right,
      #d0e7c2 0%,
      #6fb545 50%,
      #d0e7c2 100%
    );
  }

  .CTACard-score {
    position: absolute;
    bottom: -31px;
    left: 50%;
    border-radius: 0px 0px 6px 6px;
    background-color: #d0e7c2;
    width: 100%;
    z-index: 9;
    margin: 8px 0px;
    padding: 0px 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transform: translate(-50%, 180%);
    transition: transform 0.3s cubic-bezier(0.3, 0.85, 0.4, 0.95);
    box-shadow: $shadow-lg;

    div {
      padding-bottom: 2px;
    }

    .CTACard-score--text {
      height: 23px;
    }

    p {
      margin: 0px !important;
      color: #6fb545;
      font-weight: 700;
    }

    &--hovered {
      transform: translate(-50%, 0);
    }
  }

  .CTACard-actionButtons {
    position: absolute;
    bottom: 30px;
    left: 50%;
    border-radius: 6px 6px 0px 0px;
    background-color: #fefefee6;
    z-index: 9;
    margin: 8px 0px;
    padding: 0px 5px;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    transform: translate(-50%, 180%);
    transition: transform 0.3s cubic-bezier(0.3, 0.85, 0.4, 0.95);
    box-shadow: $shadow-lg;

    button {
      margin: 10px 5px;
    }

    &--hovered {
      transform: translate(-50%, 0);
    }
  }

  .CTACard-root--overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.225);
    z-index: 4;
    pointer-events: none;
    border-radius: 6px;
  }
}

.CTACard-description {
  line-height: 1.5;
}

.CTACard-actionButtonsContainer--overlay:hover {
  border-radius: $border-radius;
}

.CTACard-actionButtonContainer--hover:hover .CTACard-title {
  opacity: 0.7;
}

.CTACard-actionButtonsContainer--overlay {
  position: absolute;
  height: 100%;
  width: 100%;
  border-radius: $border-radius;
}

// Primary

.CTACardPrimary-root {
  display: flex !important;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;

  &:not(.CTACardPrimary-scaleDown) {
    border-top: 0.1px solid #d9d9d9;
    padding-top: 15px;
  }

  .CTACardPrimary-body {
    display: flex;
    flex-direction: column;
  }

  .CTACardPrimary-tagAndMetaContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
  }

  .CTACardPrimary-imageContainer {
    width: 130px;
    height: 130px;
    overflow: hidden;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: $linear-placeholder;
    flex-shrink: 0;
  }

  .CTACardPrimary-imageContainer > img {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 6px;
    object-fit: cover;

    &:hover {
      transition: transform 0.4s;
      transform: scale(1.1);
    }
  }

  .CTACardPrimary-titleContainer .CTACard-title {
    overflow: hidden;
  }
}

.CTACardPrimaryVertical-titleContainer .CTACard-title {
  margin-top: 10px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* number of lines to show */
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.CTACardPrimaryVertical-tagAndMetaContainer {
  display: flex;
  margin-top: 10px;
  gap: 8px;
}

.CTACardPrimaryVertical-imageContainer {
  height: 260px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 8.1%,
    rgba(0, 0, 0, 0.001) 15.5%,
    rgba(0, 0, 0, 0.003) 22.5%,
    rgba(0, 0, 0, 0.005) 29%,
    rgba(0, 0, 0, 0.008) 35.3%,
    rgba(0, 0, 0, 0.011) 41.2%,
    rgba(0, 0, 0, 0.014) 47.1%,
    rgba(0, 0, 0, 0.016) 52.9%,
    rgba(0, 0, 0, 0.019) 58.8%,
    rgba(0, 0, 0, 0.022) 64.7%,
    rgba(0, 0, 0, 0.025) 71%,
    rgba(0, 0, 0, 0.027) 77.5%,
    rgba(0, 0, 0, 0.029) 84.5%,
    rgba(0, 0, 0, 0.03) 91.9%,
    rgba(0, 0, 0, 0.03) 100%
  );
}

.CTACardPrimary-scaleDown .CTACardPrimary-titleContainer .CTACard-title {
  font-size: 15px;
}
.CTACardPrimary-scaleDown {
  .CTACardPrimary-imageContainer .CTACard-image {
    width: 90px;
    height: 90px;
  }
  .CTACardPrimary-imageContainer {
    width: 90px !important;
    height: 90px !important;
  }
}

.CTACard--rtl {
  .CTACardPrimary-root,
  .CTACardPrimaryVertical-root,
  .CTACardSecondary-root,
  .CTACardTertiary-root {
    direction: rtl;
  }

  .CTACard-meta {
    direction: rtl;
  }

  .CTACardPrimary-body {
    margin-right: 5px;
    direction: rtl;
  }
}

.CTACardPrimaryVertical-imageContainer > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.CTACardPrimaryVertical-imageContainer svg {
  height: 40px;
  width: 40px;
}

// Secondary

.CTACardSecondary-root {
  position: relative;
  width: 100%;
  border-radius: 6px;
  height: 150px;
  overflow: hidden;

  .CTACardSecondary-imageContainer {
    height: 100%;
  }

  img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    filter: brightness(0.7);
  }

  img:hover {
    transition: transform 0.4s;
    transform: scale(1.1);
    border-radius: $border-radius;
  }

  .CTACardSecondary-title--overlay {
    position: absolute;
    width: 90%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    display: flex;
    justify-content: center;
    align-items: baseline;

    span {
      font-size: 30px;
    }
  }

  .CTACardSecondary-title--overlay > div {
    font-size: 30px;
  }

  .CTACardSecondary-root--backgroundColor {
    height: 100%;
    width: 100%;
    background-color: $card-bg;
  }
}

// Tertiary

.CTACardTertiary-root {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: $card-bg;
  color: white;
  border-radius: 6px;
  height: 355px;

  .CTACardTertiary-imageContainer {
    overflow: hidden;
    height: 260px;

    img {
      height: 100%;
      width: 100%;
      object-fit: cover;
      border-radius: 6px 6px 0px 0px !important;
    }
  }

  .CTACard-title {
    margin: 16px 16px 8px 16px;
    overflow: hidden;
  }

  .CTACard-description {
    margin: 0 16px 16px 16px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* number of lines to show */
    line-clamp: 3;
    -webkit-box-orient: vertical;
    font-size: 16px;
  }
}

@media screen and (max-width: 600px) {
  .CTACard {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    max-height: 400px;
    min-width: 300px;
  }
}

@media screen and (max-width: 1150px) {
  .CTACardPrimary-scaleDown {
    .CTACardPrimary-imageContainer .CTACard-image {
      width: 70px;
      height: 70px;
    }
    .CTACardPrimary-imageContainer {
      width: 70px !important;
      height: 70px !important;
    }
    .CTACardPrimary-titleContainer .CTACard-title {
      font-size: 13px;
    }
    .CTACardPrimary-tagAndMetaContainer {
      margin-bottom: 0px;
    }
  }
  .CTACard-meta {
    font-size: 13px;
  }
}
@media screen and (max-width: 599px) {
  .CTACardPrimary-scaleDown {
    .CTACardPrimary-imageContainer .CTACard-image {
      display: none;
    }
    .CTACardPrimary-imageContainer {
      display: none;
    }
    .CTACardPrimary-titleContainer .CTACard-title {
      font-size: 13px;
      width: 150px;
    }
  }
}
