/*
 * The costs screen. Stone world, like the rest of the case record: this is bookkeeping the firm
 * reads and prints, not the conversation.
 *
 * Mobile-first at 360px, because that is where the principal reads everything else. Each row is a
 * stack on a phone and a single line from 48rem up; the bar carries the share so "the library
 * searches are a third of the bill" is seen rather than worked out.
 */

.costs__total {
  font-size: var(--step-1);
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.costs__total strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.costs__section {
  margin-block: 2rem;
}

.costs__section h2 {
  font-family: var(--serif);
  font-size: var(--step-1);
  margin-bottom: .75rem;
}

.costs__agent,
.costs__case-link,
.costs__job,
.costs__run {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .25rem .75rem;
  padding-block: .6rem;
  border-bottom: 1px solid var(--line);
}

.costs__case-link {
  color: inherit;
  text-decoration: none;
}

.costs__case-link:hover .costs__case-caratula,
.costs__case-link:focus-visible .costs__case-caratula {
  text-decoration: underline;
}

/* The amount is the column a reader scans down, so it is tabular and right-aligned even when the
   carátula beside it wraps to three lines. */
.costs__agent-amount,
.costs__case-amount,
.costs__job-amount,
.costs__run-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* The bar spans both columns on a phone: at 360px there is no room for a label, a number and a
   meter on one line, and squeezing it produces a bar too short to read a share off. */
.costs__bar {
  grid-column: 1 / -1;
  inline-size: 100%;
  block-size: .35rem;
  appearance: none;
  border: 0;
}

.costs__bar::-webkit-progress-bar {
  background: var(--stone-2);
  border-radius: 999px;
}

.costs__bar::-webkit-progress-value {
  background: var(--oxblood);
  border-radius: 999px;
}

.costs__bar::-moz-progress-bar {
  background: var(--oxblood);
  border-radius: 999px;
}

.costs__agent-share,
.costs__case-share,
.costs__agent-runs,
.costs__job-detail,
.costs__run-when {
  font-size: var(--step--1);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.costs__back {
  margin-bottom: 1.5rem;
  font-size: var(--step--1);
}

@media (width >= 48rem) {
  .costs__agent,
  .costs__case-link {
    grid-template-columns: minmax(0, 1fr) 8rem 10rem 3.5rem;
  }

  .costs__job,
  .costs__run {
    grid-template-columns: minmax(0, 12rem) 1fr 8rem;
  }

  .costs__bar {
    grid-column: auto;
  }
}

/* Printed and attached to the firm's own invoice to its client, which is what this page is for.
   The chrome goes; the numbers and the bars stay. */
@media print {
  .app-bar,
  .costs__download,
  .costs__ledger,
  .costs__back {
    display: none;
  }

  .costs__agent,
  .costs__case-link,
  .costs__job,
  .costs__run {
    break-inside: avoid;
  }
}
