/* The lanes view: the swarm as a multi-pen chart recorder, drawn on the same
 * zine page as the graph (plate.css). Time runs left to right over one
 * hour, every scrobble is a stroke in its person's hue, and a lane goes to
 * faint ink when its agent is quiet. */

:root {
  --label: 300px;
  --read: minmax(300px, 34%);
  /* A person's hue, set per element from its `data-hue`; ink until then. */
  --pen: var(--ink);
}

body { min-height: 100vh; background: url(grain.png), var(--ground); background-blend-mode: multiply; }
a { color: inherit; }

/* The bar is the graph's, kept on screen as the page scrolls under it. */
.bar { position: sticky; top: 0; }

/* ---- the head: the latest line, and the readings ---- */

.head {
  display: grid;
  grid-template-columns: var(--label) 1fr var(--read);
  gap: 14px;
  padding: 14px;
}
.lead { grid-column: 1 / 3; display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; min-height: 88px; }
.lead-em { font-size: 28px; flex: none; }
.lead-body { min-width: 0; }
.lead-text { margin: 0; font-size: 18px; line-height: 1.45; max-width: 70ch; overflow-wrap: anywhere; color: var(--ink); }
.lead-text.quiet { color: var(--ink-faint); }
.lead-by { margin: 8px 0 0; color: var(--ink-dim); display: flex; flex-wrap: wrap; align-items: center; gap: 0 7px; }
.lead-by b { color: var(--ink); font-weight: 600; }
.readings { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
/* The readings are the graph's sticky note, stuck on a little crooked. */
.readings.plate { background: url(grain.png), var(--sticky); transform: rotate(-0.8deg); }
.activity svg { display: block; width: 100%; height: 34px; }

/* ---- the sheet ---- */

.axis, .row { display: grid; grid-template-columns: var(--label) 1fr var(--read); align-items: stretch; }
.axis {
  position: sticky;
  top: var(--bar-h, 46px);
  z-index: 2;
  background: rgba(var(--paper-rgb), 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--rule);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.axis > div { padding: 7px 14px; }
.axis .ticks { position: relative; height: 24px; padding: 0; }
.axis .ticks span { position: absolute; top: 7px; transform: translateX(-50%); }
.axis .t50 { left: 16.667%; } .axis .t40 { left: 33.333%; } .axis .t30 { left: 50%; }
.axis .t20 { left: 66.667%; } .axis .t10 { left: 83.333%; }
.axis .ticks .t0 { left: 100%; color: var(--ink); transform: translateX(-100%); padding-right: 4px; white-space: nowrap; }
.axis .rd { border-left: 1px solid var(--line); }

/* The rows are running text set straight on the ground, so the sheet under
   them is washed with paper: the circles show through, faintly, and the
   quietest text keeps 4.5:1 over any two of them. */
main { padding-bottom: 80px; background: rgba(var(--paper-rgb), 0.74); }
.row { border-bottom: 1px solid var(--line); min-height: 26px; cursor: pointer; }
.row:hover { background: rgba(var(--ink-rgb), 0.03); }
.row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.row > .lab { padding: 6px 14px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.row > .lab .id { min-width: 0; }
.row > .lab .tree { color: var(--ink-faint); white-space: pre; }
/* The graticule under the traces: a rule every ten minutes, a fainter one
   every two. */
.row > .tr {
  position: relative; display: flex; align-items: flex-end; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(var(--ink-rgb), 0.1) 0 1px, transparent 1px calc(100% / 6)),
    repeating-linear-gradient(90deg, rgba(var(--ink-rgb), 0.035) 0 1px, transparent 1px calc(100% / 30));
}
.row > .tr svg { display: block; overflow: visible; }
/* What the lane last said, set as a line of the graph's stream: the emoji in
   a column of its own, the words in full, how long ago in the margin. */
.row > .rd { border-left: 1px solid var(--line); padding: 6px 14px; display: flex; gap: 8px; align-items: baseline; min-width: 0; color: var(--ink-dim); }
.rd .em { flex: none; font-size: 12px; align-self: center; }
.rd .tx { overflow-wrap: anywhere; }
.rd .ag { margin-left: auto; font-size: 11px; color: var(--ink-faint); flex: none; padding-left: 8px; font-variant-numeric: tabular-nums; }

/* Each lane's mark is the graph's: a host is a square, an agent a dot, solid
   in its person's hue while it is live and dim after. */
.row > .lab .tree::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border-radius: 50%;
  vertical-align: 1px;
  background: color-mix(in srgb, var(--pen) 38%, transparent);
}
.row.live > .lab .tree::after { background: var(--pen); box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 2.5px var(--pen); }
.row.live.recent > .lab .tree::after { box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 2.5px var(--ink); }
.row.path > .lab .tree::after { width: 5px; height: 5px; background: rgba(var(--ink-rgb), 0.3); }
.row.host > .lab .tree::after { margin-left: 0; border-radius: 0; width: 8px; height: 8px; background: color-mix(in srgb, var(--pen) 50%, transparent); box-shadow: inset 0 0 0 1.5px var(--pen); }

/* States: live carries the hue, idle goes faint, a path is a hairline. */
.row.live { min-height: 48px; }
.row.live > .lab .id { color: var(--ink); font-weight: 600; }
.row.live > .rd { position: relative; color: var(--ink); }
/* The person's hue down the left of what a live lane said, as in the graph's
   stream: one rule a line, so the column reads as lines and not a bar. */
.row.live > .rd::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--pen); }
.row.idle > .lab .id { color: var(--ink-dim); }
.row.idle > .tr svg { opacity: 0.6; }
.row.idle > .rd { color: var(--ink-faint); }
.row.path { min-height: 22px; }
.row.path .lab, .row.path .rd { color: var(--ink-faint); font-size: 12.5px; padding-top: 3px; padding-bottom: 3px; }
.row.host .lab .id { font-weight: 600; color: var(--ink); }
/* A person: their picture ringed in their hue, and a rule in it along the
   band's foot, as the graph labels an operator. */
.row.person { background: rgba(var(--ink-rgb), 0.03); border-bottom: 1px solid color-mix(in srgb, var(--pen) 55%, transparent); min-height: 34px; cursor: default; }
.row.person:hover { background: rgba(var(--ink-rgb), 0.03); }
.row.person .lab .id { font-weight: 600; color: var(--ink); }
.row.person .rd { font-size: 11px; color: var(--ink-dim); }
.row.open { background: rgba(var(--ink-rgb), 0.05); }
/* A model vendor's mark: ink, the same whoever's lane it is. Hovered or
   focused, a lane says vendor, family and model beside it. */
.fam { position: relative; display: inline-block; flex: none; font-size: 13px; line-height: 1; color: var(--ink-dim); }
footer.legend .fam { vertical-align: middle; margin: 0 4px 0 8px; }
footer.legend .fam:first-child { margin-left: 0; }
.history .model { margin: 0 0 6px; font: 400 12px var(--mono); color: var(--ink-dim); }
.history .model .logo { font-size: 14px; color: var(--ink); }
.history .model b { font-weight: 600; color: var(--ink); }
.history .model code { font: inherit; color: var(--ink); }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--pen); }
.face { display: block; width: 22px; height: 22px; border-radius: 50%; flex: none; object-fit: cover; box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 3px var(--pen); background: var(--pen); }
/* An agent's own picture beside its name, smaller and ringed thinner. On a
   lane it is the agent's mark in place of the dot, and carries what the dot
   did: ringed solid in its person's hue while it is live, and quiet after. */
.face.agent { width: 16px; height: 16px; box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px color-mix(in srgb, var(--pen) 45%, transparent); }
/* An agent's picture: the bot sticker plate.css frames, at this size. */
.face.agent.bot { width: 22px; height: 22px; margin-right: 4px; background: var(--bubble); box-shadow: 0 0 0 2px var(--bubble), 0 0 0 3.5px var(--ink), 2px 2.5px 0 3.5px var(--ink); }
.lead-by .face.agent { width: 18px; height: 18px; }
.row:not(.host) > .lab:has(.face.agent) .tree::after { display: none; }
.row.live > .lab .face.agent { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2.5px var(--pen); }
.row.live.recent > .lab .face.agent { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2.5px var(--ink); }
.row.idle .face.agent, .row.path .face.agent { opacity: 0.55; }
.row.path .face.agent { width: 12px; height: 12px; }
.history .who { margin: 0 0 4px; font-size: 12px; color: var(--ink); }

.history { border-bottom: 1px solid var(--line); background: rgba(var(--ink-rgb), 0.05); padding: 8px 14px 12px calc(var(--label) + 14px); color: var(--ink-dim); }
.history .did { margin: 0 0 6px; font-size: 11px; color: var(--ink-faint); overflow-wrap: anywhere; }
.history ol { list-style: none; margin: 0; padding: 0 0 0 8px; border-left: 1px solid var(--rule); }
.history li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.history time { font-size: 11px; color: var(--ink-faint); width: 36px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.history .em { flex: none; font-size: 11px; }
.history .tx { overflow-wrap: anywhere; }

/* A stroke draws once, as it arrives. */
.draw { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .5s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .draw { animation: none; stroke-dashoffset: 0; } }

.sum { padding: 6px 14px 8px calc(var(--label) + 14px); color: var(--ink-faint); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.sum span { white-space: nowrap; }

footer.legend { position: fixed; left: 14px; bottom: 12px; z-index: 3; max-width: calc(100vw - 28px); }
footer.legend svg { flex: none; }

@media (max-width: 1100px) {
  .head { grid-template-columns: 1fr; }
  .lead { grid-column: auto; }
  /* As on the graph, the strip gives way to the readings on a narrow screen. */
  .activity { display: none; }
  .axis .ticks .t10 { display: none; }
}

/* A phone: the readings under the lead, every lane one column with its
   trace above what it said, and the legend at the foot of the page. */
@media (max-width: 720px) {
  .head { padding: 8px; gap: 8px; }
  .lead { padding: 12px; gap: 10px; min-height: 0; }
  .lead-em { font-size: 22px; }
  .lead-text { font-size: 14px; }
  /* Four readings fit one row on a phone. */
  .readings { padding: 10px 12px; gap: 8px; }
  .head .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px; }
  .stats div, .stats div.minor { grid-column: span 1; }
  .stats dd, .stats .minor dd { font-size: 18px; }
  .stats dt, .stats .minor dt { font-size: 10px; letter-spacing: 0.04em; overflow-wrap: anywhere; }
  .axis, .row { grid-template-columns: 1fr; }
  .axis > div:first-child, .axis .rd { display: none; }
  .axis .ticks { margin: 0 14px; }
  .axis .ticks .minor { display: none; }
  .row > .lab { padding: 8px 14px 0; position: relative; }
  /* The model, under the lane's name across the row, rather than off its edge. */
  .fam { position: static; }
  .row > .tr { margin: 2px 14px; }
  .row.path > .tr, .row.person > .tr { display: none; }
  .row > .rd { border-left: 0; padding: 2px 14px 10px; }
  .row.live > .rd::before { left: 14px; top: 4px; bottom: 10px; }
  .row.live > .rd { padding-left: 22px; }
  .row.path > .rd, .row.person > .rd:empty { display: none; }
  .row.person > .rd { padding-bottom: 8px; }
  .history { padding-left: 14px; }
  .sum { padding: 6px 14px 10px; }
  main { padding-bottom: 0; }
  footer.legend { position: static; margin: 14px 8px; max-width: none; gap: 8px 14px; }
}

/* The traces are marker on the print: overprinted where they cross. */
.row > .tr svg, .activity svg { mix-blend-mode: multiply; }

/* An account nothing operates is its own person: its band is a die-cut
   sticker, a white cut edge round a face in its ink, a soft shadow, a 🤖 for
   the bot label that put it on the board, stuck down a little crooked. */
.row.person.solo > .lab .id {
  position: relative;
  padding: 2px 30px 2px 10px;
  background: color-mix(in srgb, var(--pen) 22%, #fffaf0);
  border: 3px solid #fff;
  border-radius: 10px;
  box-shadow: 1px 3px 5px rgba(var(--ink-rgb), 0.3);
  transform: rotate(-1deg);
}
.row.person.solo > .lab .id::after {
  content: "🤖";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) rotate(10deg);
  font-size: 13px;
}
/* And its own lane, under the band, wears the same sticker, smaller. */
.row.own > .lab .id {
  padding: 1px 8px;
  background: color-mix(in srgb, var(--pen) 14%, #fffaf0);
  border: 2.5px solid #fff;
  border-radius: 8px;
  box-shadow: 1px 2px 4px rgba(var(--ink-rgb), 0.25);
  transform: rotate(0.8deg);
}
