/*START:___article list___*/
@use "../../abstracts/mixins" as *;
@use "../../vendors/bootstrap" as *;
@use "../../components/input" as *;

.article--list {
  margin-top: var(--ev-space-2xl);

  .article__item-description {
    --article-number-of-lines: 4;
    display: -webkit-box;
    -webkit-line-clamp: var(--article-number-of-lines);
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: fit-content;
  }

  .article__description h3,
  .article__description h2 {
    margin-top: var(--ev-space-l);
    font-size: var(--ev-step-2);
  }

  .article__link:hover {
    color: var(--ev-primary);
  }

  .article__item-description {
    font-size: var(--ev-step--1);
  }

  @include media-breakpoint-up(lg) {
    &.article--with-aside:not(.list--column) .article__placeholder-content,
    &.article--with-aside:not(.list--column) .article__list {
      display: grid;
      gap: var(--ev-grid-gutter, 1rem);
      grid-template-columns: calc(8px * 35) 1fr;
    }

    .article__group {
      margin-top: 0;
    }

    &.article--with-aside:not(.list--column) .article__aside {
      height: fit-content;
      position: sticky;
      top: 7vw;
      overflow: visible;
      max-height: 827px;
      scrollbar-width: none;
      -ms-overflow-style: none;
      padding: var(--ev-space-m);
      background: var(--ev-light);
      border-radius: var(--ev-border-radius);
      z-index: 1;

      ::-webkit-scrollbar {
        display: none;
      }
    }
  }

  .article__filter-label {
    font-weight: var(--ev-heading-font-weight);
    font-family: var(--ev-heading-font-family);
    margin-bottom: var(--ev-space-xs);
    width: 100%;
  }

  .article__item-image {
    overflow: hidden;
  }

  img {
    width: 100%;
    height: auto;
    transform: scale(1);
    transition: transform 500ms;

    &:hover {
      transform: scale(1.1);
    }
  }

  .article__placeholder {
    position: relative;
    z-index: 1;

    &-content {
      display: grid;
      gap: var(--ev-grid-gutter, 1rem);
    }

    &-header {
      display: flex;
      gap: var(--ev-grid-gutter, 1rem);
      flex-wrap: wrap;
      height: fit-content;
    }

    &-filter {
      flex-grow: 1;
      min-width: 120px;
      height: 40px;
      background: var(--ev-light);
      border-radius: var(--ev-input-border-radius, var(--ev-border-radius));
    }

    &-item {
      height: calc(8px * 21);
      background: var(--ev-light);
      box-shadow: var(--ev-box-shadow);
      border-radius: var(--ev-border-radius);
    }
  }

  &:not(.list--column) .article__filter-dropdown {
    width: 100%;
  }

  .article__filter {
    /* Base styling for the filter dropdown */
    display: flex;
    flex-wrap: wrap;
    margin-bottom: var(--ev-space-xs-s);

    &-dropdown {
      position: relative;
      margin-bottom: var(--ev-space-3xs-2xs);
      margin-right: var(--ev-space-3xs-2xs);
    }

    /* Style the button that shows the dropdown */
    &-dropdown-btn {
      @extend .form-control;
      display: inline-flex;
      gap: var(--ev-space-xs);
      place-items: center;
      justify-content: space-between;
      font-size: var(--ev-step--1);

      .icon--arrow-down {
        --icon-height: 12px;
      }

      .icon--close {
        cursor: pointer;
      }

      &::placeholder {
        font-size: var(--ev-step--1, 1rem);
      }

      &:focus {
        border: 1px solid;
        border-color: var(--ev-primary, var(--ev-dark));
        box-shadow: 0 0 0 0.25rem var(--ev-primary-100, var(--ev-dark-100));
        background: var(--ev-input-bg, #f3f3f3);
      }

      :focus-visible {
        border: 0;
      }

      &.invalid,
      &.invalid:focus {
        border: 1px solid var(--ev-danger) !important;
      }

      &.invalid:focus {
        box-shadow: 0 0 0 0.25rem var(--ev-danger-100);
      }
    }

    /* Style the dropdown content. Start off hidden */
    &-dropdown-content {
      display: none;
      position: absolute;
      background-color: #f9f9f9;
      min-width: 100%;
      /* Full width of the button */
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      border-radius: 4px;
      z-index: 10;
      overflow-y: auto;
      height: 350px;
    }

    /* Style each item in the dropdown */
    &-dropdown-item {
      padding: 10px;
      border-bottom: 1px solid #eee;
      /* Light line between items */
    }

    /* Last item shouldn't have a border */
    &-dropdown-item:last-child {
      border-bottom: none;
    }

    /* Style for the label which contains the checkbox */
    &-dropdown-label {
      display: flex;
      gap: var(--ev-grid-gutter, 1rem);
      align-items: center;
      font-size: var(--ev-step--1);
      place-content: space-between;
    }

    /* Custom checkmark styles */
    &-dropdown-checkbox {
      height: 16px;
      width: 16px;
      border-radius: 3px;
      margin-right: 10px;
      border: 1px solid #ddd;
      position: relative;
    }

    /* Show the dropdown content when button is clicked */
    &-dropdown-btn:active + &-dropdown-content,
    &-dropdown-btn:focus + &-dropdown-content {
      display: block;
    }

    /* Optionally, use JavaScript to toggle the dropdown */
  }

  .article__content {
    opacity: 0;
    position: relative;
  }

  .article__item {
    --article-item-bg: hsl(
      var(--ev-light-hue),
      var(--ev-light-saturation),
      calc(var(--ev-light-lightness) - 7%)
    );
    --article-item-bg-content: var(--ev-light);
    --article-item-shadow: none;
    --article-item-border-color: transparent;
    --article-item-padding: var(--ev-space-m);
    --article-item-img-height: auto;
    display: grid;
    grid-template-rows: var(--article-item-img-height) 1fr;
    grid-template-areas: "img" "paragraph";
    background-color: var(--article-item-bg);
    border: var(--ev-border-width, 1px) var(--ev-border-style, solid)
      var(--article-item-border-color, var(--ev-border-color, transparent));
    box-shadow: var(--article-item-shadow, var(--ev-shadow-sm, none));
    border-radius: var(
      --ev-article-item-border-radius,
      var(--ev-border-radius)
    );
    overflow: hidden;

    figure {
      background-color: var(--article-item-bg);
    }

    .label-wrapper {
      position: absolute;
      z-index: 1;
    }

    .article__item-image {
      position: relative;

      &:hover .category-text {
        opacity: 1;
      }
    }

    .category-text {
      position: absolute;
      font-size: var(--ev-step--1);
      color: white;
      opacity: 0;
      margin: 0;
    }

    .author {
      position: relative;
    }

    .author-item + .author-item::before {
      color: var(--ev-breadcrumb-divider-color);
      content: var(--ev-breadcrumb-divider, "/");
    }
  }

  .article__item-content {
    display: grid;
    grid-template-areas: "author .." "title price" "paragraph paragraph";
    grid-template-columns: 1fr auto;
    grid-template-rows: repeat(2, auto) 1fr auto;
    column-gap: var(--ev-grid-gutter, 1rem);
    height: 100%;
    padding: var(--article-item-padding);
    background-color: var(--article-item-bg-content);

    & > :last-child {
      margin-bottom: 0;
    }

    .author {
      font-size: var(--ev-step--1);
    }

    .article__item-description p:last-child {
      margin-bottom: 0;
    }
  }

  img {
    width: 100%;
    height: 100%;
    transform: scale(1);
    transition: transform 500ms;
    object-fit: cover;
  }

  .article__filter-dropdown-content {
    height: fit-content;
    max-height: 350px;
  }
}

/*END:___article list___*/
