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

$params: (
   "background": global.$white,
   "min-height": 530px,

   "breakpoint": global.$md,

   "overlay-bg": global.$overlay-bg,
   "overlay-opacity": .6,

   "scrollbar-width": 5px,
   "scrollbar-track-bg": global.$border-color,
   "scrollbar-thumb-bg": global.$black,
   "scrollbar-thumb-border-radius": 4px,
);

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

   $params: map.merge($params, components.$c-cartbox-sidebar);
}

.cartbox-overlay {
   background: map.get($params, "overlay-bg");
   opacity: 0;
   position: fixed;
   bottom: 0;
   left: 0;
   transition: opacity global.$transition-speed;
   visibility: hidden;
   width: 100%;
   height: 100%;
   z-index: -1;

   &.active {
      opacity: map.get($params, "overlay-opacity");
      visibility: visible;
      z-index: 1001;
   }
}

// pravy box + pozadi pro pravy box
.cartbox-focus,
.cartbox-bg {
   background: map.get($params, "background");
   min-height: map.get($params, "min-height");
   position: fixed;
   top: 0;
   right: -$cartbox-sidebar-width - $cartbox-alsobought-width;
   transition: right global.$transition-speed;
   width: $cartbox-sidebar-width;
   height: 100%;

   &.active {
      right: 0;
   }
}

.cartbox-focus {
   display: flex;
   flex-direction: column;
   transition-delay: calc(#{global.$transition-speed} / 4);
   text-align: left;
   z-index: 1002;
}

.custom-scrollbar {
   @include global.custom-scrollbar;
}

.cartbox-bg {
   z-index: 1001;
}

@media screen and (max-width: map.get($params, "breakpoint")), (max-height: 520px) {
   .cartbox-overlay,
   .cartbox-focus,
   .cartbox-bg {
      display: none;
   }
}
