/* Tape of Plus. Flat paper, flat keys, no radius, no motion. */

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

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
}

.masthead {
  max-width: 24rem;
  margin: 0 auto;
  padding: 20px 16px 12px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.plate { display: inline-block; line-height: 0; align-self: center; }
.mark { display: block; height: 24px; width: auto; }
.masthead h1 { margin: 0; font-size: 1rem; font-weight: var(--fw-bold); }
.masthead .no { margin: 0 0 0 auto; font-size: 0.8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.machine {
  max-width: 24rem;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The paper. Its ink is written once here and never follows the theme: paper is paper. */
.paper {
  --paper-ink: #1A1A1A;
  --paper-ink-soft: #5B5B5B;
  --pad: 14px;
  --row: 1.5em;
  font-family: ui-monospace, "SF Mono", "Courier New", monospace;
  font-size: min(15px, calc((100vw - 32px - 30px) / 19.6));
  width: calc(32ch + 2 * var(--pad) + 2px);
  max-width: 100%;
  height: clamp(13rem, 40vh, 26rem);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  background: color-mix(in srgb, var(--c-cream) 35%, white);
  color: var(--paper-ink);
  border: 1px solid #D8CDBB;
  border-top: 0;
  scrollbar-width: thin;
}
.feed { margin-top: auto; }
.row {
  position: relative;
  height: var(--row);
  line-height: var(--row);
  white-space: pre;
  color: var(--paper-ink);
}
.row.foot { display: none; }
.row.caption {
  height: calc(3 * var(--row));
  color: var(--paper-ink-soft);
}
.row.rule::after,
.row.line::after {
  content: "";
  position: absolute;
  top: 50%;
}
/* The total's short rule: ten columns over the amounts (columns 21 to 30). */
.row.rule::after { left: 20ch; width: 10ch; border-top: 1px solid var(--paper-ink); }
/* The ruled line: the one rule that runs edge to edge of the paper. */
.row.line { margin-inline: calc(-1 * var(--pad)); }
.row.line::after { left: 0; right: 0; border-top: 1.5px solid var(--paper-ink); transform: translateY(-50%); }
.empty { margin: 0; line-height: var(--row); color: var(--paper-ink-soft); }

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

/* The machine */
.display {
  width: 100%;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  font-family: ui-monospace, "SF Mono", "Courier New", monospace;
}
.entry {
  display: block;
  min-height: 1.3em;
  font-size: 1.75rem;
  line-height: 1.3;
  text-align: right;
  overflow-wrap: anywhere;
}
.entry:empty::before { content: "0"; color: var(--ink-soft); }
.balance {
  margin: 2px 0 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.balance output { color: var(--ink); }

.keys {
  width: 100%;
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 52px;
  gap: 6px;
}
button {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.keys button {
  font-size: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.keys button:active { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.keys .fn { font-size: 0.9375rem; }
.keys small { font-size: 0.6875rem; color: var(--ink-soft); margin-top: 2px; }
.keys .op { font-size: 1.5rem; }
.keys .plus { grid-row: span 2; }
.keys .zero { grid-column: span 2; }
.keys .total { background: var(--c-mustard); border-color: #1A1A1A; color: #1A1A1A; }
.keys .total small { color: #1A1A1A; }
.keys .total:active { background: color-mix(in srgb, var(--c-mustard) 80%, #1A1A1A); }
button:focus-visible, .paper:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.actions {
  width: 100%;
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.actions > button { flex: 1 1 auto; padding: 8px 10px; font-size: 0.875rem; }
.confirm { margin: 0; width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.875rem; }
.confirm span { flex: 1 1 100%; }
.confirm button { padding: 8px 14px; }
[hidden] { display: none !important; }

.notes { width: 100%; margin-top: 24px; font-size: 0.875rem; }
.notes summary { cursor: pointer; color: var(--ink-soft); }
.notes p { margin: 8px 0 0; }

/* Dark: the ground and the machine turn, the paper does not. The wordmark keeps a cream plate. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .plate { background: var(--c-cream); padding: 4px 6px; }
}
[data-theme="dark"] .plate { background: var(--c-cream); padding: 4px 6px; }

/* Print: the paper alone, on a 58 mm strip, every row 3.5 mm. The page height is written by app.js. */
@media print {
  html, body { background: #fff; }
  .masthead, .unkept, .display, .keys, .actions, .notes, .empty { display: none !important; }
  .machine { display: block; max-width: none; margin: 0; padding: 0; }
  .paper {
    --pad: 5mm;
    --row: 3.5mm;
    display: block;
    width: 58mm;
    max-width: none;
    height: auto;
    overflow: visible;
    padding: 5mm;
    border: 0;
    background: #fff;
    font-size: 7pt;
  }
  .feed { margin: 0; }
  .row.foot { display: block; }
}
