/* =========================================================================
   Use case animations
   What a use case scene adds to the data type animation's stage: whoever
   sends the commands, the store they go to, the wires between them, and
   the messages that travel along the wires. The colors and the console
   come from data-type-animation.css, which must load first.
   ========================================================================= */

/* The room each animation needs, so the page below doesn't jump when the script draws it. These are
   the heights in the widest text column. In a narrower column a long command wraps and the box grows. */
.dta[data-dta="job-queue"] { min-height: 259px; }
.dta[data-dta="leaderboard"] { min-height: 316px; }
.dta[data-dta="pub-sub"] { min-height: 328px; }
.dta[data-dta="streaming"] { min-height: 343px; }

/* ---- the stage ---- */
.dta-uc { position: relative; flex: none; }
.dta-uc-wires { position: absolute; left: 0; top: 0; }
.dta-uc-wire { fill: none; stroke: var(--dta-line-strong); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 1 5; transition: opacity .3s; }
/* The wire of an actor that has disconnected. */
.dta-uc-wire.is-off { opacity: 0; }

/* Whoever sends the commands, such as the application or a worker. */
.dta-uc-app {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--dta-line-strong); border-radius: 10px; background: var(--dta-surface);
  font: 700 12.5px/16px var(--dta-mono); white-space: nowrap;
  transition: background-color .3s, border-color .3s;
}
/* A second line under its name that says what it is doing. */
.dta-uc-line { font: 10px/13px var(--dta-mono); color: var(--dta-muted); }
/* It has crashed. */
.dta-uc-app.is-down { border-style: dashed; border-color: var(--dta-no); background-color: var(--dta-no-bg); }
.dta-uc-app.is-down .dta-uc-line { color: var(--dta-no); }

/* A store is a card with a label over it that says where the key lives. */
.dta-uc-store { position: absolute; display: flex; flex-direction: column; gap: 4px; }
.dta-uc-label { font: 10px/14px var(--dta-mono); letter-spacing: .5px; text-transform: uppercase; color: var(--dta-faint); }
/* A label that stands by itself, over a part of the drawing. */
.dta-uc-over { position: absolute; white-space: nowrap; }
.dta-uc-store .dta-card-h { display: flex; align-items: center; height: 25px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
.dta-uc-title { overflow: hidden; text-overflow: ellipsis; }
.dta-uc-store .dta-rows > .dta-r:last-child { border-bottom-color: transparent; }
/* A frame around actors that belong together, such as the workers of one group, with a label that names them. */
.dta-uc-group { position: absolute; border: 1px solid var(--dta-line-strong); border-radius: 12px; background: var(--dta-wash); transition: background-color .3s, border-color .3s; }
.dta-uc-group .dta-uc-label { padding: 3px 0 0 8px; white-space: nowrap; color: var(--dta-muted); transition: color .3s; }
.dta .dta-uc-group.is-write { box-shadow: none; }
/* A group that doesn't exist yet: only an outline. */
.dta-uc-group.is-off { border-style: dashed; background: none; }
.dta-uc-group.is-off .dta-uc-label { color: var(--dta-faint); }

/* A message on the wire: a command going out, or its answer coming back. */
.dta-uc-msg {
  position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none;
  padding: 1px 7px; border: 1px solid var(--dta-line-strong); border-radius: 9px;
  font: 700 10.5px/16px var(--dta-mono); white-space: nowrap;
}
.dta .dta-uc-msg.is-read { border-color: var(--dta-read); background: #1c2254; color: #d0d3ff; box-shadow: none; }
.dta .dta-uc-msg.is-write { border-color: var(--dta-write); background: #4b1c1d; color: #ffc9c3; box-shadow: none; }

/* ---- leaderboard: the score bars ---- */
.dta-uc-bar { display: block; height: 6px; border-radius: 3px; background: var(--dta-line); }
.dta-uc-bar i { display: block; height: 100%; border-radius: 3px; background: var(--dta-on); transition: width .5s cubic-bezier(.2, .7, .2, 1), background-color .3s; }
.dta-r.is-write .dta-uc-bar i { background: var(--dta-write); }
.dta-r.is-read .dta-uc-bar i { background: var(--dta-read); }

/* ---- job queue: a lane for each list ---- */
.dta-uc-store .dta-uc-lane-h { height: 22px; border-top: 1px solid var(--dta-line-strong); }
.dta-uc-store .dta-uc-lane-h:first-child { border-top: 0; }
.dta-uc-lane { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; }
.dta-uc-lane .dta-cell { padding: 2px 7px; font-size: 11.5px; }

/* ---- pub/sub: the channels and patterns that have subscribers ---- */
/* Each one is a box on the side of the card, where the wires of its subscribers meet it. It reaches
   from the wire of its first subscriber to the wire of its last. */
.dta-uc-subs { position: relative; }
.dta-uc-sub {
  position: absolute; right: 0; display: flex; align-items: center; justify-content: center; min-width: 96px; padding: 0 8px;
  border-right: 0; border-radius: 6px 0 0 6px; font-size: 12px;
}
/* Whether it is a channel or a pattern, written beside it where the card has the room. */
.dta-uc-sub::before {
  content: attr(data-kind); position: absolute; right: 100%; top: 50%; margin-right: 8px; transform: translateY(-50%);
  font: 10px/14px var(--dta-mono); color: var(--dta-faint);
}
/* The message a subscriber has just received is brighter than one from an earlier step. */
.dta-uc-app.is-read .dta-uc-line { color: var(--dta-ink); }

/* ---- streaming: an event's ID, and the line that marks a group's place in the stream ---- */
.dta-uc-id { color: var(--dta-muted); }
/* In a narrow card, an event shows the end of its ID and no field name. */
.dta-uc-store.is-tight .dta-uc-id { font-size: .9em; }
.dta-uc-store.is-tight .dta-uc-id-start, .dta-uc-store.is-tight .dta-uc-field { display: none; }
.dta-uc-store.is-tight .dta-uc-id::before { content: "\2026"; }
/* The line isn't an event, so it looks like a divider between the rows, not like a row. */
.dta-uc-next {
  display: flex; align-items: center; gap: 8px; height: 18px; padding: 0 10px 0 12px;
  border: solid transparent; border-width: 0 0 1px; border-bottom-color: var(--dta-line); background: var(--dta-tint);
  font: 10px/17px var(--dta-mono); color: var(--dta-muted); white-space: nowrap;
  transition: color .3s;
}
.dta-uc-next b { font-weight: 700; color: var(--dta-ink); transition: color .3s; }
.dta-uc-next::after { content: ""; flex: 1 1 0; border-top: 1px dashed currentColor; opacity: .55; }
.dta-uc-next:last-child { border-bottom-color: transparent; }
/* The step that made the line or moved it colors its text, and nothing else. */
.dta .dta-uc-next.is-write, .dta .dta-uc-next.is-read { border-color: transparent transparent var(--dta-line); background-color: var(--dta-tint); box-shadow: none; }
.dta .dta-uc-next.is-write:last-child, .dta .dta-uc-next.is-read:last-child { border-bottom-color: transparent; }
.dta .dta-uc-next.is-write, .dta .dta-uc-next.is-write b { color: var(--dta-write); }
.dta .dta-uc-next.is-read, .dta .dta-uc-next.is-read b { color: var(--dta-read); }
/* What a worker holds, once it has acknowledged it: the color the console gives an OK reply. */
.dta-uc-line.is-ok { color: #8cd7b9; }

@container (max-width: 460px) {
  .dta-uc-next { gap: 6px; padding: 0 8px 0 10px; font-size: 9px; }
  .dta-uc-group .dta-uc-label { padding-left: 6px; letter-spacing: .2px; }
  .dta-uc-store .dta-card-h { font-size: 10.5px; padding-left: 8px; padding-right: 8px; }
  .dta-uc-store .dta-uc-lane-h { font-size: 9.5px; }
  .dta-uc-sub { min-width: 84px; padding: 0 6px; font-size: 11px; }
  .dta-uc-sub::before { content: none; }
  .dta-uc-over { font-size: 9px; letter-spacing: .2px; }
  .dta-uc-store .dta-r { font-size: 11.5px; column-gap: 8px; padding: 0 8px; }
  .dta-uc-app { font-size: 11px; }
  .dta-uc-line { font-size: 9.5px; }
}
