@use 'functions/color' as *;
@use 'functions/get-var' as *;
@use 'mixins/shadow' as *;
@use 'variables' as *;

// Modals
.modal {
  align-items: center;
  bottom: 0;
  display: none;
  justify-content: center;
  left: 0;
  opacity: 0;
  overflow: hidden;
  // padding: $layout-spacing; // old spectre.css
  padding: get-var('layout-spacing', $unit: 1);
  position: fixed;
  right: 0;
  top: 0;

  &:target,
  &.active {
    display: flex;
    opacity: 1;
    // z-index: $zindex-4; // old spectre.css
    z-index: get-var('z-index-4');

    .modal-overlay {
      // background: rgba($bg-color, .75); // old spectre.css
      background: color('bg-color', $alpha: 0.75);
      bottom: 0;
      cursor: default;
      display: block;
      left: 0;
      position: absolute;
      right: 0;
      top: 0;
    }

    .modal-container {
      animation: slide-down 0.2s ease 1;
      // z-index: $zindex-0; // old spectre.css
      z-index: get-var('z-index-0');
    }
  }

  &.modal-sm {
    .modal-container {
      // max-width: $control-width-sm; // old spectre.css
      max-width: get-var('control-width', $suffix: 'sm');
      // padding: 0 $unit-2; // old spectre.css
      padding: 0 get-var('unit-2');
    }
  }

  &.modal-lg {
    .modal-overlay {
      // background: $bg-color-light; // old spectre.css
      background: color('bg-color-light');
    }

    .modal-container {
      box-shadow: none;
      // max-width: $control-width-lg; // old spectre.css
      max-width: get-var('control-width', $suffix: 'lg');
    }
  }
}

.modal-container {
  @include shadow-variant(0.2rem);
  // background: $bg-color-light; // old spectre.css
  background: color('bg-color-light');
  // border-radius: $border-radius; // old spectre.css
  border-radius: get-var('border-radius');
  display: flex;
  flex-direction: column;
  max-height: 75vh;
  // max-width: $control-width-md; // old spectre.css
  max-width: get-var('control-width', $suffix: 'md');
  // padding: 0 $unit-4; // old spectre.css
  padding: 0 get-var('unit-4');
  width: 100%;

  &.modal-fullheight {
    max-height: 100vh;
  }

  .modal-header {
    // color: $dark-color; // old spectre.css
    color: color('dark-color');
    // padding: $unit-4; // old spectre.css
    padding: get-var('unit-4');
  }

  .modal-body {
    overflow-y: auto;
    // padding: $unit-4; // old spectre.css
    padding: get-var('unit-4');
    position: relative;
  }

  .modal-footer {
    // padding: $unit-4; // old spectre.css
    padding: get-var('unit-4');
    text-align: right;
  }
}
