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

$params: (
   "item-gap": global.$gap-width,
   "items-per-row": 3,
   "breakpoint" : global.$md,

   "background": global.$body-bg-alt,
   "padding": 20px,
   "margin": 0,
   "border": none,
   "border-radius": global.$border-radius-lg,

   "text-margin": 5px,
   "points-font-size": global.$font-size-h2,
   "points-font-weight": global.$font-weight-bold,
   "points-line-height": global.$headings-line-height,

   "link-offset": 10px,
);

@if global-variable-exists(c-account-userdashboard-bonuspoints, components) {
   $keys: map.keys(components.$c-account-userdashboard-bonuspoints);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Account:UserDashboard:BonusPoints", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-account-userdashboard-bonuspoints);
}

.#{component("Account:UserDashboard:BonusPoints", "class")} {
   width: 100%;
   background: map.get($params, 'background');
   padding: map.get($params, 'padding');
   margin: map.get($params, 'margin');
   border: map.get($params, 'border');
   border-radius: map.get($params, 'border-radius');

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

   .points {
      margin-bottom: 0;
      font-size: map.get($params, 'points-font-size');
      font-weight: map.get($params, 'points-font-weight');
      line-height: map.get($params, 'points-line-height');

      + a {
         display: inline-block;
         margin-top: map.get($params, 'link-offset');
      }
   }

   @container (inline-size > #{map.get($params, "breakpoint")}) {
      width: calc((100% - ( map.get($params, 'items-per-row') - 1) * map.get($params, 'item-gap')) / map.get($params, 'items-per-row'));
   }
}
