:root {
  /* 1 lightest - 6 darkest  */
  --blue1: #dee4e9;
  --blue2: #bec9d4;
  --blue3: #9eafbf;
  --blue4: #7f96aa;
  --blue5: #607e96;
  --blue6: #406682;

  --border: var(--blue6);
  --light-background: var(--blue1);
  --medium-background: var(--blue2);
  --dark-background: var(--blue3);
  --shape-background: var(--dark-background);
}

/* General */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
  font-family: sans-serif;
}

body {
  background-color: #ddd;
  color: #333;

  width: 100vw;
  min-height: 100vh;

  display: flex;
  flex-direction: column;
}

.main-header {
  width: 100%;
  background-color: var(--dark-background);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
  padding: 0.8rem 1.6rem;

  font-size: 1.6rem;
  font-weight: 600;
}

main {
  position: relative;

  flex: 1;
  height: 100%;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

button span {
  -webkit-user-select: none;
  user-select: none;
}

#board {
  position: relative;

  width: 100%;
  flex: 1;

  background-color: var(--medium-background);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-position: 0 0;
  background-size: 40px 40px;
}

/* Toolbox */
.toolbox {
  width: 100%;
  background-color: rgba(185, 185, 185, 0.3);
  backdrop-filter: blur(1px);
  border-top: 2px solid var(--border);
  padding: 1.2rem;
  transform: translateY(0);

  position: fixed;
  z-index: 999999999;
  bottom: 0;

  display: flex;
  justify-content: space-around;

  transition: all 0.4s ease-in-out;
}

.toolbox--hidden {
  transform: translateY(100%);
}

.toolbox__show-btn {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border);
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  position: absolute;
  z-index: 999;
  top: 0;
  left: 50%;
  translate: -50% -125%;

  color: #222;
  background-color: var(--dark-background);

  transition: background-color 0.2s;
}

.toolbox--hidden .toolbox__show-btn span {
  rotate: 180deg;
}

.toolbox__show-btn:hover {
  cursor: pointer;
  background-color: #ccc;
}

.toolbox__btn {
  background-color: var(--shape-background);
  border: 2px solid var(--border);
  width: 100px;
  height: 100px;
  font-family: inherit;
  font-weight: 600;
  text-transform: capitalize;
  flex: 0 2 100px;

  transition: all 0.3s;
}

.toolbox__btn:hover {
  cursor: pointer;
  background-color: #888;
}

/* Shape */
.shape {
  position: absolute;
  left: 0;
  top: 0;
}

.shape__element {
  background-color: var(--dark-background);
  border: 2px solid var(--border);
  width: 100px;
  height: 100px;

  resize: both;
  overflow: auto;
  cursor: move;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.shape.dragging {
  opacity: 0.5;
}

.shape:hover .shape__controls,
.shape:hover .anchor-btn {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.circle {
  border-radius: 50%;
}

/* Controls */
.shape__controls {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(-80%);
  z-index: 9999;
  padding-bottom: 0.4rem;
  width: 100%;

  display: flex;
  justify-content: space-between;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.shape__controls button {
  background: none;
  border: none;
  color: #333;
  transition: all 0.3s;
}

.shape__controls button:hover {
  cursor: pointer;
  color: #222;
  transform: scale(1.2);
}

.shape__input {
  width: 100%;
  height: 100%;
}

.shape__text {
  font-size: 1.4rem;
  font-weight: 600;
  width: 100%;
  word-wrap: break-word;
  text-align: center;
}

/* anchors */

.anchor-btn {
  width: 1.6rem;
  height: 1.6rem;
  font-size: 1.6rem;
  color: #222;
  border: 1px solid var(--border);
  border-radius: 50%;
  background-color: var(--light-background);

  display: flex;
  align-items: center;
  justify-content: center;

  position: absolute;
  z-index: 9999999;

  transition: all 0.3s;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.anchor-btn span {
  font-size: inherit;
}

.anchor-btn:hover {
  cursor: pointer;
  background-color: #bbb;
}

.anchor-left {
  /* 1px comes from element border size, if we set it to 0 then lines looks to be offset by 1 pixels */
  left: 1px;
  top: 50%;

  transform: translate(-50%, -50%);
}

.anchor-right {
  /* 1px comes from element border size, if we set it to 0 then lines looks to be offset by 1 pixels */
  right: 1px;
  top: 50%;

  transform: translate(50%, -50%);
}

.anchor-top {
  left: 50%;
  top: 0;

  transform: translate(-50%, -50%);
}

.anchor-bottom {
  left: 50%;
  /* 2px comes from element border size, if we set it to 0 then lines looks to be offset by 2 pixels */
  bottom: 2px;

  transform: translate(-50%, 50%);
}

/* lines */
.line {
  height: 2px;
  background-color: var(--border);
  border-radius: 10rem;

  transform-origin: left;

  position: absolute;
  z-index: 999;
}

.line:hover {
  cursor: pointer;
  background-color: #777;
}

.line::after {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

  content: "";
  width: 0;
  height: 0;

  border-top: 1rem solid transparent;
  border-bottom: 1rem solid transparent;
}

/* 'Logic' for arrow direction  */
.line[data-direction="right"]::after {
  border-right: 1.6rem solid var(--border);
}

.line[data-direction="left"]::after {
  border-left: 1.6rem solid var(--border);
}

/* Snap lines */
.snap-line {
  position: absolute;

  min-width: 1px;
  min-height: 1px;

  opacity: 0.5;
  background-color: var(--border);
}
