/* Story editor highlighting: backdrop mirror behind the textarea */

.hl-wrap {
  position: relative;
  background: var(--paper);
}

/* Textarea sits on top, transparent, so the chips show through */
.hl-wrap .story-textarea {
  position: relative;
  z-index: 1;
  display: block;
  background: transparent;
}

/* Text metrics (font, padding, border width) are copied from the textarea in JS */
.hl-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  box-sizing: border-box;
  margin: 0;
  overflow: hidden;
  border-style: solid;
  border-color: transparent;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  color: transparent;
  pointer-events: none;
}

/* Only paint and colour: no padding, border or font changes, so text never shifts */
.hl-token {
  color: transparent;
  border-radius: 3px;
  background: color-mix(in srgb, var(--blank) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blank) 30%, transparent);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Reused blank: neutral ink tint so it reads as a different kind */
.hl-token.hl-named {
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 28%, transparent);
}

/* Blank with a question: underline-style accent along the bottom */
.hl-token.hl-question {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--blank) 30%, transparent),
    inset 0 -2px 0 var(--blank);
}

.hl-token.hl-named.hl-question {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--ink) 28%, transparent),
    inset 0 -2px 0 var(--blank);
}

/* iOS Safari adds ~3px of inner padding and rounded corners to textareas
   (computed padding doesn't show it); dropping the native appearance removes both. */
@supports (-webkit-touch-callout: none) {
  .hl-wrap .story-textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
  }
}
