@mixin variable-font-size($basesize) {
  font-size: $basesize * 0.6;

  @include media-breakpoint-only(sm) {
    font-size: #{$basesize * 0.7};
  }
  @include media-breakpoint-only(md) {
    font-size: #{$basesize * 0.8};
  }
  @include media-breakpoint-only(lg) {
    font-size: #{$basesize * 0.9};
  }
  @include media-breakpoint-up(xl) {
    font-size: $basesize;
  }
}

@mixin expand-editor($editor-margin-top) {
  $header-plus-footer: $editor-margin-top + $grw-editor-navbar-bottom-height;

  $editor-margin: $header-plus-footer //
    + 25px //   add .btn-open-dropzone height
    + 30px; //  add .navbar-editor height

  .main {
    width: 100%;
    height: calc(100vh - #{$editor-margin-top});
    margin-top: 0px !important;

    .grw-container-convertible {
      max-width: unset;
      padding: 0;
      margin: 0;
    }

    &,
    .content-main,
    .tab-content {
      display: flex;
      flex: 1;
      flex-direction: column;

      .tab-pane {
        height: calc(100vh - #{$header-plus-footer});
        min-height: calc(100vh - #{$header-plus-footer}); // for IE11
      }

      #page-editor {
        // right(preview)
        &,
        & > .row,
        .page-editor-preview-container,
        .page-editor-preview-body {
          height: calc(100vh - #{$header-plus-footer});
          min-height: calc(100vh - #{$header-plus-footer}); // for IE11
        }

        // left(editor)
        .page-editor-editor-container {
          height: calc(100vh - #{$header-plus-footer});
          min-height: calc(100vh - #{$header-plus-footer}); // for IE11

          .react-codemirror2,
          .CodeMirror,
          .CodeMirror-scroll,
          .textarea-editor {
            height: calc(100vh - #{$editor-margin});
          }
        }
      }

      #page-editor-with-hackmd {
        &,
        .hackmd-preinit,
        .hackmd-error,
        #iframe-hackmd-container > iframe {
          width: 100%;
          height: calc(100vh - #{$header-plus-footer});
          min-height: calc(100vh - #{$header-plus-footer}); // for IE11
        }
      }
    }
  }
}

@mixin expand-modal-fullscreen($hasModalHeader: true, $hasModalFooter: true) {
  // full-screen modal
  width: auto;
  max-width: unset !important;
  height: calc(100vh - 30px);
  margin: 15px !important;

  .modal-content {
    height: calc(100vh - 30px);
  }

  // expand .modal-body (with calculating height)
  .modal-body {
    $modal-header: 54px;
    $modal-footer: 46px;

    $margin: 0px;
    @if $hasModalHeader {
      $margin: $margin + $modal-header;
    }
    @if $hasModalFooter {
      $margin: $margin + $modal-footer;
    }
    height: calc(100% - #{$margin});
  }
}

@mixin apply-navigation-transition() {
  transition-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
  transition-duration: 300ms;
}

@mixin border-vertical($beforeOrAfter, $borderLength, $zIndex: initial, $isBtnGroup: false) {
  position: relative;
  @if $isBtnGroup {
    &:not(:first-child) {
      margin-left: 0;
      border-left: none;
    }
    &:not(:last-child) {
      border-right: none;
    }
  }
  &:not(:first-child) {
    &::#{$beforeOrAfter} {
      position: absolute;
      top: calc((100% - #{$borderLength}) / 2);
      left: 0;
      z-index: $zIndex;
      width: 100%;
      height: $borderLength;
      margin-left: -0.5px;
      content: '';
      border-left: 1px solid transparent;
      transition: border-color 0.15s ease-in-out;
    }
  }
}

@mixin blink-bgcolor($bgcolor) {
  @keyframes fadeout {
    100% {
      opacity: 0;
    }
  }
  position: relative;
  z-index: 1;

  &::after {
    position: absolute;
    top: 15%;
    left: 0;
    z-index: -1;
    width: 100%;
    height: 70%;
    content: '';
    background-color: $bgcolor;
    border-radius: 2px;
    animation: fadeout 1s ease-in 1.5s forwards;
  }
}

@mixin button-svg-icon-variant($background, $hover-background: darken($background, 7.5%), $active-background: darken($background, 10%)) {
  svg {
    fill: color-yiq($background);
  }

  @include hover() {
    svg {
      fill: color-yiq($hover-background);
    }
  }

  &:focus,
  &.focus {
    svg {
      fill: color-yiq($hover-background);
    }
  }

  // Disabled comes first so active can properly restyle
  &.disabled,
  &:disabled {
    svg {
      fill: color-yiq($background);
    }
  }

  &:not(:disabled):not(.disabled):active,
  &:not(:disabled):not(.disabled).active,
  .show > &.dropdown-toggle {
    svg {
      fill: color-yiq($active-background);
    }
  }
}

@mixin button-outline-svg-icon-variant($value, $color-hover: $value) {
  svg {
    fill: $value;
  }
  @include hover() {
    svg {
      fill: $color-hover;
    }
  }
  &.disabled,
  &:disabled {
    svg {
      fill: $value;
    }
  }
  &:not(:disabled):not(.disabled):active,
  &:not(:disabled):not(.disabled).active,
  .show > &.dropdown-toggle {
    svg {
      fill: $color-hover;
    }
  }
}

@mixin count-badge($color, $bg-color, $min-width: initial) {
  min-width: $min-width;
  padding: 0.1rem 0.5rem;
  font-family: $font-family-monospace;
  font-size: 12px;
  font-weight: 500;
  color: $color;
  background-color: $bg-color;
}
