@import '../mixins';

$img-horizontal-space: 28px;
$footer-item-space: 12px;
$footer-item-margin: $footer-item-space / 2;

.tix-figure.v4 {
  text-align: center;

  .figure-img-outer-wrapper {
    width: calc(100% - 2 * #{$img-horizontal-space});
    margin: 0 auto 16px auto;

    .figure-img-inner-wrapper {
      height: 0;
      padding-top: calc(
        2 / 3 * 100%
      ); // force to 3:2 aspect ratio based on design principle
      position: relative;
      overflow: hidden;

      img {
        height: 100%;
        width: 100%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }

  .figure-title {
    margin-top: 0;
    margin-bottom: 8px;
    text-overflow: ellipsis;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .figure-description {
    margin-bottom: 24px;
    margin-top: 0;
  }

  .footer {
    .tix-button.v4 {
      @include font-size-b1;
      @include font-base;
      font-weight: $font-weight-bold;
    }

    @at-root {
      .tix-figure:not(.full-width-button)#{&} {
        margin: 0 -#{$footer-item-margin};

        .tix-button.v4 {
          margin: 0 $footer-item-margin;
          float: left;

          &:nth-child(1):nth-last-child(1) {
            width: calc(100% - #{$footer-item-space});
          }

          &:nth-child(1):nth-last-child(2),
          &:nth-child(2):nth-last-child(1) {
            width: calc(50% - #{$footer-item-space});
          }
        }
      }

      .tix-figure.full-width-button#{&} {
        .tix-button.v4 {
          width: 100%;

          &:nth-child(2):nth-last-child(1) {
            margin-top: 10px;
          }
        }
      }
    }

    &::after {
      content: '';
      display: block;
      clear: both;
    }
  }

  &.desktop {
    width: 336px;
    max-width: 100%;
    margin: 0 auto;

    .figure-title {
      @include font-size-h3-desktop;
    }

    .figure-description {
      margin-bottom: 16px;
    }

    .figure-img-outer-wrapper {
      width: 290px;
      height: 194px;
    }

    .footer {
      .tix-button.v4 {
        @include font-size-b2-desktop;
      }
    }
  }
}
