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

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

   "title-margin-bottom": 25px,
   "title-font-size": global.$font-size-h2,
   "title-font-weight": global.$headings-font-weight,
   "title-text-transform": none,
   "title-letter-spacing": normal,

   "producer-info-wrapper-margin-top": 0,
   "producer-info-wrapper-padding-top": 0,
   "producer-info-wrapper-border-top": none,

   "producer-info-margin": 15px 0 0 0,

   "producer-color": global.$text-dark,
   "producer-font-size": global.$font-size-base,

   "importer-color": global.$text-dark,
   "importer-font-size": global.$font-size-base,

   "producer-title-margin-bottom": 0,
   "producer-title-color": global.$text-dark,
   "producer-title-font-size": global.$font-size-base,
   "producer-title-font-weight": global.$font-weight-bold,
   "producer-title-text-transform": none,
   "producer-title-letter-spacing": normal,
);

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

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

.#{component("Product:Producer", "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");

   .producer-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: map.get($params, "title-margin-bottom");

      .title {
         margin: 0;
         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");
      }
   }

   .producer-info {
      margin-top: map.get($params, "producer-info-wrapper-margin-top");
      padding-top: map.get($params, "producer-info-wrapper-padding-top");
      border-top: map.get($params, "producer-info-wrapper-border-top");

      > div {
         margin: map.get($params, "producer-info-margin");
      }

      .producer-details, .importer-details {
         display: flex;
         flex-direction: column;
      }

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

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

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