@use '@uppy/core/src/_variables.scss' as *;
@use '@uppy/core/src/_utils.scss' as *;

// ***
// View type: grid and unsplash
// ***
.uppy-ProviderBrowser-viewType--grid,
.uppy-ProviderBrowser-viewType--unsplash {
  ul.uppy-ProviderBrowser-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    padding: 6px;

    &::after {
      flex: auto;
      content: '';
    }
  }

  li.uppy-ProviderBrowserItem {
    position: relative;
    width: 50%;
    margin: 0;

    .uppy-size--md & {
      width: 33.3333%;
    }

    .uppy-size--lg & {
      width: 25%;
    }

    &::before {
      display: block;
      padding-top: 100%;
      content: '';
    }
  }

  li.uppy-ProviderBrowserItem--selected {
    img,
    svg {
      opacity: 0.85;
    }
  }

  li.uppy-ProviderBrowserItem--disabled {
    opacity: 0.5;
  }

  li.uppy-ProviderBrowserItem--noPreview {
    .uppy-ProviderBrowserItem-inner {
      background-color: rgba($gray-500, 0.2);

      [data-uppy-theme='dark'] & {
        background-color: rgba($gray-200, 0.2);
      }
    }

    svg {
      width: 30%;
      height: 30%;
      fill: rgba($black, 0.7);

      [data-uppy-theme='dark'] & {
        fill: rgba($white, 0.8);
      }
    }
  }

  // button with a large picture
  .uppy-ProviderBrowserItem-inner {
    position: absolute;
    top: 7px;
    right: 7px;
    bottom: 7px;
    left: 7px;
    width: calc(100% - 14px);
    height: calc(100% - 14px);
    overflow: hidden;
    text-align: center;
    border-radius: 4px;

    // Always show the author on touch devices
    // https://www.w3.org/TR/mediaqueries-4/#hover
    @media (hover: none) {
      .uppy-ProviderBrowserItem-author {
        display: block;
      }
    }

    [data-uppy-theme='dark'] & {
      box-shadow: 0 0 0 3px rgba($lightblue, 0.7);
    }

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border-radius: 4px;
    }
  }

  .uppy-ProviderBrowserItem-author {
    position: absolute;
    display: none;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(black, 0.3);
    color: white;
    font-weight: 500;
    font-size: 12px;
    margin: 0;
    padding: 5px;
    text-decoration: none;

    &:hover {
      background: rgba(black, 0.4);
      text-decoration: underline;
    }
  }

  // Checkbox
  .uppy-ProviderBrowserItem-checkbox {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: $zIndex-3;
    width: 26px;
    height: 26px;
    background-color: $blue;
    border-radius: 50%;
    opacity: 0;

    // Checkmark icon
    &::after {
      top: 8px;
      width: 12px;
      height: 7px;
      inset-inline-start: 7px;
    }
  }
  // Checked: show the checkmark
  .uppy-ProviderBrowserItem--is-checked .uppy-ProviderBrowserItem-checkbox {
    opacity: 1;
  }

  .uppy-ProviderBrowserItem-checkbox--grid:hover,
  .uppy-ProviderBrowserItem-checkbox--grid:focus {
    + label .uppy-ProviderBrowserItem-author {
      display: block;
    }
  }

  .uppy-ProviderBrowserItem-checkbox--grid:focus + label {
    @include clear-focus();

    box-shadow: $focus-shadow;
  }
}
