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

$params: (
   "margin": 0,
   "display": grid,
   "gap": global.$gap-width,
   "gift-row-margin": 10px,
   "show-more-text-decoration": underline,
   "grid-template-columns": repeat(3, 1fr),
   "grid-template-columns-sm": repeat(2, 1fr),
   "title-color": global.$text-dark,
   "title-font-size": 16px,
   "title-font-weight": global.$font-weight-bold,
);

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

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

.#{component("Product:Gifts", "class")} {
   width: 100%;
   margin: map.get($params, "margin");

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

   .gift-row {
      margin-bottom: map.get($params, "gift-row-margin");

      &.is-hidden {
         display: none;
      }
   }

   .gift-row, .is-hidden {
      display: map.get($params, "display");
      @if (map.get($params, "display") == "grid") {
         grid-template-columns: map.get($params, "grid-template-columns-sm");
         gap: map.get($params, "gap");
      }

      @container (inline-size > 600px) {
         grid-template-columns: map.get($params, "grid-template-columns");
      }
   }

   .show-more-text {
      cursor: pointer;
      text-decoration: map.get($params, "show-more-text-decoration");
   }
}
