@use 'sass:map';

@mixin typography {
  font-size: 13px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", "Fira Sans",
    "Droid Sans", "Helvetica Neue", sans-serif;
  font-weight: 400;
}

@mixin center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin center-left {
  display: flex;
  align-items: center;
  justify-content: left;
}

$width: 250px;
$height: 150px;
$slider-width: 60px;
$anchor-padding: 13px;
$card-padding: 15px;
$track-height: 24px;
$checkbox-size: 24px;
$control-size: 30px;
$anchor-height: 50px;

@mixin generate($colors) {
  .scaptcha-anchor-container {
    @include center-left;
    box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.12);
    background-color: map.get($colors, 'anchor-background');
    width: 100%;
    height: $anchor-height;
    padding: $anchor-padding;
    max-width: 400px;
  }

  .scaptcha-anchor-checkbox {
    @include center;
    padding: 0;
    display: flex;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    height: $checkbox-size;
    width: $checkbox-size;
    background-color: map.get($colors, 'anchor-checkbox');
  }

  .scaptcha-anchor-checkbox-default:hover {
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.35);
  }

  .scaptcha-anchor-label {
    @include typography;
    @include center-left;
    color: map.get($colors, 'anchor-label');
    transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    margin-left: $anchor-padding;
    cursor: default;
  }

  .scaptcha-card-background {
    width: $width;
    height: $height;
  }

  .scaptcha-card-loading {
    @include center;
    margin: $card-padding;
    position: absolute;
    top: 0;
    left: 0;
    min-width: $width;
    min-height: $height;
    z-index: 1;
  }

  .scaptcha-card-container {
    position: absolute;
    padding: $card-padding $card-padding 0px $card-padding;
    min-width: $width + 2 * $card-padding;
    min-height: $height + 66px;
    background-color: map.get($colors, 'card-background');
    box-shadow: 0px -1px 0px -2px rgba(0, 0, 0, 0.2),
      0px 2px 9px 0px rgba(0, 0, 0, 0.14), 0px 5px 9px 0px rgba(0, 0, 0, 0.15);
    margin-top: -110px - $height;
    margin-left: -7px;
  }

  @media only screen and (max-width: 639px) {
    .scaptcha-card-container {
      left: 50%;
      margin-left: - ($width / 2) - $card-padding;
    }
  }

  .scaptcha-card-slider-puzzle {
    margin-left: $card-padding;
    margin-top: $card-padding;
    position: absolute;
    left: 5px;
    top: 0;
    height: $height;
    width: $slider-width;
    cursor: pointer;
  }

  .scaptcha-card-slider-control {
    @include center;
    position: absolute;
    top: 0;
    left: 0;
    width: $control-size;
    height: $control-size;
    cursor: pointer;
    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
      box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
      border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    border-radius: 50%;
  }

  .scaptcha-card-slider-control-default {
    background-color: map.get($colors, 'card-control-background');
    box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2),
      0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
  }

  .scaptcha-card-slider-control-active,
  .scaptcha-card-slider-control-success,
  .scaptcha-card-slider-control-failure {
    box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2),
      0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
  }

  .scaptcha-card-slider-control-active {
    background-color: map.get($colors, 'card-control-active');
  }

  .scaptcha-card-slider-control-success {
    background-color: map.get($colors, 'card-control-success');
  }

  .scaptcha-card-slider-control-failure {
    background-color: map.get($colors, 'card-control-failure');
  }

  .scaptcha-card-slider-container {
    margin-top: 7px;
    position: relative;
    height: 44px;
    width: $width;
  }

  .scaptcha-card-slider-track {
    box-shadow: inset 0px 0px 20px 0px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 3px;
    left: 0;
    width: $width;
    height: $track-height;
    background-color: map.get($colors, 'card-track-background');
    border-radius: $track-height / 2;
  }

  .scaptcha-card-slider-mask {
    box-shadow: inset 0px 0px 20px 0px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 3px;
    left: 0;
    width: 0;
    height: $track-height;
    border-radius: $track-height / 2;
    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
  }

  .scaptcha-card-slider-track-default,
  .scaptcha-card-slider-track-active {
    background-color: map.get($colors, 'card-track-active');
  }

  .scaptcha-card-slider-track-success {
    background-color: map.get($colors, 'card-track-success');
  }

  .scaptcha-card-slider-track-failure {
    background-color: map.get($colors, 'card-track-failure');
  }

  .scaptcha-card-slider-label {
    @include typography;
    @include center;
    color: map.get($colors, 'card-track-label');
    padding-left: 20px;
    position: absolute;
    top: 3px;
    left: 0;
    width: $width;
    height: $track-height;
    transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    cursor: default;
  }

  .scaptcha-icon-container {
    @include center;
    margin-left: 1px;
    margin-top: 1px;
  }

  .scaptcha-hidden {
    background: none;
    top: 0;
    left: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    position: fixed;
  }

  .scaptcha-container * {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }
}
