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

$params: (
   "margin-bottom": global.$spacer-lg,
   "padding-bottom": 0,
   "border-bottom": none,

   "title-margin": 0 0 global.$headings-margin-bottom,
   "title-color": global.$text-dark,
   "title-font-size": global.$font-size-h3,
   "title-font-weight": global.$headings-font-weight,
   "title-text-transform": none,
   "title-letter-spacing": normal,

   "item-gap": global.$gap-width,
   "item-color": global.$text-dark,
   "item-font-size": global.$font-size-base,
   "item-font-weight": global.$font-weight-base,
   "item-line-height": global.$line-height-sm,
   "item-background": global.$body-bg-alt,
   "item-padding": 5px 10px,
   "item-border-radius": global.$border-radius-base,
   "item-border": global.$border-width solid global.$body-bg-alt,
   "item-hover-background": global.$body-bg-alt,
   "item-hover-border": global.$border-width solid global.$brand-primary,
   "item-hover-color": global.$text-dark,
);

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

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

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

   .title-default {
      margin: map.get($params, "title-margin");
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
      text-transform: map.get($params, "title-text-transform");
      letter-spacing: map.get($params, "title-letter-spacing");
   }

   > div {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      gap: map.get($params, "item-gap");

      a {
         @include global.underline-never;

         display: inline-flex;
         align-items: center;
         justify-content: center;
         padding: map.get($params, "item-padding");
         background: map.get($params, "item-background");
         border: map.get($params, "item-border");
         border-radius: map.get($params, "item-border-radius");
         color: map.get($params, "item-color");
         font-size: map.get($params, "item-font-size");
         font-weight: map.get($params, "item-font-weight");
         line-height: map.get($params, "item-line-height");
         transition: background-color global.$transition-speed,
         border-color global.$transition-speed,
         color global.$transition-speed;

         @include global.haf {
            background: map.get($params, "item-hover-background");
            border: map.get($params, "item-hover-border");
            color: map.get($params, "item-hover-color");
         }
      }
   }
}
