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

$params: (
   "gap": global.$gap-width,

   "background": global.$body-bg,
   "background-hover": global.$body-bg,
   "background-active": global.$brand-primary,
   "background-soldout": global.$body-bg-alt,
   "border": global.$border-width solid global.$border-color,
   "border-hover": global.$border-width solid global.$brand-primary,
   "border-active": global.$border-width solid global.$brand-primary,
   "border-soldout": global.$border-width solid global.$body-bg-alt,
   "color": global.$text-dark,
   "color-hover": global.$text-dark,
   "color-active": global.$white,
   "color-soldout": global.$text-muted,
   "text-decoration-soldout": line-through,
   "font-size": global.$font-size-tiny,
   "font-weight": global.$font-weight-bold,
   "line-height": global.$line-height-tiny,
   "border-radius": global.$border-radius-base,
   "height": 28px,
   "padding": 0 5px,
   "background-color": global.$white,

   "visible-count": 4,

   "icon-position-top": 2px,
   "icon-position-right": 2px,
   "icon-color": global.$text-dark,
   "icon-font-size": 12px,
   "icon-color-by-delivery": (),
);

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

   $params: map.merge($params, components.$c-product-variationlabel-cellsmall-catalog);
}

.#{component("Product:VariationLabel:CellSmallCatalog", "class")} {
   width: 100%;
   container-type: inline-size;

   > div {
      display: none;
      grid-template-columns: repeat(#{map.get($params, "visible-count")}, 1fr);
      gap: map.get($params, "gap");
   }

   a {
      @include global.underline-never;

      border: map.get($params, "border");
      color: map.get($params, "color");
      font-size: map.get($params, "font-size");
      font-weight: map.get($params, "font-weight");
      line-height: map.get($params, "line-height");
      border-radius: map.get($params, "border-radius");
      cursor: pointer;
      display: flex;
      justify-content: center;
      align-items: center;
      height: map.get($params, "height");
      padding: map.get($params, "padding");
      position: relative;
      margin: 0;
      transition: all global.$transition-speed;
      text-align: center;
      background-color: map.get($params, "background-color");

      &:hover {
         color: map.get($params, "color-hover");
         background: map.get($params, "background-hover");
         border: map.get($params, "border-hover");
      }
   }

   .soldout {
      color: map.get($params, "color-soldout");
      background: map.get($params, "background-soldout");
      border: map.get($params, "border-soldout");
      text-decoration: map.get($params, "text-decoration-soldout");
   }

   .c-icon {
      position: absolute;
      top: map.get($params, "icon-position-top");
      right: map.get($params, "icon-position-right");
      color: map.get($params, "icon-color");
      font-size: map.get($params, "icon-font-size");
   }

   @each $time, $color in map.get($params, "icon-color-by-delivery") {
      .delivery-#{$time} .c-icon {
         color: $color;
      }
   }

   @container (inline-size > 250px) {
      @include global.container-query-selector("> div") {
         display: grid;
      }
   }
}
