:global {
  .selection-imposter-rect {
    position: absolute;
    background-color: var(--text-editor-selection-background-color);
  }
}

.text-editor-container {
  height: 100%;
  position: relative;
  cursor: text;
}

.text-editor-selection-imposter {
  position: relative;
}

.text-editor-content {
  height: 100%;
  font-family: "sourcesanspro", sans-serif;
  outline: none;
  user-select: text;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  caret-color: var(--text-editor-caret-color);
  color: transparent;

  // Match Skia's text layout precision: prevent browser text-size
  // adjustments and ensure consistent kerning across browsers.
  text-size-adjust: none;
  font-kerning: normal;

  &::selection,
  *::selection {
    color: transparent;
    -webkit-text-fill-color: transparent; // WebKit/Safari
  }

  &::selection,
  *::selection {
    color: transparent;
  }

  [data-itype="paragraph"] {
    line-height: inherit;
    user-select: text;
    margin: 0;
    font-size: 0;
  }

  // Text spans emitted by @penpot/text-editor use `data-itype="span"`.
  // Keep whitespace rules attached to the real node type so trailing spaces
  // are handled consistently while editing.
  [data-itype="span"] {
    box-sizing: content-box;
    display: inline;
    line-height: inherit;
    caret-color: var(--text-editor-caret-color);
    word-break: normal;
    overflow-wrap: break-word;
    tab-size: 2;
  }

  [data-itype="root"] {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
}

.grow-type-auto-width {
  [data-itype="span"],
  [data-itype="paragraph"] {
    // Keep auto-width editing on a single preformatted line so trailing
    // spaces are part of caret geometry and browser selection math.
    white-space: pre;
    overflow-wrap: normal;
    word-break: keep-all;
  }
}

// Vertical align.
.align-top {
  [data-itype="root"] {
    justify-content: start;
  }
}

.align-center {
  [data-itype="root"] {
    justify-content: center;
  }
}

.align-bottom {
  [data-itype="root"] {
    justify-content: end;
  }
}
