/* Typing, made fluid (fluid-input.js): the input's own text and caret
   give way to a copy of the text, a span a letter, and a liquid caret in
   the primary colour, laid over it exactly. Without the script's fluid
   mode (reduced motion, forced colours, an IME composing), the input shows
   itself as it is. */

.fluid-field {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-self: stretch;
	min-width: 0;
}

.fluid-field > input {
	flex: 1 1 auto;
	min-width: 0;
}

.fluid-field.fluid-on > input {
	color: transparent;
	caret-color: transparent;
}

.fluid-text {
	position: absolute;
	display: none;
	pointer-events: none;
}

.fluid-on > .fluid-text {
	display: block;
}

/* The text is cut off where the input's is; the caret may stand a pixel
   past it. */
.fluid-clip {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

.fluid-line {
	position: absolute;
	top: 50%;
	left: 0;
	translate: 0 -50%;
	line-height: normal;
	white-space: pre;
	color: var(--text);
}

/* Each letter where the input paints it (fluid-input.js); a deleted one
   lifts away from where it was. */
.fluid-line > :not(.fluid-strut) {
	position: absolute;
	top: 0;
	display: inline-block;
}

.fluid-caret {
	position: absolute;
	top: 0;
	left: 0;
	border-radius: 999px;
	background: var(--accent);
	opacity: 0;
	transition: opacity 100ms cubic-bezier(0.2, 0, 0, 1);
}

.fluid-caret.fluid-focused {
	opacity: 1;
}

/* Drawn out, a comet: its trail fades behind its head. */
.fluid-caret.fluid-trailing {
	background: linear-gradient(var(--trail, to right), color-mix(in srgb, var(--accent) 0%, transparent), color-mix(in srgb, var(--accent) 45%, transparent) 60%, var(--accent) calc(100% - 2px));
}

/* Idle, it blinks as the system's caret does, about once a second, but
   by fading. */
.fluid-caret.fluid-focused.fluid-blinking {
	animation: fluid-blink 1060ms ease-in-out infinite;
}

/* A range selected, the selection shows where the caret is. */
.fluid-caret.fluid-focused.fluid-hidden {
	opacity: 0;
	animation: none;
}

@keyframes fluid-blink {
	0%,
	40%,
	100% {
		opacity: 1;
	}

	50%,
	90% {
		opacity: 0;
	}
}
