/* global reset */
html,
body {
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: normal;
}

.as-text {
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.flex-grow {
  flex-grow: 1;
}

.editor {
  position: relative;

  & .editorframe {
    width: 100%;
    border: 1px solid #000;
  }

  & .editbar {
    display: flex;
    flex-wrap: wrap;
    line-height: 0;
    padding-left: 1px;

    & button {
      border: none;
      margin: 0;
      padding: 0;
      background: url("wysiwygbar.png");
      height: 24px;
      display: inline-block;
      cursor: pointer;
      margin-left: -1px;

      &:hover {
        background-position-y: -24px;
      }
    }

    & .fontface {
      vertical-align: top;
      height: 24px;
      margin-left: -1px;
      width: 150px;
      max-width: 200px;
      flex-grow: 1;
    }

    & .bold {
      width: 33px;
    }

    & .italic {
      width: 34px;
      background-position: -32px 0;
    }

    & .underline {
      width: 36px;
      background-position: -65px 0;
    }

    & .strikethrough {
      width: 31px;
      background-position: -100px 0;
    }

    & .forecolor {
      width: 32px;
      background-position: -130px 0;
    }

    & .backcolor {
      width: 33px;
      background-position: -161px 0;
    }

    & .insertimage {
      width: 30px;
      background-position: -193px 0;
    }

    & .createlink {
      width: 29px;
      background-position: -222px 0;
    }

    & .c_email {
      width: 28px;
      background-position: -250px 0;
    }

    & .justifyleft {
      width: 27px;
      background-position: -277px 0;
    }

    & .justifycenter {
      width: 28px;
      background-position: -303px 0;
    }

    & .justifyright {
      width: 27px;
      background-position: -330px 0;
    }

    & .c_youtube {
      width: 29px;
      background-position: -356px 0;
    }

    & .c_code {
      width: 27px;
      background-position: -384px 0;
    }

    & .c_quote {
      width: 26px;
      background-position: -410px 0;
    }

    & .c_spoiler {
      width: 30px;
      background-position: -435px 0;
    }

    & .insertorderedlist {
      width: 29px;
      background-position: -464px 0;
    }

    & .insertunorderedlist {
      width: 29px;
      background-position: -492px 0;
    }

    & .c_smileys {
      width: 30px;
      background-position: -520px 0;
    }

    & .c_switcheditmode {
      padding-left: 29px;
      background-position: -549px 0;
      border-right: 1px solid #777;
    }
  }
}

.emotewin {
  height: 200px;
  width: 150px;
  overflow-x: auto;
  background: #eef;
  border: 1px solid #000;

  & button {
    display: block;
    text-decoration: none;
    padding: 10px;
    width: 100%;

    & img {
      border: 0;
      float: left;
    }
  }
}

/* datepicker */

#datepicker {
  position: absolute;
  width: 200px;
  border: 1px solid #000;
  background: #fff;

  & td {
    vertical-align: middle;
    text-align: center;
  }

  & .control {
    cursor: pointer;
  }

  & .year {
    font-weight: bold;
  }

  & .month {
    font-weight: bold;
  }

  & .weekdays td {
    width: 50px;
    font-weight: bold;
    font-size: smaller;
  }

  & .day:hover {
    background: #eee;
    cursor: pointer;
  }

  & .day.selected {
    background: #ccc;
  }
}

.bbcode {
  &.checkerboard {
    user-select: none;

    & th,
    & td {
      width: 30px;
      height: 30px;
      text-align: center;
      vertical-align: middle;
      line-height: 30px;
    }

    & td {
      font-size: 30px;
    }

    & tr:nth-child(2n) {
      td:nth-child(2n) {
        background-color: tan;
      }

      td:nth-child(2n + 1) {
        background-color: brown;
      }
    }

    & tr:nth-child(2n + 1) {
      td:nth-child(2n) {
        background-color: brown;
      }

      td:nth-child(2n + 1) {
        background-color: tan;
      }
    }

    .piece {
      cursor: pointer;
    }

    &.chess .piece {
      &.danger {
        &::before {
          content: "💧";
          font-size: 10px;
          position: absolute;
          top: 0;
          right: 0;
          line-height: 10px;
        }

        &[data-piece="k" i] {
          animation: shake-x 50ms alternate linear infinite;

          &::before {
            content: "‼️";
          }
        }
      }

      &.white {
        color: white;
        -webkit-text-stroke: 1px #222;
      }

      &.black {
        color: black;
      }
    }

    &.checkers .piece {
      font-size: 20px;
    }
  }

  &.othello {
    background: #009045;
    border-collapse: collapse;
    border: 10px inset #000;

    td {
      border: 2px solid #00dc69 !important;
      height: 30px;
      width: 30px;
    }

    tfoot {
      background: linear-gradient(transparent, #000);
      padding: 5px;
      color: white;

      & td {
        vertical-align: middle !important;
        text-align: center;
      }
    }

    .piece {
      height: 100%;
      width: 100%;
      position: relative;
      transform-style: preserve-3d;
      transition: all 1s;

      &.white {
        transform: rotateY(180deg);
      }

      &,
      &::before,
      &::after {
        display: block;
        width: 100%;
        height: 100%;
        border-radius: 100%;
      }

      &::before,
      &::after {
        position: absolute;
        inset: 0;
        content: "";
        transform-style: preserve-3d;
        backface-visibility: hidden;
      }

      &::before {
        background: black;
      }

      &::after {
        background: white;
        transform: rotateY(180deg);
      }
    }
  }

  &.rainbow {
    animation: scroll-background-rainbow linear infinite 2s;
    font-weight: bold;
    background-clip: text;
    color: transparent;
    background-image: linear-gradient(
      to right,
      red,
      orange,
      yellow,
      green,
      blue,
      indigo,
      violet
    );
    background-size: 200% auto;
  }
}

@keyframes scroll-background-rainbow {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 200% 0;
  }
}

@keyframes shake-x {
  from {
    translate: -2px;
  }

  to {
    translate: 2px;
  }
}
