$spacing-md: var(--mantine-spacing-md, 16px);
$white: var(--mantine-color-white, #ffffff);
$black: var(--mantine-color-black, #000000);

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--min-width, 280px), 1fr));
  grid-template-rows: repeat(var(--rows, 2), auto);
  grid-auto-rows: 0;
  overflow: hidden;
  margin-top: -8px;

  &::-webkit-scrollbar {
    background: transparent;
    opacity: 0;
    height: 8px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 4px;
  }

  &>* {
    margin: 8px;
  }

  @container (max-width: theme('screens.sm')) {
    grid-auto-flow: column;
    grid-template-columns: repeat(var(--item-count), var(--default-width, 280px));
    grid-template-rows: auto;
    scroll-snap-type: x mandatory;
    overflow-x: auto;
    margin-right: -$spacing-md;
    margin-left: -$spacing-md;
    padding-left: $spacing-md;
    padding-right: $spacing-md;

    &>* {
      scroll-snap-align: center;
    }
  }
}

.grid-carousel {
  grid-auto-rows: unset;
  grid-auto-flow: column;
  grid-template-columns: repeat(var(--item-count), var(--default-width, 280px));
  grid-template-rows: auto;
  overflow: visible;
  margin-right: -$spacing-md;
  margin-left: -$spacing-md;
  padding-left: $spacing-md;
  padding-right: $spacing-md;

  &>* {
    scroll-snap-align: initial;
  }

  @container (max-width: theme('screens.sm')) {

    scroll-snap-type: x mandatory;

    &>* {
      scroll-snap-align: center;
    }
  }
}

.container {
  position: relative;

  &:hover {
    .scroll-area {
      &::-webkit-scrollbar {
        opacity: 1;
      }

      &::-webkit-scrollbar-thumb {
        background-color: light-dark(
          rgba($black, 0.5),
          rgba($white, 0.5)
        );
      }
    }
  }
}

.scroll-area {
  overflow: auto;
  scroll-snap-type: auto;

  @container (max-width: theme('screens.sm')) {

    scroll-snap-type: x mandatory;
  }

  &::-webkit-scrollbar {
    background: transparent;
    opacity: 0;
    height: 8px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 4px;
  }
}
