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

$params: (
   "margin": 0 0 global.$spacer,
   "item-background": global.$body-bg,
   "item-border": 0,
   "item-border-radius": global.$border-radius-base,
   "gap": 0,

   "btn-link-font-weight": global.$btn-font-weight,
   "btn-link-underline-default": "false",
   "btn-link-color": inherit,

   "image-border": 0,
   "image-border-radius": global.$border-radius-lg,
   "image-margin": 0,

   "content-padding": 0,

   "title-font-size": global.$font-size-base,
   "title-font-weight": global.$font-weight-bold,
   "title-color": global.$text-dark,
   "title-margin": global.$gap-width 0 global.$gap-width 0,
   "title-line-clamp": 1,
   "title-line-height": global.$headings-line-height,

   "info-padding": 0 0 global.$gap-width 0,
);

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

   $params: map.merge($params, components.$c-articleslist-articleSmall);
}

.#{component("ArticlesList:ArticleSmall", "class")} {
   flex: 1 0 100%;
   display: flex;
   flex-direction: column;
   gap: map.get($params, "gap");
   margin: map.get($params, "margin");
   background: map.get($params, "item-background");
   border: map.get($params, "item-border");
   border-radius: map.get($params, "item-border-radius");

   a:not(.link) {
      @include global.underline-hover;
   }

   a.btn-link {
      font-weight: map.get($params, "btn-link-font-weight");
      color: map.get($params, "btn-link-color");

      @if (map.get($params, "btn-link-underline-default") == "true") {
         @include global.underline-default;
      }
   }

   p {
      margin: 0;
   }

   .content {
      flex: 1 0 50%;
      padding: map.get($params, "content-padding");
   }

   .title {
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
      color: map.get($params, "title-color");
      margin: map.get($params, "title-margin");
      line-height: map.get($params, "title-line-height");
      height: calc(map.get($params, "title-line-clamp") * map.get($params, "title-line-height") * map.get($params, "title-font-size"));
      overflow: hidden;
      -webkit-line-clamp: map.get($params, "title-line-clamp");
      display: -webkit-box;
      -webkit-box-orient: vertical;
   }

   .#{component("Articles:ArticleInfo", "class")} {
      padding: map.get($params, "info-padding");
   }

   .#{component("Picture", "class")} {
      border: map.get($params, "image-border");
      border-radius: map.get($params, "image-border-radius");
      overflow: hidden;
      margin: map.get($params, "image-margin");

      img {
         margin: auto;
         border-radius: map.get($params, "image-border-radius");
      }
   }
}
