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

$params: (
   "border-width": global.$border-width,
   "border-color": global.$border-color,

   "trigger-color": global.$text-dark,
   "trigger-font-size": global.$font-size-base,
   "trigger-font-weight": global.$font-weight-base,
   "trigger-padding": 5px 10px,
   "trigger-icon-size": global.$font-size-smaller,
   "trigger-icon-color": global.$text-dark,
   "trigger-icon-offset": 10px,

   "trigger-color-active": global.$text-dark,
   "trigger-icon-color-active": global.$text-dark,

   "list-background": global.$body-bg,
   "list-color": global.$text-dark,
   "list-font-size": global.$font-size-base,
   "list-font-weight": global.$font-weight-base,
   "list-padding": 5px 10px,
);

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

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

.#{component("Header:LanguageSwitcher", "class")} {
   position: relative;

   .trigger {
      @include global.btn-reset;

      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: map.get($params, "trigger-padding");
      color: map.get($params, "trigger-color");
      font-size: map.get($params, "trigger-font-size");
      font-weight: map.get($params, "trigger-font-weight");
      border: map.get($params, "border-width") solid map.get($params, "border-color");
      text-transform: uppercase;

      .c-icon {
         color: map.get($params, "trigger-icon-color");
         font-size: map.get($params, "trigger-icon-size");
         margin-left: map.get($params, "trigger-icon-offset");
         transition: transform global.$transition-speed;
      }

      &.is-opened {
         color: map.get($params, "trigger-color-active");
         background: map.get($params, "list-background");
         border-bottom-color: transparent;
         .c-icon {
            color: map.get($params, "trigger-icon-color-active");
            transform: rotate(180deg);
         }
      }
   }

   ul {
      @include global.list-unstyled;

      position: absolute;
      width: 100%;
      left: 0;
      top: 100%;
      background: map.get($params, "list-background");
      padding: map.get($params, "list-padding");
      border: map.get($params, "border-width") solid map.get($params, "border-color");
      border-top: 0;

      a {
         @include global.underline-hover;

         color: map.get($params, "list-color");
         font-size: map.get($params, "list-font-size");
         font-weight: map.get($params, "list-font-weight");
         text-transform: uppercase;
      }
   }
}
