@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": 0,
   "line-height": global.$line-height-sm,

   "delivery-font-size": global.$font-size-base,
   "delivery-font-weight": global.$font-weight-bold,
   "delivery-margin": 0,

   "deliveries-info-font-size": global.$font-size-base,
   "deliveries-info-color": global.$body-color,
   "deliveries-info-display": flex,

   "future-delivery-font-size": global.$font-size-smaller,
   "future-delivery-color": global.$body-color,
);

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

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

.#{component("Product:DeliveryTime", "class")} {
   margin-bottom: map.get($params, "margin-bottom");
   padding-bottom: map.get($params, "padding-bottom");
   border-bottom: map.get($params, "border-bottom");
   line-height: map.get($params, "line-height");

   .delivery {
      color: global.$delivery-ondemand;
      font-size: map.get($params, "delivery-font-size");
      font-weight: map.get($params, "delivery-font-weight");
      margin: map.get($params, "delivery-margin");

      a {
         @include global.underline-hover;
      }
   }

   button {
      @include global.btn-reset;

      color: inherit;
      font-weight: inherit;
      cursor: pointer;

      @include global.underline-default;
   }

   .future-delivery {
      display: block;
      color: map.get($params, "future-delivery-color");
      font-size: map.get($params, "future-delivery-font-size");
   }

   .delivery-info {
      display: map.get($params, "deliveries-info-display");
      flex-wrap: wrap;
      gap: 0 .5ch;
   }

   p {
      color: map.get($params, "deliveries-info-color");
      font-size: map.get($params, "deliveries-info-font-size");
      line-height: inherit;
      margin: 0;
   }

   @each $time, $color in global.$deliveries {
      .delivery-#{$time} {
         color: $color;
      }
   }
}
