:host {
  display: contents;
  tab-size: 4;

  & .container {
    all: inherit;
    display: flex;
    position: relative;
    box-sizing: border-box;
    background: var(--tm-background-color, inherit);
    overflow: auto;
    color: var(--tm-foreground-color, inherit);
  }
}

.container {
  --tm-min-height: calc(var(--tm-line-count) * var(--tm-char-height));
  --tm-min-width: calc(var(--tm-line-size) * 1ch);
  display: flex;
  position: relative;
  box-sizing: border-box;
  background-color: var(--tm-background-color);
  overflow: auto;
  color: var(--tm-foreground-color);
  font-size: 13px;
  tab-size: 4;

  & .code {
    display: block;
    position: absolute;
    z-index: 1;
    /* fixes color change when textarea is focused */
    backface-visibility: hidden;
    contain: layout;
    pointer-events: none;
    font-size: inherit;
    line-height: inherit;
    font-family: monospace;
    white-space: pre;

    & .line {
      position: absolute;
      top: calc(var(--tm-line-number) * var(--tm-char-height));
      contain: layout;
      margin: 0px;

      & span {
        margin: 0px;
        background: transparent !important;
      }
    }
  }

  & .character {
    position: absolute;
    align-self: start;
    visibility: hidden;
    pointer-events: none;
    font-size: inherit;
    line-height: inherit;
  }

  & .textarea {
    transition: color 0.5s;
    outline: none;
    border: none;
    background: transparent;
    padding: 0px;
    width: 100%;
    min-width: var(--tm-min-width);
    height: 100%;
    min-height: var(--tm-min-height);
    overflow: hidden;
    overflow-anchor: none;
    resize: none;
    color: transparent;
    caret-color: var(--tm-foreground-color);
    font-size: inherit;
    line-height: inherit;
    font-family: monospace;
    text-align: inherit;
    white-space: pre;
  }

  & .textarea::selection {
    background: var(--tm-selection-color);
  }
}
