/**
 * product-reviews.css
 */

/* Component: Product Reviews */
.reviews {
  --reviews-pad: 32px;

  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 64px;
  padding: var(--reviews-pad);
  border-radius: var(--border-radius-default);
  background: var(--color-white-dark);

  .reviews-title {
    margin: 0;
    font-size: var(--font-size-h3);
    line-height: var(--line-height-h3);
  }

  /* Spans the wrapper padding to line up with the details columns. */
  .reviews-body {
    display: grid;
    grid-template-columns: var(--section-columns);
    align-items: start;
    gap: var(--section-gap);
    margin-inline: calc(-1 * var(--reviews-pad));
  }

  .reviews-list {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 0 0 0 var(--reviews-pad);
    list-style: none;
  }

  .reviews-summary {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    gap: 16px;
    min-width: 0;
    padding-right: var(--reviews-pad);
  }

  /* Five text stars, filled up to --rating. */
  .reviews-stars {
    display: inline-block;
    flex: none;
    background: linear-gradient(90deg, var(--color-yellow) var(--rating, 0%), var(--color-grey-light) var(--rating, 0%));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: var(--font-size-body);
    letter-spacing: 2px;
    line-height: 1;
    white-space: nowrap;

    &::before {
      content: '\2605\2605\2605\2605\2605';
    }
  }

  .reviews-average {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;

    .reviews-score {
      color: var(--color-black-light);
      font-family: var(--font-family-headings);
      font-size: var(--font-size-h1);
      font-weight: 600;
      line-height: var(--line-height-h1);
    }

    .reviews-stars {
      font-size: var(--font-size-h4);
    }

    .reviews-count {
      flex-basis: 100%;
      color: var(--color-grey-dark);
      font-size: var(--font-size-medium);
      line-height: var(--line-height-body);
    }
  }

  .reviews-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;

    .reviews-bar {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .reviews-bar-label {
      flex: 0 0 12px;
      color: var(--color-grey-dark);
      font-size: var(--font-size-small);
      font-weight: 600;
      line-height: 1;
      text-align: right;
    }

    .reviews-bar-track {
      flex: 1;
      overflow: hidden;
      height: 8px;
      border-radius: var(--border-radius-default);
      background: var(--color-white);
    }

    .reviews-bar-fill {
      display: block;
      height: 100%;
      border-radius: var(--border-radius-default);
      background: var(--color-yellow);
    }
  }

  .reviews-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border-radius: var(--border-radius-default);
    background: var(--color-white);

    .reviews-item-head {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 4px 12px;
      font-size: var(--font-size-small);
      line-height: var(--line-height-body);
    }

    .reviews-author {
      color: var(--color-black-light);
      font-weight: 600;
    }

    .reviews-verified {
      color: var(--color-grey-dark);

      &::before {
        content: '';
        display: inline-block;
        width: 10px;
        height: 10px;
        margin-right: 6px;
        background: var(--color-green);
        mask: url('../../images/icons/icon-check-48x48.png') no-repeat center / contain;
        -webkit-mask: url('../../images/icons/icon-check-48x48.png') no-repeat center / contain;
      }
    }

    .reviews-date {
      margin-left: auto;
      color: var(--color-grey);
    }

    .reviews-text {
      color: var(--color-grey-dark);
      font-size: var(--font-size-medium);
      line-height: var(--line-height-single);
      overflow-wrap: anywhere;

      p {
        margin: 0 0 8px;
      }

      p:last-child {
        margin-bottom: 0;
      }
    }
  }
}

/* Tablet: Product Reviews */
@media (max-width: 1024px) {
  .reviews {
    --reviews-pad: 16px;
  }
}

/* Mobile: Product Reviews */
@media (max-width: 767px) {
  .reviews {
    --reviews-pad: 0px;

    gap: 0;
    margin-bottom: 48px;

    .reviews-title {
      padding: 16px 16px 8px;
    }

    .reviews-body {
      grid-template-columns: minmax(0, 1fr);
      gap: 0;
    }

    .reviews-summary {
      padding: 16px;
    }

    .reviews-list {
      padding: 16px;
    }

    /* The summary leads when stacked. */
    .reviews-summary,
    .reviews-list {
      grid-column: auto;
      grid-row: auto;
    }
  }
}
