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

$params: (
   "padding": 0 0 0 0,
   "margin": 0 0 global.$spacer 0,

   "title-font-weight": global.$font-weight-bold,
   "title-font-size": global.$font-size-h2,
   "title-color": global.$headings-color,
   "title-line-height": global.$headings-line-height,
   "title-margin": 0,

   "title-wrapper-before": "false",
   "title-wrapper-padding": 0,

   "count-color": global.$text-muted,
   "count-font-size": global.$font-size-base,

   "button-max-width": 230px,
);

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

   $params: map.merge($params, components.$c-comments-header);
}

.#{component("Comments:Header", "class")} {
   width: 100%;
   display: flex;
   align-items: center;
   justify-content: space-between;
   flex-wrap: wrap;
   gap: global.$gap-width;
   margin: map.get($params, "margin");
   padding: map.get($params, "padding");
   container-type: inline-size;

   p {
      margin-bottom: 0;
   }

   @if (map.get($params, "title-wrapper-before") == "true") {
      .title-wrapper {
         padding: map.get($params, "title-wrapper-padding");
         position: relative;

         &:before {
            content: url(global.iconUrl("discussion"));
            color: global.$brand-primary;
            position: absolute;
            left: 5px;
         }
      }
   }

   .title {
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
      line-height: map.get($params, "title-line-height");
      margin: map.get($params, "title-margin");
   }

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

   .btn {
      align-items: center;
      display: flex;
      justify-content: center;
      padding-left: 0;
      padding-right: 0;
      width: 100%;
   }

   @container (inline-size > 500px) {
      @include global.container-query-selector('.btn') {
         max-width: map.get($params, "button-max-width");
      }
   }
}
