/*
 * Four lanes. Designed at 375 px as four full-width bands, text over a short
 * silhouette; from 1024 the silhouette sits beside the text. The ruling of
 * each lane is its only decoration and its only motion.
 */

.lanes {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: var(--hairline) solid var(--rule);
}

.lane {
  --accent: var(--rule-strong);
  border-bottom: var(--hairline) solid var(--rule);
}

.lane[data-module="financa"] {
  --accent: var(--m-financa);
}

.lane[data-module="materiale"] {
  --accent: var(--m-materiale);
}

.lane[data-module="paga"] {
  --accent: var(--m-paga);
}

.lane[data-module="bar-restorant"] {
  --accent: var(--m-bar-restorant);
}

.link {
  display: grid;
  gap: var(--s5);
  padding-block: var(--s6);
  text-decoration: none;
  color: inherit;
}

.text {
  display: grid;
  gap: var(--s3);
  align-content: start;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2) var(--s3);
}

.code {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--accent);
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.name {
  font-size: var(--step-body);
  color: var(--ink-2);
}

.line {
  font-size: 1.0625rem;
  color: var(--ink-2);
  max-width: 48ch;
}

/* The documents this lane counts, in the document voice. */
.unit {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  letter-spacing: 0.04em;
  color: var(--ink);
}

.forWhom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  align-items: baseline;
  font-size: var(--step-small);
  color: var(--ink-2);
}

.forLabel {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.link:hover .brand {
  color: var(--accent);
}

/* ---- Silhouettes --------------------------------------------------------- */

.sil {
  display: grid;
  gap: var(--s2);
  align-content: start;
  width: 100%;
}

/* Ledger and delivery note: ruled lines of bars. */
.row {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr) 4.5ch 4.5ch;
  gap: var(--s3);
  align-items: center;
  height: 18px;
  border-bottom: var(--hairline) solid var(--rule);
}

.sil[data-kind="pos"] .row {
  grid-template-columns: 2ch minmax(0, 1fr) 5ch;
}

.nr,
.desc,
.fig,
.total,
.gridName,
.gridFig,
.cell {
  display: block;
  transform-origin: left center;
}

.nr {
  height: 6px;
  background: var(--rule-strong);
}

.desc {
  height: 6px;
  width: 62%;
  background: var(--mat);
}

.row:nth-child(2) .desc {
  width: 44%;
}

.row:nth-child(3) .desc {
  width: 55%;
}

.fig {
  height: 6px;
  background: var(--rule-strong);
  justify-self: end;
  width: 100%;
}

/* A delivery note counts goods: the quantity column is the accent. */
.sil[data-kind="pos"] .fig {
  background: var(--accent);
}

/* The double rule under the total: the one place two rules meet. */
.total {
  height: 0;
  border-top: 3px double var(--ink);
  margin-top: var(--s1);
}

/* Payslip: a grid of people and figures. */
.gridRow {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: var(--s2);
  align-items: center;
  height: 18px;
  border-bottom: var(--hairline) solid var(--rule);
}

.gridName {
  height: 6px;
  width: 70%;
  background: var(--mat);
}

.gridFig {
  height: 6px;
  width: 80%;
  justify-self: end;
  background: var(--rule-strong);
}

.gridFig[data-net] {
  background: var(--accent);
}

/* Table map: places, two of them open. */
.sil[data-kind="tables"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s2);
}

.cell {
  height: 44px;
  border: var(--hairline) solid var(--rule);
  background: var(--paper-2);
  transform-origin: center;
}

.cell[data-open] {
  border-left: 3px solid var(--accent);
  background: var(--paper);
}

/* ---- A phone: the lane is its name, its sentence and a strip ----------- */

/*
 * At 375 the hero index already lists what each lane counts, so the unit line
 * is not repeated here, and the silhouette becomes a strip under the text —
 * still the document's shape, at the height of a ruled line.
 */
@media (max-width: 1023px) {
  .link {
    gap: var(--s4);
    padding-block: var(--s5);
  }

  .unit {
    display: none;
  }

  .row,
  .gridRow {
    height: 12px;
    gap: var(--s2);
  }

  .nr,
  .desc,
  .fig,
  .gridName,
  .gridFig {
    height: 4px;
  }

  .cell {
    height: 28px;
  }

  .total {
    margin-top: 2px;
  }
}

/* ---- Wider -------------------------------------------------------------- */

@media (min-width: 1024px) {
  .link {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--s8);
    align-items: center;
    padding-block: var(--s7);
  }

  .row,
  .gridRow {
    height: 22px;
  }

  .cell {
    height: 56px;
  }
}

/* ---- Motion: the ruling draws ------------------------------------------ */

/*
 * One verb. When the chapter enters, each lane's bars post left to right,
 * line after line, 60 ms apart; the lanes themselves are 120 ms apart. The
 * text does not move — it is already there, and the reader is reading it.
 */
@media (prefers-reduced-motion: no-preference) {
  [data-enter="out"] .nr,
  [data-enter="out"] .desc,
  [data-enter="out"] .fig,
  [data-enter="out"] .gridName,
  [data-enter="out"] .gridFig,
  [data-enter="out"] .total {
    transform: scaleX(0);
  }

  [data-enter="out"] .cell {
    transform: scaleY(0);
  }

  [data-enter="in"] .nr,
  [data-enter="in"] .desc,
  [data-enter="in"] .fig,
  [data-enter="in"] .gridName,
  [data-enter="in"] .gridFig {
    animation: lane-draw 180ms var(--ease) calc(var(--i) * 120ms + var(--r, 0) * 60ms) both;
  }

  [data-enter="in"] .total {
    animation: lane-draw 200ms var(--ease) calc(var(--i) * 120ms + 260ms) both;
  }

  [data-enter="in"] .cell {
    animation: lane-rise 160ms var(--ease) calc(var(--i) * 120ms) both;
  }

  [data-enter="in"] .cell:nth-child(2) {
    animation-delay: calc(var(--i) * 120ms + 50ms);
  }

  [data-enter="in"] .cell:nth-child(3) {
    animation-delay: calc(var(--i) * 120ms + 100ms);
  }

  [data-enter="in"] .cell:nth-child(4) {
    animation-delay: calc(var(--i) * 120ms + 150ms);
  }

  [data-enter="in"] .cell:nth-child(5) {
    animation-delay: calc(var(--i) * 120ms + 200ms);
  }

  [data-enter="in"] .cell:nth-child(6) {
    animation-delay: calc(var(--i) * 120ms + 250ms);
  }

  @keyframes lane-draw {
    from {
      transform: scaleX(0);
    }
    to {
      transform: scaleX(1);
    }
  }

  @keyframes lane-rise {
    from {
      transform: scaleY(0);
    }
    to {
      transform: scaleY(1);
    }
  }
}
