@use '../theme.scss' as *;

.gallery {
  margin-bottom: $block-elem-vertical-gap;
  position: relative;
  width: 100%;
  background-color: $gallery-bg-color;
}

.gallery-header {
  margin-top: 0.6em;
  margin-bottom: 1em;
  width: 100%;
  background-color: $gallery-header-bg-color;
  color: $gallery-header-color;
  text-align: center;
}

.gallery-content {
  z-index: 1;
  position: relative;
  overflow: hidden;
}

.gallery-footer {
  padding: 0.5em;
  background-color: $gallery-footer-bg-color;
  color: $gallery-footer-color;
}

.gallery {
  display: flex;
  height: 100%;

  & .gallery-body-norow {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 2;
  }

  & .gallery-body-row {
    width: 100%;
    height: 100%;
  }

  & .gallery-content {
    height: 100%;

    & .gallery-images-container {
      position: relative;
      width: 100%;
      height: 100%;
      transition: transform 0.5s;
    }

    & .gallery-image {
      touch-action: pan-y;
      user-select: none;
      -webkit-user-drag: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      position: absolute;
      left: 0;
      top: 50%;
      max-width: 100%;
      max-height: 100%;
      transform: translate(0, -50%);
    }

    & .gallery-next-pane,
    & .gallery-prev-pane {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 50%;
      z-index: 2;
      cursor: pointer;
    }

    & .gallery-next-pane {
      right: 0;
    }

    & .gallery-prev-pane {
      left: 0;
    }

    & .gallery-next-button,
    & .gallery-prev-button {
      z-index: 3;
      top: 50%;
      transform: translate(0, -50%);
      position: absolute;
      height: 6em;
      padding: 0;
      width: 4em;
      margin: 0;
      opacity: $gallery-initial-buttons-opacity;
      transition: 0.2s opacity ease;

      & .icon {
        font-size: 3em;
      }

      &:hover {
        opacity: 1;
        display: block;
      }
    }

    & .gallery-next-button {
      right: 0;
    }

    & .gallery-prev-button {
      left: 0;
    }
  }

  &.navigation-buttons-on-hover {
    transition: 0.2s opacity ease;

    & .gallery-content {
      & .gallery-next-button,
      & .gallery-prev-button {
        display: none;
        opacity: 0;
      }
    }

    &:hover {
      & .gallery-next-button,
      & .gallery-prev-button {
        opacity: 1;
        display: block;
      }
    }
  }

  & .gallery-thumbnails-host {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;

    & .gallery-thumbs {
      display: flex;
      justify-content: center;
      overflow-x: auto;
      text-align: center;
      width: 100%;

      & .gallery-thumbs-container {
        display: flex;
        gap: 1rem;
        overflow-x: auto;
        scroll-snap-type: x;

        & .gallery-thumb-wrapper {
          z-index: 1;
          position: relative;

          &:after {
            content: '';
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            border-width: 4px;
            border-style: solid;
            border-color: transparent;
            cursor: pointer;
          }

          &:hover {
            &:after {
              background-color: $gallery-thumbnail-hover-bg-color;
            }
          }

          &.selected:after {
            border-color: $gallery-thumbnail-selected-border-color;
            border-radius: 10px;
          }
        }

        & .gallery-thumb {
          box-sizing: border-box;
          object-fit: contain;
          display: block;
          scroll-snap-align: center;
          border-radius: 10px;
        }
      }
    }
  }

  & .gallery-thumbs-vertical {
    display: flex;
    justify-content: center;
    overflow-y: auto;
    text-align: center;
    height: 100%;

    & .gallery-thumbs-container-vertical {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      overflow-y: auto;
      scroll-snap-type: y;
    }
  }
}

/* test release */

@media only screen and (max-width: 600px) {
  .gallery-next-button,
  .gallery-prev-button {
    display: none;
  }
}
