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

$params: (
   "breakpoint-md": 610px,
   "breakpoint-lg": 980px,

   "background-color": transparent,
   "color": global.$text-muted,
   "border-bottom": 0,
   "margin": auto 0 0,
   "border-radius": 0,

   "gap": global.$gap-width,
   "padding-block": 40px,
   "container-type": inline-size,
   "container-size": "true",
   "container-border-bottom": global.$border-width solid global.$border-color-dark,
   "container-max-width": 1230px,
   "container-display": flex,
   "container-flex-direction": column,
   "container-align-items": center,
   "container-text-align": center,
   "container-flex-direction-md": row,
   "container-justify-content-md": space-between,
   "container-text-align-md": unset,

   "text-flex": 1,
   "text-display": flex,
   "text-flex-direction": column,
   "text-gap": global.$gap-width,
   "text-inner-margin": 0 auto,
   "text-inner-margin-md": 0,
   "text-flex-direction-lg": row,
   "text-align-items-lg": center,
   "text-justify-content-lg": space-around,

   "title-color": global.$white,
   "title-font-size": global.$font-size-h3,
   "title-font-weight": global.$font-weight-bold,
   "title-text-transform": none,
   "title-letter-spacing": normal,

   "subtitle-max-width": 260px,
   "subtitle-color": global.$text-dark,
   "subtitle-font-size": global.$font-size-base,
   "subtitle-font-weight": global.$font-weight-base,
);

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

   $params: map.merge($params, components.$c-footer-newslettersubscribe);
}

.#{component("Footer:NewsletterSubscribe", "class")} {
   container-type: map.get($params, "container-type");
   background-color: map.get($params, "background-color");
   color: map.get($params, "color");
   border-bottom: map.get($params, "border-bottom");
   margin: map.get($params, "margin");
   border-radius: map.get($params, "border-radius");

   > .container {
      display: map.get($params, "container-display");
      flex-direction: map.get($params, "container-flex-direction");
      align-items: map.get($params, "container-align-items");
      text-align: map.get($params, "container-text-align");
      gap: map.get($params, "gap");
      padding-block: map.get($params, "padding-block");
      border-bottom: map.get($params, "container-border-bottom");

      @if (map.get($params, "container-size") != "true") {
         max-width: global.$unset-max;
      } @else if (map.get($params, "container-max-width" ) != "false") {
         max-width: map.get($params, "container-max-width");
      }
   }

   .text {
      flex: map.get($params, "text-flex");
      display: map.get($params, "text-display");
      flex-direction: map.get($params, "text-flex-direction");
      gap: map.get($params, "text-gap");

      p {
         margin: map.get($params, "text-inner-margin");
      }
   }

   .title-default {
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
      text-transform: map.get($params, "title-text-transform");
      letter-spacing: map.get($params, "title-letter-spacing");
   }

   .subtitle {
      color: map.get($params, "subtitle-color");
      font-size: map.get($params, "subtitle-font-size");
      font-weight: map.get($params, "subtitle-font-weight");
      white-space: normal;
      max-width: map.get($params, "subtitle-max-width");
   }

   // fallback na sticky paticku
   + .#{component("Footer", "class")} {
      margin-top: 0;
   }

   @container (inline-size > #{map.get($params, "breakpoint-md")}) {
      @include global.container-query-selector('> .container') {
         flex-direction: map.get($params, "container-flex-direction-md");
         justify-content: map.get($params, "container-justify-content-md");
         text-align: map.get($params, "container-text-align-md");

         .text {
            p {
               margin: map.get($params, "text-inner-margin-md");
            }
         }
      }
   }

   @container (inline-size > #{map.get($params, "breakpoint-lg")}) {
      @include global.container-query-selector('.text') {
         flex-direction: map.get($params, "text-flex-direction-lg");
         align-items: map.get($params, "text-align-items-lg");
         justify-content: map.get($params, "text-justify-content-lg");
      }
   }
}
