ontology-stream {
  --focus-aperture: ellipse 47% 43% at 50% 49%;
  display: block;
  position: relative;
  block-size: calc(clamp(1, var(--stream-rows, 30), 32) * var(--stream-row-height, 15px));
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  contain: layout paint style;
  opacity: var(--stream-opacity, .8);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: var(--stream-font-size, 10.5px);
  mask-image: linear-gradient(
    to bottom, transparent, #000 var(--stream-fade-start, 15%),
    #000 var(--stream-fade-end, 68%), transparent
  );
}

/* The scanlines hold position while the grain changes between frames. */
ontology-stream::before,
ontology-stream::after {
  content: "";
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
ontology-stream::before {
  inset: 0;
  background-image: repeating-linear-gradient(to bottom, transparent 0 2px, #03080334 2px 3px);
}
ontology-stream::after {
  inset: -5px;
  background: url("/hero/crt-grain.png");
  transform: var(--stream-grain-transform, none);
}

.ontology-stream-track {
  position: relative;
  padding-inline: var(--stream-gutter, 0px);
  color: #899881;
  text-shadow: 0 0 1.2px #a0b28b70;
  font-variant-ligatures: none;
  font-kerning: none;
  line-height: var(--stream-row-height, 15px);
  white-space: pre;
}

.ontology-stream-layer {
  position: absolute;
  inset: 0;
}
.ontology-stream-layer--soft {
  mask-image: radial-gradient(var(--focus-aperture), #000c 24%, #0007 57%, transparent 100%);
}
.ontology-stream-layer--soft .ontology-stream-track {
  filter: blur(var(--stream-defocus, 1.3px));
}
.ontology-stream-layer--sharp {
  mask-image: radial-gradient(var(--focus-aperture), #0003 24%, #0008 57%, #000 100%);
}
.ontology-stream-layer--sharp .ontology-stream-track { filter: blur(.35px); }

/* Red separates outward from the optical axis, cyan inward. The lens
   displaces these shadows and their source text together. */
.ontology-stream-track[data-fringe] {
  --fringe-offset: .11em;
  --fringe-drift: .28px;
  --fringe-falloff: #000 4%, #000c 12%, #0005 23%, transparent 34%;
}
.ontology-stream-track[data-fringe]::before,
.ontology-stream-track[data-fringe]::after {
  content: attr(data-fringe);
  position: absolute;
  z-index: -1;
  inset: 0;
  padding-inline: inherit;
  color: transparent;
  opacity: calc(.93 + .07 * var(--stream-fringe-phase, 0));
  pointer-events: none;
}
.ontology-stream-track[data-fringe]::before {
  mask-image: linear-gradient(to right, var(--fringe-falloff));
  text-shadow: calc(-1 * var(--fringe-offset)) 0 #f05849d6, var(--fringe-offset) 0 #39c7d6b8;
  transform: translateX(calc(-1 * var(--fringe-drift) * var(--stream-fringe-phase, 0)));
}
.ontology-stream-track[data-fringe]::after {
  mask-image: linear-gradient(to left, var(--fringe-falloff));
  text-shadow: var(--fringe-offset) 0 #f05849d6, calc(-1 * var(--fringe-offset)) 0 #39c7d6b8;
  transform: translateX(calc(var(--fringe-drift) * var(--stream-fringe-phase, 0)));
}
@media (max-width: 640px) {
  .ontology-stream-track[data-fringe] {
    --fringe-offset: .095em;
    --fringe-drift: .18px;
    --fringe-falloff: #000 5%, #000b 11%, #0004 20%, transparent 28%;
  }
}

.ontology-stream-row {
  block-size: 3lh;
}

.ontology-stream-row[data-highlight]::first-line {
  color: #c0cbb1;
  text-shadow: 0 0 2.6px #c1d1aa9c;
}

/* Resolve a monospace character to pixels without measuring the scrolling text. */
.ontology-stream-measure {
  position: absolute;
  inline-size: 1ch;
  visibility: hidden;
}
