// Variables
@import 'styles/colors';
@import 'styles/transitions';

// Constructors
@import 'styles/checkbox';
@import 'styles/input-range';
@import 'styles/radio';

/*
 * -----------------------------------------------------------------------------
 * Global styles
 * -----------------------------------------------------------------------------
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 16px;
  line-height: 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: $black;
  background: $white;
}

body.dark-mode {
  color: $white;
  background: $black;
}

a {
  color: inherit;
  text-decoration: underline;
}

a:visited {
  color: inherit;
}

a:hover {
  color: $primary;
}

a:focus {
  color: $primary;
  background: transparentize($primary, 0.9);
  box-shadow: inset 0 0 0 1px transparentize($primary, 0.95);
  outline: none;
  border-radius: 0.125rem;
  text-decoration: none;
}

header {
  position: absolute;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  height: 3rem;
  display: flex;
  align-items: center;
}

h1 {
  margin: 0;
  padding: 0 0.5rem;
  font-size: 2rem;
  line-height: 3rem;
  color: $white;
  background: $black;
  border-radius: 0.25rem;
}

h1 a,
h1 a:hover {
  color: inherit;
  text-decoration: none;
}

body.dark-mode h1 {
  color: $black;
  background: $white;
}

h2 {
  margin: 0 0.5rem 0 -0.25rem;
  padding: 0 0.5rem 0 0.75rem;
  font-size: 1.25rem;
  line-height: 3rem;
  color: $black;
  text-transform: uppercase;
  border-radius: 0 0.25rem 0.25rem 0;
  box-shadow: inset 0 0 0 2px black;
}

body.dark-mode h2 {
  color: $white;
  box-shadow: inset 0 0 0 2px white;
}

abbr,
abbr[title] {
  border-bottom: 0;
  text-decoration: none !important;
}

input,
button {
  color: inherit;
  font-size: inherit;
}

button:active {
  outline: none;
}

button {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: inherit;
  background: $gray-light;
  border: 0;
  border-radius: 0.25rem;
}

input[type='text'],
input[type='number'] {
  width: 100%;
  padding: 0.125rem;
  border: 1px solid $gray-lighter;
  border-radius: 0.25rem;

  &:focus {
    outline: none;
    border-color: $primary-darker;
    box-shadow: 0 0 0 1px $primary-darker;
  }
}

body.dark-mode {
  input[type='text'],
  input[type='number'] {
    border-color: $gray-dark;
    background: $black;

    &:focus {
      border-color: $primary;
      box-shadow: 0 0 0 1px $primary;
    }
  }
}

::-webkit-selection {
  color: $black;
  background: $primary-rgba;
}

::-moz-selection {
  color: $black;
  background: $primary-rgba;
}

::selection {
  color: $black;
  background: $primary-rgba;
}

@include range($white, $black, $gray-lighter, $primary-darker);

body.dark-mode {
  @include range($black, $white, $gray-dark, $primary);
}

@include radio($white, $black, $gray-lighter, $primary-darker);

body.dark-mode {
  @include radio($black, $white, $gray-dark, $primary);
}

/*
 * -----------------------------------------------------------------------------
 * General styles, i.e. classes
 * -----------------------------------------------------------------------------
 */

@include checkbox($white, $black, $gray-lighter, $primary-darker);

body.dark-mode {
  @include checkbox($black, $white, $gray-dark, $primary);
}

.container {
  position: absolute;
  z-index: 1;
  top: 5rem;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  transition: right $normal $ease;
}

body.permanent-options .container {
  right: 17rem;
}

body.fullscreen .container {
  top: 1rem;
  bottom: 1rem;
  left: 1rem;
}

.credits {
  margin-top: 0.25rem;
}

.credits,
.credits a {
  color: $gray-medium;
}

.inputs {
  display: inline-block;
  max-width: 100%;
}

.inputs > select {
  width: 100%;
}

.checkboxes.scrollbar {
  width: 100%;
  max-height: 6.25rem;
  overflow: auto;
}

.scrollbar::-webkit-scrollbar {
  width: 0.8rem;
}

.scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar::-webkit-scrollbar-thumb {
  border: 0.2rem solid rgba(0, 0, 0, 0);
  border-radius: 0.85rem;
  background: $black-lighter-rgba;
  background-clip: padding-box;
}

.scrollbar:hover::-webkit-scrollbar-thumb {
  background: $black-medium-rgba;
  background-clip: padding-box;
}

body.dark-mode {
  .scrollbar::-webkit-scrollbar-thumb {
    border: 0.2rem solid rgba(0, 0, 0, 0);
    border-radius: 0.85rem;
    background: $white-lighter-rgba;
    background-clip: padding-box;
  }

  .scrollbar:hover::-webkit-scrollbar-thumb {
    background: $white-medium-rgba;
    background-clip: padding-box;
  }
}

/*
 * -----------------------------------------------------------------------------
 * Specific styles, i.e. ids
 * -----------------------------------------------------------------------------
 */

.warning {
  position: absolute;
  z-index: 9999;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, 0);
  max-width: 40rem;
  padding: 1rem;
  background: $primary-darker;
  color: white;
  line-height: 1.25rem;
  border-radius: 0.5rem;
  opacity: 0.9;

  a:hover {
    color: white;
  }
}

body.dark-mode .warning {
  background: $primary;
}

body.fullscreen header {
  display: none;
}

#selection {
  display: flex !important;
  align-items: center;
  position: relative;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  height: 1.5rem;
  line-height: 1.5rem;
}

#selection label {
  margin-right: 0.5rem;
}

#matrices,
#matrices-credit,
#svg,
#svg-credit {
  display: none;
}

#group-by-grid {
  position: absolute;
  z-index: -1;
  top: 5rem;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;

  canvas {
    width: 100%;
    height: 100%;
  }
}

body.permanent-options #group-by-grid {
  right: 17rem;
}

#options {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  bottom: 0;
  width: 16rem;
  background: $white;
  border-left: 1px solid $gray-lighter;
  color: $black;
  transform: translate(16rem, 0);
  transition: transform $normal $ease;

  &.open {
    transform: translate(0, 0);
  }

  .toggler {
    position: absolute;
    display: block;
    top: 1rem;
    left: 0;
    height: 3rem;
    width: 3rem;
    padding: 0.5rem;
    background: $white;
    color: $black;
    border: 1px solid $gray-light;
    border-radius: 0.25rem;
    opacity: 0.2;
    transform: translate(-4rem, 0);
    transition: transform $normal $ease, border-radius $normal $ease,
      background $normal $ease, opacity $normal $ease, box-shadow $normal $ease;
    transform-origin: center;
    animation: 10s $ease 0s 1 fadeInLight;

    &:hover {
      opacity: 0.4;
    }

    &:focus {
      outline: none;
      box-shadow: 0 0 0 2px $primary-rgba;
    }

    svg {
      width: 100%;
      height: 100%;
    }
  }

  @keyframes fadeInLight {
    0% {
      opacity: 1;
      color: $white;
      border-color: $black;
      background: $black;
      transform: translate(-4rem, 0) scale(1);
    }
    80% {
      opacity: 1;
      color: $white;
      border-color: $black;
      background: $black;
      transform: translate(-4rem, 0) scale(1);
    }
    82.5% {
      opacity: 1;
      color: $white;
      border-color: $primary-darker;
      background: $primary-darker;
      transform: translate(-4rem, 0) scale(1.2);
    }
    85% {
      opacity: 1;
      color: $white;
      border-color: $black;
      background: $black;
      transform: translate(-4rem, 0) scale(1.1);
    }
    87.5% {
      opacity: 1;
      color: $white;
      border-color: $primary-darker;
      background: $primary-darker;
      transform: translate(-4rem, 0) scale(1.2);
    }
    90% {
      opacity: 1;
      color: $white;
      border-color: $primary-darker;
      background: $primary-darker;
      transform: translate(-4rem, 0) scale(1.1);
    }
    100% {
      opacity: 0.2;
      color: $black;
      border-color: $gray-light;
      background: $white;
      transform: translate(-4rem, 0) scale(1);
    }
  }

  &.open .toggler {
    opacity: 1;
    transform: translate(-3rem, 0);
    border-color: $gray-lighter;
    border-right: 0;
    border-radius: 0.25rem 0 0 0.25rem;
    background: $white;
    animation: none;
  }

  .content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.5rem;
    overflow: auto;
  }

  .content h4 {
    margin: 1rem 0 0.5rem 0;
    box-shadow: 0 1px 0 0 $gray-lighter;
  }

  .label-wrapper {
    display: block;
    margin: 0.25rem 0;
  }

  .label-wrapper .label-title {
    display: block;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .checkbox,
  .radio,
  .button,
  input[type='text'],
  input[type='number'] {
    display: block;
    margin: 0.25rem 0;
    font-size: 0.8rem;
    min-width: 0;
  }

  .button {
    color: $white;
    background: black;
    line-height: 1.5em;
    border-radius: 0.25rem;
    border: 0;
    background: $black;
    transition: color $normal $ease, background $normal $ease,
      opacity $normal $ease, box-shadow $normal $ease;

    &:focus {
      outline: none;
      box-shadow: 0 0 0 1px black, 0 0 0 3px $primary-rgba;
    }

    :disabled {
      color: $black;
      background: $white;
      opacity: 0.33;
    }
  }

  .title:after {
    content: ':';
    margin-right: 0.25rem;
  }

  .inputs {
    display: flex;
    align-items: center;
  }

  .value {
    font-size: 0.8em;
    text-align: right;
    width: 2rem;
  }

  .input-wrapper.with-sub-inputs {
    display: flex;

    .button {
      white-space: nowrap;
      margin-right: 0.25rem;
    }

    .inputs {
      width: 100%;
    }
  }
}

body.permanent-options #options {
  transform: translate(0, 0);

  .toggler {
    display: none;
  }
}

body.fullscreen #options .toggler {
  opacity: 0;
}

body.fullscreen #options.open .toggler {
  opacity: 1;
}

body.dark-mode #options {
  color: $white;
  border-left-color: $gray-darker;
  background: $black;

  .content h4 {
    box-shadow: 0 1px 0 0 $gray-darker;
  }

  .toggler {
    color: $white;
    border-color: $gray-dark;
    background: $black;
    animation: 10s $ease 0s 1 fadeInDark;
  }

  @keyframes fadeInDark {
    0% {
      opacity: 1;
      color: $black;
      border-color: $white;
      background: $white;
      transform: translate(-4rem, 0) scale(1);
    }
    80% {
      opacity: 1;
      color: $black;
      border-color: $white;
      background: $white;
      transform: translate(-4rem, 0) scale(1);
    }
    82.5% {
      opacity: 1;
      color: $black;
      border-color: $primary;
      background: $primary;
      transform: translate(-4rem, 0) scale(1.2);
    }
    85% {
      opacity: 1;
      color: $black;
      border-color: $white;
      background: $white;
      transform: translate(-4rem, 0) scale(1.1);
    }
    87.5% {
      opacity: 1;
      color: $black;
      border-color: $primary;
      background: $primary;
      transform: translate(-4rem, 0) scale(1.2);
    }
    90% {
      opacity: 1;
      color: $black;
      border-color: $primary;
      background: $primary;
      transform: translate(-4rem, 0) scale(1.1);
    }
    100% {
      opacity: 0.2;
      color: $white;
      border-color: $gray-dark;
      background: $black;
      transform: translate(-4rem, 0) scale(1);
    }
  }

  &.open .toggler {
    border-color: $gray-darker;
    background: $black;
    animation: none;
  }

  .button {
    color: $black;
    background: $white;

    :disabled {
      color: $white;
      background: $black;
    }
  }
}

body.options-opened #options .toggler {
  animation: none;
}

#undo {
  position: relative;
  display: block;
  width: 100%;
  line-height: 1.5rem;
  border-radius: 0.25rem;
  color: $white;
  border: 0;
  background: $black;
  transition: color $normal $ease, border $normal $ease,
    background $normal $ease, opacity $normal $ease, box-shadow $normal $ease;

  &:focus {
    outline: none;
    box-shadow: 0 0 0 1px black, 0 0 0 3px $primary-rgba;
  }

  :disabled {
    color: $black;
    background: $white;
    opacity: 0.33;
  }
}

body.dark-mode #undo {
  color: $black;
  background: $white;

  :disabled {
    color: $white;
    background: $black;
  }
}

#error {
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  > div {
    width: 100%;
    max-width: 24rem;
    padding: 1rem;
    color: black;
    border-radius: 0.25rem;
    background: #c76526;
  }

  a,
  a:hover {
    color: inherit;
  }

  ::-webkit-selection {
    color: $white;
    background: $black;
  }

  ::-moz-selection {
    color: $white;
    background: $black;
  }

  ::selection {
    color: $white;
    background: $black;
  }
}

#no-webgl2-support,
#unknown-example {
  display: none;
}

#footer {
  position: absolute;
  display: none;
  justify-content: space-between;
  z-index: 2;
  bottom: 0;
  left: 0;
  right: 0;
  color: $gray-medium;
  background: rgba(204, 204, 204, 0.95);
  opacity: 0;
  transform: translate(0, 3rem);

  &.show {
    display: flex;
    animation: 8s $ease 0s 1 fadeOut;
  }

  p {
    margin: 1rem;
  }
}

body.dark-mode #footer {
  background: rgba(51, 51, 51, 0.95);
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translate(0, 3rem);
  }
  10% {
    opacity: 1;
    transform: translate(0, 3rem);
  }
  15% {
    opacity: 1;
    transform: translate(0, 0);
  }
  95% {
    opacity: 1;
    transform: translate(0, 0);
  }
  100% {
    opacity: 0;
    transform: translate(0, 3rem);
  }
}

#hue-mrna::-webkit-slider-runnable-track,
#hue-nuclei::-webkit-slider-runnable-track {
  // prettier-ignore
  background: -webkit-linear-gradient(
    right, red, orange, yellow, green, cyan, blue, violet, red
  );
  // prettier-ignore
  background: linear-gradient(
    to right, red, orange, yellow, green, cyan, blue, violet, red
  );
}

#hue-mrna::-moz-range-track,
#hue-nuclei::-moz-range-track {
  // prettier-ignore
  background: -moz-linear-gradient(
    right, red, orange, yellow, green, cyan, blue, violet, red
  );
  // prettier-ignore
  background: linear-gradient(
    to right, red, orange, yellow, green, cyan, blue, violet, red
  );
}

/*
 * -----------------------------------------------------------------------------
 * Media Queries
 * -----------------------------------------------------------------------------
 */
