<template>
  <a
    :href="platform.url"
    target="_blank"
    rel="noopener nofollow"
    class="review-platform"
    :class="[{ reversed }, color]">
    <div class="logo-block">
      <img v-lazy="{ src: platform.logo }" />
    </div>

    <div class="content">
      <div class="stars">
        <div v-for="i in 5" :key="i" class="star">
          <img :src="starIcon" alt="star" />
        </div>
      </div>

      <div class="info">
        <div class="score">
          <span class="platform-name">{{ platform.name }} / </span>
          {{ platform.rating }} score
        </div>
        <div class="reviews-count">{{ platform.count }} reviews</div>
      </div>

      <VButton class="button" size="medium" type="white">Show more</VButton>

      <div class="logo-inline">
        <img v-lazy="{ src: platform.logo }" />
      </div>
    </div>
  </a>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import type { IFeedbackGrid } from '@/components/sections/FeedbackGrid/FeedbackGrid.types';
import starIcon from '@/assets/img/static-icons/star.svg?url';
import VButton from '@/components/ui/common/VButton.vue';

export default defineComponent({
  components: { VButton },

  props: {
    platform: {
      type: Object as PropType<IFeedbackGrid.ReviewPlatform>,
      required: true,
    },
    reversed: {
      type: Boolean,
    },
    color: {
      type: String as PropType<'red' | 'navy'>,
      default: 'red',
    },
  },

  data: () => ({ starIcon }),
});
</script>

<style lang="scss" scoped>
.review-platform {
  height: 270px;
}

.content {
  position: relative;

  flex: 1;
  height: 100%;
  padding: 32px;

  border-radius: 16px;

  .red & {
    background: #ff492c;
  }

  .navy & {
    background: #17313b;
  }

  .reversed & {
    order: 1;
  }
}

.stars {
  display: flex;
  gap: 10px;
  max-width: 233px;
  margin-bottom: 18px;

  color: white;
}

.star {
  width: 37px;
  height: 37px;

  filter: brightness(0) invert(1);

  img {
    width: 100%;
    height: 100%;
  }
}

.info {
}

.score {
  font-size: 18px;
  line-height: 168%;
  white-space: nowrap;

  .red & {
    color: #ffe4d8;
  }

  .navy & {
    color: #b1b2b4;
  }

  .platform-name {
    color: white;
    font-weight: 600;
    text-transform: capitalize;
  }
}

.reviews-count {
  margin-bottom: 42px;

  font-size: 16px;
  line-height: 180%;

  .red & {
    color: #ffa380;
  }

  .navy & {
    color: #7d7f82;
  }
}

.logo-inline {
  position: absolute;
  right: 24px;
  bottom: 24px;

  width: 80px;
  height: 80px;

  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;

  img {
    width: 100%;
    height: 100%;
  }
}

.logo-block {
  display: none;

  .red & {
    background: #ff492c;
  }

  .navy & {
    background: #17313b;
  }
}

.button {
}
</style>
