/* Epoche Reader. A critical edition page crossed with a ledger sheet. */

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

html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

main { max-width: 46rem; margin: 0 auto; padding: 2rem 16px 3rem; }

.vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

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

/* Header */
.wordmark { display: block; width: 105px; height: 24px; }
h1 {
  margin: 1.75rem 0 0.25rem;
  font-family: ui-serif, Georgia, serif;
  font-weight: normal;
  font-size: 2rem;
  line-height: 1.2;
  color: var(--c-earth);
}
.lede { margin: 0 0 1.5rem; font-size: 1rem; }

h2, h3 { font-family: var(--font-body); font-size: 0.8125rem; font-weight: var(--fw-bold); margin: 0; }

/* Controls */
button, input, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: none;
}
button { font-size: 0.8125rem; padding: 0.3rem 0.7rem; cursor: pointer; }
button:active { background: var(--ink); color: var(--bg); }

textarea#source {
  display: block;
  width: 100%;
  min-height: 9rem;
  padding: 0.6rem 0.75rem;
  font-family: ui-serif, Georgia, serif;
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
}
textarea#source::placeholder { color: var(--ink-soft); opacity: 1; }

input[type="text"] { padding: 0.3rem 0.5rem; font-size: 0.8125rem; width: 14rem; max-width: 100%; }

input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.8125rem;
  height: 0.8125rem;
  margin: 0 0.3rem 0 0;
  padding: 2px;
  vertical-align: -0.1rem;
  background-clip: content-box;
  cursor: pointer;
}
input[type="checkbox"]:checked, input[type="radio"]:checked { background-color: var(--ink); }

/* View switch */
.views { border: 0; margin: 1rem 0 0; padding: 0; font-size: 0.8125rem; }
.views label { margin-right: 1.25rem; cursor: pointer; white-space: nowrap; }
.caption { margin: 0.4rem 0 0; min-height: 1.25rem; color: var(--ink-soft); }

/* Reading view: running text with numerals in a fixed 2rem gutter */
.reading {
  margin: 1.25rem 0 0;
  padding: 0 0 0 2rem;
  min-height: 4rem;
  font-family: ui-serif, Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  counter-reset: par;
}
.para { position: relative; }
.para.n { counter-increment: par; }
.para.n::before {
  content: counter(par);
  position: absolute;
  left: -2rem;
  top: 0;
  width: 1.5rem;
  text-align: right;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  line-height: 1.9125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.reading button {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  line-height: inherit;
  white-space: inherit;
  text-align: inherit;
  cursor: pointer;
}
.reading .hold { color: var(--ink-soft); }
.reading .free {
  color: var(--ink);
  text-decoration: underline dotted var(--ink-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.reading .quiet { cursor: default; }
.reading .gap { color: var(--ink-soft); }
.reading .trace, #ledger tr.trace { outline: 2px solid var(--accent); outline-offset: 1px; }
#ledger tr.trace { outline-offset: -2px; }
.reading .trace:focus-visible { outline-color: var(--ink); }

/* Copy line and stats: the apparatus under the text */
.copy { margin: 1.5rem 0 0; font-size: 0.8125rem; }
.status { margin-left: 0.6rem; color: var(--ink-soft); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 0.25rem 1.5rem;
  justify-content: start;
  margin: 1.25rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--ink);
  font-size: 0.8125rem;
}
.stats dt { color: var(--ink-soft); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Entire list */
.list { margin: 2.5rem 0 0; padding: 0.75rem 0 0; border-top: 1px solid var(--ink); font-size: 0.8125rem; }
.list summary { cursor: pointer; }
.list summary h2 { display: inline; }
.note { margin: 0.4rem 0 0; color: var(--ink-soft); }
.row { margin: 0.9rem 0 0; }
.group { margin: 1rem 0 0; }
.group h3 { font-weight: normal; color: var(--ink-soft); margin-bottom: 0.35rem; }
.entries { list-style: none; margin: 0; padding: 0; columns: 9rem; column-gap: 1rem; }
.entries li { break-inside: avoid; line-height: 1.6; }
.entries label { cursor: pointer; }
.list > h3 { margin-top: 1rem; font-weight: normal; color: var(--ink-soft); }
.kept { list-style: none; margin: 0.35rem 0 0; padding: 0; columns: 9rem; column-gap: 1rem; }
.kept li { line-height: 1.6; }
#add-form label { display: block; margin-bottom: 0.35rem; }
.add-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.add-line .status { margin-left: 0.2rem; }
button.remove { padding: 0 0.35rem; font-size: 0.75rem; }

/* Ledger, whose last row is the sum */
.ledger { margin: 2.5rem 0 0; }
.ledger h2 { margin-bottom: 0.5rem; }
.wrap { overflow-x: auto; }
#ledger { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
#ledger th, #ledger td { padding: 0.3rem 0.5rem 0.3rem 0; text-align: left; vertical-align: top; }
#ledger thead th { font-weight: normal; color: var(--ink-soft); border-bottom: 1px solid var(--ink); }
#ledger .num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0.9rem; }
#ledger .paras { overflow-wrap: break-word; }
#ledger .use { white-space: nowrap; padding-right: 0; }
#ledger tfoot td { border-top: 3px double var(--ink); padding-top: 0.4rem; }

/* Phone: one step smaller so all six columns fit 358px, the longest starter entry included. */
@media (max-width: 30rem) {
  .stats { grid-template-columns: auto auto; }
  #ledger { font-size: 0.75rem; }
  #ledger th, #ledger td { padding-right: 0.3rem; }
  #ledger .num { padding-right: 0.45rem; }
}

@media print {
  html, body { background: none; }
  main { max-width: none; padding: 0; }
  .ctl, textarea#source, #ledger .use { display: none; }
  h1 { margin-top: 0; }
  .reading button { color: inherit; }
  .reading .hold { color: var(--ink-soft); }
  .ledger { break-inside: auto; }
  #ledger tr { break-inside: avoid; }
}
