/**
 * @file
 * Video
 *
 * Contains styles for inline video objects.
 */

@use '_helper' as *;
@use '../base/_base';

.vid-inline {
  margin: $spacing-vertical-sm 0;

  @media screen and (min-width: $break-large) {
    margin: $spacing-vertical-lg 0;
  }

  &__container {
    position: relative;
    overflow: hidden;
    border-radius: rem(15px);
  }

  &__cover {
    @include focus-light();
    position: relative;
    z-index: 2;
    cursor: pointer;
    opacity: 1;
    transition: 0.3s ease;

    &:focus-visible {
      outline-offset: -8px;
    }

    &:hover {
      .vid-inline__icon {
        circle {
          fill: transparent;
        }

        path {
          fill: $color-white;
        }

        &:before {
          border-color: $color-white;
        }
      }
    }

    &.js-loading {
      &:hover {
        &:before {
          opacity: 1;
        }
      }

      &:before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        margin: 0;
        height: 60px;
        width: 60px;
        background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns:svg=\'http://www.w3.org/2000/svg\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' version=\'1.0\' width=\'60px\' height=\'60px\' viewBox=\'0 0 128 128\' xml:space=\'preserve\'%3e%3cg%3e%3cpath d=\'M78.75 16.18V1.56a64.1 64.1 0 0 1 47.7 47.7H111.8a49.98 49.98 0 0 0-33.07-33.08zM16.43 49.25H1.8a64.1 64.1 0 0 1 47.7-47.7V16.2a49.98 49.98 0 0 0-33.07 33.07zm33.07 62.32v14.62A64.1 64.1 0 0 1 1.8 78.5h14.63a49.98 49.98 0 0 0 33.07 33.07zm62.32-33.07h14.62a64.1 64.1 0 0 1-47.7 47.7v-14.63a49.98 49.98 0 0 0 33.08-33.07z\' fill=\'%23000000\' fill-opacity=\'1\'/%3e%3canimateTransform attributeName=\'transform\' type=\'rotate\' from=\'0 64 64\' to=\'-90 64 64\' dur=\'800ms\' repeatCount=\'indefinite\'%3e%3c/animateTransform%3e%3c/g%3e%3c/svg%3e');
        background-position: center;
        background-size: contain;
        border: 0;
        transform: translate(-50%, -50%);
      }

      .vid-inline__icon {
        display: none;
      }
    }

    &.js-hide {
      display: block;
      z-index: 1;
      opacity: 0;
    }

    img {
      width: 100%;
    }
  }

  &__embed {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    height: 100%;
    width: 100%;
    opacity: 0;
    transition: 0.5s ease;

    &.js-show {
      z-index: 2;
      opacity: 1;

      iframe {
        visibility: visible;
      }
    }
  }

  &__media {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    height: 100%;
    width: 100%;
    opacity: 0;
    transition: 0.5s ease;

    &.js-show {
      z-index: 2;
      opacity: 1;

      video {
        visibility: visible;
      }
    }

    video {
      width: 100%;
      height: 100%;
      visibility: hidden;
    }
  }

  &__icon {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: rem(40px);
    height: rem(40px);

    @media screen and (min-width: $break-medium) {
      width: rem(50px);
      height: rem(50px);
    }

    @media screen and (min-width: $break-large) {
      width: rem(68px);
      height: rem(68px);
    }

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

    circle,
    path {
      transition: all 0.1s ease;
    }

    path {
      @media screen and (min-width: $break-medium) {
        transform: scale(0.7) translate(10px, 8px);
      }

      @media screen and (min-width: $break-large) {
        transform: scale(0.75) translate(8px, 6px);
      }
    }

    &:before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: calc(100% - 2px);
      height: calc(100% - 2px);
      border: 1px solid $color-gold;
      border-radius: 100%;
      transition: all 0.3s ease;
    }
  }

  iframe {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    border: 0;
    visibility: hidden;
  }

  &__caption {
    @extend figcaption;
  }

  &--full {
    @media screen and (min-width: $break-large) {
      @include full-width;
      @include gutter;
    }

    .vid-inline {

      &__container,
      &__caption {
        max-width: calc($content-max - 58px * 2);
        margin-right: auto;
        margin-left: auto;
      }
    }
  }

  &--file-upload {
    .vid-inline__cover {
      &::after {
        content: '';
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 3;
      }
    }

    video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
}