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

$params: (
   "breakpoint": 310px,
   "border-top": global.$border-width solid global.$border-color,

   "gap": 5px,
   "color": global.$text-dark,
   "font-size": global.$font-size-base,
   "font-weight": global.$font-weight-base,
   "line-height": global.$line-height-sm,
   "background": global.$body-bg-alt,
   "padding": 5px 10px,
   "border-radius": global.$border-radius-base,
   "border": global.$border-width solid global.$body-bg-alt,
   "hover-background": global.$body-bg-alt,
   "hover-border": global.$border-width solid global.$brand-primary,
   "hover-color": global.$text-dark,

   "title-font-size": global.$font-size-h4,
   "title-font-weight": global.$font-weight-bold,
   "title-color": global.$text-dark,
   "title-margin": global.$gap-width 0 global.$gap-width 0,

   "lg-margin": global.$spacer 0 global.$spacer 0,
   "lg-padding": 15px 20px,
   "lg-gap": global.$spacer,
   "lg-background": global.$body-bg-alt,
   "lg-border-radius": global.$border-radius-base,

   "lg-tags-gap": global.$spacer,

   "lg-title-font-size": global.$font-size-base,
   "lg-title-font-weight": global.$font-weight-base,
   "lg-title-color": global.$text-muted,
   "lg-title-margin": 0,
);

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

   $params: map.merge($params, components.$c-articles-labels);
}

.#{component("Articles:Labels", "class")} {
   border-top: map.get($params, "border-top");

   ul {
      @include global.list-inline;

      display: flex;
      gap: map.get($params, "gap");
      flex-wrap: wrap;
   }

   li {
      a {
         @include global.underline-never;

         display: inline-flex;
         align-items: center;
         justify-content: center;
         padding: map.get($params, "padding");
         background: map.get($params, "background");
         border: map.get($params, "border");
         border-radius: map.get($params, "border-radius");
         color: map.get($params, "color");
         font-size: map.get($params, "font-size");
         font-weight: map.get($params, "font-weight");
         line-height: map.get($params, "line-height");
         transition:
            background global.$transition-speed,
            border global.$transition-speed,
            color global.$transition-speed;

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

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

   @container (inline-size > #{map.get($params, "breakpoint")}) {
      @include global.container-query-selector("&") {
         display: flex;
         border-top: none;
         margin: map.get($params, "lg-margin");
         gap: map.get($params, "lg-tags-gap");
         padding: map.get($params, "lg-padding");
         background: map.get($params, "lg-background");
         border-radius: map.get($params, "lg-border-radius");
      }

      @include global.container-query-selector(".title") {
         font-size: map.get($params, "lg-title-font-size");
         font-weight: map.get($params, "lg-title-font-weight");
         color: map.get($params, "lg-title-color");
         margin: map.get($params, "lg-title-margin");
      }

      @include global.container-query-selector("ul") {
         gap: map.get($params, "lg-gap");
      }

      @include global.container-query-selector("a") {
         text-decoration: underline;
         background: none;
         border: none;
         padding: 0;

         @include global.haf {
            border: none;
         }
      }
   }
}
