@use '../components/mixins' as mixins;

.gallery {
  width: 100%;

  &__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  &__title {
    line-height: 1.2;
    font-weight: 700;
  }

  &__text {
    line-height: 1.5;
  }

  &__count {
    font-size: 0.95rem;
    opacity: 0.75;
  }

  &__empty {
    opacity: 0.75;
    padding: 1rem 0;
  }

  &__layout {
    display: grid;
    gap: 0.9rem;
  }

  &__big {
    appearance: none;
    border: 0;
    padding: 0;
    cursor: pointer;

    border-radius: 16px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);

    &__img {
      width: 100%;
      height: auto;
      display: block;
      aspect-ratio: 16 / 9;
      object-fit: cover;
    }
  }

  &__thumbs {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  &__thumb {
    appearance: none;
    border: 0;
    padding: 0;
    cursor: pointer;

    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.04);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);

    &__img {
      width: 100%;
      height: 100%;
      display: block;
      aspect-ratio: 1 / 1;
      object-fit: cover;
    }

    &__overlay {
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;

      font-size: 2rem;
      font-weight: 700;
      color: #fff;
      background: rgba(0, 0, 0, 0.55);
    }
  }

  &__grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    @include mixins.media-sm {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    @include mixins.media-md {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  &__card {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;

    border-radius: 16px;
    overflow: hidden;
    position: relative;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    transform: translateZ(0);
    transition: transform 180ms ease, box-shadow 180ms ease;

    &:hover,
    &:focus-visible {
      transform: translateY(-2px);
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);

      .gallery__card__meta {
        opacity: 1;
        transform: translateY(0);
      }
    }

    &:focus-visible {
      outline: 3px solid rgba(70, 130, 255, 0.6);
      outline-offset: 3px;
    }

    &__media {
      aspect-ratio: 1 / 1;
      background: rgba(0, 0, 0, 0.04);

      .gallery__card__img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transform: scale(1);
        transition: transform 220ms ease;
      }
    }

    &:hover .gallery__card__img {
      transform: scale(1.03);
    }

    &__meta {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;

      padding: 0.75rem 0.85rem;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));

      opacity: 0;
      transform: translateY(8px);
      transition: opacity 180ms ease, transform 180ms ease;
    }

    &__caption {
      display: block;
      color: #fff;
      font-size: 0.9rem;
      line-height: 1.25;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    }

    &--featured {
      grid-column: span 2;

      @include mixins.media-sm {
        grid-column: span 2;
        grid-row: span 2;

        .gallery__card__media {
          aspect-ratio: 1 / 1;
        }
      }

      @include mixins.media-md {
        grid-column: span 2;
      }
    }
  }

  &__lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(6px);

    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 9999;

    &__panel {
      //   width: min(1100px, 100%);
      border-radius: 18px;
      overflow: hidden;
      //   background: #0f1115;
      color: #fff;
      box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
      //   position: relative;
    }

    &__media {
      background: #0b0d10;
      display: grid;
      place-items: center;
      max-height: min(72vh, 720px);
    }

    &__img {
      width: 100%;
      height: 100%;
      max-height: min(72vh, 720px);
      object-fit: contain;
      display: block;
    }

    &__footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 0.9rem 1rem;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    &__info {
      display: grid;
      gap: 0.25rem;
      min-width: 0;
    }

    &__index {
      font-size: 0.85rem;
      opacity: 0.8;
    }

    &__caption {
      font-size: 0.95rem;
      opacity: 0.95;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: min(70vw, 760px);
    }

    &__controls {
      display: flex;
      gap: 0.5rem;
      flex-shrink: 0;
    }
  }

  &__btn {
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease;

    &:hover {
      background: rgba(255, 255, 255, 0.12);
      transform: translateY(-1px);
    }

    &:active {
      transform: translateY(0);
    }

    &__icon {
      border: 0;
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
      width: 40px;
      height: 40px;
      border-radius: 999px;
      cursor: pointer;

      display: grid;
      place-items: center;

      transition: background 160ms ease, transform 160ms ease;

      &:hover {
        background: rgba(255, 255, 255, 0.14);
        transform: translateY(-1px);
      }

      &--close {
        position: absolute;
        top: 15px;
        right: 15px;
      }
    }
  }
}
