@use "sass:string";
@use '../../00-settings/settings' as *;
@use '../../00-mixins/mixins' as *;

////
/// This file defines helper classes.
////


///
/// Prevent text wrapping.
///
.nowrap {
  white-space: nowrap;
}

///
/// Add bold styling
///
.bold {
  @include bold-text;
}

///
/// Visually hidden
///
%visually-hidden,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

///
/// Force a link to have no link styling.
///
%no-link-style,
.no-link-style {
  @include no-link-style;
}

///
/// Margin helper classes.
///
$directions: top, right, bottom, left;
@for $i from 0 through 40 {
  @each $d in $directions {
    $ds: string.slice($d, 0, 1); // Get first letter of direction

    .m#{$ds}-#{$i} {
      margin-#{$d}: $i * .1rem;
    }
  }
}

///
/// Hiding helper classes.
///
@mixin hide($breakpoint: null) {
  @if ($breakpoint == 'mobile') {
    @include mobile {
      display: none;
    }
  }

  @if ($breakpoint == 'mobile-only') {
    @include breakpoint(max-width $bp-mobile - 1) {
      display: none;
    }
  }

  @if ($breakpoint == 'phablet') {
    @include phablet {
      display: none;
    }
  }

  @if ($breakpoint == 'phablet-only') {
    @include breakpoint((min-width $bp-mobile) (max-width $bp-phablet - 1)) {
      display: none;
    }
  }

  @if ($breakpoint == 'tablet') {
    @include tablet {
      display: none;
    }
  }

  @if ($breakpoint == 'tablet-only') {
    @include breakpoint((min-width $bp-phablet) (max-width $bp-tablet - 1)) {
      display: none;
    }
  }

  @if ($breakpoint == 'desktop') {
    @include desktop {
      display: none;
    }
  }

  @if ($breakpoint == 'desktop-only') {
    @include breakpoint((min-width $bp-tablet) (max-width $bp-desktop - 1)) {
      display: none;
    }
  }
}

.hidden-mobile {
  @include hide('mobile');
}

.hidden-mobile-only {
  @include hide('mobile-only');
}

.hidden-phablet {
  @include hide('phablet');
}

.hidden-phablet-only {
  @include hide('phablet-only');
}

.hidden-tablet {
  @include hide('tablet');
}

.hidden-tablet-only {
  @include hide('tablet-only');
}

.hidden-desktop {
  @include hide('desktop');
}

.hidden-desktop-only {
  @include hide('desktop-only');
}

.show-desktop-only {
  @include desktop-and-below {
    display: none;
  }
}
