@charset "UTF-8";

.gallery {
  margin: calc(2% + 20px) 0;
  width: 100%;

  @media(min-width: 567px) {
    &.content-media-right {
      max-width: calc(50% - 15px);
      float: right;
      margin: 18px 0 20px 30px;

      @media(max-width: 767px) {
        max-width: calc(50% - 10px);
        margin: 14px 0 15px 20px;
      }

      &:first-child {
        margin-top: 0;
      }
    }

    &.content-media-left {
      max-width: calc(50% - 15px);
      float: left;
      margin: 18px 30px 20px 0;

      @media(max-width: 767px) {
        max-width: calc(50% - 10px);
        margin: 14px 20px 15px 0;
      }

      &:first-child {
        margin-top: 0;
      }
    }
  }

  .gallery-wrapper {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -5px;
  }

  .image {
    padding: 5px;

    a {
      position: relative;
      display: block;
      background-color: $color-primary-light-04;
      background-color: var(--theme-color-primary-dimmed-04, $color-primary-light-04);
      @include focusvisible;
      transition: 0.2s ease;

      &:after {
        content: "";
        @include fullsize;
        opacity: 0;
        transition: 0.3s ease;
      }
    }

    img {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .copyright {
      position: absolute;
      left: 100%;
      bottom: 0;
      transform-origin: 0 100%;
      color: $color-white;
      color: var(--theme-color-background, $color-white);
      font-size: 12px;
      line-height: 1.2;
      text-shadow: 0px 0px 3px rgba($color-black, 0.6), 0px 0px 8px rgba($color-black, 0.6);
      z-index: 2;
      width: 66%;
      padding: 8px;
      transform: rotate(-90deg);

      @media(max-width: 767px) {
        font-size: 10px;
        padding: 6px 18px;
      }
    }

  }

  &[data-type="grid"], &[data-type="first-image"] {
    a:after {
      padding-top: 66.2%;
      position: relative;
    }
  }


  &[data-type="grid"] {
    .image {
      flex: 1 1 33.3333%;
      max-width: 33.3333%;

      @media(max-width: 567px) {
        flex: 1 1 50%;
        max-width: 50%;
      }
    }
  }

  &[data-type="grid"] {
    .image {
      opacity: 1;
      transition: opacity 0.4s linear;
    }
    .image:not(.loaded):not(.loading) {
      position: absolute;
      opacity: 0;
      z-index: -1;
    }
    .copyright, .image-description {
      display: none;
    }
  }

  &[data-type="first-image"], &[data-type="single-image"] {
    .image:first-child {
      flex: 1 1 100%;
      max-width: 100%;

      .btn {
        position: absolute;
        top: 0;
        right: 0;
        margin: 20px;
      }

      ~ .image {
        display: none;
      }
    }

    .gallery-wrapper {
      padding: 5px;

      > .image-description {
        font-weight: 400;
        font-size: 18px;
        line-height: 1.2;
        margin-top: 12px;
      }
    }

    img, .copyright, .image-description {
      opacity: 0;
      transition: 0.4s ease;
    }

    .image {
      position: relative;
      background-color: $color-white;

      &:before {
        content: "";
        position: relative;
        display: block;
        padding-top: 66.2%;
        background-image: url("../../../img/loader.gif");
        background-size: 100px;
        background-position: center;
        background-repeat: no-repeat;
      }

      &:after {
        content: "";
        @include fullsize;
        background-color: $color-primary-light-04;
        background-color: var(--theme-color-primary-dimmed-04, $color-primary-light-04);
        opacity: 0.2;
        background-blend-mode: multiply;
      }

      a {
        @include fullsize;
        background-color: transparent;
        z-index: 1;
      }
    }

    a:after {
      display: none;
    }

    &.loaded {
      img, .image-description, .image .copyright {
        opacity: 1;
      }
    }
  }

  &[data-type="single-image"] {
    .image {
      position: relative;
      min-width: 100%;
      margin-bottom: 20px;
      padding: 0;

      a {
        position: relative;
      }

      &:before {
        @include fullsize;
        padding: 0;
      }
    }

    .btn {
      display: none;
    }
  }

  &[data-type="grid"], &[data-type="masonry"] {
    .image .image-description {
      display: none !important;
    }

    .image a {
      @extend .icon-zoom;
      overflow: hidden;

      img {
        transform: translate3d(0, 0, 0) scale(1);
        transition: 0.3s ease;
      }

      &:after {
        background-color: $color-primary;
        background-color: var(--theme-color-primary, $color-primary);
      }

      &:before {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 40px;
        height: 40px;
        font-family: "Icons";
        line-height: 40px;
        font-size: 30px;
        margin: -20px;
        z-index: 1;
        color: white;
        opacity: 0;
        transition: 0.3s ease;
      }

      &:hover, &.focus-visible:focus {
        &:before {
          opacity: 1;
        }
        &:after {
          opacity: 0.5;
        }
        img {
          transform: translate3d(0, 0, 0) scale(1.04);
        }
      }

      &:focus-visible, &.-moz-focusring {
        &:before {
          opacity: 1;
        }
        &:after {
          opacity: 0.5;
        }
        img {
          transform: translate3d(0, 0, 0) scale(1.04);
        }
      }
    }
  }

  &[data-type="masonry"] {
    flex-wrap: nowrap;
    align-items: flex-start;

    .gallery-wrapper {
      flex-wrap: nowrap;
      align-items: flex-start;
    }

    .image {
      position: relative;
      display: block;
      opacity: 0;
      transition: opacity 0.3s ease;

      &.loaded {
        opacity: 1;
      }
    }

    .column {
      position: relative;
      display: block;
      flex: 1 1 100%;

      .image {
        position: relative;
        display: block;
        max-width: 100%;
        opacity: 1;
        transition: 0.4s ease;

        &.loading {
          opacity: 0;
        }
      }
    }

    &[data-cols="2"] .column {
      flex: 1 1 50%;
      max-width: 50%;
    }
    &[data-cols="3"] .column {
      flex: 1 1 33.3333%;
      max-width: 33.3333%;
    }
    &[data-cols="4"] .column {
      flex: 1 1 25%;
      max-width: 25%;
    }
  }

  .button-wrapper {
    text-align: center;

    .btn {
      margin: 40px 0 20px;
      background-color: $color-primary-light-04;
      background-color: var(--theme-color-primary-dimmed-04, $color-primary-light-04);
      color: $color-primary;
      color: var(--theme-color-primary, $color-primary);

      &:hover {
        box-shadow: 0 0 0 5px rgba($color-primary-light-04, 0.4), 0 0 4px rgba($color-black, 0.1);
      }
    }
  }

  &[data-infinite-scroll="true"] {
    .button-wrapper .btn {
      position: absolute;
      visibility: hidden;
    }
  }
}

.gallery-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: calc(var(--viewport-height, 1vh) * 100);
  background-color: rgba(#0F1C28, 0.95);
  color: $color-white;
  z-index: 100;
  @include hide;
  color: $color-white;

  &.open {
    @include show;
  }

  .image-box {
    position: relative;
    display: block;
    opacity: 1;
    max-width: 90%;

    img {
      max-height: 66.2vh;
      max-height: calc(var(--viewport-height, 1vh) * 66.2);
      @media(min-width: 1000px) {
        max-width: calc(100vw - 200px);
      }
    }
  }

  .text-box {
    color: $color-white;
    font-size: 18px;
    display: flex;
    flex-direction: column;
    margin: 20px 20px -10px;

    .copyright {
      order: 1;
      font-size: 14px;
      font-style: italic;
    }


    @media(max-width: 767px) {
      font-size: 16px;
    }
  }

  .controls {
    .prev, .next {
      position: absolute;
      top: 50%;
      right: 0;
      display: block;
      width: 50px;
      height: 50px;
      @extend .icon-pfeil-rechts;
      font-size: 0;
      line-height: 0;
      text-align: center;
      padding: 10px 0;
      margin: -25px 15px;
      border: 0;
      background-color: transparent;
      color: white;
      cursor: pointer;

      &:before {
        font-family: "Icons";
        font-size: 30px;
        line-height: 1;
      }

      @media(max-width: 999px) {
        display: none;
      }
    }

    .prev {
      left: 0;
      transform: rotate(180deg);
    }

    .tabs {
      display: none;
    }

    .count {
      position: absolute;
      top: 25px;
      left: 50%;
      width: 120px;
      margin-left: -60px;
      text-align: center;
      font-size: 18px;

      span {
        margin: 0 5px;
      }
    }
  }

  .slide {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100vh;
    height: calc(var(--viewport-height, 1vh) * 100);
    transition: 0.4s linear;
    opacity: 1;

    &.preload {
      opacity: 0;
    }
  }

  .closer, .download {
    position: absolute;
    top: 0;
    width: 50px;
    height: 50px;
    font-size: 30px;
    line-height: 1;
    padding: 10px 0;
    color: $color-white;
    background-color: transparent;
    margin: 15px;
    border: 0;
    cursor: pointer;
    z-index: 1;

    &:before {
      font-family: "Icons";
    }
  }

  .closer {
    right: 0;
    @extend .icon-schliessen;
  }

  .download {
    left: 0;
    @extend .icon-download;
    text-decoration: none;
    text-align: center;
  }

  a, button {
    @include focusvisible;
  }
}

.teaser, .slider {
  .gallery[data-type="first-image"] .image:before {
    padding-top: 66.6666%;
  }
}
