/**
 * List with illustration print
 * @define list-illustration
 */

@use 'sass:map';

// Exposed variables
$theme: null !default;
$list-illustration: null !default;
$list-illustration-print: null !default;

.ecl-list-illustration {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ecl-list-illustration__item {
  display: flex;
  flex-direction: row;
  padding: map.get($theme, 'spacing-print', 'm');
}

.ecl-list-illustration__image {
  margin-inline-end: map.get($theme, 'spacing-print', 'm');
  object-fit: cover;

  &:not(.ecl-list-illustration__image--square) {
    width: 15.875rem;
  }
}

// manage ratio 1:1
.ecl-list-illustration__image--square {
  aspect-ratio: 1/1;
  width: 100px;

  &.ecl-list-illustration__image--s {
    width: 48px;
  }

  &.ecl-list-illustration__image--l {
    width: 150px;
  }
}

.ecl-list-illustration__title-container {
  display: flex;
  flex-direction: column;
  max-width: var(--max-w);
}

.ecl-list-illustration__icon {
  color: map.get($list-illustration, 'icon-color');
  margin-bottom: map.get($theme, 'spacing-print', 'm');
}

.ecl-list-illustration__value {
  color: map.get($list-illustration, 'title-color');
  font: map.get($list-illustration-print, 'value-font-desktop-l');
  margin-bottom: map.get($theme, 'spacing-print', 'xs');

  .ecl-list-illustration--font-m & {
    font: map.get($list-illustration-print, 'value-font-desktop-m');
  }
}

.ecl-list-illustration__title {
  color: map.get($list-illustration, 'title-color');
  font: map.get($theme, 'font-prolonged-print', 'xl');
}

.ecl-list-illustration__description {
  color: map.get($list-illustration, 'description-color');
  font: map.get($theme, 'font-prolonged-print', 'm');
  margin-top: map.get($theme, 'spacing-print', 'xs');
  max-width: var(--max-w);
}

// Horizontal list
.ecl-list-illustration--col-2,
.ecl-list-illustration--col-3,
.ecl-list-illustration--col-4 {
  display: grid;
  grid-auto-rows: auto;
  grid-column-gap: map.get($theme, 'grid', 'gutter');
  grid-row-gap: map.get($theme, 'spacing-print', '3xl');
  width: 100%;

  .ecl-list-illustration__item {
    flex-direction: column;
    margin-bottom: 0;
    padding: 0;
  }

  .ecl-list-illustration__picture:not(.ecl-list-illustration__picture--square) {
    width: 100%;
  }

  .ecl-list-illustration__image {
    margin-inline-end: 0;
    margin-bottom: map.get($theme, 'spacing-print', 'm');

    &:not(.ecl-list-illustration__image--square) {
      width: 100%;
    }
  }
}

.ecl-list-illustration--col-2 {
  grid-template-columns: repeat(2, 1fr);
}

.ecl-list-illustration--col-3 {
  grid-template-columns: repeat(3, 1fr);
}

.ecl-list-illustration--col-4 {
  grid-template-columns: repeat(4, 1fr);
}

// Zebra
.ecl-list-illustration--zebra {
  .ecl-list-illustration__item:nth-child(even) {
    background-color: map.get($list-illustration, 'background-color');
  }
}

// Centered items
.ecl-list-illustration--centered {
  // stylelint-disable-next-line no-descending-specificity
  .ecl-list-illustration__item {
    display: flex;
    flex-direction: column;
    text-align: center;

    .ecl-list-illustration__detail {
      align-items: center;
      display: flex;
      flex-direction: column;
    }

    .ecl-list-illustration__description {
      align-self: center;
      display: inline-block;
    }

    * {
      text-align: center;
    }

    .ecl-list-illustration__icon,
    .ecl-list-illustration__picture {
      align-self: center;
    }
  }
}
