@use "sass:map";
@import "./borderless-animation";

$btn_border_clr: rgba(0, 0, 0, 12%);
$btn_bg: rgba(0, 0, 0, 2%);
$btn_corner_tile_clr: #e5a74f;

:root {
  body {
    background-color: #eef2f2;
  }
}

@mixin corner_tile($px, $py, $wt, $ht) {
  $view_box: "#svgView(viewBox(#{strip_unit($px)} #{strip_unit($py)} #{strip_unit($wt)} #{strip_unit($ht)}))";

  content: "";
  mask-image: url("https://res.cloudinary.com/firesafety/image/upload/v1651520240/svg-items/sci-fi--btn_txgxlg.svg#{$view_box}");
  background-color: $btn_corner_tile_clr;
  position: absolute;
  width: $wt;
  height: $ht;
}

@mixin corner_tile_position($custom-options: ()) {
  $options: map.merge(("top": initial, "left": initial, "bottom": initial, "right": initial), $custom-options);

  top: map.get($options, "top");
  left: map.get($options, "left");
  bottom: map.get($options, "bottom");
  right: map.get($options, "right");
}

[data-theme="sci-fi"] {
  .btn {
    border: 1px solid $btn_border_clr;

    &::after {
      @include corner_tile(0, 0, 6px, 6px);
      @include corner_tile_position(("top": -1.5px, "left": -1.5px));
    }

    &::before {
      @include corner_tile(0, 42px, 6px, 6px);
      @include corner_tile_position(("bottom": -1.5px, "left": -1.5px));
    }

    &:hover {
      &::after {
        animation: ripple_tl 1.4s ease-in-out infinite 0.4s;
      }

      &::before {
        animation: ripple_bl 1.4s ease-in-out infinite 0.4s;
      }

      .btn {
        @include element((), "inner") {
          &::after {
            animation: ripple_tr 1.4s ease-in-out infinite 0.4s;
          }

          &::before {
            animation: ripple_br 1.4s ease-in-out infinite 0.4s;
          }
        }
      }
    }

    @include element((), "inner") {
      outline: 0;
      border-radius: 0;
      background-color: $btn_bg;

      &::after {
        @include corner_tile(42px, 0, 6px, 6px);
        @include corner_tile_position(("top": -1.5px, "right": -1.5px));
      }

      &::before {
        @include corner_tile(42px, 42px, 6px, 6px);
        @include corner_tile_position(("bottom": -1.5px, "right": -1.5px));
      }
    }

    @include element((), "text") {
      color: #000;
      letter-spacing: 0.150em;
      text-transform: uppercase;
      filter: drop-shadow(1px 1px 0 rgb(10 189 240 / 30%)) drop-shadow(-1px -1px 0 rgb(254 1 1 / 30%));
      padding: 0 3px;
    }
  }

  .region-bg {
    @include modifiers((), "mono-low") {
      background-color: #f4f8f8;
      mask-image: repeating-linear-gradient(#fff, #fff 2px, transparent 3px);
    }
  }
}
