/* --- LIVE LIST — the signup page's example (live-list.js, _live_list.html) ---
 *
 * A company list that runs through Krake: the rows rise through a line, above it
 * they are enriched, below it they wait. The Krake node sits on the line where it
 * meets the list's left edge and lights up as each row crosses.
 *
 * A port of the Portal's home hero list (Portal: static/css/components/home.css,
 * .live-list; the node is surfaces.css' .tile--node). Keep the two alike. Unlike
 * the Portal's, it has no place column (Ort), and every size is a multiple of --u,
 * the list's font size, so a page can scale the whole table to its space and keep
 * every column (auth.css sets it for the signup page). --above (the template's live_list_above) places the line in
 * whole rows, so without script it lies between two of them.
 */

.live-list {
  --u: 0.72rem;
  --row: calc(var(--u) * 3.82);
  --head: calc(var(--u) * 3.47);
  --node: 48px;
  /* The Portal's muted grey: the console's --dim is too faint for the small text */
  --list-muted: #8f9397;
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-size: var(--u);
}

.live-list__row {
  /* The Portal's columns without its place (Ort): number, company, then the
     fields. Their minimums add up to 59.86 --u. */
  --columns: calc(var(--u) * 4.17) minmax(calc(var(--u) * 15.28), 1.3fr)
    minmax(calc(var(--u) * 17.01), 1.3fr) minmax(calc(var(--u) * 12.29), 1fr)
    minmax(calc(var(--u) * 11.11), 1fr);
  --bar: 1;
  display: grid;
  grid-template-columns: var(--columns);
  height: var(--row);
}

.live-list__cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 calc(var(--u) * 1.215);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.live-list__row--head {
  height: var(--head);
  color: var(--list-muted);
  font-size: calc(var(--u) * 0.889);
}

.live-list__number {
  justify-content: flex-end;
  padding-inline: calc(var(--u) * 0.833);
  color: var(--list-muted);
  font-size: calc(var(--u) * 0.861);
}

.live-list__name,
.live-list__value {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-list__name {
  color: var(--text);
}

/* A field still waiting: a washed bar where its value will be, as long as values
   tend to be in its column, a little longer or shorter by row. */
.live-list__row:nth-child(3n + 2) {
  --bar: 0.8;
}

.live-list__row:nth-child(3n) {
  --bar: 0.9;
}

.live-list__pending {
  width: calc((85% - var(--i) * 10%) * var(--bar));
  height: calc(var(--u) * 0.556);
  border-radius: var(--radius-compact);
  background: rgba(255, 255, 255, 0.07);
}

/* A field found: typed in in the accent, then settling to the table's grey. A
   field without a finding: a dash. */
.live-list__value {
  width: fit-content;
  color: var(--muted);
  transition: color 1.6s ease;
}

.live-list__value.is-none {
  color: var(--list-muted);
}

.live-list__row:not(.is-filled) .live-list__value,
.live-list__row.is-filled .live-list__pending {
  display: none;
}

.live-list__row.is-new {
  animation: liveListWash 1.4s ease-out;
}

.live-list__row.is-new .live-list__value:not(.is-none) {
  color: var(--accent);
  transition: none;
}

.live-list__row.is-new .live-list__value {
  animation: liveListType 0.6s steps(22, end) calc(var(--i) * 0.15s) both;
}

@keyframes liveListWash {
  from {
    background: rgba(255, 106, 0, 0.16);
  }

  to {
    background: transparent;
  }
}

@keyframes liveListType {
  from {
    clip-path: inset(0 100% 0 0);
  }

  to {
    clip-path: inset(0 0 0 0);
  }
}

/* The rows run in a window under the column names. Shadows at both ends: they
   come up out of the dark at its foot and sink into it under the names, as in a
   table that scrolls. */
.live-list__body {
  position: relative;
  flex: 1;
  min-height: calc((var(--above) + 2) * var(--row));
}

.live-list__window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mask-image: linear-gradient(
    to bottom,
    transparent,
    #000 var(--row),
    #000 calc(100% - 2 * var(--row)),
    transparent
  );
}

.live-list__rows {
  will-change: transform;
}

/* The line, on the border under the last enriched row, with a faint glow over the
   rows it has just filled. */
.live-list__line {
  position: absolute;
  top: calc(var(--above) * var(--row) - 1px);
  right: 0;
  left: 0;
  z-index: 1;
  height: 1px;
  background: rgba(255, 106, 0, 0.7);
  pointer-events: none;
}

.live-list__line::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  height: calc(var(--row) * 1.5);
  background: linear-gradient(to top, rgba(255, 106, 0, 0.08), transparent);
}

/* The node, centred on the line where it meets the list's left border: an accent
   tile with the logo, opaque, so the line ends at its edge. Reached by a row, it
   lights up and sends out a ring. */
.live-list__node {
  position: absolute;
  top: calc(var(--above) * var(--row) - 0.5px - var(--node) / 2);
  left: calc(-0.5px - var(--node) / 2);
  z-index: 3;
  display: grid;
  place-items: center;
  width: var(--node);
  height: var(--node);
  border: 1px solid rgba(255, 106, 0, 0.45);
  border-radius: var(--radius-control);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
  transition:
    border-color 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    background-color 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.live-list__node.is-hit {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
}

.live-list__node::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--accent);
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

/* A gentler curve than the page's, so the ring stays in sight while it grows. */
.live-list__node.is-hit::after {
  animation: liveListPing 0.7s cubic-bezier(0.33, 1, 0.68, 1) both;
}

@keyframes liveListPing {
  from {
    opacity: 0.9;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(1.3);
  }
}

/* The logo's 9 pixels at 3px each; its eyes are the node's own background. */
.live-list__logo {
  width: 27px;
  height: 27px;
  fill: var(--accent);
}

/* The note on the example, for screen readers: the list itself is decoration. */
.live-list__caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .live-list__node,
  .live-list__value {
    transition: none;
  }
}
