@font-face {
  font-family: 'default';
  src: url('./inter.woff2');
}

@font-face {
  font-family: 'mono';
  src: url('./mono.woff2');
}

:root {
  --text: #fff;
  --placeholder: #ffffff4e;
  --footer-color: #ffffff78;
  --border: #3d3d3d;
  --cmd-background: #191919;
  --cmd-hover: #212121;
  --background: #121212;
  --overlay: #00000095;
  --primary: #344cb7;
  --padding: 1rem;
  --height: calc(100dvh - 30px - 2 * var(--padding));
  --font-size: 16px;
  --font: 'default', sans-serif;

  &.light {
    --text: #000;
    --placeholder: #0000004e;
    --background: #fff;
    --footer-color: #00000085;
    --border: #d5d5d5;
    --cmd-background: #e9e9e9;
    --cmd-hover: #dfdfdf;
  }

  &.mica {
    --background: transparent;
  }

  &:not(.mono) {
    div[contenteditable] {
      div,
      span {
        color: var(--text);
        text-decoration: none;
        font-style: normal;
      }
    }
  }

  &.glow {
    div[contenteditable] {
      div,
      span {
        --glow: #fff;
        text-shadow: 1px 1px 10px var(--glow);
      }
    }
  }

  &.mono {
    --font: 'mono', 'Courier New', Courier, monospace;
  }

  &.rainbow {
    & * {
      color: #7373fe !important;
    }
    filter: hue-rotate(0deg);
    animation: hueRotate 3s infinite linear;
  }
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font);
  scrollbar-width: none;
  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

html {
  scroll-behavior: smooth;
  background: var(--background);
}

/* Main editor */

div[contenteditable] {
  height: var(--height);
  max-height: var(--height);
  overflow-y: auto;
  outline: none;
  padding: var(--padding);
  padding-top: 0;
  margin-top: var(--padding);
  color: var(--text);
  font-size: var(--font-size);

  &:before {
    content: attr(placeholder);
    z-index: 9;
    line-height: 1.7;
    color: var(--placeholder);
    word-break: break-all;
    user-select: none;
  }

  &:focus::before {
    content: '';
  }
}

/* Grid */

.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  opacity: 0.3;
  background: repeating-linear-gradient(0deg, transparent, transparent 19px, var(--footer-color) 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, var(--footer-color) 20px);
  height: calc(var(--height) + 2 * var(--padding));
}

/* Footer */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100dvw;
  border-top: 1.5px solid var(--border);
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  z-index: 9;
  color: var(--footer-color);
  background: var(--background);
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;

  div {
    overflow-x: auto;
    white-space: nowrap;
    text-align: left;
  }

  div,
  span {
    font-weight: 500;
    font-family: 'default', sans-serif !important;
  }
}

/* Command palette */

.command-palette {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 99;
  background: var(--overlay);
  width: 100%;
  height: 100%;

  .wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;

    input {
      width: 25rem;
      max-width: calc(100% - 2rem);
      outline: none;
      border: none;
      background: var(--cmd-background);
      border-bottom: 1px solid var(--border);
      border-radius: 1rem 1rem 0 0;
      padding: 1rem;
      color: var(--text);
      font-size: 16px;
    }

    .bottom {
      width: 25rem;
      max-width: calc(100% - 2rem);
      height: 100dvh;
      max-height: 70%;
      border-radius: 0 0 1rem 1rem;

      .results {
        max-height: 100%;
        border-radius: 0 0 1rem 1rem;
        overflow-y: scroll;
      }

      .item {
        background: var(--cmd-background);
        padding: 1rem;
        white-space: nowrap;
        overflow-y: hidden;
        cursor: pointer;
        user-select: none;
        transition: background 200ms ease-in-out;
        color: var(--text) !important;

        .shortcut {
          background: var(--primary);
          font-family: 'mono', monospace;
          border-radius: 9rem;
          font-size: 10px;
          padding: 0.3rem 0.6rem;
          margin-right: 0.5rem;
          text-transform: uppercase;
          color: #fff;
        }

        &:last-of-type {
          border-radius: 0 0 1rem 1rem;
        }

        &:hover {
          background: var(--cmd-hover);
        }
      }
    }
  }
}

/* Keyframes */

@keyframes hueRotate {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}
