/* Filing Order: a library filing card on screen, an index sheet on paper. Light only, square corners. */
:root {
  color-scheme: light;
  --mono: ui-monospace, "Courier New", monospace;
  --hair: 1px solid var(--ink);
  --faint: rgb(26 26 26 / 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.45 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 82rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.wordmark {
  display: block;
  width: auto;
  height: 24px;
}

h1 {
  margin: 2.25rem 0 0.4rem;
  color: var(--c-earth);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.lede {
  max-width: 40rem;
  margin: 0 0 2rem;
}

.print-only {
  display: none;
}

.intake {
  max-width: 40rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

textarea {
  display: block;
  width: 100%;
  min-height: 12rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border: var(--hair);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 14px/1.5 var(--mono);
  resize: vertical;
}

button {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.9rem;
  border: var(--hair);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

button:hover {
  background: var(--ink);
  color: var(--bg);
}

textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#status {
  margin: 0.75rem 0 0.15rem;
  font-variant-numeric: tabular-nums;
}

.privacy {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

#sheet {
  margin-top: 2.5rem;
}

#print {
  margin: 0 0 1.25rem;
}

.band-wrap {
  margin-bottom: 2.25rem;
  overflow-x: auto;
}

/* A long list: a band below the fold is laid out as it comes near, at about its own height. */
#bands.long .band-wrap {
  content-visibility: auto;
  contain-intrinsic-size: auto calc(var(--rows) * 1.57rem + 12rem);
}

table.band {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  padding: 0.55rem 0.75rem 0.6rem;
  border-top: 2px solid var(--ink);
  border-bottom: var(--hair);
  font-weight: 400;
  text-align: left;
  vertical-align: bottom;
}

th + th,
td + td {
  border-left: var(--hair);
}

.rule {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.tag {
  color: var(--ink-soft);
  font: 0.6875rem var(--mono);
  white-space: nowrap;
}

.cert {
  display: block;
  margin-top: 0.2rem;
  color: var(--c-earth);
  font-size: 1rem;
  font-weight: 700;
}

tbody td {
  /* An empty cell (a rule this browser cannot honour) still holds one ruled line of height. */
  --lh: calc(14px * 1.4);
  --pad: 0.14rem;
  --top: 0.35rem;
  height: calc(var(--lh) + 2 * var(--pad));
  padding: 0 0.6rem 0 0.35rem;
  vertical-align: top;
}

tbody tr + tr td {
  border-top: 1px solid var(--faint);
}

tbody tr:first-child td {
  position: relative;
  height: calc(var(--lh) + 2 * var(--pad) + var(--top));
  padding-top: var(--top);
}

tbody tr:last-child td {
  padding-bottom: 0.35rem;
}

.row {
  /* The number hangs in the margin; "was N" floats right and drops to its own line only when the
     line itself needs the room, so a word is never broken to make space for a mark. */
  --num: 2.1rem;
  --gap: 0.55rem;
  display: flow-root;
  padding: 0.14rem 0 0.14rem calc(0.3rem + var(--num) + var(--gap));
  border-left: 3px solid transparent;
  font: 14px/1.4 var(--mono);
  text-indent: calc(-1 * (var(--num) + var(--gap)));
  overflow-wrap: anywhere;
}

.row.moved {
  border-left-color: var(--error);
}

.n,
.was {
  font: 0.75rem/calc(14px * 1.4) var(--font-body);
  text-indent: 0;
}

.n {
  display: inline-block;
  width: var(--num);
  margin-right: var(--gap);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.was {
  float: right;
  margin-left: 0.6rem;
  color: var(--error);
  white-space: nowrap;
}

/* Laid over the empty cells below it, so a narrow column wraps the sentence without making
   the first line of the other columns taller. */
.na {
  position: absolute;
  top: var(--top);
  right: 0;
  left: 0;
  z-index: 1;
  padding: var(--pad) 0.6rem 0 1rem; /* no bottom padding: it must not cover the next rule */
  background: var(--bg);
  font-size: 0.875rem;
  line-height: var(--lh);
}

tfoot td {
  padding: 0.6rem 0.75rem 0.25rem;
  border-top: var(--hair);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  vertical-align: top;
}

tfoot p {
  margin: 0 0 0.25rem;
}

.save {
  margin-top: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
}

.notes {
  max-width: 48rem;
  padding-top: 1rem;
  border-top: var(--hair);
  font-size: 0.8125rem;
}

.notes h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.notes ol {
  margin: 0;
  padding-left: 1.4rem;
}

.notes li {
  margin-bottom: 0.3rem;
}

.notes .engine {
  margin-top: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.6875rem;
  overflow-wrap: anywhere;
}

@media (min-width: 48rem) {
  .page {
    padding: 2rem 2.5rem 4rem;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  :root {
    --bg: #fff;
  }

  body {
    background: #fff;
    color: var(--ink);
    font-size: 9pt;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .lede,
  .intake,
  button {
    display: none;
  }

  .masthead {
    display: flex;
    gap: 6mm;
    align-items: flex-end;
    margin-bottom: 5mm;
    padding-bottom: 3mm;
    border-bottom: 2px solid var(--ink);
  }

  .wordmark {
    height: 18px;
  }

  h1 {
    margin: 0;
    font-size: 15pt;
  }

  .meta.print-only {
    display: flex;
    gap: 5mm;
    margin: 0 0 0 auto;
    font-size: 9pt;
  }

  #sheet {
    margin-top: 0;
  }

  .band-wrap {
    margin-bottom: 6mm;
    overflow: visible;
    break-inside: avoid;
  }

  #bands.long .band-wrap {
    content-visibility: visible;
  }

  table.band {
    min-width: 0;
  }

  thead {
    display: table-header-group;
  }

  tfoot {
    display: table-row-group;
  }

  tr {
    break-inside: avoid;
  }

  .cert {
    font-size: 10.5pt;
  }

  th {
    padding: 1.5mm 2.5mm 1.8mm;
  }

  tbody td {
    --lh: calc(9pt * 1.3);
    --pad: 0.6pt;
    --top: 1mm;
  }

  .na {
    font-size: 8pt;
  }

  .row {
    padding-top: 0.6pt;
    padding-bottom: 0.6pt;
    font-size: 9pt;
    line-height: 1.3;
  }

  .n,
  .was {
    font-size: 7.5pt;
    line-height: calc(9pt * 1.3);
  }

  tfoot td {
    padding: 1.5mm 2.5mm 0;
    font-size: 7.5pt;
  }

  .notes {
    max-width: none;
    break-inside: avoid;
    font-size: 8pt;
  }
}
