/*
 * SPDX-FileCopyrightText: 2024 Siemens AG
 *
 * SPDX-License-Identifier: MIT
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

@use 'sass:map' as map;

$screen-breakpoints: (
  sm: (
    max: 48em,
  ),
  md: (
    min: 48.0625em,
    max: 80em,
  ),
  lg: (
    min: 80.0625em,
  ),
);

@function breakpoint-min($name, $breakpoints: $screen-breakpoints) {
  @return map.get($map: map.get($map: $breakpoints, $key: $name), $key: min);
}

@function breakpoint-max($name, $breakpoints: $screen-breakpoints) {
  @return map.get($map: map.get($map: $breakpoints, $key: $name), $key: max);
}

@mixin media-breakpoint-match($name, $breakpoints: $screen-breakpoints) {
  $min: breakpoint-min($name, $breakpoints);
  $max: breakpoint-max($name, $breakpoints);
  @if $min and $max {
    @media only screen and (min-width: $min) and (max-width: $max) {
      @content;
    }
  } @else if $min and not $max {
    @media only screen and (min-width: $min) {
      @content;
    }
  } @else if not $min and $max {
    @media only screen and (max-width: $max) {
      @content;
    }
  } @else {
    @content;
  }
}
