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

$params: (
   "breakpoint-sm": 320px,

   "align-items": center,
   "justify-content": normal,
   "min-height": 75px,
   "padding": 10px,
   "border": global.$border-width solid transparent,
   "border-radius": global.$border-radius-base,
   "box-shadow": none,
   "border-color-active": global.$brand-primary,
   "box-shadow-active": none,
   "text-decoration": none,

   "image-overlay": "true",
   "image-display": block,
   "image-border-radius": global.$border-radius-base,

   "title-padding": 0 20px,
   "title-color": global.$black,
   "title-font-size": global.$font-size-larger,
   "title-font-size-resp": global.$font-size-base,
   "title-font-weight": global.$font-weight-bold,
   "title-letter-spacing": normal,
   "title-line-height": global.$line-height-base,
   "title-text-transform": none,
);

@if global-variable-exists(c-section-subcategories-item, components) {
   $keys: map.keys(components.$c-section-subcategories-item);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Section:SubCategories:Item", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-section-subcategories-item);
}

.#{component("Section:SubCategories:Item", "class")} {
   container-type: inline-size;
   width: 100%;
   border-radius: map.get($params, "border-radius");

   @if (map.get($params, "image-overlay") == "true") {
      @include global.image-overlay(0);
   }

   .item {
      position: relative;
      display: flex;
      align-items: map.get($params, "align-items");
      justify-content: map.get($params, "justify-content");
      min-height: map.get($params, "min-height");
      height: 100%;
      padding: map.get($params, "padding");
      border: map.get($params, "border");
      border-radius: inherit;
      box-shadow: map.get($params, "box-shadow");
      text-decoration: map.get($params, "text-decoration");
      transition: border-color global.$transition-speed, box-shadow global.$transition-speed;

      @include global.haf {
         border-color: map.get($params, "border-color-active");
         box-shadow: map.get($params, "box-shadow-active");
      }
   }

   .image {
      flex: 0 0 auto;
      display: map.get($params, "image-display");
      border-radius: map.get($params, "image-border-radius");

      @if (map.get($params, "image-overlay") == "true") {
         @include global.image-overlay(0);
      }
   }

   .title {
      flex: 0 1 auto;
      padding: map.get($params, "title-padding");
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size-resp");
      font-weight: map.get($params, "title-font-weight");
      letter-spacing: map.get($params, "title-letter-spacing");
      line-height: map.get($params, "title-line-height");
      text-transform: map.get($params, "title-text-transform");
   }

   @container (inline-size > #{map.get($params, "breakpoint-sm")}) {
      @include global.container-query-selector(".title") {
         font-size: map.get($params, "title-font-size");
      }
   }
}
