@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeout {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@mixin big-tile-overlay {
  display: flex;
  pointer-events: all;
  opacity: 1;
  animation: fadein $transition-duration;
}

.homepage .gallery {
  max-width: initial;
  z-index: 1;

  @include touch {
    width: 100vw;
    margin-left: -1.6667rem;
    margin-bottom: 1.1112rem;
  }

  @include mobile {
    margin-left: -0.6667rem;
  }
}

.gallery {
  .columns,
  .column {
    padding: 0;
    margin: 0;
  }

  @include touch {
    .tile-rows-stack {
      > .tile-row:not(:first-child) {
        display: none;
      }
    }
  }

  .tile-row {
    flex-wrap: wrap;

    > .is-vertical {
      max-width: min-content;

      > .tile {
        display: flex;
      }
    }
  }

  .big-tile,
  .small-tile {
    opacity: 0;
    animation-duration: $transition-duration * 2;

    &.animated {
      opacity: 1;
    }
  }

  .big-tile {
    background-size: contain;
    height: calc(1320px / 4);
    width: calc(1320px / 4);
    min-width: calc(1320px / 4);
    position: relative;
    align-items: flex-start;

    @include desktop-only {
      height: calc(960px / 4);
      width: calc(960px / 4);
      min-width: calc(960px / 4);
    }

    @include widescreen-only {
      height: calc(1152px / 4);
      width: calc(1152px / 4);
      min-width: calc(1152px / 4);
    }

    @include tablet-only {
      height: 50vw;
      width: 50vw;
      min-width: 50vw;
      max-width: 50vw;
    }

    @include mobile {
      height: 100vw;
      width: 100vw;
      min-width: 100vw;
      max-width: 100vw;
      display: flex;
    }

    @include desktop {
      &:hover {
        .big-tile-overlay {
          @include big-tile-overlay;
        }
      }
    }

    .big-tile-overlay {
      pointer-events: none;
      opacity: 0;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      font-size: $font-size-small;
      animation: fadeout $transition-duration;
      z-index: 1;

      &.active {
        @include big-tile-overlay;
      }

      .overlay-description {
        margin-top: 0.5rem;
      }
    }

    .overlay-trigger {
      display: none;
    }

    @include touch {
      .overlay-trigger {
        display: flex;
        font-family: $font-tgn-hv-condensed;
        font-size: $font-size-body-text;
        align-self: flex-end;
        background: $ami-white;
        box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.8);
        margin: 1.3334rem 1.7223rem;
        padding: 0.4445rem;
        color: $dark-grey;
        cursor: pointer;
        position: absolute;
        left: 0;
        bottom: 0;

        &.close {
          position: absolute;
          bottom: 0;
          left: 0;
          background-color: $grey;
          color: $ami-white;
        }
      }
    }
  }

  .action-tile {
    background-color: $dark-grey;
    background-image: none;
    padding: 1.3334rem 1.7223rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    > a {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      width: 100%;
      height: 100%;
    }

    &.highlight {
      background-color: $ami-yellow;

      h3 {
        color: $light-black;
      }
    }

    h3 {
      color: $ami-white;
      margin-bottom: 0;

      @include from($widescreen) {
        font-size: 2rem;
        line-height: 2.4445rem;
      }

      @include desktop-only {
        font-size: 1.3334rem;
        line-height: 1.6667rem;
      }

      @include mobile {
        font-size: 2.7778rem;
        line-height: 3.2223rem;
      }
    }

    .link-container {
      margin-bottom: 35%;
      font-size: $font-size-small;

      @include mobile {
        margin-bottom: 50%;
      }
    }
  }

  .small-tile {
    width: calc(1320px / 8);
    height: calc(1320px / 8);

    @include desktop-only {
      height: calc(960px / 8);
      width: calc(960px / 8);
    }

    @include widescreen-only {
      height: calc(1152px / 8);
      width: calc(1152px / 8);
    }

    @include tablet-only {
      height: 25vw;
      width: 25vw;
      min-width: 25vw;
      max-width: 25vw;
    }

    @include mobile {
      height: 50vw;
      width: 50vw;
      min-width: 50vw;
      max-width: 50vw;
    }
  ;

    .flip-container {
      perspective: 1000px;
    }

    .flipper.flip {
      transform: rotateY(180deg);
    }

    .flip-container,
    .flipper,
    .front,
    .back {
      width: 100%;
      height: 100%;
    }

    .flipper {
      transition: $transition-duration * 3;
      transform-style: preserve-3d;
      position: relative;
    }

    .front, .back {
      backface-visibility: hidden;
      position: absolute;
      top: 0;
      left: 0;
      background-size: contain;
    }

    .front {
      z-index: 2;
      transform: rotateY(0deg);
    }

    .back {
      transform: rotateY(180deg);
    }

    .flipper-side img {
      width: 100%;
      height: 100%;
    }
  }

  &.clearchannel {
    .small-tile {
      width: 1080px;
      height: 1080px;
    }
  }
}

.gallery-button-container {
  @include desktop {
    display: none;
  }
}

.report-image-message-wrapper {
  padding: 0 1.6667rem;

  @include from($desktop) {
    padding-right: 0;
  }

  @include mobile {
    padding: 0 0.6667rem;
  }
}

.report-image-message {
  text-align: right;
  margin-top: 1rem;
  font-size: $font-size-body-text;

  @include touch {
    text-align: left;
    margin-left: auto;
    margin-right: auto;
    max-width: 876px;
    width: 100%;
  }
}

@mixin odometer-text {
  font-family: $font-tgn-hv-condensed;
  font-size: 6.6667rem;
  letter-spacing: 0;

  @include touch {
    font-size: 2.4445rem;
    line-height: 2.7778rem;
  }
}

.homepage .odometer-block,
.reach-counter-container .odometer-block {
  margin-bottom: -1rem;
  display: flex;
  align-items: flex-end;

  @include touch {
    margin-bottom: -0.5rem;
  }

  @include mobile {
    align-items: flex-start;
    flex-direction: column;
  }

  .odometer {
    z-index: 2;

    @include mobile {
      order: 1;
    }

    .odometer-inside {
      display: flex;
    }

    .odometer-digit {
      @include odometer-text;
      color: $footer-grey;
      background: $ami-white;
      width: 5rem;
      height: 6.7223rem;
      line-height: 5.9rem;
      margin: 1px;

      @include touch {
        height: 2.7778rem;
        width: 2.0556rem;
      }
    }

    .odometer-value,
    .odometer-last-value,
    .odometer-first-value {
      text-align: center;
      width: 100%;
    }

    .odometer-formatting-mark {
      @include odometer-text;
      color: $ami-white;
      margin-top: -2.19rem;

      @include touch {
        margin-top: -1.95rem;
      }
    }
  }

  .odometer-text {
    font-family: $font-tgn-condensed-bold;
    font-size: $font-size-body-text;
    color: $ami-white;
    letter-spacing: 0;
    text-transform: uppercase;
    padding: 0 0 1.5rem 0.5rem;
    max-width: 11rem;

    @include touch {
      max-width: none;
      padding-bottom: 1rem;
    }

    @include mobile {
      padding-bottom: 0.5rem;
      padding-left: 0;
    }
  }
}

html.clearchannel-layout {
  height: 100%;

  &::-webkit-scrollbar {
    display: none;
  }

  body {
    margin: 0;
    height: 100%;
  }
}

.clearchannel-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-top: 0;
  max-width: 100%;
}

.reach-counter-container {
  margin-bottom: 32px;

  .odometer-block {
    margin: 0;

    .odometer-text {
      padding-bottom: 0;
      font-size: 1.2rem;
      max-width: 11rem;
      line-height: 1.2rem;
    }
  }
}

.info-footer {
  margin: 0 32px 32px;

  > .tile {
    height: calc((1016px / 4) * 2);
  }

  .small-tile {
    transition: opacity $transition-duration ease-in-out;
    opacity: 1;

    &.fade-out {
      opacity: 0;
    }

    img {
      width: calc(1016px / 4);
      max-height: calc(1016px / 4);
    }
  }
}
