@use "sass:map";
@use "@twig/scss/_global" as global;
@use "@twig/scss/variables/_variables-components" as components;

$params: (
   "margin-top": 0,
   "margin-bottom": global.$spacer,

   "carousel-resp-margin": 0,
   "carousel-scrollbar-height": 0,
   "products-gap": global.$gap-width 30px,

   "square-item-carousel-resp-margin": 0 -31px 0 0,
   "square-item-carousel-resp-gap": 10px,

   "more-btn-padding": 10px 12px,
   "more-btn-font-size": global.$font-size-smaller,
   "btn-transform-y": -9px,

   "carousel-item-width": 1 0 75%,
   "carousel-item-border-bottom": none,
);

@if global-variable-exists(c-recommender, components) {
   $keys: map.keys(components.$c-recommender);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Recommender", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-recommender);
}

.#{component("Recommender", "class")} {
   container-type: inline-size;
   position: relative;
   width: 100%;
   margin-top: map.get($params, "margin-top");
   margin-bottom: map.get($params, "margin-bottom");

   .products {
      display: flex;
      flex-wrap: wrap;
      gap: map.get($params, "products-gap");
   }

   .more-products {
      text-align: center;
      transform: translateY(map.get($params, "btn-transform-y"));

      > button {
         font-size: map.get($params, "more-btn-font-size");
         padding: map.get($params, "more-btn-padding");

         @include global.btn-alt-outline;
      }
   }

   @container (inline-size < #{global.$md}) {
      @include global.container-query-selector(".carousel-wrapper") {
         flex-wrap: nowrap;
         overflow-y: auto;
         margin: map.get($params, "carousel-resp-margin");

         &::-webkit-scrollbar,
         ::-webkit-scrollbar {
            height: map.get($params, "carousel-scrollbar-height");
         }

         .#{component("ProductList:LineItem", "class")} {
            flex: map.get($params, "carousel-item-width");
            border-bottom: map.get($params, "carousel-item-border-bottom");
         }
      }

      @include global.container-query-selector(".square-item-carousel") {
         margin: map.get($params, "square-item-carousel-resp-margin");
         gap: map.get($params, "square-item-carousel-resp-gap");
      }

      button:not(.#{component("Product:AddToCartButton", "class")}) {
         display: none;
      }
   }
}
