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

$params: (
   "content-padding": 25px 20px,
   "content-line-height": 1.1,

   "description-margin": 0 0 8px,
   "description-color": global.$white,
   "description-font-size": global.$font-size-base,
   "description-font-weight": global.$font-weight-bold,
   "description-text-decoration": underline,

   "title-margin": 0 0 8px,
   "title-color": global.$white,
   "title-font-size": 24px,
   "title-font-weight": global.$font-weight-bold,

   "price-margin": 0 0 8px,
   "price-color": global.$white,
   "price-font-size": 20px,
   "price-font-weight": global.$font-weight-bold,

   "delivery-margin": 0,
   "delivery-color": global.$white,
   "delivery-font-size": global.$font-size-smaller,
   "delivery-font-weight": global.$font-weight-bold,
   "delivery-0-padding": 3px 5px,
   "delivery-0-color": global.$white,
   "delivery-0-background": global.$delivery-instore,
   "delivery-0-border-radius": global.$border-radius-base,

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

   "hide-banner-responsive": "false",
   "breakpoint": global.$md - 1,
);

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

   $params: map.merge($params, components.$c-productlist-bannerwithproduct);
}

.#{component("ProductList:BannerWithProduct", "class")} {
   flex: 1;

   .catalog-banner {
      position: relative;
      display: block;
      height: 100%;
   }

   .content {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      width: 100%;
      padding: map.get($params, "content-padding");
      line-height: map.get($params, "content-line-height");
   }

   .description {
      margin: map.get($params, "description-margin");
      color: map.get($params, "description-color");
      font-size: map.get($params, "description-font-size");
      font-weight: map.get($params, "description-font-weight");
      text-decoration: map.get($params, "description-text-decoration");
   }

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

   .#{component("Product:Price", "class")} {
      margin: map.get($params, "price-margin");

      > div {
         margin: 0;

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

   .#{component("Product:DeliveryTime:Availability", "class")} {
      .delivery {
         display: inline-block;
         margin: map.get($params, "delivery-margin");
         color: map.get($params, "delivery-color");
         font-size: map.get($params, "delivery-font-size");
         font-weight: map.get($params, "delivery-font-weight");

         &.delivery-0 {
            padding: map.get($params, "delivery-0-padding");
            color: map.get($params, "delivery-0-color");
            background: map.get($params, "delivery-0-background");
            border-radius: map.get($params, "delivery-0-border-radius");
         }
      }
   }
   
   .#{component("Picture", "class")} {
      height: 100%;

      img {
         width: 100%;
         height: 100%;
         object-fit: cover;
         border-radius: map.get($params, "img-border-radius");
      }
   }

   @if (map.get($params, "hide-banner-responsive") == "true") {
      @media screen and (max-width: map.get($params, "breakpoint")) {
         display: none;
      }
   }
}
