@import "./phoenix.scss";

$font_size_xl: 24px;
$font_size_l: 18px;
$font_size_m: 16px;
$font_size_s: 12px;

$margin_mini: 4px;
$margin_small: 8px;
$margin_medium: 16px;
$margin_big: 32px;

$white: white;
$black: black;
$red: rgb(200, 50, 50);
$light_gray: #e7e7e7;

$small_screen: 640px;
$medium_screen: 800px;
$big_screen: 1200px;

$small: 'screen and (min-width: #{$small_screen})';
$medium: 'screen and (min-width: #{$medium_screen})';
$big: 'screen and (min-width: #{$big_screen})';

@mixin outline() {
  outline: 2px solid $red;
  outline-offset: -2px;
}

@mixin keyboard_only_focus() {
  [data-whatintent='keyboard'] &:focus {
    @content;
  }
}

* {
  *:focus {
    outline: 0;
  }

  @include keyboard_only_focus {
    @include outline();
  }
}

html, body {
  margin: 0;
}

body {
  background-color: $light_gray;
  font-family: -apple-system, Helvetica Neue, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;

  &:visited {
    color: inherit;
  }
}

.grid {
  display: grid;
  position: relative;
  min-height: 0;
  grid-template-columns: 1fr;
  grid-column-gap: $margin_medium;
  grid-row-gap: $margin_medium;
  padding: $margin_medium;
  max-width: 2600px;
  margin: 0 auto;

  @media #{$medium} {
    grid-template-columns: 320px 1fr;
  }

  @media #{$big} {
    overflow: hidden;
    grid-template-columns: 320px 1fr 320px;
  }
}

h1, h2 {
  margin-top: 0;
  margin-bottom: $margin_medium;
}

h1 {
  font-size: $font_size_xl;
}

h2 {
  font-size: $font_size_l;
}

input[type="text"], input[type="number"], select {
  border: 1px solid $black;
  background: $white;
  padding: $margin_mini;
}

select {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg width="12" height="6" viewBox="0 0 12 6" xmlns="http://www.w3.org/2000/svg"><path d="M -6 -6 L 0 0 L -12 0 L -6 -6 Z" style="" transform="matrix(-1, 0, 0, -1, 0, 0)" fill="%23000000"/></svg>');
  background-repeat: no-repeat;
  background-position: top 50% right $margin_small;
  padding-right: $margin_big;
}

.button {
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  border: 1px solid $black;
  background: $white;
  padding: $margin_mini $margin_small;
  font-size: $font_size_m;
  color: inherit;
  cursor: pointer;
  box-shadow: $margin_mini $margin_mini 0 0 $light_gray;
  position: relative;

  &:active {
    color: inherit;
  }

  &:hover {
    top: $margin_mini / 2;
    left: $margin_mini / 2;
    box-shadow: $margin_mini / 2 $margin_mini / 2 0 0 $light_gray;
  }
}

.button-primary {
  background: $black;
  color: $white;
}

table {
  border-collapse: collapse;

  tr td, tr th {
    border: 1px solid $black;
    padding: $margin_small;
  }
}

input {
  min-width: 0;
}

.radio, .checkbox {
  $height: 12px;

  display: inline-flex;
  white-space: nowrap;
  position: relative;

  input {
    background: transparent;
    opacity: 0;
    position: absolute;
    margin: 0;
    padding: 0;
    width: $height;
    height: $height;
    z-index: -1;
  }

  input + label {
    cursor: pointer;
    position: relative;
    padding-left: $height + $margin_small;

    &:before, &:after {
      content: '';
      display: block;
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: $height;
      height: $height;
      border: 1px solid $black;
      background: $white;
    }

    &:after {
      margin-left: $height / 4;
      width: $height / 2;
      height: $height / 2;
      background: $white;
    }

    &:hover {
      &:after {
        background: $light_gray;
      }
    }
  }

  input:checked + label {
    &:before {
      background: $light_gray;
    }

    &:after {
      background: $black;
    }
  }

  input {
    @include keyboard_only_focus {
      & + label {
        @include outline();
      }
    }
  }
}

.radio {
  input + label {
    &:before, &:after {
      border-radius: 50%;
    }
  }
}


.column-main {
  display: flex;
  min-height: 0;
  grid-row: 1 / 2;

  @media #{$medium} {
    grid-row: 1 / 3;
    grid-column: 2 / 3;
    height: calc(100vh - #{2 * $margin_medium});
  }

  @media #{$big} {
    grid-row: 1 / 2;
  }
}

.column-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: auto;
}

.column-right, .column-left {
  @media #{$big} {
    max-height: calc(100vh - #{2 * $margin_medium});
    overflow: auto;
  }
}

.maze-settings, footer, .maze-stats, .maze {
  width: 100%;
  padding: $margin_medium;
  border: 2px solid $black;
  background-color: $white;
}

footer {
  margin-top: $margin_medium;
  font-size: $font_size_s;
}

.alert-container {
  position: fixed;
  z-index: 100;
  top: $margin_medium;
  right: $margin_medium;

  .alert {
    border-radius: 0;
    border-width: 2px;
    margin: 0 0 $margin_medium $margin_medium;
    max-width: 480px;
    position: relative;
    padding: $margin_medium $margin_big $margin_medium $margin_medium;
    word-wrap: break-word;

    p {
      margin: 0;
    }
  }

  .alert-close {
    position: absolute;
    top: $margin_small;
    right: $margin_small;
    border-radius: 0;
    -webkit-appearance: none;
    appearance: none;
    text-decoration: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: inherit;
    background: transparent;
    font-size: 1.5rem;
  }
}

@import './range.scss';
@import './maze.scss';
@import './maze_settings';
@import './maze_stats';
