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

$params: (
   "margin-bottom": global.$spacer-lg,
   "title-font-size": global.$font-size-h3,

   "gap": global.$gap-width,

   "image-border-radius": global.$border-radius-base,

   "name-color": global.$body-color,
   "name-font-size": global.$font-size-base,
   "name-font-weight": global.$font-weight-base,
);

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

   $params: map.merge($params, components.$c-product-parameters-image);
}

.#{component("Product:Parameters:Image", "class")} {
   width: 100%;
   margin-bottom: map.get($params, "margin-bottom");
   container-type: inline-size;

   .title-default {
      font-size: map.get($params, "title-font-size");
   }

   ul {
      @include global.list-inline;

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

   li {
      flex: 1 0 30%;
      max-width: calc(percentage(math.div(1, 3)) - #{global.$gap-width});
   }

   figure {
      aspect-ratio: 1;
      margin-bottom: 7px;

      img {
         border-radius: map.get($params, "image-border-radius");
      }
   }

   .name {
      color: map.get($params, "name-color");
      font-size: map.get($params, "name-font-size");
      font-weight: map.get($params, "name-font-weight");
   }

   @container (inline-size > 370px) {
      @include global.container-query-selector("li") {
         flex-basis: 22%;
         max-width: calc(25% - #{global.$gap-width});
      }
   }

   @container (inline-size > 470px) {
      @include global.container-query-selector("li") {
         flex-basis: 17%;
         max-width: calc(20% - #{global.$gap-width});
      }
   }
}
